From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753969AbcBWPVb (ORCPT ); Tue, 23 Feb 2016 10:21:31 -0500 Received: from outbound-smtp10.blacknight.com ([46.22.139.15]:48726 "EHLO outbound-smtp10.blacknight.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751016AbcBWPV3 (ORCPT ); Tue, 23 Feb 2016 10:21:29 -0500 Date: Tue, 23 Feb 2016 15:21:26 +0000 From: Mel Gorman To: Linux-MM Cc: Rik van Riel , Vlastimil Babka , Johannes Weiner , LKML Subject: [PATCH 27/27] mm: page_alloc: Cache the last node whose dirty limit is reached Message-ID: <20160223152126.GM2854@techsingularity.net> References: <1456239890-20737-1-git-send-email-mgorman@techsingularity.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <1456239890-20737-1-git-send-email-mgorman@techsingularity.net> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If a page is about to be dirtied then the page allocator attempts to limit the total number of dirty pages that exists in any given zone. The call to node_dirty_ok is expensive so this patch records if the last pgdat examined hit the dirty limits. In some cases, this reduces the number of calls to node_dirty_ok(). Signed-off-by: Mel Gorman --- mm/page_alloc.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 4fcd6298b9a1..b20713c42bd1 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -2580,6 +2580,7 @@ get_page_from_freelist(gfp_t gfp_mask, unsigned int order, int alloc_flags, struct zoneref *z; struct page *page = NULL; struct zone *zone; + struct pglist_data *last_pgdat_dirty_limit = NULL; /* * Scan zonelist, looking for a zone with enough free. @@ -2619,8 +2620,15 @@ get_page_from_freelist(gfp_t gfp_mask, unsigned int order, int alloc_flags, * will require awareness of zones in the * dirty-throttling and the flusher threads. */ - if (ac->spread_dirty_pages && !node_dirty_ok(zone->zone_pgdat)) - continue; + if (ac->spread_dirty_pages) { + if (last_pgdat_dirty_limit == zone->zone_pgdat) + continue; + + if (!node_dirty_ok(zone->zone_pgdat)) { + last_pgdat_dirty_limit = zone->zone_pgdat; + continue; + } + } mark = zone->watermark[alloc_flags & ALLOC_WMARK_MASK]; if (!zone_watermark_ok(zone, order, mark, -- 2.6.4