From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752023AbcBWJSy (ORCPT ); Tue, 23 Feb 2016 04:18:54 -0500 Received: from mx2.suse.de ([195.135.220.15]:36420 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751514AbcBWJSu (ORCPT ); Tue, 23 Feb 2016 04:18:50 -0500 Subject: Re: [PATCH] mm,vmscan: compact memory from kswapd when lots of memory free already To: Rik van Riel , linux-kernel@vger.kernel.org References: <20160222225054.1f6ab286@annuminas.surriel.com> Cc: linux-mm@kvack.org, hannes@cmpxchg.org, akpm@linux-foundation.org, mgorman@suse.de From: Vlastimil Babka Message-ID: <56CC23F7.8010709@suse.cz> Date: Tue, 23 Feb 2016 10:18:47 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <20160222225054.1f6ab286@annuminas.surriel.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/23/2016 04:50 AM, Rik van Riel wrote: > If kswapd is woken up for a higher order allocation, for example > from alloc_skb, but the system already has lots of memory free, > kswapd_shrink_zone will rightfully decide kswapd should not free > any more memory. > > However, at that point kswapd should proceed to compact memory, on > behalf of alloc_skb or others. > > Currently kswapd will only compact memory if it first freed memory, > leading kswapd to never compact memory when there is already lots of > memory free. > > On my home system, that lead to kswapd occasionally using up to 5% > CPU time, with many man wakeups from alloc_skb, and kswapd never > doing anything to relieve the situation that caused it to be woken > up. Hi, I've proposed replacing kswapd compaction with kcompactd, so this hunk is gone completely in mmotm. This imperfect comparison was indeed one of the things I've noted, but it's not all: http://marc.info/?l=linux-kernel&m=145493881908394&w=2 > Going ahead with compaction when kswapd did not attempt to reclaim > any memory, and as a consequence did not reclaim any memory, is the > right thing to do in this situation. > > Signed-off-by: Rik van Riel > --- > mm/vmscan.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/vmscan.c b/mm/vmscan.c > index 71b1c29948db..9566a04b9759 100644 > --- a/mm/vmscan.c > +++ b/mm/vmscan.c > @@ -3343,7 +3343,7 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, int order, > * Compact if necessary and kswapd is reclaiming at least the > * high watermark number of pages as requsted > */ > - if (pgdat_needs_compaction && sc.nr_reclaimed > nr_attempted) > + if (pgdat_needs_compaction && sc.nr_reclaimed >= nr_attempted) > compact_pgdat(pgdat, order); > > /* >