tags:

views:

42

answers:

1

Hi everyone,

I am writing a simple memory manager for my application which will free any excess memory being used by my modules, so that it's available again for use. My modules allocate memory using alloc_page & kmem_cache_alloc and so the memory manager uses put_page & kmem_cache_free respectively to free up the memory which is not in use.

The problem I am facing is, even after I free the memory using put_page & kmem_cache_free, my modules are not able to get the free memory. I have written a test code which allocates a lot of memory in loop and when out of memory sleeps on memory manager to free up the memory. Memory manager successfully executes free code and wakes up the sleeping process as memory should be available now. Interestingly the alloc_page / kmem_cache_alloc calls still fail to allocate memory. Now, I am clueless why it is happening so seeking help.

A: 

I figured out the problem, it was with the API I was using. If I use __free_page instead of put_page to free the memory pages, everything works absolutely fine.

That brings another question on when and why "put_page" is used. I can guess it has some thing to do with swap memory as it is defined in mm/swap.c and my system is an embedded system without any swap memory support.

Vikash
If you have answered your own question, you should accept your answer. Its probably better to start another question for the rest.
Tim Post