2024-01-22 19:51:25

by Yosry Ahmed

[permalink] [raw]
Subject: Re: [PATCH v2 2/2] mm/zswap: split zswap rb-tree

On Fri, Jan 19, 2024 at 3:22 AM Chengming Zhou
<[email protected]> wrote:
>
> Each swapfile has one rb-tree to search the mapping of swp_entry_t to
> zswap_entry, that use a spinlock to protect, which can cause heavy lock
> contention if multiple tasks zswap_store/load concurrently.
>
> Optimize the scalability problem by splitting the zswap rb-tree into
> multiple rb-trees, each corresponds to SWAP_ADDRESS_SPACE_PAGES (64M),
> just like we did in the swap cache address_space splitting.
>
> Although this method can't solve the spinlock contention completely, it
> can mitigate much of that contention. Below is the results of kernel build
> in tmpfs with zswap shrinker enabled:
>
> linux-next zswap-lock-optimize
> real 1m9.181s 1m3.820s
> user 17m44.036s 17m40.100s
> sys 7m37.297s 4m54.622s
>
> So there are clearly improvements.

If/when you respin this, can you mention that testing was done with a
single swapfile? I assume the improvements will be less with multiple
swapfiles as lock contention should be better.

>
> Acked-by: Johannes Weiner <[email protected]>
> Acked-by: Nhat Pham <[email protected]>

I think the diff in zswap_swapoff() should be much simpler with the
tree(s) cleanup removed. Otherwise LGTM.

Acked-by: Yosry Ahmed <[email protected]>


2024-01-23 07:46:41

by Chengming Zhou

[permalink] [raw]
Subject: Re: [PATCH v2 2/2] mm/zswap: split zswap rb-tree

On 2024/1/23 03:49, Yosry Ahmed wrote:
> On Fri, Jan 19, 2024 at 3:22 AM Chengming Zhou
> <[email protected]> wrote:
>>
>> Each swapfile has one rb-tree to search the mapping of swp_entry_t to
>> zswap_entry, that use a spinlock to protect, which can cause heavy lock
>> contention if multiple tasks zswap_store/load concurrently.
>>
>> Optimize the scalability problem by splitting the zswap rb-tree into
>> multiple rb-trees, each corresponds to SWAP_ADDRESS_SPACE_PAGES (64M),
>> just like we did in the swap cache address_space splitting.
>>
>> Although this method can't solve the spinlock contention completely, it
>> can mitigate much of that contention. Below is the results of kernel build
>> in tmpfs with zswap shrinker enabled:
>>
>> linux-next zswap-lock-optimize
>> real 1m9.181s 1m3.820s
>> user 17m44.036s 17m40.100s
>> sys 7m37.297s 4m54.622s
>>
>> So there are clearly improvements.
>
> If/when you respin this, can you mention that testing was done with a
> single swapfile? I assume the improvements will be less with multiple
> swapfiles as lock contention should be better.
>

Ok. Not sure how much improvement, may do some tests later.

>>
>> Acked-by: Johannes Weiner <[email protected]>
>> Acked-by: Nhat Pham <[email protected]>
>
> I think the diff in zswap_swapoff() should be much simpler with the
> tree(s) cleanup removed. Otherwise LGTM.
>
> Acked-by: Yosry Ahmed <[email protected]>

Right, thanks!