From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CCF33C433DF for ; Fri, 3 Jul 2020 06:34:41 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8EB68204EA for ; Fri, 3 Jul 2020 06:34:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="j179t90F" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8EB68204EA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 301FE8D0036; Fri, 3 Jul 2020 02:34:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 28B988D0010; Fri, 3 Jul 2020 02:34:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 17B5A8D0036; Fri, 3 Jul 2020 02:34:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0006.hostedemail.com [216.40.44.6]) by kanga.kvack.org (Postfix) with ESMTP id 0163C8D0010 for ; Fri, 3 Jul 2020 02:34:40 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id B51AA1AAF7 for ; Fri, 3 Jul 2020 06:34:40 +0000 (UTC) X-FDA: 76995801120.25.grass94_100f4dd26e8f Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin25.hostedemail.com (Postfix) with ESMTP id 8B6861804E3A1 for ; Fri, 3 Jul 2020 06:34:40 +0000 (UTC) X-HE-Tag: grass94_100f4dd26e8f X-Filterd-Recvd-Size: 5033 Received: from mail-qt1-f194.google.com (mail-qt1-f194.google.com [209.85.160.194]) by imf16.hostedemail.com (Postfix) with ESMTP for ; Fri, 3 Jul 2020 06:34:40 +0000 (UTC) Received: by mail-qt1-f194.google.com with SMTP id w34so3126291qte.1 for ; Thu, 02 Jul 2020 23:34:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=u3qUOwsLsxiI6rED0QEYL5qR8wzRy0UEcKjWHFa8UvI=; b=j179t90FJYaHQ8HrtSupONgPsJoyTJ/0hYShVlyk5GgeN4gfTvp0PrqUpIGefV6oDd RmvOZIjjs5Kmax3U05y02v290UF7xB3UhruS01xuLJMEDTMomlsgJo3epZsHwwf8JBEG W535mzODdv7E0+RPlUcNGU6VnY5Wkl0xgbZ6/aTtP5LagZt4veLnACzgg3gJZnxHlPYM 66BLAfjbv68vHAazNY+f10Q7sbsiscMIAtGIvy4VIXJGDJ3wMT/EvajAdXMeFZeYP6FE yl0dvptsEmOYuGHG/nX3SRE/wW4aPIlSJ3OTAeabW1hVvrjGKwnvXRVfx+Z+LOLjbo4h ZUJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=u3qUOwsLsxiI6rED0QEYL5qR8wzRy0UEcKjWHFa8UvI=; b=SlWHUYqohroZWFNb0Mp8rCChEqFxrzvEeNLXBhGJ4pIqdyrIberDGUmXwUZ9Ol153U teXTph0DVG6taZa2tWFkg1FPVpT19xdCqr01I0EVk3zReofKS1sF+w8+BnRwsmZ+b4w2 hG7WX+an8SR5REOIM1jbo6FXY+lW6zuDvRBehlZZOJ1N/onM6c1zojQ0oW/dFmBr1l3A nV/yxRCA3DCVg0CcwaR87+fzFuLqVKUvHWFSnM2na/bsqXu0SaT7X8G15sNrrd7C222K vsXjAWhyBQrCYgWiFKrcLyveSpOV8HZbEEb0wrHLJAS2y+PIIXi7DLJIpWyWuWujPqYY No7g== X-Gm-Message-State: AOAM530jF0ywjAuEqtJjK5nBPfPxcfIK56bExlMtrwsaV+0mlzFNflJl l3jLaTxNjB0LOXmXevht4RlLiYbQTlM+S5Ogr98= X-Google-Smtp-Source: ABdhPJxp99OgQObzPF0as7boQdLWlTQnTQqoQluZE28e6gu3A2d44LTgDPnGhHIijm2s/ty9DSHmsis/xk6UUCzE/C8= X-Received: by 2002:ac8:18b2:: with SMTP id s47mr21636760qtj.114.1593758079511; Thu, 02 Jul 2020 23:34:39 -0700 (PDT) MIME-Version: 1.0 References: <20200703061350.94474-1-songmuchun@bytedance.com> In-Reply-To: <20200703061350.94474-1-songmuchun@bytedance.com> From: Pekka Enberg Date: Fri, 3 Jul 2020 09:34:24 +0300 Message-ID: Subject: Re: [PATCH RESEND] mm/page_alloc: skip setting nodemask when we are in interrupt To: Muchun Song Cc: Andrew Morton , david@redhat.com, "linux-mm@kvack.org" , LKML Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 8B6861804E3A1 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 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: On Fri, Jul 3, 2020 at 9:14 AM Muchun Song wrote: > > 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 > --- > mm/page_alloc.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index b48336e20bdcd..a6c36cd557d1d 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -4726,10 +4726,12 @@ static inline bool prepare_alloc_pages(gfp_t gfp_mask, unsigned int order, > > if (cpusets_enabled()) { > *alloc_mask |= __GFP_HARDWALL; > - if (!ac->nodemask) > - ac->nodemask = &cpuset_current_mems_allowed; > - else > + if (!ac->nodemask) { > + if (!in_interrupt()) > + ac->nodemask = &cpuset_current_mems_allowed; If !ac->nodemask and in_interrupt() the ALLOC_CPUSET flag is not set, which by-passes the __cpuset_zone_allowed() check for allocations. This works fine because in the case if in_interrupt() the function allows allocation on any zone/node. > + } else { > *alloc_flags |= ALLOC_CPUSET; > + } > } However, if you write the condition as follows: if (cpusets_enabled()) { *alloc_mask |= __GFP_HARDWALL; if (!in_interrupt() && !ac->nodemask) ac->nodemask = &cpuset_current_mems_allowed; else *alloc_flags |= ALLOC_CPUSET; } then the code is future-proof in case of __cpuset_zone_allowed() is one day extended to support IRQ context too (it probably should eventually respect IRQ SMP affinity). > > fs_reclaim_acquire(gfp_mask); > -- > 2.11.0 > >