On Fri, Oct 18, 2024 at 12:57:08PM GMT, Joanne Koong wrote: > On Thu, Oct 17, 2024 at 10:57 PM Shakeel Butt <shakeel.butt@xxxxxxxxx> wrote: > > > > On Thu, Oct 17, 2024 at 06:30:08PM GMT, Joanne Koong wrote: > > > On Tue, Oct 15, 2024 at 3:01 AM Miklos Szeredi <miklos@xxxxxxxxxx> wrote: > > > > > > > > On Mon, 14 Oct 2024 at 20:23, Joanne Koong <joannelkoong@xxxxxxxxx> wrote: > > > > > > > > > This change sets AS_NO_WRITEBACK_RECLAIM on the inode mapping so that > > > > > FUSE folios are not reclaimed and waited on while in writeback, and > > > > > removes the temporary folio + extra copying and the internal rb tree. > > > > > > > > What about sync(2)? And page migration? > > > > > > > > Hopefully there are no other cases, but I think a careful review of > > > > places where generic code waits for writeback is needed before we can > > > > say for sure. > > > > > > The places where I see this potential deadlock still being possible are: > > > * page migration when handling a page fault: > > > In particular, this path: handle_mm_fault() -> > > > __handle_mm_fault() -> handle_pte_fault() -> do_numa_page() -> > > > migrate_misplaced_folio() -> migrate_pages() -> migrate_pages_sync() > > > -> migrate_pages_batch() -> migrate_folio_unmap() -> > > > folio_wait_writeback() > > > > So, this is numa fault and if fuse server is not mapping the fuse folios > > which it is serving, in its address space then this is not an issue. > > However hugepage allocation on page fault can cause compaction which > > might migrate unrelated fuse folios. So, fuse server doing compaction > > is an issue and we need to resolve similar to reclaim codepath. (Though > > I think for THP it is not doing MIGRATE_SYNC but doing for gigantic > > hugetlb pages). > > Thanks for the explanation. Would you mind pointing me to the > compaction function where this triggers the migrate? Is this in > compact_zone() where it calls migrate_pages() on the cc->migratepages > list? > Something like the following: __alloc_pages_direct_compact() -> try_to_compact_pages() -> compact_zone_order() -> /* MIGRATE_ASYNC or MIGRATE_SYNC_LIGHT */ compact_zone() -> migrate_pages() -> migrate_pages_sync() -> migrate_pages_batch() -> migrate_folio_unmap() -> folio_wait_writeback() The following is one code path from hugetlb: alloc_contig_range_noprof() -> /* MIGRATE_SYNC */ __alloc_contig_migrate_range() -> migrate_pages() -> migrate_pages_sync() -> migrate_pages_batch() -> migrate_folio_unmap() -> folio_wait_writeback()