* [PATCH 1/2] alloc_tag: export mem_alloc_profiling_key used by modules
@ 2024-07-17 1:16 Suren Baghdasaryan
2024-07-17 1:16 ` [PATCH 2/2] alloc_tag: outline and export {get|put}_page_tag_ref() " Suren Baghdasaryan
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Suren Baghdasaryan @ 2024-07-17 1:16 UTC (permalink / raw)
To: akpm
Cc: kent.overstreet, hch, vbabka, pasha.tatashin, souravpanda,
keescook, linux-kernel, linux-mm, surenb, kernel test robot
Export mem_alloc_profiling_key as it is used by modules (indirectly via
mem_alloc_profiling_enabled()).
Fixes: 22d407b164ff ("lib: add allocation tagging support for memory allocation profiling")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202407080044.DWMC9N9I-lkp@intel.com/
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
---
lib/alloc_tag.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/lib/alloc_tag.c b/lib/alloc_tag.c
index 81e5f9a70f22..832f79a32b3e 100644
--- a/lib/alloc_tag.c
+++ b/lib/alloc_tag.c
@@ -15,6 +15,7 @@ EXPORT_SYMBOL(_shared_alloc_tag);
DEFINE_STATIC_KEY_MAYBE(CONFIG_MEM_ALLOC_PROFILING_ENABLED_BY_DEFAULT,
mem_alloc_profiling_key);
+EXPORT_SYMBOL(mem_alloc_profiling_key);
struct allocinfo_private {
struct codetag_iterator iter;
base-commit: 0434dbe32053d07d658165be681505120c6b1abc
--
2.45.2.993.g49e7a77208-goog
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/2] alloc_tag: outline and export {get|put}_page_tag_ref() used by modules
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
2024-07-17 4:47 ` Christoph Hellwig
2024-07-17 9:30 ` Vlastimil Babka
2024-07-17 1:25 ` [PATCH 1/2] alloc_tag: export mem_alloc_profiling_key " Suren Baghdasaryan
2024-07-17 9:25 ` Vlastimil Babka
2 siblings, 2 replies; 8+ messages in thread
From: Suren Baghdasaryan @ 2024-07-17 1:16 UTC (permalink / raw)
To: akpm
Cc: kent.overstreet, hch, vbabka, pasha.tatashin, souravpanda,
keescook, linux-kernel, linux-mm, surenb, kernel test robot
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
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] alloc_tag: export mem_alloc_profiling_key used by modules
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 ` [PATCH 2/2] alloc_tag: outline and export {get|put}_page_tag_ref() " Suren Baghdasaryan
@ 2024-07-17 1:25 ` Suren Baghdasaryan
2024-07-17 9:25 ` Vlastimil Babka
2 siblings, 0 replies; 8+ messages in thread
From: Suren Baghdasaryan @ 2024-07-17 1:25 UTC (permalink / raw)
To: akpm
Cc: kent.overstreet, hch, vbabka, pasha.tatashin, souravpanda,
keescook, linux-kernel, linux-mm, kernel test robot
On Tue, Jul 16, 2024 at 6:16 PM Suren Baghdasaryan <surenb@google.com> wrote:
>
> Export mem_alloc_profiling_key as it is used by modules (indirectly via
> mem_alloc_profiling_enabled()).
>
> Fixes: 22d407b164ff ("lib: add allocation tagging support for memory allocation profiling")
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202407080044.DWMC9N9I-lkp@intel.com/
> Signed-off-by: Suren Baghdasaryan <surenb@google.com>
This patchset should replace
https://lore.kernel.org/all/20240711204626.1669138-1-surenb@google.com
patch which was objected to by Christoph. I think this version should
be acceptable.
Thanks,
Suren.
> ---
> lib/alloc_tag.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/lib/alloc_tag.c b/lib/alloc_tag.c
> index 81e5f9a70f22..832f79a32b3e 100644
> --- a/lib/alloc_tag.c
> +++ b/lib/alloc_tag.c
> @@ -15,6 +15,7 @@ EXPORT_SYMBOL(_shared_alloc_tag);
>
> DEFINE_STATIC_KEY_MAYBE(CONFIG_MEM_ALLOC_PROFILING_ENABLED_BY_DEFAULT,
> mem_alloc_profiling_key);
> +EXPORT_SYMBOL(mem_alloc_profiling_key);
>
> struct allocinfo_private {
> struct codetag_iterator iter;
>
> base-commit: 0434dbe32053d07d658165be681505120c6b1abc
> --
> 2.45.2.993.g49e7a77208-goog
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] alloc_tag: outline and export {get|put}_page_tag_ref() used by modules
2024-07-17 1:16 ` [PATCH 2/2] alloc_tag: outline and export {get|put}_page_tag_ref() " Suren Baghdasaryan
@ 2024-07-17 4:47 ` Christoph Hellwig
2024-07-17 9:30 ` Vlastimil Babka
1 sibling, 0 replies; 8+ messages in thread
From: Christoph Hellwig @ 2024-07-17 4:47 UTC (permalink / raw)
To: Suren Baghdasaryan
Cc: akpm, kent.overstreet, hch, vbabka, pasha.tatashin, souravpanda,
keescook, linux-kernel, linux-mm, kernel test robot
Thanks, this looks much better:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] alloc_tag: export mem_alloc_profiling_key used by modules
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 ` [PATCH 2/2] alloc_tag: outline and export {get|put}_page_tag_ref() " 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
2 siblings, 0 replies; 8+ messages in thread
From: Vlastimil Babka @ 2024-07-17 9:25 UTC (permalink / raw)
To: Suren Baghdasaryan, akpm
Cc: kent.overstreet, hch, pasha.tatashin, souravpanda, keescook,
linux-kernel, linux-mm, kernel test robot
On 7/17/24 3:16 AM, Suren Baghdasaryan wrote:
> Export mem_alloc_profiling_key as it is used by modules (indirectly via
> mem_alloc_profiling_enabled()).
>
> Fixes: 22d407b164ff ("lib: add allocation tagging support for memory allocation profiling")
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202407080044.DWMC9N9I-lkp@intel.com/
> Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
> ---
> lib/alloc_tag.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/lib/alloc_tag.c b/lib/alloc_tag.c
> index 81e5f9a70f22..832f79a32b3e 100644
> --- a/lib/alloc_tag.c
> +++ b/lib/alloc_tag.c
> @@ -15,6 +15,7 @@ EXPORT_SYMBOL(_shared_alloc_tag);
>
> DEFINE_STATIC_KEY_MAYBE(CONFIG_MEM_ALLOC_PROFILING_ENABLED_BY_DEFAULT,
> mem_alloc_profiling_key);
> +EXPORT_SYMBOL(mem_alloc_profiling_key);
>
> struct allocinfo_private {
> struct codetag_iterator iter;
>
> base-commit: 0434dbe32053d07d658165be681505120c6b1abc
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] alloc_tag: outline and export {get|put}_page_tag_ref() used by modules
2024-07-17 1:16 ` [PATCH 2/2] alloc_tag: outline and export {get|put}_page_tag_ref() " Suren Baghdasaryan
2024-07-17 4:47 ` Christoph Hellwig
@ 2024-07-17 9:30 ` Vlastimil Babka
2024-07-17 16:56 ` Suren Baghdasaryan
1 sibling, 1 reply; 8+ messages in thread
From: Vlastimil Babka @ 2024-07-17 9:30 UTC (permalink / raw)
To: Suren Baghdasaryan, akpm
Cc: kent.overstreet, hch, pasha.tatashin, souravpanda, keescook,
linux-kernel, linux-mm, kernel test robot
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 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>
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 memalloc
profiling part there and leave the rest as that seems to be used only from
core code and no modules.
> ---
> 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;
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] alloc_tag: outline and export {get|put}_page_tag_ref() used by modules
2024-07-17 9:30 ` Vlastimil Babka
@ 2024-07-17 16:56 ` Suren Baghdasaryan
2024-07-17 18:24 ` Suren Baghdasaryan
0 siblings, 1 reply; 8+ messages in thread
From: Suren Baghdasaryan @ 2024-07-17 16:56 UTC (permalink / raw)
To: Vlastimil Babka
Cc: akpm, kent.overstreet, hch, pasha.tatashin, souravpanda, keescook,
linux-kernel, linux-mm, kernel test robot
On Wed, Jul 17, 2024 at 2:30 AM Vlastimil Babka <vbabka@suse.cz> 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_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>
>
> 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 memalloc
> profiling part there and leave the rest as that seems to be used only from
> 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 = 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;
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] alloc_tag: outline and export {get|put}_page_tag_ref() used by modules
2024-07-17 16:56 ` Suren Baghdasaryan
@ 2024-07-17 18:24 ` Suren Baghdasaryan
0 siblings, 0 replies; 8+ messages in thread
From: Suren Baghdasaryan @ 2024-07-17 18:24 UTC (permalink / raw)
To: Vlastimil Babka
Cc: akpm, kent.overstreet, hch, pasha.tatashin, souravpanda, keescook,
linux-kernel, linux-mm, kernel test robot
On Wed, Jul 17, 2024 at 9:56 AM Suren Baghdasaryan <surenb@google.com> wrote:
>
> On Wed, Jul 17, 2024 at 2:30 AM Vlastimil Babka <vbabka@suse.cz> 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_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>
> >
> > 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 memalloc
> > profiling part there and leave the rest as that seems to be used only from
> > 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 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;
> >
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2024-07-17 18:24 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH 2/2] alloc_tag: outline and export {get|put}_page_tag_ref() " Suren Baghdasaryan
2024-07-17 4:47 ` 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
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).