Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1480367pxu; Thu, 17 Dec 2020 10:56:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJxYWrSGJd9cuU08cicTmz2RRn9SHXjfcf/Pr1mk8xYfdxwKfJnOoGZ5llC6DaUjPVqxy4hK X-Received: by 2002:a50:d604:: with SMTP id x4mr811918edi.64.1608231373570; Thu, 17 Dec 2020 10:56:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608231373; cv=none; d=google.com; s=arc-20160816; b=RNK2rcVCsXH1WBEqBXFR9WH28XlSRMzWtiFYKMjO8WBnbAFfpMQGqN+pnU9Ms6EpIi vXbkhi8HIDbe/B9/148mN0G3stP/qKvmGxDhhaOOnZREpyS98lAcd2O5vGnqybkqaJpG dYYCp1eOwPCCVTzljerWtnjJ/2Tx1GFCAw/ThfFzNs0Fy2W2PaMBq3O/7uqD/XZGNvO9 bH+71SUvFuniPNhl2FfZ7h7U8s2cWC6yGsbE8OZORMW9UcZBDv/ByLJQPjdHNSjhVtcZ k8drYgOoMzr9YOmbgxtYaonNNuv8Dxp/Pli4RcIHM2ar6G1jW/p39My4HR+DHFwUXpRq 7Fbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=7fMarcPKbF8eZ1EkRUpeh/DuV7Asm97DUovse3OVSm8=; b=jW3e1qb/Xr2NSBCi2mxXsdOWssavJsc0Dc1xSfQCBH454NfmjsLSarCOTqg7XLnfyB wejyFtJ4aOJ69POv6YyTm1N4NG1icFOZ75HQO02EpZv8cBG3xHvXbc4gMbGEN0DXyFqC NoCkRO1DSoQROaMTKM2VUGV68mFmfodv9V/GDYb+oI56+ZLsTXb8vI76EgXt2DvoYBiU Khvwj5GbnTXj5ImzehkRst21wQv0QP2dr7j4QKI6FdDu2QnHqZHNonSMYSw99PrYFabt +nHzlSkDPYIvZGpw22Y4VK/qUhAQXzXmYKA8OAYjx49UYoKYfOY0ekJhrU5TFyfz2XYg foBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@soleen.com header.s=google header.b=KAR7G1r8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i8si3502201ejj.424.2020.12.17.10.55.50; Thu, 17 Dec 2020 10:56:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@soleen.com header.s=google header.b=KAR7G1r8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730795AbgLQSyL (ORCPT + 99 others); Thu, 17 Dec 2020 13:54:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730190AbgLQSyJ (ORCPT ); Thu, 17 Dec 2020 13:54:09 -0500 Received: from mail-qt1-x82d.google.com (mail-qt1-x82d.google.com [IPv6:2607:f8b0:4864:20::82d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57753C0611CB for ; Thu, 17 Dec 2020 10:52:53 -0800 (PST) Received: by mail-qt1-x82d.google.com with SMTP id 7so20886726qtp.1 for ; Thu, 17 Dec 2020 10:52:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=7fMarcPKbF8eZ1EkRUpeh/DuV7Asm97DUovse3OVSm8=; b=KAR7G1r8yuIWa8PDp7CdQKfOdfBpq07/k6cAWElzxpy4lPAVDkyKNpz9GBsAjB+Mpz lxfemf+m/mTOfXRnI35Ee7KfkGcGIfv8CsVkvE0jAIdadt6l+8UbKkhv4etz+g6LOVaE YkFRyvV3s4qovarOY2EKXMvRRCDjZQ9rphgdpf/4va2tXF7c1EpmTIp7c9SH3O9qckhc k8Q9ggvp7Iel3UqSuov4qqKqB0FRAf47mOMPiV7GcjAUIh2KC99oq7l4e7U+VCZ1CRcm +cfFMPGkm300n/RM66V7Tst7/0nWpLsrja6P/8KdZrEeLdVvP/swKvoLNUQf+sZI9fON 2O9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7fMarcPKbF8eZ1EkRUpeh/DuV7Asm97DUovse3OVSm8=; b=cRdlANU14GZJ+vmfBy9+aZNPxViPF0KN4N+g7fSkMUNgf52v/Q4/h6sSl5Cpf2PE7L ugxp9bNwGB9xVvVfHyLASIWxcscsns7eIKCtkOM5Jm+b3xqFxK5QDMjOFDQNoXrWb2JJ Sn/z1l6wdRd0A/uT7LZ5tloHCf6cUzj65GSzQfIkMGSSW6up0WsgbHBTveaiN9JDo0w9 24lncz4ZjFFQxL+nNDZ3iwv1fwP2L2Vz/ZaNyr8NZeKW3cpdMUR+4vZKhRpYM1F92BQw MNH/sod04egzLUUmS+nYiA6wn0pfA680WExE7SeSLqf5+ObrIGvG2/HMu/wVGH6npx0k fY9g== X-Gm-Message-State: AOAM531tCO63Jd0OVxloqBJGB7A7Ig/XzbRbencor6Xs2rFdaxJI6cZN ccbz/pESfurXiB5/b8PK79/Mpw== X-Received: by 2002:ac8:4f13:: with SMTP id b19mr184478qte.150.1608231172508; Thu, 17 Dec 2020 10:52:52 -0800 (PST) Received: from localhost.localdomain (c-73-69-118-222.hsd1.nh.comcast.net. [73.69.118.222]) by smtp.gmail.com with ESMTPSA id m8sm4127434qkn.41.2020.12.17.10.52.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Dec 2020 10:52:51 -0800 (PST) From: Pavel Tatashin To: pasha.tatashin@soleen.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, vbabka@suse.cz, mhocko@suse.com, david@redhat.com, osalvador@suse.de, dan.j.williams@intel.com, sashal@kernel.org, tyhicks@linux.microsoft.com, iamjoonsoo.kim@lge.com, mike.kravetz@oracle.com, rostedt@goodmis.org, mingo@redhat.com, jgg@ziepe.ca, peterz@infradead.org, mgorman@suse.de, willy@infradead.org, rientjes@google.com, jhubbard@nvidia.com, linux-doc@vger.kernel.org, ira.weiny@intel.com, linux-kselftest@vger.kernel.org Subject: [PATCH v4 03/10] mm: apply per-task gfp constraints in fast path Date: Thu, 17 Dec 2020 13:52:36 -0500 Message-Id: <20201217185243.3288048-4-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201217185243.3288048-1-pasha.tatashin@soleen.com> References: <20201217185243.3288048-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Function current_gfp_context() is called after fast path. However, soon we will add more constraints which will also limit zones based on context. Move this call into fast path, and apply the correct constraints for all allocations. Also update .reclaim_idx based on value returned by current_gfp_context() because it soon will modify the allowed zones. Note: With this patch we will do one extra current->flags load during fast path, but we already load current->flags in fast-path: __alloc_pages_nodemask() prepare_alloc_pages() current_alloc_flags(gfp_mask, *alloc_flags); Later, when we add the zone constrain logic to current_gfp_context() we will be able to remove current->flags load from current_alloc_flags, and therefore return fast-path to the current performance level. Suggested-by: Michal Hocko Signed-off-by: Pavel Tatashin Acked-by: Michal Hocko --- mm/page_alloc.c | 15 ++++++++------- mm/vmscan.c | 10 ++++++---- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index ec05396a597b..c2dea9ad0e98 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -4976,6 +4976,13 @@ __alloc_pages_nodemask(gfp_t gfp_mask, unsigned int order, int preferred_nid, } gfp_mask &= gfp_allowed_mask; + /* + * Apply scoped allocation constraints. This is mainly about GFP_NOFS + * resp. GFP_NOIO which has to be inherited for all allocation requests + * from a particular context which has been marked by + * memalloc_no{fs,io}_{save,restore}. + */ + gfp_mask = current_gfp_context(gfp_mask); alloc_mask = gfp_mask; if (!prepare_alloc_pages(gfp_mask, order, preferred_nid, nodemask, &ac, &alloc_mask, &alloc_flags)) return NULL; @@ -4991,13 +4998,7 @@ __alloc_pages_nodemask(gfp_t gfp_mask, unsigned int order, int preferred_nid, if (likely(page)) goto out; - /* - * Apply scoped allocation constraints. This is mainly about GFP_NOFS - * resp. GFP_NOIO which has to be inherited for all allocation requests - * from a particular context which has been marked by - * memalloc_no{fs,io}_{save,restore}. - */ - alloc_mask = current_gfp_context(gfp_mask); + alloc_mask = gfp_mask; ac.spread_dirty_pages = false; /* diff --git a/mm/vmscan.c b/mm/vmscan.c index 469016222cdb..d9546f5897f4 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -3234,11 +3234,12 @@ static bool throttle_direct_reclaim(gfp_t gfp_mask, struct zonelist *zonelist, unsigned long try_to_free_pages(struct zonelist *zonelist, int order, gfp_t gfp_mask, nodemask_t *nodemask) { + gfp_t current_gfp_mask = current_gfp_context(gfp_mask); unsigned long nr_reclaimed; struct scan_control sc = { .nr_to_reclaim = SWAP_CLUSTER_MAX, - .gfp_mask = current_gfp_context(gfp_mask), - .reclaim_idx = gfp_zone(gfp_mask), + .gfp_mask = current_gfp_mask, + .reclaim_idx = gfp_zone(current_gfp_mask), .order = order, .nodemask = nodemask, .priority = DEF_PRIORITY, @@ -4158,17 +4159,18 @@ static int __node_reclaim(struct pglist_data *pgdat, gfp_t gfp_mask, unsigned in { /* Minimum pages needed in order to stay on node */ const unsigned long nr_pages = 1 << order; + gfp_t current_gfp_mask = current_gfp_context(gfp_mask); struct task_struct *p = current; unsigned int noreclaim_flag; struct scan_control sc = { .nr_to_reclaim = max(nr_pages, SWAP_CLUSTER_MAX), - .gfp_mask = current_gfp_context(gfp_mask), + .gfp_mask = current_gfp_mask, .order = order, .priority = NODE_RECLAIM_PRIORITY, .may_writepage = !!(node_reclaim_mode & RECLAIM_WRITE), .may_unmap = !!(node_reclaim_mode & RECLAIM_UNMAP), .may_swap = 1, - .reclaim_idx = gfp_zone(gfp_mask), + .reclaim_idx = gfp_zone(current_gfp_mask), }; trace_mm_vmscan_node_reclaim_begin(pgdat->node_id, order, -- 2.25.1