From patchwork Fri Nov 23 11:45:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mel Gorman X-Patchwork-Id: 10695663 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A84EE13BB for ; Fri, 23 Nov 2018 11:45:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9897F2C02D for ; Fri, 23 Nov 2018 11:45:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8CAB12C90C; Fri, 23 Nov 2018 11:45:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F33332C02D for ; Fri, 23 Nov 2018 11:45:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 57BBA6B2CF4; Fri, 23 Nov 2018 06:45:32 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 55D356B2CF6; Fri, 23 Nov 2018 06:45:32 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 30A1C6B2CF8; Fri, 23 Nov 2018 06:45:32 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by kanga.kvack.org (Postfix) with ESMTP id C77986B2CF6 for ; Fri, 23 Nov 2018 06:45:31 -0500 (EST) Received: by mail-ed1-f71.google.com with SMTP id l45so5697293edb.1 for ; Fri, 23 Nov 2018 03:45:31 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=67eksPrwLW39zu9wZTOZe/O2EYcDl/Fitm/q/93Nxng=; b=Ng3SEVxjcU1VYlK/UBIFujAizriQ6Kyxqy09qEhUup4Vj1f24Lgv/+OHYkfdW43flj I4LitEOePrzYi+Y6htY1NtsJBzMLFZ/WHvI41uRiBJR1JzF7189po4VA7mUfTiGp9mZx 96zmQw9e78ISkxLEl9ZObmbhv5bVjnsanRZp1cqOnrqplbu/yYDeMDRw8YE9dBTV4GUq 2bbeSRGtnJzY3T+/3oxr5kvnJa8Q9wVEyhW7QBN+9iA3KZF8bkIqg8/wArfDUf23MNs6 Ark5Z6rLsDdBlF8d/AxZAGRNW4V7QO0B02iYNTgle8h2rQOXWk8+SbcldQg15EFL728n fPmw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of mgorman@techsingularity.net designates 46.22.139.15 as permitted sender) smtp.mailfrom=mgorman@techsingularity.net X-Gm-Message-State: AGRZ1gJy8o8z50UgErkQ1NPgzyJ4y13nefoWnM/3feLtTS7uoLP729xd ILK3phOD0FIw9iUp7bXndA+B2EONmYhaoxYjx0V/E4fLGf0wABaToRVJAAANdJSHeAdlv0z9N7y hLT7yTZDtbk7YDwhT0R8XlfqBXI/derTx+1mQVNsCO5M7TpizQxokfujA+1nzxkD2Bw== X-Received: by 2002:a17:906:f1c9:: with SMTP id gx9-v6mr11229176ejb.144.1542973531259; Fri, 23 Nov 2018 03:45:31 -0800 (PST) X-Google-Smtp-Source: AJdET5e6okPZA24wv/cR1bBGL7On3VAd4VDa2Qx2EWUk4/Flu0wiIiLVyQXxlsh14mZs0CiCWSQ5 X-Received: by 2002:a17:906:f1c9:: with SMTP id gx9-v6mr11229127ejb.144.1542973530160; Fri, 23 Nov 2018 03:45:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542973530; cv=none; d=google.com; s=arc-20160816; b=KQ95+FnjWqDyFdO5E4bYm+OrCFq4H5517GFhf86i006fdci6PEDM5/Ookda3FHjZ7X WaP1v5lFiyOqO76FfQZCRQ/fBn1zkffhNUldnJiksmBi4+lzO6sSD39xplTovichF2j2 Y8XhNHoQNWMYhIKVpxW8Dx/SBut0ZuAwNgFnNCy1aJ+8yU925cPZctqIsFsujDLcRgoX gTR2g7EEsTdbHm3L/kqWvIRsnrgS3VW3jjMz7aydzARmOagqZT1WjdcEDYXxgDNyY8iU c2pvhvooxPRYrDbrInHOm7NzLHVrlJXCpFodyJ8nrYfRIIL5U3aHozpnjsfI0PtIiQ9R 5DYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=67eksPrwLW39zu9wZTOZe/O2EYcDl/Fitm/q/93Nxng=; b=d8aRExdRqRmrtbfz/jZfES84bwbeKunDZVAsSj5hoMSrPHUSqo6gRIYJg4y8mw3Lx8 PzhPteqFMIwoIOO+79tWGd0N0wwNcXd617jAJM/ZvqaN3q57EQlUfwBYPMsxKec+WWcf jjBE/prF/HBP84xtkmstU17jBZdFm1NoHQA1gPK8Kb4DS6jCkYztYynrPpjmsRdO5DKb 2TnYht+fg0b9C5ltoWPL4PFq+WSouQw0iyJLSmMW6d1CHUY6PJWSNBbyNEVw4/zitBtu RwY24GxiyjN1ywX9hD6qRobf5+3+kJU2kHvh1+XQyopdA5R7kBoNw9As//R6XSB2viw8 NlQg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of mgorman@techsingularity.net designates 46.22.139.15 as permitted sender) smtp.mailfrom=mgorman@techsingularity.net Received: from outbound-smtp10.blacknight.com (outbound-smtp10.blacknight.com. [46.22.139.15]) by mx.google.com with ESMTPS id x12si2569576edh.28.2018.11.23.03.45.29 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Nov 2018 03:45:30 -0800 (PST) Received-SPF: pass (google.com: domain of mgorman@techsingularity.net designates 46.22.139.15 as permitted sender) client-ip=46.22.139.15; Authentication-Results: mx.google.com; spf=pass (google.com: domain of mgorman@techsingularity.net designates 46.22.139.15 as permitted sender) smtp.mailfrom=mgorman@techsingularity.net Received: from mail.blacknight.com (pemlinmail04.blacknight.ie [81.17.254.17]) by outbound-smtp10.blacknight.com (Postfix) with ESMTPS id C8B411C2CEF for ; Fri, 23 Nov 2018 11:45:29 +0000 (GMT) Received: (qmail 12335 invoked from network); 23 Nov 2018 11:45:29 -0000 Received: from unknown (HELO stampy.163woodhaven.lan) (mgorman@techsingularity.net@[37.228.229.69]) by 81.17.254.9 with ESMTPA; 23 Nov 2018 11:45:29 -0000 From: Mel Gorman To: Andrew Morton Cc: Vlastimil Babka , David Rientjes , Andrea Arcangeli , Zi Yan , Michal Hocko , LKML , Linux-MM , Mel Gorman Subject: [PATCH 3/5] mm: Use alloc_flags to record if kswapd can wake Date: Fri, 23 Nov 2018 11:45:26 +0000 Message-Id: <20181123114528.28802-4-mgorman@techsingularity.net> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20181123114528.28802-1-mgorman@techsingularity.net> References: <20181123114528.28802-1-mgorman@techsingularity.net> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP This is a preparation patch that copies the GFP flag __GFP_KSWAPD_RECLAIM into alloc_flags. This is a preparation patch only that avoids having to pass gfp_mask through a long callchain in a future patch. Note that the setting in the fast path happens in alloc_flags_nofragment() and it may be claimed that this has nothing to do with ALLOC_NO_FRAGMENT. That's true in this patch but is not true later so it's done now for easier review to show where the flag needs to be recorded. No functional change. Signed-off-by: Mel Gorman Acked-by: Vlastimil Babka --- mm/internal.h | 1 + mm/page_alloc.c | 25 +++++++++++++++++-------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/mm/internal.h b/mm/internal.h index 544355156c92..be826ee9dc7f 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -489,6 +489,7 @@ unsigned long reclaim_clean_pages_from_list(struct zone *zone, #else #define ALLOC_NOFRAGMENT 0x0 #endif +#define ALLOC_KSWAPD 0x200 /* allow waking of kswapd */ enum ttu_flags; struct tlbflush_unmap_batch; diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 4ba84cd2977a..e44eb68744ed 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3278,10 +3278,15 @@ static bool zone_allows_reclaim(struct zone *local_zone, struct zone *zone) * fragmentation between the Normal and DMA32 zones. */ static inline unsigned int -alloc_flags_nofragment(struct zone *zone) +alloc_flags_nofragment(struct zone *zone, gfp_t gfp_mask) { + unsigned int alloc_flags = 0; + + if (gfp_mask & __GFP_KSWAPD_RECLAIM) + alloc_flags |= ALLOC_KSWAPD; + if (zone_idx(zone) != ZONE_NORMAL) - return 0; + goto out; /* * If ZONE_DMA32 exists, assume it is the one after ZONE_NORMAL and @@ -3290,13 +3295,14 @@ alloc_flags_nofragment(struct zone *zone) */ BUILD_BUG_ON(ZONE_NORMAL - ZONE_DMA32 != 1); if (nr_online_nodes > 1 && !populated_zone(--zone)) - return 0; + goto out; - return ALLOC_NOFRAGMENT; +out: + return alloc_flags; } #else static inline unsigned int -alloc_flags_nofragment(struct zone *zone) +alloc_flags_nofragment(struct zone *zone, gfp_t gfp_mask) { return 0; } @@ -3939,6 +3945,9 @@ gfp_to_alloc_flags(gfp_t gfp_mask) } else if (unlikely(rt_task(current)) && !in_interrupt()) alloc_flags |= ALLOC_HARDER; + if (gfp_mask & __GFP_KSWAPD_RECLAIM) + alloc_flags |= ALLOC_KSWAPD; + #ifdef CONFIG_CMA if (gfpflags_to_migratetype(gfp_mask) == MIGRATE_MOVABLE) alloc_flags |= ALLOC_CMA; @@ -4170,7 +4179,7 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order, if (!ac->preferred_zoneref->zone) goto nopage; - if (gfp_mask & __GFP_KSWAPD_RECLAIM) + if (alloc_flags & ALLOC_KSWAPD) wake_all_kswapds(order, gfp_mask, ac); /* @@ -4228,7 +4237,7 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order, retry: /* Ensure kswapd doesn't accidentally go to sleep as long as we loop */ - if (gfp_mask & __GFP_KSWAPD_RECLAIM) + if (alloc_flags & ALLOC_KSWAPD) wake_all_kswapds(order, gfp_mask, ac); reserve_flags = __gfp_pfmemalloc_flags(gfp_mask); @@ -4451,7 +4460,7 @@ __alloc_pages_nodemask(gfp_t gfp_mask, unsigned int order, int preferred_nid, * Forbid the first pass from falling back to types that fragment * memory until all local zones are considered. */ - alloc_flags |= alloc_flags_nofragment(ac.preferred_zoneref->zone); + alloc_flags |= alloc_flags_nofragment(ac.preferred_zoneref->zone, gfp_mask); /* First allocation attempt */ page = get_page_from_freelist(alloc_mask, order, alloc_flags, &ac);