Re: [PATCH -V6 06/21] swap: Support PMD swap mapping when splitting huge PMD

From: Daniel Jordan
Date: Thu Oct 25 2018 - 11:01:08 EST


On Thu, Oct 25, 2018 at 08:54:16AM +0800, Huang, Ying wrote:
> Daniel Jordan <daniel.m.jordan@xxxxxxxxxx> writes:
>
> > On Wed, Oct 10, 2018 at 03:19:09PM +0800, Huang Ying wrote:
> >> +#ifdef CONFIG_THP_SWAP
> >> +/*
> >> + * The corresponding page table shouldn't be changed under us, that
> >> + * is, the page table lock should be held.
> >> + */
> >> +int split_swap_cluster_map(swp_entry_t entry)
> >> +{
> >> + struct swap_info_struct *si;
> >> + struct swap_cluster_info *ci;
> >> + unsigned long offset = swp_offset(entry);
> >> +
> >> + VM_BUG_ON(!IS_ALIGNED(offset, SWAPFILE_CLUSTER));
> >> + si = _swap_info_get(entry);
> >> + if (!si)
> >> + return -EBUSY;
> >
> > I think this return value doesn't get used anywhere?
>
> Yes. And the error is only possible if page table is corrupted. So
> maybe add a VM_BUG_ON() in it caller __split_huge_swap_pmd()?

Taking a second look at this, I see we'd get some nice pr_err message in this
case, so VM_BUG_ON doesn't seem necessary.

Still odd there's an unchecked return value, but it could be useful to future
callers. Just my nitpick, feel free to leave as is.