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 11D1DC3DA42 for ; Wed, 17 Jul 2024 16:56:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9D6636B0082; Wed, 17 Jul 2024 12:56:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 986836B0088; Wed, 17 Jul 2024 12:56:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 827306B0093; Wed, 17 Jul 2024 12:56:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 5E7D36B0082 for ; Wed, 17 Jul 2024 12:56:50 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id D0340A0A60 for ; Wed, 17 Jul 2024 16:56:49 +0000 (UTC) X-FDA: 82349848938.07.6AE411E Received: from mail-yb1-f172.google.com (mail-yb1-f172.google.com [209.85.219.172]) by imf22.hostedemail.com (Postfix) with ESMTP id 100A6C0017 for ; Wed, 17 Jul 2024 16:56:47 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=lelQm3nz; spf=pass (imf22.hostedemail.com: domain of surenb@google.com designates 209.85.219.172 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=1721235377; 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=i12G5VJh/goLi96BaqvcVsnUNHX/Q+GQ2O62pkYYJ8w=; b=npXt+C6/WTSJ2WIAiSnHLy2w77Ru9ps8wG9FaTKHB+0bg1jJzFNNU3NdhyCufWYcQi3awl fbkGWvJWExfevqKEZnA4189xppQBnYm0Q41Ru4PlJKTBNQsYjbu5XmhVr65YwnbhmMd4r3 VJO1MaNqSp1KMIYkS6veTynhbw0PAjM= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=lelQm3nz; spf=pass (imf22.hostedemail.com: domain of surenb@google.com designates 209.85.219.172 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=1721235377; a=rsa-sha256; cv=none; b=ARDHhHPstlSqcDgnqqDy6QnPorwvPAcGW3k3gzBRBgFaOLI/lhwoOi7O+ZYS9HktFugejX 2HYRDtS0uxVkJLbfU4/4q0LkGsdWZipmWBHsT9iZDXk2zgYLxGbeR3VNEenRMClq0UjABO qsxORy3emfYu7TmqlpU3I0u/aq5Q3ZA= Received: by mail-yb1-f172.google.com with SMTP id 3f1490d57ef6-df4d5d0b8d0so6632970276.2 for ; Wed, 17 Jul 2024 09:56:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721235407; x=1721840207; 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=i12G5VJh/goLi96BaqvcVsnUNHX/Q+GQ2O62pkYYJ8w=; b=lelQm3nzUDcIh6WGM/r8ImZNSqzYmNHqIzmpp6x+rGKpX44ROeTUfExTdNyg3YE3gM BPXjxHnBXuJqFA6SU0RyY8/W1XdueFt8oVV/OyOZkjJ0YgNAuGcU3zeeIYbfFWZZhbET Cz5+v/EO+0nBuJxZc11oaRUNKJ14XmA10hjdHXlw0Hh0BhYHTUxsHHt+Ob1eunKo7WOT SzJ1SFkxA17ZabiSLMkPH3E76LjMyqFETAMFLPEcxhffh8B7e/HgcU2TroCuCFuN2ds2 qCxEf+ughaRxpo90ddg3BFToCVMySqWXvz8spCtlz7XOlBdJJjWkGXydQVMExNy+ZGkg nGNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721235407; x=1721840207; 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=i12G5VJh/goLi96BaqvcVsnUNHX/Q+GQ2O62pkYYJ8w=; b=OFQNRl6+UYq+FJCBo173nJnzRIMMLq9U7UEyms6PtQpsUcnRPU41byutLOeGLPiBZ3 OrRbK1HDfv5XZYQZw3w1bJHicRZ0pP0EisLtlioUEgWiZ8WzhQbaKpw2hVBtySYYHjZC HCv8Rcg+aUJO6d6Vbk7kDiWsrN98uBXmu+vfMMd7NoWF1KcaMyTEQaCHht2ZtWbGzXVj odNmA5Tkasaloh0M5MN+A+GKbKXwvYdDXEzcYCwdrRcahCa9uIXmU1Jg/3FPjxm5PH42 qvjq8m3BiTgsS13oiwnnSBDWYeq51cPumeeds1NIFAxLxOfY2apo/VebrQlVD6+RX85z qQwQ== X-Forwarded-Encrypted: i=1; AJvYcCW60TrGH4QPWqpI69wF9QSgceaB7ZqhtIKjZ7eqPwwz2hHSJZzwOVA0+D1ZGdPjJHcka39+IZvNXZWcwvcgZzn7ieo= X-Gm-Message-State: AOJu0Yx4SNDOoEzITmtUUbcSEl6WHcIcX04dSeOSY3wd6ti04aD2rqsT wJHP/y13nGnRuAh8S59rBao79VK92F8drfHdnZGxtEAq5ehzdnCGeGkfJxsNYmskgavu5zr7An6 GSr6GOQuUd6/Snmt1bdXhenRN4azYK7HXY529 X-Google-Smtp-Source: AGHT+IEmx8OrtXRUak6/SiGNEY+kGmjwd8ndsOjMSJQDmChtuL8gBVr9FQvJUijQRToVxds28QJGFrFCMN/ARF5T+7U= X-Received: by 2002:a05:6902:1006:b0:e03:4253:2d77 with SMTP id 3f1490d57ef6-e05fe7a52eamr37614276.0.1721235406711; Wed, 17 Jul 2024 09:56:46 -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: <3ac089e1-7a30-42ef-a11a-d4d080e06c69@suse.cz> From: Suren Baghdasaryan Date: Wed, 17 Jul 2024 09:56:33 -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-Stat-Signature: j8nxr1kma7wuk81qtudjc557sy8mxknf X-Rspam-User: X-Rspamd-Queue-Id: 100A6C0017 X-Rspamd-Server: rspam02 X-HE-Tag: 1721235407-891052 X-HE-Meta: U2FsdGVkX18+9tRvYS9Q9tyuhdSvxEJZZ6jmn+DZkDAXWk8OcpN7s59h3slx2GgbXDW63z+popxX2xbIwmbM8IIPcujEOk0nukJ6aaCKvtCIxblHqbSszG6Yxtb4NS7AZdFlN6kt2LIcSs3BbAyK4W92kz0RtkWcX7KS17TThXzN5juXVXdjzw52mYYbNNSyYTM8c1EJ5Ghy5qm8BI4xXl0cbWwj+3X9cMMJAjSQTczjAnw+SJgB94+T4Ug2mnzP+RJS5u9J8Vz/X7eIljAcH6G50cXwvHe908VBOVFNxswbOCXJeZg26MQO7WjzcOnN8cDFcZhKVBXmFlFdZVOHABPzqyRQ76Hx8BoitWN0/3vnAo5yXPZ6kdnVU/iFOTdHoyzV7q1kpHnNtiMLHcVdDfDyoX8L/aNfyKqqoyBUu1YpRM14fBu+/rA8e8AT3mnVm8QAU8LkcD2Pk6yGRD1ucbPiuRFPC0bRWOxnlaFOtcrQ+C9Z+NzdiqWcVkosQTQM/wWxVc0XPwnsY1y2kikLLbKUPXPRMVqjjtOlpNk8p1xhDt39hfgnz8WACRh5hY+03U6aOc9saXzqa1uhuJh/fZzgT1Rxp+S8OMgogsemI2KUF9EqQBXlAXzglgg8UvF8BXt3+b1jarp+sh54Iy4ZjWyMAWcM2JzLbssll5iKlS2bjB6++AtXGlu1iuKTZFIrsZH54d8fQaSyBY6yTBofHYiX2gOwKpDJhRvyiQo9Molf27O2eg0GGI/jyrhsATshBCY0K4lfg7+RRxtTCgKTvSl4WHPOFAZSRtuGtdzLs09xG6Hr105D73fIeiUhI2xWXtWW2NIjxIuAvjF9rXkW6zOP0V4EQ9vekaSITfZ/oN0R7Z9rIixX3nh2FRAbjiHGRs25SW+1Sv54TEC/DHYoMqf0PYnlzcyK/t9RNX6XiZFmidbZgj2fbY20On1/DUu2KCxl7yUtjM1Bbz1Js0k O101T5LU Xw4/a9H/iGsuBBgs+o3dr8/W8FLO0ABOncNTSWQ/rouXhLSpfSmE5uikEtwYImvgZeXZGhPD5ckEw694l8qLgryDl3GEBrkxmoN2UOPT+CjqtGu64SUEStI2C9weOVOHqBOmXpyy7hdVw9k5AsWzqrv0gLHZPjBgqs7j5g7Cxg/BFffdC0o7NionZ33WWDwty+2Ly6DSr6V+ZSEHkXeBd102YtjtHEP6na+ALpq2vHuLUCrAVR9hOqslIfi4CzbJuesHN0+/xIIsn0/DTE9NWfDDt2fAqrPFixaaliAogwSwjRN3T9vi6Bm6WuD5ehvmnMqt59nkiYQAyeX/DKLfn83bKP7SZYBvgstVWwndRfGQVjT86ePR1KpZUHBrGZFFAKAQc 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 2:30=E2=80=AFAM Vlastimil Babka wr= ote: > > 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_put(= ). > > > > Fixes: dcfe378c81f7 ("lib: introduce support for page allocation taggin= g") > > Reported-by: kernel test robot > > Closes: https://lore.kernel.org/oe-kbuild-all/202407080044.DWMC9N9I-lkp= @intel.com/ > > Suggested-by: Christoph Hellwig > > Signed-off-by: Suren Baghdasaryan > > Better than exporting page_ext but still seems like suboptimal level to m= e. > You have various inline functions that use get/put_page_tag_ref and now w= ill > call into them both. IMHO outlining those (and leaving only the static ke= y > 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 memalloc > profiling part there and leave the rest as that seems to be used only fro= m > 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! > > > --- > > 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 page= _ext *page_ext) > > { > > return (void *)page_ext + page_alloc_tagging_ops.offset; > > @@ -23,26 +26,6 @@ static inline struct page_ext *page_ext_from_codetag= _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_stru= ct *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; >