Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 5 Jul 2021 22:47:41 +0300
From:      Vitaliy Gusev <gusev.vitaliy@gmail.com>
To:        Konstantin Belousov <kostikbel@gmail.com>
Cc:        freebsd-hackers@freebsd.org, gljennjohn@gmail.com, Mark Johnston <markj@freebsd.org>, Peter Grehan <grehan@freebsd.org>
Subject:   Re: madvise(MADV_FREE) doesn't work in some cases?
Message-ID:  <2A7A1E60-766D-427B-8288-E92B4090022E@gmail.com>
In-Reply-To: <YONVgjgqREDAucok@kib.kiev.ua>
References:  <D5749BDF-36B5-4AE9-A75F-2A702DF71F8C@gmail.com> <20210703065420.6dbafb5f@ernst.home> <D542E8C1-4E97-48E8-8748-BBA19B2216EC@gmail.com> <2390FA9B-319E-45D4-BEA7-10878E43AD4B@gmail.com> <YONVgjgqREDAucok@kib.kiev.ua>

next in thread | previous in thread | raw e-mail | index | archive | help

> On 5 Jul 2021, at 21:54, Konstantin Belousov <kostikbel@gmail.com> wrote:
> 
> On Mon, Jul 05, 2021 at 07:32:00PM +0300, Vitaliy Gusev wrote:
> 
> DONTNEED does not allow system to free pages at all.  It means that pages
> are less useful and can be paged out with higher priority.
> 

That caused behaviour that memory is not freed! 

Is there a reason why FreeBSD behaviour for MADV_DONTNEED is different than in Linux and illumos ? Why it needs swap and cannot be easily dropped ?

As Mark wrote in another thread:

Indeed, in FreeBSD madvise() never reclaims pages.  I'm not sure which
hint is being provided here, but MADV_DONTNEED and MADV_FREE both
prioritize reclamation of the pages backing the specified virtual
address range.  The difference between the two is that MADV_FREE permits
dirty pages to be freed without paging out their contents first and so
is destructive.

That is why I expected the same behaviour for both.


>>> 
>>> You can read more details in the referenced commit, as well as some musings
>>> about way to make it somewhat better.
>>> 
>>> I must say, that trying to allocated 1/2 + 1/2 of RAM this way, on a system
>>> without swap, is the way to ask for troubles anyway.
>> I’ve just notify that other operation systems work well with that, whereas FreeBSD has troubles. Probably something in madvise() is not finished ?
> 
> Well, yes, as I said, non-trivial shadow chains for MADV_FREE are not
> handled due to the 'old content revival' bug.  For your specific case, the
> following patch might help (modulo bugs).

Thanks, I will try and report result.

——
Vitaliy Gusev




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?2A7A1E60-766D-427B-8288-E92B4090022E>