Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp3099701rwl; Fri, 6 Jan 2023 15:52:14 -0800 (PST) X-Google-Smtp-Source: AMrXdXvkCnIlMzJxoKYMAhz5EM2M2w/nD9oua2X0JFD/RnMHIKFVcQBUlwJ4t0SLCqDxdyJuKpfi X-Received: by 2002:a17:906:a38f:b0:7c4:f348:3b1f with SMTP id k15-20020a170906a38f00b007c4f3483b1fmr49163043ejz.44.1673049134255; Fri, 06 Jan 2023 15:52:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673049134; cv=none; d=google.com; s=arc-20160816; b=kOLjhXPkFdUalCyGXZBQlYwqskVlW6ocvOPEc4Pzo7WdsTMgCCsndg3SpDmIjioY5i 5P16/E4v9HsC0HXHA7ZNlx+f+RBgQ2G7rZ+WXLg+wIoyQuzEClI950LGtGBGTqUFw93p LM8j4j60OdyD+ja1lIFE4ztbx93FXcAeBmwQ0VDN7QOFOlBo2T6dKcmaH6IJhKClkYdl MyEojD7Jh7UsTg6XxINfZB9N2g3s8Iagfu/l6f9IFSzCAalK1AanQqltH2lDwtk9tpIn wquHoVvy14ok4RYUGYqdN1VkmRyzg+F2t6y/Dw0scvFRl47wrEAhdW57jHUJRAiXgYKJ My8A== 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:cc:to:from :dkim-signature; bh=z0CwGrxELIAzTH6XvbJHxAjTC7f+hD8FqVOP90neThk=; b=X5uqH4LEcbAxKQAOzXlbbjs33sg3QYZ5JRTG6SUDpOumgqWnpeu85Edx4vipOio51y K+xRQCnTKjG59WLOqbpHFzPVNUxa6cUmN8INIcP1bC7glpCzUMRclTNFYaUn77IN2323 HOvMKI/AXOrduQ1pLlabkdBP775nUev4dd6rocnu1PGXAJFD9iJqFuM4bDhXNU4N/9Va 7eLdjovFYgJNHWVD/VF+jQQTP0Aiqb/8OOnMKu9PYO+HJ1jE/M/DtcMcgEU3vJeV2Z7J 5pjye10Y+v3Qms3rlcFThc1oVuk06vdf32ptmidThkMBffMO5JW6dkOMv4BHZHppCpS9 1EHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=V6hoVNwO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ji6-20020a170907980600b007877b1c7f27si3106710ejc.829.2023.01.06.15.52.01; Fri, 06 Jan 2023 15:52:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=V6hoVNwO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229686AbjAFXX5 (ORCPT + 55 others); Fri, 6 Jan 2023 18:23:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229521AbjAFXXz (ORCPT ); Fri, 6 Jan 2023 18:23:55 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4226D77D0B for ; Fri, 6 Jan 2023 15:23:55 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C0A8561F9F for ; Fri, 6 Jan 2023 23:23:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 99C0AC433EF; Fri, 6 Jan 2023 23:23:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673047434; bh=3vR6NKS+8/yDQjacQCEJb90byWuxg5F7fZOgQOiReDg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V6hoVNwOsxR3O9WTuGhqKa+r81MHV/aTvBqWvil5PnvOy5xGqsZ9nMgVfiK9mGT5I r+XdOGgbyG75OkC1/VVdK+To2F5z7zoNXFTXt1csLg7QZqsWkTOW0KDDPQwcy86EDl xpbZmfWQuK+Ob6smVigQePpwaSh7IHgJlsHmFIJj3tjJIruOMEoGqyBxZ+2vYZRqq7 6y42FY2OFq/avhdsaAV26tUoPv1m5eHiymgKti95A/rtEZD6iV8vjO8zrdtOBLvUWJ i9KmIwjAEoKdKXWOyZTsOaoOOCohixJvFM5wKeuOrVOoB4kPQy7U7LdawdCRVkMvEy fyuVr4ncJs40g== From: SeongJae Park To: Sidhartha Kumar Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, vbabka@suse.cz, sj@kernel.org, Matthew Wilcox Subject: Re: [PATCH mm-unstable] mm: introduce folio_is_pfmemalloc Date: Fri, 6 Jan 2023 23:23:52 +0000 Message-Id: <20230106232352.1520-1-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230106215251.599222-1-sidhartha.kumar@oracle.com> References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Sidhartha, On Fri, 6 Jan 2023 15:52:51 -0600 Sidhartha Kumar wrote: > Add a folio equivalent for page_is_pfmemalloc. This removes two instances > of page_is_pfmemalloc(folio_page(folio, 0)) so the folio can be used > directly. > > Suggested-by: Matthew Wilcox > Signed-off-by: Sidhartha Kumar Reviewed-by: SeongJae Park Thanks, SJ > --- > include/linux/mm.h | 15 +++++++++++++++ > mm/slab.c | 2 +- > mm/slub.c | 2 +- > 3 files changed, 17 insertions(+), 2 deletions(-) > > diff --git a/include/linux/mm.h b/include/linux/mm.h > index c37f9330f14e..79d5a0cbf4c3 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -1906,6 +1906,21 @@ static inline bool page_is_pfmemalloc(const struct page *page) > return (uintptr_t)page->lru.next & BIT(1); > } > > +/* > + * Return true only if the folio has been allocated with > + * ALLOC_NO_WATERMARKS and the low watermark was not > + * met implying that the system is under some pressure. > + */ > +static inline bool folio_is_pfmemalloc(const struct folio *folio) > +{ > + /* > + * lru.next has bit 1 set if the page is allocated from the > + * pfmemalloc reserves. Callers may simply overwrite it if > + * they do not need to preserve that information. > + */ > + return (uintptr_t)folio->lru.next & BIT(1); > +} > + > /* > * Only to be called by the page allocator on a freshly allocated > * page. > diff --git a/mm/slab.c b/mm/slab.c > index 7a269db050ee..01291ecbc0d8 100644 > --- a/mm/slab.c > +++ b/mm/slab.c > @@ -1373,7 +1373,7 @@ static struct slab *kmem_getpages(struct kmem_cache *cachep, gfp_t flags, > /* Make the flag visible before any changes to folio->mapping */ > smp_wmb(); > /* Record if ALLOC_NO_WATERMARKS was set when allocating the slab */ > - if (sk_memalloc_socks() && page_is_pfmemalloc(folio_page(folio, 0))) > + if (sk_memalloc_socks() && folio_is_pfmemalloc(folio)) > slab_set_pfmemalloc(slab); > > return slab; > diff --git a/mm/slub.c b/mm/slub.c > index 13459c69095a..0cbe6eff23fa 100644 > --- a/mm/slub.c > +++ b/mm/slub.c > @@ -1859,7 +1859,7 @@ static inline struct slab *alloc_slab_page(gfp_t flags, int node, > __folio_set_slab(folio); > /* Make the flag visible before any changes to folio->mapping */ > smp_wmb(); > - if (page_is_pfmemalloc(folio_page(folio, 0))) > + if (folio_is_pfmemalloc(folio)) > slab_set_pfmemalloc(slab); > > return slab; > -- > 2.39.0 > >