On Fri, Mar 8, 2024 at 1:15 PM Jared Hulbert <jaredeh@xxxxxxxxx> wrote: > > On Thu, Mar 7, 2024 at 1:17 PM Barry Song <21cnbao@xxxxxxxxx> wrote: > > > > I don't understand why we need this level of complexity. All we need to know > > are the offsets during pageout. After that, the large folio is > > destroyed, and all > > offsets are stored in page table entries (PTEs) or xa. Swap-in doesn't depend > > on a complex file system; it can make its own decision on how to swap-in > > based on the values it reads from PTEs. > > > > Swap-in doesn't need to know whether the swapped-out folio was large or not. > > Right if the folio was broken down to individual pages on swap out > then individual pages PTEs know where the data is. So I agree it's not > necessary. Hi Jared, My point is that even if we fail to obtain contiguous swap offsets, there's no need to split large folios into smaller ones. We only need to temporarily record discontiguous offsets for each subpage, then proceed with pageout and try_to_unmap_one. After this process, the lifecycle of the large folio is complete. Once the pageout and try_to_unmap_one operations are done, the folio is no longer present, and the related offset information in memory can also be cleared. So, I'd like to concentrate on how to record that offset information and perform anti-fragmentation in the swap system. I don't understand why we should get a complex fs involved here. > > But the folio was destroyed. We want to recreate the folio on swap in? IDK Indeed, the primary purpose of swap-out is to release the folio (or "release" it to the buddy system). Before doing so, we store offsets in Page Table Entries (PTEs) or xa in try_to_unmap_one. Swap-in already has all the necessary information to retrieve its memory from the swapfile. Sorry I abused the word "destroy", I meant "release". > > \What if you flip the argument? The complexity of the file path exists > already... If swap didn't exist could we justify adding the > duplicated (albeit simpler) functionality of swap? I don't quite get your point. Can you please give a concrete example? Thanks Barry