linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
To: Mel Gorman <mel@csn.ul.ie>
Cc: kosaki.motohiro@jp.fujitsu.com, Frans Pop <elendil@planet.nl>,
	Jiri Kosina <jkosina@suse.cz>,
	Sven Geggus <lists@fuchsschwanzdomain.de>,
	Karol Lewandowski <karol.k.lewandowski@gmail.com>,
	Tobias Oetiker <tobi@oetiker.ch>,
	"Rafael J. Wysocki" <rjw@sisk.pl>,
	David Miller <davem@davemloft.net>,
	Reinette Chatre <reinette.chatre@intel.com>,
	Kalle Valo <kalle.valo@iki.fi>,
	David Rientjes <rientjes@google.com>,
	Mohamed Abbas <mohamed.abbas@intel.com>,
	Jens Axboe <jens.axboe@oracle.com>,
	"John W. Linville" <linville@tuxdriver.com>,
	Pekka Enberg <penberg@cs.helsinki.fi>,
	Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>,
	Greg Kroah-Hartman <gregkh@suse.de>,
	Stephan von Krawczynski <skraw@ithnet.com>,
	Kernel Testers List <kernel-testers@vger.kernel.org>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	"linux-mm@kvack.org\"" <linux-mm@kvack.org>
Subject: Re: [PATCH 3/5] vmscan: Force kswapd to take notice faster when high-order watermarks are being hit
Date: Tue, 27 Oct 2009 11:42:55 +0900 (JST)	[thread overview]
Message-ID: <20091026232924.2F75.A69D9226@jp.fujitsu.com> (raw)
In-Reply-To: <1256221356-26049-4-git-send-email-mel@csn.ul.ie>

> When a high-order allocation fails, kswapd is kicked so that it reclaims
> at a higher-order to avoid direct reclaimers stall and to help GFP_ATOMIC
> allocations. Something has changed in recent kernels that affect the timing
> where high-order GFP_ATOMIC allocations are now failing with more frequency,
> particularly under pressure. This patch forces kswapd to notice sooner that
> high-order allocations are occuring.
> 
> Signed-off-by: Mel Gorman <mel@csn.ul.ie>
> ---
>  mm/vmscan.c |    9 +++++++++
>  1 files changed, 9 insertions(+), 0 deletions(-)
> 
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 64e4388..cd68109 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -2016,6 +2016,15 @@ loop_again:
>  					priority != DEF_PRIORITY)
>  				continue;
>  
> +			/*
> +			 * Exit quickly to restart if it has been indicated
> +			 * that higher orders are required
> +			 */
> +			if (pgdat->kswapd_max_order > order) {
> +				all_zones_ok = 1;
> +				goto out;
> +			}
> +
>  			if (!zone_watermark_ok(zone, order,
>  					high_wmark_pages(zone), end_zone, 0))
>  				all_zones_ok = 0;

this is simplest patch and seems reasonable.
	Reviewed-by: KOSAKI Motohiro <kosaki.motohiro>


btw, now balance_pgdat() have too complex flow. at least Vincent was
confused it.
Then, I think kswap_max_order handling should move into balance_pgdat()
at later release.
the following patch addressed my proposed concept.



From 2c5be772f6db25a5ef82975960d0b5788736ec2b Mon Sep 17 00:00:00 2001
From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Date: Mon, 26 Oct 2009 23:25:29 +0900
Subject: [PATCH] kswapd_max_order handling move into balance_pgdat()

Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
---
 mm/vmscan.c |   45 +++++++++++++++++++++------------------------
 1 files changed, 21 insertions(+), 24 deletions(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 64e4388..49001d3 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1915,7 +1915,7 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem_cont,
  * interoperates with the page allocator fallback scheme to ensure that aging
  * of pages is balanced across the zones.
  */
-static unsigned long balance_pgdat(pg_data_t *pgdat, int order)
+static unsigned long balance_pgdat(pg_data_t *pgdat)
 {
 	int all_zones_ok;
 	int priority;
@@ -1928,7 +1928,7 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, int order)
 		.may_swap = 1,
 		.swap_cluster_max = SWAP_CLUSTER_MAX,
 		.swappiness = vm_swappiness,
-		.order = order,
+		.order = 0,
 		.mem_cgroup = NULL,
 		.isolate_pages = isolate_pages_global,
 	};
@@ -1938,6 +1938,8 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, int order)
 	 * free_pages == high_wmark_pages(zone).
 	 */
 	int temp_priority[MAX_NR_ZONES];
+	int order = 0;
+	int new_order;
 
 loop_again:
 	total_scanned = 0;
@@ -1945,6 +1947,11 @@ loop_again:
 	sc.may_writepage = !laptop_mode;
 	count_vm_event(PAGEOUTRUN);
 
+	new_order = pgdat->kswapd_max_order;
+	pgdat->kswapd_max_order = 0;
+	if (order < new_order)
+		order = sc.order = new_order;
+
 	for (i = 0; i < pgdat->nr_zones; i++)
 		temp_priority[i] = DEF_PRIORITY;
 
@@ -2087,11 +2094,17 @@ out:
 
 		zone->prev_priority = temp_priority[i];
 	}
-	if (!all_zones_ok) {
-		cond_resched();
 
-		try_to_freeze();
+	cond_resched();
+	try_to_freeze();
 
+	/*
+	 * restart if someone wants a larger 'order' allocation
+	 */
+	if (order < pgdat->kswapd_max_order)
+		goto loop_again;
+
+	if (!all_zones_ok) {
 		/*
 		 * Fragmentation may mean that the system cannot be
 		 * rebalanced for high-order allocations in all zones.
@@ -2130,7 +2143,6 @@ out:
  */
 static int kswapd(void *p)
 {
-	unsigned long order;
 	pg_data_t *pgdat = (pg_data_t*)p;
 	struct task_struct *tsk = current;
 	DEFINE_WAIT(wait);
@@ -2160,32 +2172,17 @@ static int kswapd(void *p)
 	tsk->flags |= PF_MEMALLOC | PF_SWAPWRITE | PF_KSWAPD;
 	set_freezable();
 
-	order = 0;
 	for ( ; ; ) {
-		unsigned long new_order;
-
 		prepare_to_wait(&pgdat->kswapd_wait, &wait, TASK_INTERRUPTIBLE);
-		new_order = pgdat->kswapd_max_order;
-		pgdat->kswapd_max_order = 0;
-		if (order < new_order) {
-			/*
-			 * Don't sleep if someone wants a larger 'order'
-			 * allocation
-			 */
-			order = new_order;
-		} else {
-			if (!freezing(current))
-				schedule();
-
-			order = pgdat->kswapd_max_order;
-		}
+		if (!freezing(current))
+			schedule();
 		finish_wait(&pgdat->kswapd_wait, &wait);
 
 		if (!try_to_freeze()) {
 			/* We can speed up thawing tasks if we don't call
 			 * balance_pgdat after returning from the refrigerator
 			 */
-			balance_pgdat(pgdat, order);
+			balance_pgdat(pgdat);
 		}
 	}
 	return 0;
-- 
1.6.2.5






--
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>

  parent reply	other threads:[~2009-10-27  2:43 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-22 14:22 [PATCH 0/5] Candidate fix for increased number of GFP_ATOMIC failures V2 Mel Gorman
2009-10-22 14:22 ` [PATCH 1/5] page allocator: Always wake kswapd when restarting an allocation attempt after direct reclaim failed Mel Gorman
2009-10-22 14:24   ` [PATCH 1/5 Against 2.6.31.4] " Mel Gorman
2009-10-22 14:41   ` [PATCH 1/5] " Pekka Enberg
2009-10-22 15:49     ` Mel Gorman
2009-10-26  1:11   ` KOSAKI Motohiro
2009-10-26  7:10     ` David Rientjes
2009-10-27  2:42       ` KOSAKI Motohiro
2009-10-27 12:27         ` Mel Gorman
2009-10-22 14:22 ` [PATCH 2/5] page allocator: Do not allow interrupts to use ALLOC_HARDER Mel Gorman
2009-10-22 16:33   ` Stephan von Krawczynski
2009-10-22 16:37     ` Mel Gorman
2009-10-23  9:57       ` Stephan von Krawczynski
2009-10-24  2:03       ` Christoph Lameter
2009-10-27 15:19         ` Mel Gorman
2009-10-25 12:57       ` Stephan von Krawczynski
2009-10-26  1:15   ` KOSAKI Motohiro
2009-10-22 14:22 ` [PATCH 3/5] vmscan: Force kswapd to take notice faster when high-order watermarks are being hit Mel Gorman
2009-10-23 17:52   ` Vincent Li
2009-10-23 22:12     ` Vincent Li
2009-10-27 10:38     ` Mel Gorman
2009-10-27  2:42   ` KOSAKI Motohiro [this message]
2009-10-22 14:22 ` [PATCH 4/5] page allocator: Pre-emptively wake kswapd when high-order watermarks are hit Mel Gorman
2009-10-22 19:41   ` David Rientjes
2009-10-23  9:13     ` Mel Gorman
2009-10-23  9:36       ` David Rientjes
2009-10-23 11:25         ` Mel Gorman
2009-10-23 11:31           ` Tobias Oetiker
2009-10-23 13:39             ` Mel Gorman
2009-10-27  2:42   ` KOSAKI Motohiro
2009-10-27 15:26     ` Mel Gorman
2009-10-22 14:22 ` [PATCH 5/5] ONLY-APPLY-IF-STILL-FAILING Revert 373c0a7e, 8aa7e847: Fix congestion_wait() sync/async vs read/write confusion Mel Gorman
2009-10-22 14:25   ` Against 2.6.31.4 [PATCH 5/5] " Mel Gorman
2009-10-22 21:49   ` [PATCH 5/5] ONLY-APPLY-IF-STILL-FAILING " Jens Axboe
2009-10-27  2:42   ` KOSAKI Motohiro
2009-10-27 10:29     ` Frans Pop
2009-10-22 14:47 ` [PATCH 0/5] Candidate fix for increased number of GFP_ATOMIC failures V2 Pekka Enberg
2009-10-22 16:03   ` Mel Gorman
2009-10-24  1:52   ` Christoph Lameter
2009-10-24  6:48     ` Pekka Enberg
2009-10-24  6:48     ` Pekka Enberg
2009-10-22 15:43 ` reinette chatre
2009-10-27 10:40   ` Mel Gorman
2009-10-27 23:34     ` reinette chatre
2009-10-23  7:31 ` Sven Geggus
2009-10-23 16:58 ` Karol Lewandowski
2009-10-23 21:12   ` Karol Lewandowski
2009-10-24 13:46     ` Mel LKML
2009-10-28 11:42       ` Karol Lewandowski
2009-10-28 11:59         ` Mel Gorman
2009-10-30 14:23           ` Karol Lewandowski
2009-11-02 20:30             ` Mel Gorman
2009-11-04  2:03               ` Karol Lewandowski
2009-10-28 12:55         ` Tobi Oetiker
2009-10-24 13:51 ` Frans Pop
2009-10-24 14:02 ` Sven Geggus
2009-10-27 13:27   ` Mel Gorman
2009-10-26 17:37 ` Tobias Oetiker
2009-10-27 15:36   ` Mel Gorman
2009-10-26 22:17 ` Frans Pop
2009-10-26 23:45   ` Frans Pop
2009-11-06  6:03 ` Tobias Diedrich
2009-11-06  9:24   ` Mel Gorman
2009-11-06  9:24   ` Mel Gorman
2009-11-06 11:15     ` Tobias Diedrich

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=20091026232924.2F75.A69D9226@jp.fujitsu.com \
    --to=kosaki.motohiro@jp.fujitsu.com \
    --cc=bzolnier@gmail.com \
    --cc=davem@davemloft.net \
    --cc=elendil@planet.nl \
    --cc=gregkh@suse.de \
    --cc=jens.axboe@oracle.com \
    --cc=jkosina@suse.cz \
    --cc=kalle.valo@iki.fi \
    --cc=karol.k.lewandowski@gmail.com \
    --cc=kernel-testers@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linville@tuxdriver.com \
    --cc=lists@fuchsschwanzdomain.de \
    --cc=mel@csn.ul.ie \
    --cc=mohamed.abbas@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=penberg@cs.helsinki.fi \
    --cc=reinette.chatre@intel.com \
    --cc=rientjes@google.com \
    --cc=rjw@sisk.pl \
    --cc=skraw@ithnet.com \
    --cc=tobi@oetiker.ch \
    /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