linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm,vmscan: compact memory from kswapd when lots of memory free already
@ 2016-02-23  3:50 Rik van Riel
  2016-02-23  9:18 ` Vlastimil Babka
  0 siblings, 1 reply; 3+ messages in thread
From: Rik van Riel @ 2016-02-23  3:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: linux-mm, hannes, akpm, mgorman

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.

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 <riel@redhat.com>
---
 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);
 
 		/*
-- 
-- 
All rights reversed.

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] mm,vmscan: compact memory from kswapd when lots of memory free already
  2016-02-23  3:50 [PATCH] mm,vmscan: compact memory from kswapd when lots of memory free already Rik van Riel
@ 2016-02-23  9:18 ` Vlastimil Babka
  2016-02-23 15:39   ` Rik van Riel
  0 siblings, 1 reply; 3+ messages in thread
From: Vlastimil Babka @ 2016-02-23  9:18 UTC (permalink / raw)
  To: Rik van Riel, linux-kernel; +Cc: linux-mm, hannes, akpm, mgorman

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 <riel@redhat.com>
> ---
>   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);
>
>   		/*
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mm,vmscan: compact memory from kswapd when lots of memory free already
  2016-02-23  9:18 ` Vlastimil Babka
@ 2016-02-23 15:39   ` Rik van Riel
  0 siblings, 0 replies; 3+ messages in thread
From: Rik van Riel @ 2016-02-23 15:39 UTC (permalink / raw)
  To: Vlastimil Babka, linux-kernel; +Cc: linux-mm, hannes, akpm, mgorman

[-- Attachment #1: Type: text/plain, Size: 1245 bytes --]

On Tue, 2016-02-23 at 10:18 +0100, Vlastimil Babka wrote:
> 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

Never mind my patch, then. Your solution is nicer,
and already in -mm :)

-- 
All Rights Reversed.


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-02-23 15:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-23  3:50 [PATCH] mm,vmscan: compact memory from kswapd when lots of memory free already Rik van Riel
2016-02-23  9:18 ` Vlastimil Babka
2016-02-23 15:39   ` Rik van Riel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).