Re: [PATCH] make MADV_FREE lazily free memory

From: Eric Dumazet
Date: Wed Apr 11 2007 - 18:41:57 EST


Rik van Riel a Ãcrit :
Make it possible for applications to have the kernel free memory
lazily. This reduces a repeated free/malloc cycle from freeing
pages and allocating them, to just marking them freeable. If the
application wants to reuse them before the kernel needs the memory,
not even a page fault will happen.


Hi Rik

I dont understand this last sentence. If not even a page fault happens, how the kernel knows that the page was eventually reused by the application, and should not be freed in case of memory pressure ?

ptr = mmap(some space);
madvise(ptr, length, MADV_FREE);
/* kernel may free the pages */
sleep(10);

/* what the application must do know before reusing space ? */
memset(ptr, data, 10000);
/* kernel should not free ptr[0..10000] now */

Thank you
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/