On Tue, Jul 2, 2024 at 1:53 AM Yosry Ahmed <yosryahmed@xxxxxxxxxx> wrote: > > [..] > > +static struct folio *alloc_swap_folio(struct vm_fault *vmf) > > +{ > > + struct vm_area_struct *vma = vmf->vma; > > +#ifdef CONFIG_TRANSPARENT_HUGEPAGE > > + unsigned long orders; > > + struct folio *folio; > > + unsigned long addr; > > + spinlock_t *ptl; > > + pte_t *pte; > > + gfp_t gfp; > > + int order; > > + > > + /* > > + * If uffd is active for the vma we need per-page fault fidelity to > > + * maintain the uffd semantics. > > + */ > > + if (unlikely(userfaultfd_armed(vma))) > > + goto fallback; > > + > > + /* > > + * a large folio being swapped-in could be partially in > > + * zswap and partially in swap devices, zswap doesn't > > + * support large folios yet, we might get corrupted > > + * zero-filled data by reading all subpages from swap > > + * devices while some of them are actually in zswap > > + */ > > If we read all subpages from swap devices while some of them are > actually in zswap, the corrupted data won't be zero-filled AFAICT, it > could be anything (old swapped out data). There are also more ways > this can go wrong: if the first page is in zswap, we will only fill > the first page and leave the rest of the folio uninitialized. > > How about a more generic comment? Perhaps something like: > > A large swapped out folio could be partially or fully in zswap. We > lack handling for such cases, so fallback to swapping in order-0 > folio. looks good to me, thanks! > > > + if (!zswap_never_enabled()) > > + goto fallback; > > +