Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp3370497ybc; Thu, 21 Nov 2019 07:23:05 -0800 (PST) X-Google-Smtp-Source: APXvYqwHvJ/81d5rc3lrT50hTUTo1ynCiwOBFkHiPmOEgj5Brk/4VTStWOn8UOV5e7RdTU/y2zof X-Received: by 2002:adf:fb8b:: with SMTP id a11mr11356096wrr.83.1574349785574; Thu, 21 Nov 2019 07:23:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574349785; cv=none; d=google.com; s=arc-20160816; b=lqm0c7VG/qNkk5QFAZ+6Mg71q0WR5H6TlR0FmD+guGqSBZPM3QMkN7MPQBJ4yPtXmJ yAdgYI5zW2T/AGNZ4c6BmuDt94S4HTk7ls/Qoyvjcu9UHrjFAwoVPngBvjmwX0gQGFCY oYvVdXlzhRyJDNzj5WrOmLkKy5AllKChIQrX0HBHBcFjSHbFrPXSvi2P15JryVHgA/Ab 7UocBQH/Mw2MfZwRHNFGoQwgNjtFgTjMAWFhUlcTdsaZfJIhcaG9xc7PzyB8X/Gf4vGU 54wfVi+t6htQpPDhUzNV1KhSU7GXzkRvW0rI4egYa9+oRe7Nez+pPYbDszq4tN+0dC8g 6byw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=2sl3uWJUjIY5ByU5mWAGd0GcM3li7DM/MRM+yA3BmGs=; b=vqfPLnb8lNQF//f6k0GPx36sH3rSPTcEh/K3nmIoRa0hVgx9Fai+C7CxEcaf4LThN7 8Zw/kkxvP9EvHLGnzmiR7r0F17zPy/jKujR21i6YPhnTNAKjiQ6UwLkbOWhouP18dKZc kY97KdU3h8Wopi/XOk61I+M58ynuIaDXbo2/gj4cXeVDDz2L2YjdHOnGHkxdiIHOWgo+ 96MqKlwO62aJdhWdC8MRpM9qbocmnyQCABxLvFfUslqH581tQcGHPj8AAB6S4dgXa5VW 5IO3V5iqZF4nH+YYbGM+StalWd393LkcHpQqAheoUeuGSoTAWb7ugqTslTUzs976Iirt bIrQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l36si2353793edc.272.2019.11.21.07.22.41; Thu, 21 Nov 2019 07:23:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727148AbfKUPUq (ORCPT + 99 others); Thu, 21 Nov 2019 10:20:46 -0500 Received: from relay5-d.mail.gandi.net ([217.70.183.197]:58933 "EHLO relay5-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726541AbfKUPUq (ORCPT ); Thu, 21 Nov 2019 10:20:46 -0500 X-Originating-IP: 153.3.140.100 Received: from localhost.localdomain.localdomain (unknown [153.3.140.100]) (Authenticated sender: fly@kernel.page) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 85FE91C0002; Thu, 21 Nov 2019 15:20:33 +0000 (UTC) From: Pengfei Li To: akpm@linux-foundation.org Cc: mgorman@techsingularity.net, mhocko@kernel.org, vbabka@suse.cz, cl@linux.com, iamjoonsoo.kim@lge.com, guro@fb.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Pengfei Li Subject: [RFC v1 07/19] mm, vmscan: use first_node in throttle_direct_reclaim() Date: Thu, 21 Nov 2019 23:17:59 +0800 Message-Id: <20191121151811.49742-8-fly@kernel.page> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191121151811.49742-1-fly@kernel.page> References: <20191121151811.49742-1-fly@kernel.page> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In throttle_direct_reclaim(), we want to access first node instead of first zone, so use first_node_nlist instead of first_zone_zonelist. Signed-off-by: Pengfei Li --- mm/vmscan.c | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 159a2aaa8db1..7554c8ba0841 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -3166,9 +3166,9 @@ static bool allow_direct_reclaim(pg_data_t *pgdat) static bool throttle_direct_reclaim(gfp_t gfp_mask, struct nodelist *nodelist, nodemask_t *nodemask) { - struct nlist_traverser t; - struct zone *zone; - pg_data_t *pgdat = NULL; + pg_data_t *pgdat; + enum zone_type high_idx; + int node; /* * Kernel threads should not be throttled as they may be indirectly @@ -3178,21 +3178,24 @@ static bool throttle_direct_reclaim(gfp_t gfp_mask, struct nodelist *nodelist, * processes to block on log_wait_commit(). */ if (current->flags & PF_KTHREAD) - goto out; + return false; /* * If a fatal signal is pending, this process should not throttle. * It should return quickly so it can exit and free its memory */ if (fatal_signal_pending(current)) - goto out; + return false; /* * Check if the pfmemalloc reserves are ok by finding the first node * with a usable ZONE_NORMAL or lower zone. The expectation is that * GFP_KERNEL will be required for allocating network buffers when * swapping over the network so ZONE_HIGHMEM is unusable. - * + */ + high_idx = min_t(enum zone_type, ZONE_NORMAL, gfp_zone(gfp_mask)); + + /* * Throttling is based on the first usable node and throttled processes * wait on a queue until kswapd makes progress and wakes them. There * is an affinity then between processes waking up and where reclaim @@ -3201,21 +3204,16 @@ static bool throttle_direct_reclaim(gfp_t gfp_mask, struct nodelist *nodelist, * for remote pfmemalloc reserves and processes on different nodes * should make reasonable progress. */ - for_each_zone_nlist_nodemask(zone, &t, nodelist, - gfp_zone(gfp_mask), nodemask) { - if (zone_idx(zone) > ZONE_NORMAL) - continue; - - /* Throttle based on the first usable node */ - pgdat = zone->zone_pgdat; - if (allow_direct_reclaim(pgdat)) - goto out; - break; - } + node = first_node_nlist_nodemask(nodelist, high_idx, nodemask); /* If no zone was usable by the allocation flags then do not throttle */ - if (!pgdat) - goto out; + if (node == NUMA_NO_NODE) + return false; + + pgdat = NODE_DATA(node); + /* Throttle based on the first usable node */ + if (allow_direct_reclaim(pgdat)) + return false; /* Account for the throttling */ count_vm_event(PGSCAN_DIRECT_THROTTLE); @@ -3236,14 +3234,13 @@ static bool throttle_direct_reclaim(gfp_t gfp_mask, struct nodelist *nodelist, } /* Throttle until kswapd wakes the process */ - wait_event_killable(zone->zone_pgdat->pfmemalloc_wait, - allow_direct_reclaim(pgdat)); + wait_event_killable(pgdat->pfmemalloc_wait, + allow_direct_reclaim(pgdat)); check_pending: if (fatal_signal_pending(current)) return true; -out: return false; } -- 2.23.0