Re: [PATCH 1/2] mm: swap: swap cluster switch to double link list

From: Chris Li
Date: Tue May 28 2024 - 20:51:12 EST


On Tue, May 28, 2024 at 3:27 PM Chris Li <chriscli@xxxxxxxxxx> wrote:
> > > @@ -670,7 +562,8 @@ static bool scan_swap_map_try_ssd_cluster(struct swap_info_struct *si,
> > > goto new_cluster;
> > > } else
> > > return false;
> > > - }
> > > + } else
> > > + ci = si->cluster_info + tmp;
> >
> > This "else ci = ..." seems wrong, tmp is not an array index, and not
> > needed either.
>
> Yes, there is a bug there, pointed out by OPPO as well. It should be
> ci = si->cluster_info + (tmp/ SWAPFILE_CLUSTER);
>
> "tmp" is needed because "tmp" or " cluster->next[order]" keep track of
> the current cluster allocation offset,
> in the per cpu cluster struct.

Hi Kairui,


Actually, you are right, the "ci" is not used here. That is why that
ci out of bound error does not trigger kernel OOPS.
We can delete that else line completely.

Chris