Re: [PATCH 2/2] alloc_tag: outline and export {get|put}_page_tag_ref() used by modules

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
> Closes: https://lore.kernel.org/oe-kbuild-all/202407080044.DWMC9N9I-lkp@xxxxxxxxx/
> Suggested-by: Christoph Hellwig <hch@xxxxxxxxxxxxx>
> Signed-off-by: Suren Baghdasaryan <surenb@xxxxxxxxxx>

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;





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux