From patchwork Mon Jul 6 02:59:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 11644843 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1833513BD for ; Mon, 6 Jul 2020 02:59:42 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CFC1420C09 for ; Mon, 6 Jul 2020 02:59:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=bytedance-com.20150623.gappssmtp.com header.i=@bytedance-com.20150623.gappssmtp.com header.b="TIfYnbWc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CFC1420C09 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bytedance.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 11DB86B0006; Sun, 5 Jul 2020 22:59:41 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0A9786B0007; Sun, 5 Jul 2020 22:59:41 -0400 (EDT) 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 E89DB6B000A; Sun, 5 Jul 2020 22:59:40 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0092.hostedemail.com [216.40.44.92]) by kanga.kvack.org (Postfix) with ESMTP id CFEF56B0006 for ; Sun, 5 Jul 2020 22:59:40 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 8E857180AD801 for ; Mon, 6 Jul 2020 02:59:40 +0000 (UTC) X-FDA: 77006145720.03.push58_15018cf26ea8 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin03.hostedemail.com (Postfix) with ESMTP id 61C2F28A4E8 for ; Mon, 6 Jul 2020 02:59:40 +0000 (UTC) X-Spam-Summary: 1,0,0,db5c2a0d6bc0a6f4,d41d8cd98f00b204,songmuchun@bytedance.com,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1311:1314:1345:1437:1515:1534:1541:1711:1730:1747:1777:1792:2198:2199:2393:2559:2562:2731:2904:3138:3139:3140:3141:3142:3352:3865:3866:3867:3868:3870:3871:3872:3874:4321:5007:6261:6653:7903:10004:11026:11658:11914:12297:12438:12517:12519:12555:12895:12986:13069:13311:13357:13894:14096:14181:14384:14394:14721:21080:21433:21444:21451:21627:21740:30012:30054,0,RBL:209.85.214.195:@bytedance.com:.lbl8.mailshell.net-62.14.0.100 66.201.201.201;04yr1esn37ynbkiqzb5jjeopabf9aop6jah4bjkdzcjhouxhusiy3qzx3caq6ba.7b9gx1gsrso4fifuak671c4tyethh8c7awtz7o7pxd48bqyu8n1pr561g1tpoty.g-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:29,LUA_SUMMARY:none X-HE-Tag: push58_15018cf26ea8 X-Filterd-Recvd-Size: 4223 Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) by imf21.hostedemail.com (Postfix) with ESMTP for ; Mon, 6 Jul 2020 02:59:39 +0000 (UTC) Received: by mail-pl1-f195.google.com with SMTP id j7so1410032plk.13 for ; Sun, 05 Jul 2020 19:59:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=DGAUzjy/XhmI74RBjvCLCFYywNRTd6tVl+Zu7OWC5SI=; b=TIfYnbWcNnjcprjJouqUCmxuohAPvGPCE9Tgmy5A/vCTOwSTLwL5gJFFHSQweCb/jL 2GkNyo5jChOwHUL5mSRyH08Gf21EIUWNx0LvRAQ/MeO4pniVUNdQHqDiMbREPGEiiiKb /3ALD88wvPderiGgatDu3bd0Zm8cYIdOQ+35dGWsWjOuwYODLxl0biosSOfM5+NCVvRR qx8Pg56oF0F38Qb3G4kePP69GsjFu7qTU5BQcFGi4N5lU+8afOGeVvyeNLs2/CyJHrLu qEd/lBKy3+K7tA0A3RsBKjJb3SMFjbDEC+7SGay9yly7nj7mkEjqOPWOuZKjhcGj3yFY K8yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=DGAUzjy/XhmI74RBjvCLCFYywNRTd6tVl+Zu7OWC5SI=; b=MIyoKhGLcF50NpfZY+sYvF3XBC2IMT8H6xy/8bHG2I/EEKqZ4F+5ivSrK4NIz4t6Y1 vESJhBgwm7y29NqMiyODc9NtFDMRugGmtJpV9ABJicmfXM+EOJ5AsMEPvwnPsggSUVnv wz6A1QX17LiFWHknjdF7sTw3KvkERUHCVWoJxLrJlztsYsnyM7KwlAA0C+XAJmbhJLpz az1+Wyoox6hxTN2qMQxg4pF2ioztMysnNj7UQsDPVC85IyHunvR9bBPpa+Vu2w8th/iA Axo+S4eJhp9VA95D+NqUdJm0KF34HqiNRpVexsKk5ygZbAeNFVwIi3c0QPG4VnfPh4jS l7AQ== X-Gm-Message-State: AOAM530AFcwUeprO1YIJQV4gJjqN/b2Sl/Iul1bZrnTCtAnKzOkXONxc uUZaidvkbRpfhWKAn6BQ39dUvw== X-Google-Smtp-Source: ABdhPJwK+09JRKTiaglUg2rIl55+RRz//tPhPpYbiuiUeQmqdPVMLlGkF1Kr+4L5VjytGMFqBCHQrw== X-Received: by 2002:a17:90a:fd03:: with SMTP id cv3mr48786206pjb.111.1594004378800; Sun, 05 Jul 2020 19:59:38 -0700 (PDT) Received: from Smcdef-MBP.local.net ([103.136.220.69]) by smtp.gmail.com with ESMTPSA id q1sm18491594pfk.132.2020.07.05.19.59.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 05 Jul 2020 19:59:38 -0700 (PDT) From: Muchun Song To: akpm@linux-foundation.org, david@redhat.com, penberg@gmail.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Muchun Song Subject: [PATCH v2] mm/page_alloc: skip setting nodemask when we are in interrupt Date: Mon, 6 Jul 2020 10:59:21 +0800 Message-Id: <20200706025921.53683-1-songmuchun@bytedance.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) MIME-Version: 1.0 X-Rspamd-Queue-Id: 61C2F28A4E8 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 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: When we are in the interrupt context, it is irrelevant to the current task context. If we use current task's mems_allowed, we can fair to alloc pages in the fast path and fall back to slow path memory allocation when the current node(which is the current task mems_allowed) does not have enough memory to allocate. In this case, it slows down the memory allocation speed of interrupt context. So we can skip setting the nodemask to allow any node to allocate memory, so that fast path allocation can success. Signed-off-by: Muchun Song Reviewed-by: Pekka Enberg --- changelog in v2: 1) rework the code suggested by Pekka Enberg 2) add a comment mm/page_alloc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 9808339a6e93b..6678c4c1c3087 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -4799,7 +4799,11 @@ static inline bool prepare_alloc_pages(gfp_t gfp_mask, unsigned int order, if (cpusets_enabled()) { *alloc_mask |= __GFP_HARDWALL; - if (!ac->nodemask) + /* + * When we are in the interrupt context, it is irrelevant + * to the current task context. It means that any node ok. + */ + if (!in_interrupt() && !ac->nodemask) ac->nodemask = &cpuset_current_mems_allowed; else *alloc_flags |= ALLOC_CPUSET;