Re: [PATCH v4 06/22] mm/zsmalloc: convert create_page_chain() and its users to use zpdesc

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

 



On Mon, Jul 29, 2024 at 07:25:18PM +0800, alexs@xxxxxxxxxx wrote:
> From: Alex Shi <alexs@xxxxxxxxxx>
> 
> Introduce a few helper functions for conversion to convert create_page_chain()
> to use zpdesc, then use zpdesc in replace_sub_page() too.

As a general note, I've been having trouble keeping track of your helper
functions throughout your patchset. Things get confusing when helper
functions are "add-ons" to patches and are then replaced/rewritten
in various subsequent patches - might just be me though.

> Originally-by: Hyeonggon Yoo <42.hyeyoo@xxxxxxxxx>
> Signed-off-by: Alex Shi <alexs@xxxxxxxxxx>
> ---
>  mm/zpdesc.h   |   6 +++
>  mm/zsmalloc.c | 115 +++++++++++++++++++++++++++++++++-----------------
>  2 files changed, 82 insertions(+), 39 deletions(-)
> 
> diff --git a/mm/zpdesc.h b/mm/zpdesc.h
> index 79ec40b03956..2293453f5d57 100644
> --- a/mm/zpdesc.h
> +++ b/mm/zpdesc.h
> @@ -102,4 +102,10 @@ static inline struct zpdesc *pfn_zpdesc(unsigned long pfn)
>  {
>  	return page_zpdesc(pfn_to_page(pfn));
>  }
> +
> +static inline void __zpdesc_set_movable(struct zpdesc *zpdesc,
> +					const struct movable_operations *mops)
> +{
> +	__SetPageMovable(zpdesc_page(zpdesc), mops);
> +}
>  #endif
> diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
> index bbc165cb587d..a8f390beeab8 100644
> --- a/mm/zsmalloc.c
> +++ b/mm/zsmalloc.c
> @@ -248,6 +248,41 @@ static inline void *zpdesc_kmap_atomic(struct zpdesc *zpdesc)
>  	return kmap_atomic(zpdesc_page(zpdesc));
>  }
>  
> +static inline void zpdesc_set_zspage(struct zpdesc *zpdesc,
> +				     struct zspage *zspage)
> +{
> +	zpdesc->zspage = zspage;
> +}
> +
> +static inline void zpdesc_set_first(struct zpdesc *zpdesc)
> +{
> +	SetPagePrivate(zpdesc_page(zpdesc));
> +}
> +

I'm not a fan of the names above. IMO, naming should follow some
semblance of consistency regarding their purpose (or have comments
that describe their purpose instead).

At a glance zpdesc_set_zspage() and zpdesc_set_first() sound like they
are doing similar things, but I don't think they serve similar purposes?

> +static inline void zpdesc_inc_zone_page_state(struct zpdesc *zpdesc)
> +{
> +	inc_zone_page_state(zpdesc_page(zpdesc), NR_ZSPAGES);
> +}
> +
> +static inline void zpdesc_dec_zone_page_state(struct zpdesc *zpdesc)
> +{
> +	dec_zone_page_state(zpdesc_page(zpdesc), NR_ZSPAGES);
> +}
> +
> +static inline struct zpdesc *alloc_zpdesc(gfp_t gfp)
> +{
> +	struct page *page = alloc_page(gfp);
> +
> +	return page_zpdesc(page);
> +}
> +
> +static inline void free_zpdesc(struct zpdesc *zpdesc)
> +{
> +	struct page *page = zpdesc_page(zpdesc);
> +
> +	__free_page(page);
> +}
> +
 




[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