linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Suren Baghdasaryan <surenb@google.com>
To: akpm@linux-foundation.org
Cc: kent.overstreet@linux.dev, hch@infradead.org, vbabka@suse.cz,
	 pasha.tatashin@soleen.com, souravpanda@google.com,
	keescook@chromium.org,  linux-kernel@vger.kernel.org,
	linux-mm@kvack.org, surenb@google.com,
	 kernel test robot <lkp@intel.com>
Subject: [PATCH 2/2] alloc_tag: outline and export {get|put}_page_tag_ref() used by modules
Date: Tue, 16 Jul 2024 18:16:30 -0700	[thread overview]
Message-ID: <20240717011631.2150066-2-surenb@google.com> (raw)
In-Reply-To: <20240717011631.2150066-1-surenb@google.com>

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 tagging")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202407080044.DWMC9N9I-lkp@intel.com/
Suggested-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
---
 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 = 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_struct *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 <linux/gfp.h>
 #include <linux/module.h>
 #include <linux/page_ext.h>
+#include <linux/pgalloc_tag.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_buf.h>
 #include <linux/seq_file.h>
@@ -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 = 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;
-- 
2.45.2.993.g49e7a77208-goog



  reply	other threads:[~2024-07-17  1:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-17  1:16 [PATCH 1/2] alloc_tag: export mem_alloc_profiling_key used by modules Suren Baghdasaryan
2024-07-17  1:16 ` Suren Baghdasaryan [this message]
2024-07-17  4:47   ` [PATCH 2/2] alloc_tag: outline and export {get|put}_page_tag_ref() " Christoph Hellwig
2024-07-17  9:30   ` Vlastimil Babka
2024-07-17 16:56     ` Suren Baghdasaryan
2024-07-17 18:24       ` Suren Baghdasaryan
2024-07-17  1:25 ` [PATCH 1/2] alloc_tag: export mem_alloc_profiling_key " Suren Baghdasaryan
2024-07-17  9:25 ` Vlastimil Babka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240717011631.2150066-2-surenb@google.com \
    --to=surenb@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=hch@infradead.org \
    --cc=keescook@chromium.org \
    --cc=kent.overstreet@linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lkp@intel.com \
    --cc=pasha.tatashin@soleen.com \
    --cc=souravpanda@google.com \
    --cc=vbabka@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).