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 C9F7EC3DA62 for ; Wed, 17 Jul 2024 18:24:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5FEFF6B0083; Wed, 17 Jul 2024 14:24:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5AF9A6B0088; Wed, 17 Jul 2024 14:24:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 49D8B6B0092; Wed, 17 Jul 2024 14:24:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 316DA6B0083 for ; Wed, 17 Jul 2024 14:24:39 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id CBFEFA1875 for ; Wed, 17 Jul 2024 18:24:38 +0000 (UTC) X-FDA: 82350070236.14.65D1C6B Received: from mail-yb1-f178.google.com (mail-yb1-f178.google.com [209.85.219.178]) by imf10.hostedemail.com (Postfix) with ESMTP id CAA98C001C for ; Wed, 17 Jul 2024 18:24:36 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=GM0988YF; spf=pass (imf10.hostedemail.com: domain of surenb@google.com designates 209.85.219.178 as permitted sender) smtp.mailfrom=surenb@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721240657; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=zMJjm2pZ+DsvMud7srr2XuUYDRXABLVy/3Jc46rHkUw=; b=njwZBjwpmZpaDFYQswQ/lyNYH6Df+T3MsSfFgHJWvnxiuYqteFOQkIl7Aw1zBbHp17Xag2 oN8AOQ9FncLOLQOYRDaz4mfR4voUhE6XNga9xU3S79jNklzCxWj5zT2PDXPPuUNDVvv89E 2J8OC7n6b1EN2X/Y/jUtG1s9eOEZWOg= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=GM0988YF; spf=pass (imf10.hostedemail.com: domain of surenb@google.com designates 209.85.219.178 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=1721240657; a=rsa-sha256; cv=none; b=n+VjEF7LYxX4oo0SteyVAvQygRnRVsQHaTP8CttnDTx4ZoK521FHQlVT+Igh6C6B4KP2nD aZ6A07idL4ACFrRrCTGLsjD5NY1D6MwABRuzP/6Z0bNZminvOhe3o9vSt8tQagcWIycia4 NdYYovwf9qDwNDhdKkQBzKAtTWusAUw= Received: by mail-yb1-f178.google.com with SMTP id 3f1490d57ef6-e05d48cf642so83463276.2 for ; Wed, 17 Jul 2024 11:24:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721240676; x=1721845476; darn=kvack.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=zMJjm2pZ+DsvMud7srr2XuUYDRXABLVy/3Jc46rHkUw=; b=GM0988YF1tIINYCNelzNdZo9xND6D8IRE/IacyCCf9xOjpOeHv0Rukr+wFWCXoseOm CTaqkIDADolki9JQKUevohf4VMWY15daiHhj2wDH7dga62LyAhFaLIVtUsT58hodJVk0 sJV0uACRyo1UTjIJnFGbWe7s7SGi5wMl6OCFKsI27oYuN0CYOa8/Z5Fixc/nJ7+aQLmo nzpKbGmZ0bLSrKg7pn5obMzgiQFKnPld8STE7G/i7un+DaIrf310ZxZsLScvrOgB/7sq Fb+ELIwePlqdEQYDXaLAQ3k8DlpvyWBwK+IGb2bmtIJZ7lnK1KAVhIoaCr34zrPwRxNa c0hQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721240676; x=1721845476; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zMJjm2pZ+DsvMud7srr2XuUYDRXABLVy/3Jc46rHkUw=; b=SYhfDQAE8NGRa/N4mft03zAJpROcpcN+B1iHTdWahRpt3LvtvivysMrW6EnqTOiqOK ZRsa5M/6ppj0iB8TCDXKaVEYIvealmTLT++4EjctzX8tRlcNHeJ9aES7qabFfjqZbqu2 0upVWgLZwsvTkLRq4NKj82AvnDlrNI/HHX9Q94UJmrqLSuUuZUUbu63mKpLJ3Ka1o3PL bhnoa3XIOQWHVvYU8It9ouI6gg5P7ukEeOVBGg0P6kG6appj5n4sMkdkmd7KxVgZDc0m hkzVPkSbbsF0J+tQToHCCnC2FHYNl3NE24BS7a6VJU3ZLeCygHlFRpb6jrUjsFu3M+DO +reg== X-Forwarded-Encrypted: i=1; AJvYcCWv/SEfXS+Nba1iTkaZEmu5a2ofnywRgZ9r3jCbImAulpwex2ajijQt+68596F2hxhZ2jeLndcOfmbxNCw9VknvN0I= X-Gm-Message-State: AOJu0YworRrk7+g1c17zh5F99JLpSdNUvSXloO3KtQhl3Lsx9wRstIms 3rfol0AYY975xz9INPFkOPeHAI7vAVeYmvyuYsBKWO4QmeZ5QRaTkxKrod681JcjJzO/+QlmjQW dVErAmRqjxSHZdjspnZjTO8a2ntCmCx2aVXH1 X-Google-Smtp-Source: AGHT+IHaGgUTh8zHuGL3Sp7GT1Pb+jqBZz4bQYJnQQgmRrsGK/qpfFglBTy5nUzChaux1YuFNB5zoEi6ac5f8yr1mCM= X-Received: by 2002:a05:6902:1883:b0:dfa:ebf2:51ab with SMTP id 3f1490d57ef6-e05ed7360f6mr3328176276.16.1721240675406; Wed, 17 Jul 2024 11:24:35 -0700 (PDT) MIME-Version: 1.0 References: <20240717011631.2150066-1-surenb@google.com> <20240717011631.2150066-2-surenb@google.com> <3ac089e1-7a30-42ef-a11a-d4d080e06c69@suse.cz> In-Reply-To: From: Suren Baghdasaryan Date: Wed, 17 Jul 2024 11:24:22 -0700 Message-ID: Subject: Re: [PATCH 2/2] alloc_tag: outline and export {get|put}_page_tag_ref() used by modules To: Vlastimil Babka Cc: akpm@linux-foundation.org, kent.overstreet@linux.dev, hch@infradead.org, pasha.tatashin@soleen.com, souravpanda@google.com, keescook@chromium.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, kernel test robot Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: CAA98C001C X-Stat-Signature: 9khdnjz9imjh8jypjzb9spgegihydq46 X-HE-Tag: 1721240676-157207 X-HE-Meta: U2FsdGVkX1/JZw4+q3rNn3CI+Cm5zUcuQLSh1iiSphZcegUUnhBY1SR1cRs2KsLaE17sk9rWVRbHfKyZOhdk82iklbEOncb5HIzpMZvBPd6+mOU8tC67lQn4qfxzHfIXRVOB2JzAdVAsCXuFkB2rrcPVzLnbakaYhhGZq7+7gPFO4F0KLYG/228h5/2aaYpe3icagR6ALmgyUlFlfMpjIBylHIKhQ5gTM9XKM4EwJJFKvYz/vSUf4Zx5k/31DRVyigyhXiEhgRe+U264UL+GEFN8Njw9BvI6JPlbEfGJqjVuJ3L5rrrmYqge/7DdZ86VhPU+8WXbuW8h9ok/iZufTMOqG7pZa9O1TG2NYQgZ7og176UKQII6AuOmBdolPT2HAM9omtSdlyoWzhJn0fApwsUVJZX+qS5kmntLFRLLa6WMwr5oHgG3LngzZPtI2v9NkUopiXqTiianrYSoWv5qqSCX2ec3s5IrMemOZdJ9YFZsMYlPGFueG7/4thjIY0qfmR93HiDknHtJwekSPXkJjXyce8pA5QnrANEVh+trU9rIewFRCSwNUrIcjf2PdmZXKSQas/SBwwAP+5gUpsdT7yR5UQg/CjugyNjADmgsoGIY6JnPOCxRsyIJGlsdUJCXAnnB7VEt+11Zsg/olV7gLuaTvAGFILqyIAcoIGjLFiy2c7ifWSMKFTE9MojcVFiSXZXb6cFS1lVsjVKSMNp6tgigVJo+/SlK6ViNdjWufxXKBriXKWNQAbnQy4Flvg8zDlcSM0VeVlNaajA2V/WirGK0yk4N5w+ij09rATEXdutNJbX4x0oZJaSB9wIGR5sStvDkFgnH5faCAkb15NMc0PlA0kQxhSLc4G3ekHSbLLzDn0YIAlnYw7nI7ts9cnE1cXDWMi4ITZtC4KYMN/3/RZ9X4yi4Aniev0RD1I0IC2n0M1BJI1shUFNtqCuG5zfTLPkWEwKNlTE8j+DhSKf yp4zZLKI onBc8fRF0OyDNlo7hnJC5jLL7jQLM1uQxLX5P+8GBkvDj6rKSlLElFe93mK1DCTlkgDcH60u9ze6dfk7hwuRUGNeiRdKOmWRmwn6i/jmUzjz9YKBEkxfYieNT6X40dy4aIPs0Rp4B+1qyH5dnDD1as99c70pfBcwbfNfYUfjRxCT3bqWRuDB7X3S7gQmGmeHoO/ZL2Hghn9i+Zy2pm8bNDCwMtZvPLVP3WUQEBu/drmHDQn7S8CTwk+wQyzYXGBYzreE0zD0XwO8jPHuB+5bCGUZo8iArsK0oDERPAV6eHjP+c9TzGTrMssZZo9UKKnwI0d57WE+ior/Se8aejftyp06tDYgGfv3+gyHkYTyh6p2fqcla7+7qqNmmbjrBJRyE4Zam 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: List-Subscribe: List-Unsubscribe: On Wed, Jul 17, 2024 at 9:56=E2=80=AFAM Suren Baghdasaryan wrote: > > On Wed, Jul 17, 2024 at 2:30=E2=80=AFAM Vlastimil Babka = wrote: > > > > On 7/17/24 3:16 AM, Suren Baghdasaryan wrote: > > > Outline and export get_page_tag_ref() and put_page_tag_ref() so that > > > modules can use them without exporting page_ext_get() and page_ext_pu= t(). > > > > > > Fixes: dcfe378c81f7 ("lib: introduce support for page allocation tagg= ing") > > > Reported-by: kernel test robot > > > Closes: https://lore.kernel.org/oe-kbuild-all/202407080044.DWMC9N9I-l= kp@intel.com/ > > > Suggested-by: Christoph Hellwig > > > Signed-off-by: Suren Baghdasaryan > > > > Better than exporting page_ext but still seems like suboptimal level to= me. > > You have various inline functions that use get/put_page_tag_ref and now= will > > call into them both. IMHO outlining those (and leaving only the static = key > > check inline) is the better way. > > > > As for the report that triggered this, AFAICS it was due to > > free_reserved_page() so it could be enough to only outline that memallo= c > > profiling part there and leave the rest as that seems to be used only f= rom > > core code and no modules. > > Doh! I didn't realize that's the only place these functions are used > directly but looks like you are right. Outlining free_reserved_page() > is definitely a much better solution with less performance impact. > I'll post a replacement patch shortly. > Thanks Vlastimil! v2 posted at [1] As a reminder for Andrew, the patchset [1] should replace the older patch [2] currently present in mm-unstable and mm-hotfixes-unstable. [1] https://lore.kernel.org/all/20240717181239.2510054-2-surenb@google.com/ [2] ac5ca7954e4e ("alloc_tag: export memory allocation profiling symbols used by modules") Thanks, Suren. > > > > > > --- > > > include/linux/pgalloc_tag.h | 23 +++-------------------- > > > lib/alloc_tag.c | 23 +++++++++++++++++++++++ > > > 2 files changed, 26 insertions(+), 20 deletions(-) > > > > > > diff --git a/include/linux/pgalloc_tag.h b/include/linux/pgalloc_tag.= h > > > index 9cacadbd61f8..3c6ab717bd57 100644 > > > --- a/include/linux/pgalloc_tag.h > > > +++ b/include/linux/pgalloc_tag.h > > > @@ -13,6 +13,9 @@ > > > > > > extern struct page_ext_operations page_alloc_tagging_ops; > > > > > > +union codetag_ref *get_page_tag_ref(struct page *page); > > > +void put_page_tag_ref(union codetag_ref *ref); > > > + > > > static inline union codetag_ref *codetag_ref_from_page_ext(struct pa= ge_ext *page_ext) > > > { > > > return (void *)page_ext + page_alloc_tagging_ops.offset; > > > @@ -23,26 +26,6 @@ static inline struct page_ext *page_ext_from_codet= ag_ref(union codetag_ref *ref) > > > return (void *)ref - page_alloc_tagging_ops.offset; > > > } > > > > > > -/* Should be called only if mem_alloc_profiling_enabled() */ > > > -static inline union codetag_ref *get_page_tag_ref(struct page *page) > > > -{ > > > - if (page) { > > > - struct page_ext *page_ext =3D page_ext_get(page); > > > - > > > - if (page_ext) > > > - return codetag_ref_from_page_ext(page_ext); > > > - } > > > - return NULL; > > > -} > > > - > > > -static inline void put_page_tag_ref(union codetag_ref *ref) > > > -{ > > > - if (WARN_ON(!ref)) > > > - return; > > > - > > > - page_ext_put(page_ext_from_codetag_ref(ref)); > > > -} > > > - > > > static inline void pgalloc_tag_add(struct page *page, struct task_st= ruct *task, > > > unsigned int nr) > > > { > > > diff --git a/lib/alloc_tag.c b/lib/alloc_tag.c > > > index 832f79a32b3e..5271cc070901 100644 > > > --- a/lib/alloc_tag.c > > > +++ b/lib/alloc_tag.c > > > @@ -4,6 +4,7 @@ > > > #include > > > #include > > > #include > > > +#include > > > #include > > > #include > > > #include > > > @@ -22,6 +23,28 @@ struct allocinfo_private { > > > bool print_header; > > > }; > > > > > > +/* Should be called only if mem_alloc_profiling_enabled() */ > > > +union codetag_ref *get_page_tag_ref(struct page *page) > > > +{ > > > + if (page) { > > > + struct page_ext *page_ext =3D page_ext_get(page); > > > + > > > + if (page_ext) > > > + return codetag_ref_from_page_ext(page_ext); > > > + } > > > + return NULL; > > > +} > > > +EXPORT_SYMBOL_GPL(get_page_tag_ref); > > > + > > > +void put_page_tag_ref(union codetag_ref *ref) > > > +{ > > > + if (WARN_ON(!ref)) > > > + return; > > > + > > > + page_ext_put(page_ext_from_codetag_ref(ref)); > > > +} > > > +EXPORT_SYMBOL_GPL(put_page_tag_ref); > > > + > > > static void *allocinfo_start(struct seq_file *m, loff_t *pos) > > > { > > > struct allocinfo_private *priv; > >