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

Alex Shi
2024-08-05T04:36:19Z

On 8/3/24 3:30 AM, Matthew Wilcox wrote:
> On Mon, Jul 29, 2024 at 07:25:13PM +0800, alexs@kernel.org 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;
> };
>

Yes, we still have a huge gap between this target.

> 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 am not very clear the way to get there. The easy path for me, I guess,
would move struct zpdesc members out to zspage, like 2nd way of your suggestion.

I believe you has much more idea of the ways to memdesc.
Is there some references or detailed info which I could learn from you?

Many thanks!
Alex

>
> 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.