From: Nick Piggin <nickpiggin@yahoo.com.au>
To: Eric Dumazet <dada1@cosmosbay.com>
Cc: Rik van Riel <riel@redhat.com>,
linux-kernel <linux-kernel@vger.kernel.org>,
linux-mm <linux-mm@kvack.org>,
Ulrich Drepper <drepper@redhat.com>
Subject: Re: [PATCH] make MADV_FREE lazily free memory
Date: Thu, 12 Apr 2007 16:08:43 +1000 [thread overview]
Message-ID: <461DCCEB.70004@yahoo.com.au> (raw)
In-Reply-To: <461DC75B.8040200@cosmosbay.com>
Eric Dumazet wrote:
> Rik van Riel a ecrit :
>
>> Eric Dumazet wrote:
>>
>>> Rik van Riel a ecrit :
>>>
>>>> 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.
>>
>>
>>> 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 ?
>>
>>
>> Before maybe freeing the page, the kernel checks the referenced
>> and dirty bits of the page table entries mapping that page.
>>
>>> ptr = mmap(some space);
>>> madvise(ptr, length, MADV_FREE);
>>> /* kernel may free the pages */
>>
>>
>> All this call does is:
>> - clear the accessed and dirty bits
>> - move the page to the far end of the inactive list,
>> where it will be the first to be reclaimed
>>
>>> sleep(10);
>>>
>>> /* what the application must do know before reusing space ? */
>>> memset(ptr, data, 10000);
>>> /* kernel should not free ptr[0..10000] now */
>>
>>
>> Two things can happen here.
>>
>> If this program used the pages before the kernel needed
>> them, the program will be reusing its old pages.
>
>
> ah ok, this is because accessed/dirty bits are set by hardware and not a
> page fault.
No it isn't.
> Is it true for all architectures ?
No.
--
SUSE Labs, Novell Inc.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2007-04-12 6:08 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-11 4:30 Rik van Riel
2007-04-11 22:41 ` Eric Dumazet
2007-04-11 22:56 ` Rik van Riel
2007-04-12 5:44 ` Eric Dumazet
2007-04-12 6:08 ` Nick Piggin [this message]
2007-04-12 6:12 ` Nick Piggin
2007-04-12 7:22 ` Rik van Riel
2007-04-12 13:14 ` Nick Piggin
2007-04-12 20:58 ` Rik van Riel
2007-04-13 0:34 ` Nick Piggin
2007-04-16 16:10 ` Anton Blanchard
2007-04-16 16:30 ` Jakub Jelinek
2007-04-16 18:39 ` Anton Blanchard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=461DCCEB.70004@yahoo.com.au \
--to=nickpiggin@yahoo.com.au \
--cc=dada1@cosmosbay.com \
--cc=drepper@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=riel@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox