Re: [PATCHv4 0/4] zsmalloc: fine-grained fullness and new compaction algorithm

From: Yosry Ahmed
Date: Mon Apr 17 2023 - 04:29:55 EST


Hi Sergey,

On Sun, Apr 16, 2023 at 8:52 PM Sergey Senozhatsky
<senozhatsky@xxxxxxxxxxxx> wrote:
>
> On (23/04/16 20:55), Yu Zhao wrote:
> > > Do you run some specific test?
> >
> > E.g.,
> > tools/testing/selftests/kvm/max_guest_memory_test -c 112 -m 800 -s 800
> > with 112 CPUs and ~770GB DRAM + 32GB zram.
>
> Hmm ...
>
> Something like this maybe?
>
> The src zspage pointer is not NULL-ed after non-empty zspage is
> put back to corresponding fullness list.
>
> ---
>
> @@ -2239,8 +2241,8 @@ static unsigned long __zs_compact(struct zs_pool *pool,
> if (fg == ZS_INUSE_RATIO_0) {
> free_zspage(pool, class, src_zspage);
> pages_freed += class->pages_per_zspage;
> - src_zspage = NULL;
> }
> + src_zspage = NULL;
>
> if (get_fullness_group(class, dst_zspage) == ZS_INUSE_RATIO_100
> || spin_is_contended(&pool->lock)) {

For my own education, how can this result in the "next is NULL" debug
error Yu Zhao is seeing?

IIUC if we do not set src_zspage to NULL properly after putback, then
we will attempt to putback again after the main loop in some cases.
This can result in a zspage being present more than once in the
per-class fullness list, right?

I am not sure how this can lead to "next is NULL", which sounds like a
corrupted list_head, because the next ptr should never be NULL as far
as I can tell. I feel like I am missing something.