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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 457A5ECAAD1 for ; Wed, 31 Aug 2022 15:45:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CDD718D0001; Wed, 31 Aug 2022 11:45:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C8C9D6B0072; Wed, 31 Aug 2022 11:45:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B55BD8D0001; Wed, 31 Aug 2022 11:45:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id A7F286B0071 for ; Wed, 31 Aug 2022 11:45:28 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 709431C64D4 for ; Wed, 31 Aug 2022 15:45:28 +0000 (UTC) X-FDA: 79860312336.01.E79D207 Received: from mail-yb1-f170.google.com (mail-yb1-f170.google.com [209.85.219.170]) by imf26.hostedemail.com (Postfix) with ESMTP id 23E4D140053 for ; Wed, 31 Aug 2022 15:45:27 +0000 (UTC) Received: by mail-yb1-f170.google.com with SMTP id l196so4740890ybl.12 for ; Wed, 31 Aug 2022 08:45:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc; bh=Yg5lEIxwkC8L9g2KyGsqswRBhk4gAo50nJ7nWIpcdXc=; b=f3+0Eh/W8OX4KuooBQ0WgBNbVwjJbAXBKTWgD/1rnSxw8Or+o0OJFGSWtlhyJfP9gD QCFEtC0rc3uk17x5AtGX0ukxT/fwVuDehIBS7C3A9pMG33oU0ZJGMmly+vrXS5p4by0+ jDT69+FR9RtMW6e1SjrFZnroYNBot0xZKZX0R51jheU+mrpvrFLrGntTcPsTHaijk6mV iKPavpo7jboK8+tsNQ9Az/YAZSJr40a0Ai7H69DS5U2PS7wmYchRHvmW2/w/UajBDN7Y I8Esb137FVo77guaGTuDVZBl6klQw58Xua4rWyO6cGYeV+DdQ1NJpxEpQh+0pcY1wICS 8E3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=Yg5lEIxwkC8L9g2KyGsqswRBhk4gAo50nJ7nWIpcdXc=; b=OXZ7Fc6jWvFpnFw8V1317gx75h5lLatnd5cOLwfGMcIkeJqmSz0tLcrmT47wswWjix X8zHhqMEnmGq7B+hZ1MMloYf5wZMXSdjQbLRqNZm/tHBDxP6hctFQht3WbE6j/pFqnMA iXuSNO7nr8acGroP4EccI38BBvpQxXSIcYlVwRyuOP8BcqLwQG8zPeR3639kGvJDjNVU ItHbAksgoqn1gXCTr/FZ1II4dJpDdBSEPjIcJjrXcr7oAvwG7/GbfNCRDNEdpdQO66vQ +BCPaUOne5y/YcpbR7xdZfwvnsyRFhCGCDtw3fv5dkTDdPyaxY9+2WUhxQ/aUkLc2Nd+ YwcA== X-Gm-Message-State: ACgBeo28KMohp8Xi5RxFtQfFeNBguUBpOI3o74QjmIpOQko3t8Q4461o L6iYOO1PT6+0wtxYeS9+4bAeoSehyQfjlgl+FZcsWA== X-Google-Smtp-Source: AA6agR7eJQcze4oyVJ5u+oBz3mWkBzYq0MHuMfNSxceWOgOVlxBCkZ6NIfrADtyTqEPi+FGZK0IDnHN5ZKC4stom7pQ= X-Received: by 2002:a05:6902:705:b0:695:b3b9:41bc with SMTP id k5-20020a056902070500b00695b3b941bcmr16070987ybt.426.1661960727041; Wed, 31 Aug 2022 08:45:27 -0700 (PDT) MIME-Version: 1.0 References: <20220830214919.53220-1-surenb@google.com> <20220830214919.53220-11-surenb@google.com> <20220831101103.fj5hjgy3dbb44fit@suse.de> In-Reply-To: <20220831101103.fj5hjgy3dbb44fit@suse.de> From: Suren Baghdasaryan Date: Wed, 31 Aug 2022 08:45:16 -0700 Message-ID: Subject: Re: [RFC PATCH 10/30] mm: enable page allocation tagging for __get_free_pages and alloc_pages To: Mel Gorman Cc: Andrew Morton , Kent Overstreet , Michal Hocko , Vlastimil Babka , Johannes Weiner , Roman Gushchin , Davidlohr Bueso , Matthew Wilcox , "Liam R. Howlett" , David Vernet , Peter Zijlstra , Juri Lelli , Laurent Dufour , Peter Xu , David Hildenbrand , Jens Axboe , mcgrof@kernel.org, masahiroy@kernel.org, nathan@kernel.org, changbin.du@intel.com, ytcoode@gmail.com, Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Benjamin Segall , Daniel Bristot de Oliveira , Valentin Schneider , Christopher Lameter , Pekka Enberg , Joonsoo Kim , 42.hyeyoo@gmail.com, Alexander Potapenko , Marco Elver , dvyukov@google.com, Shakeel Butt , Muchun Song , arnd@arndb.de, jbaron@akamai.com, David Rientjes , Minchan Kim , Kalesh Singh , kernel-team , linux-mm , iommu@lists.linux.dev, kasan-dev@googlegroups.com, io-uring@vger.kernel.org, linux-arch@vger.kernel.org, xen-devel@lists.xenproject.org, linux-bcache@vger.kernel.org, linux-modules@vger.kernel.org, LKML Content-Type: text/plain; charset="UTF-8" ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b="f3+0Eh/W"; spf=pass (imf26.hostedemail.com: domain of surenb@google.com designates 209.85.219.170 as permitted sender) smtp.mailfrom=surenb@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661960728; a=rsa-sha256; cv=none; b=tcWQ/e65dlWWUZaWbzvNwAhrIujzzb/xmpiU0mYwRf0PxyPjDt2bCqZfo+eImToYb0ZfcB Rs4+6AMNGqA/z0nufBnGiYFgvHBRPg6mTb6IkZws1x5beBIpSve6tR4HrUHT81epwhVa36 5b3k9JXtsG62LbGJNlZO6oT8tVwWrFk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661960728; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Yg5lEIxwkC8L9g2KyGsqswRBhk4gAo50nJ7nWIpcdXc=; b=PhAzH8rA5S48xO1AXtpQdP0+G64lPnDT4CKxJ3cCfz3patmSPWhMnrsqsBPY28hNjeNd62 iGVxCZEfUsSvRHt4Si6BFfNZtf2P6IgHUPDtUwmdvMIR7GeqeGTVyimLppceUwllxARtMc Mwbb+mMpz00q2G9IwXOkC2hxM90FrVI= X-Rspam-User: X-Rspamd-Queue-Id: 23E4D140053 Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b="f3+0Eh/W"; spf=pass (imf26.hostedemail.com: domain of surenb@google.com designates 209.85.219.170 as permitted sender) smtp.mailfrom=surenb@google.com; dmarc=pass (policy=reject) header.from=google.com X-Stat-Signature: 8op4mmaqsdk63xys41w88p4in85d41na X-Rspamd-Server: rspam11 X-HE-Tag: 1661960727-963494 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 Wed, Aug 31, 2022 at 3:11 AM Mel Gorman wrote: > > On Tue, Aug 30, 2022 at 02:48:59PM -0700, Suren Baghdasaryan wrote: > > Redefine alloc_pages, __get_free_pages to record allocations done by > > these functions. Instrument deallocation hooks to record object freeing. > > > > Signed-off-by: Suren Baghdasaryan > > +#ifdef CONFIG_PAGE_ALLOC_TAGGING > > + > > #include > > #include > > > > @@ -25,4 +27,37 @@ static inline void pgalloc_tag_dec(struct page *page, unsigned int order) > > alloc_tag_sub(get_page_tag_ref(page), PAGE_SIZE << order); > > } > > > > +/* > > + * Redefinitions of the common page allocators/destructors > > + */ > > +#define pgtag_alloc_pages(gfp, order) \ > > +({ \ > > + struct page *_page = _alloc_pages((gfp), (order)); \ > > + \ > > + if (_page) \ > > + alloc_tag_add(get_page_tag_ref(_page), PAGE_SIZE << (order));\ > > + _page; \ > > +}) > > + > > Instead of renaming alloc_pages, why is the tagging not done in > __alloc_pages()? At least __alloc_pages_bulk() is also missed. The branch > can be guarded with IS_ENABLED. Hmm. Assuming all the other allocators using __alloc_pages are inlined, that should work. I'll try that and if that works will incorporate in the next respin. Thanks! I don't think IS_ENABLED is required because the tagging functions are already defined as empty if the appropriate configs are not enabled. Unless I misunderstood your node. > > > +#define pgtag_get_free_pages(gfp_mask, order) \ > > +({ \ > > + struct page *_page; \ > > + unsigned long _res = _get_free_pages((gfp_mask), (order), &_page);\ > > + \ > > + if (_res) \ > > + alloc_tag_add(get_page_tag_ref(_page), PAGE_SIZE << (order));\ > > + _res; \ > > +}) > > + > > Similar, the tagging could happen in a core function instead of a wrapper. > > > +#else /* CONFIG_PAGE_ALLOC_TAGGING */ > > + > > +#define pgtag_alloc_pages(gfp, order) _alloc_pages(gfp, order) > > + > > +#define pgtag_get_free_pages(gfp_mask, order) \ > > + _get_free_pages((gfp_mask), (order), NULL) > > + > > +#define pgalloc_tag_dec(__page, __size) do {} while (0) > > + > > +#endif /* CONFIG_PAGE_ALLOC_TAGGING */ > > + > > #endif /* _LINUX_PGALLOC_TAG_H */ > > diff --git a/mm/mempolicy.c b/mm/mempolicy.c > > index b73d3248d976..f7e6d9564a49 100644 > > --- a/mm/mempolicy.c > > +++ b/mm/mempolicy.c > > @@ -2249,7 +2249,7 @@ EXPORT_SYMBOL(vma_alloc_folio); > > * flags are used. > > * Return: The page on success or NULL if allocation fails. > > */ > > -struct page *alloc_pages(gfp_t gfp, unsigned order) > > +struct page *_alloc_pages(gfp_t gfp, unsigned int order) > > { > > struct mempolicy *pol = &default_policy; > > struct page *page; > > @@ -2273,7 +2273,7 @@ struct page *alloc_pages(gfp_t gfp, unsigned order) > > > > return page; > > } > > -EXPORT_SYMBOL(alloc_pages); > > +EXPORT_SYMBOL(_alloc_pages); > > > > struct folio *folio_alloc(gfp_t gfp, unsigned order) > > { > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > > index e5486d47406e..165daba19e2a 100644 > > --- a/mm/page_alloc.c > > +++ b/mm/page_alloc.c > > @@ -763,6 +763,7 @@ static inline bool pcp_allowed_order(unsigned int order) > > > > static inline void free_the_page(struct page *page, unsigned int order) > > { > > + > > if (pcp_allowed_order(order)) /* Via pcp? */ > > free_unref_page(page, order); > > else > > Spurious wide-space change. > > -- > Mel Gorman > SUSE Labs