On Tue, Mar 14, 2023 at 9:43 AM Matthew Wilcox <willy@xxxxxxxxxxxxx> wrote: > > The problem is that we might have swapped out the shmem folio. So we > don't want to clear the page, but ask swap to fill the page. Doesn't shmem_swapin_folio() already basically do all that work? The real oddity with shmem - compared to other filesystems - is that the xarray has a value entry instead of being a real folio. And yes, the current filemap code will then just ignore such entries as "doesn't exist", and so the regular read iterators will all fail on it. But while filemap_get_read_batch() will stop at a value-folio, I feel like filemap_create_folio() should be able to turn a value page into a "real" page. Right now it already allocates said page, but then I think filemap_add_folio() will return -EEXIST when said entry exists as a value. But *if* instead of -EEXIST we could just replace the value with the (already locked) page, and have some sane way to pass that value (which is the swap entry data) to readpage(), I think that should just do it all. Admittedly I really don't know this area very well, so I may be *entirely* out to lunch. But the whole "teach the filemap code to actually react to XA value entries" would be how I'd solve the hole issue too. So I think there are commonalities here. Linus Linus