Re: [PATCH v4 01/22] mm/zsmalloc: add zpdesc memory descriptor for zswap.zpool

From: Matthew Wilcox
Date: Fri Aug 02 2024 - 15:30:19 EST


On Mon, Jul 29, 2024 at 07:25:13PM +0800, alexs@xxxxxxxxxx wrote:
> +/*
> + * struct zpdesc - Memory descriptor for zpool memory, now is for zsmalloc
> + * @flags: Page flags, PG_private: identifies the first component page
> + * @lru: Indirectly used by page migration
> + * @mops: Used by page migration
> + * @next: Next zpdesc in a zspage in zsmalloc zpool
> + * @handle: For huge zspage in zsmalloc zpool
> + * @zspage: Pointer to zspage in zsmalloc
> + * @memcg_data: Memory Control Group data.
> + *
> + * This struct overlays struct page for now. Do not modify without a good
> + * understanding of the issues.
> + */
> +struct zpdesc {
> + unsigned long flags;
> + struct list_head lru;
> + struct movable_operations *mops;
> + union {
> + /* Next zpdescs in a zspage in zsmalloc zpool */
> + struct zpdesc *next;
> + /* For huge zspage in zsmalloc zpool */
> + unsigned long handle;
> + };
> + struct zspage *zspage;
> + unsigned long _zp_pad_1;
> +#ifdef CONFIG_MEMCG
> + unsigned long memcg_data;
> +#endif
> +};

Before we do a v5, what's the plan for a shrunk struct page? It feels
like a lot of what's going on here is just "because we can". But if you
actually had to allocate the memory, would you?

That is, if we get to

struct page {
unsigned long memdesc;
};

what do you put in the 60 bits of information? Do you allocate a
per-page struct zpdesc, and have each one pointing to a zspage? Or do
you extend the current contents of zspage to describe the pages allocated
to it, and make each struct page point to the zspage?

I don't know your code, so I'm not trying to choose for you. I'm just
trying to make sure we're walking in the right direction.