Take the 2-minute tour ×
Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It's 100% free, no registration required.

Please tell me if it is possible to lock cache memory of raspberry PI board. If so, what is the procedure.

share|improve this question

1 Answer 1

I'm not shure what cache you mean.

ARM L2 cache: 128kiB; probably not a good idea to disable it, the pi might become awfully slow. From http://elinux.org/RPiconfig : setting disable_l2cache in config.txt disables ARM access to GPU's L2 cache. Default 0.
Needs corresponding L2 disabled kernel. This means: compile a custom kernel, replace your kernel.img etc with your custom build on the vfat partition of the SD card, and keep a copy of the files somewhere. Or grab & install berryboot (berryboot.com).

Linux kernel cache: from http://www.commandlinefu.com/commands/view/2888/release-memory-used-by-the-linux-kernel-on-caches :

free && sync && echo 3 > /proc/sys/vm/drop_caches && free

On 2nd thought, I assume you mean locking cache out, aren't you?

echo 10 > /proc/sys/vm/swappiness

will swap as little as possible; default is 60. Note that I didn't try, I just removed the swapfile.

Edit: The linux kernel automagically assign unused memory pages to system cache, mostly for I/O. This can be write cache to mass storage, which is slow and can benefit a lot of reordering, to get contiguous sectors on a hdd, or to reduce erase block usage on flash based devices (sd card, ssd, usb key, etc). Search lwn.net for gory details about the kernel. (As a newbie here I'm not allowed to post more than 2 links in a post and I already cheated with 2 extra non-URL domain names :)
The cache pages are notably used for caching swap, the thing used to free real RAM, by putting the memory pages (the space allocated for a program) on the disk. This actually improve performance. Computing science is weird.
Cache is also used for network buffers.

sync force writes deferred to disks, to empty the pages used in kernel space as cache. They are now unused but remain allocated to the kernel. The proc thingy is a way to send an order to the kernel to mark these as free for use, in user space if need be.
Google /proc/sys/vm/drop_caches for more info.
swappiness controls the aggressiveness of the kernel about putting stuff that seems not to be used a lot to swap, just in case a user program might need some.
free is just there to show free memory before and after.

Again: Linux Weekly News is a good reference for understanding what is linux and how it works. Just try to understand what you can, and skip what makes you sick at a glance.

Hope this helps, at least for you to get a more precise question;)

share|improve this answer
    
Noit Thank you very much for your answer. –  Shiny Fathima Jan 3 '13 at 13:28
    
I could not get the below lines.Could you please briefly explain this free && sync && echo 3 > /proc/sys/vm/drop_caches && free On 2nd thought, I assume you mean locking cache out, aren't you? echo 10 > /proc/sys/vm/swappiness will swap as little as possible; default is 60. Note that I didn't try, I just removed the swapfile. –  Shiny Fathima Jan 3 '13 at 13:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.