Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 07 Jan 2014 11:43:43 +0200
From:      Alexander Motin <mav@FreeBSD.org>
To:        Konstantin Belousov <kostikbel@gmail.com>
Cc:        hackers@freebsd.org
Subject:   Re: UMA caches draining
Message-ID:  <52CBCC4F.8020900@FreeBSD.org>
In-Reply-To: <20140107054825.GI59496@kib.kiev.ua>
References:  <52CB4F7D.2080909@FreeBSD.org> <20140107054825.GI59496@kib.kiev.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
On 07.01.2014 07:48, Konstantin Belousov wrote:
> On Tue, Jan 07, 2014 at 02:51:09AM +0200, Alexander Motin wrote:
>> I have some questions about memory allocation. At this moment our UMA
>> never returns freed memory back to the system until it is explicitly
>> asked by pageout daemon via uma_reclaim() call, that happens only when
>> system is quite low on memory. How does that coexist with buffer cache
>> and other consumers? Will, for example, buffer cache allocate buffers
>> and be functional when most of system's memory uselessly consumed by UMA
>> caches? Is there some design how that supposed to work?
> Allocation of the pages which consitute a new buffer creates the pressure
> and causes pagedaemon wakeup if amount of free pages is too low.  Look
> at the vm_page_grab() call in allocbuf().  Also note that buffer cache
> is not shrinked in response to the low memory events, and buffers pages
> are excluded from the page daemon scans since pages are wired.

Thanks. I indeed can't see respective vm_lowmem handler. But how does it 
adapt then? It should have some sort of back pressure. And since it 
can't know about UMA internals, it should probably just see that system 
is getting low on physical memory. Won't it shrink itself first in such 
case before pagedaemon start its reclaimage?

When vm_lowmem condition finally fire, it will purge different data from 
different subsystems, potentially still usable. UMA caches though have 
no valid data, only an allocation optimization. Shouldn't they be freed 
first somehow, at least an unused part, as in my patch? Also I guess 
having more really free memory should make M_NOWAIT allocations to fail 
less often.

>> I've made an experimental patch for UMA
>> (http://people.freebsd.org/~mav/drain_unused.patch) to make it every 20
>> seconds return back to the system cached memory, unused for the last 20
>> seconds. Algorithm is quite simple and patch seems like working, but I
>> am not sure whether I am approaching problem from the right side. Any
>> thoughts?

-- 
Alexander Motin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?52CBCC4F.8020900>