On Tue, Sep 28, 2021 at 5:07 AM Matthew Wilcox <willy@xxxxxxxxxxxxx> wrote: > > On Mon, Sep 27, 2021 at 03:24:47PM -0700, Song Liu wrote: > > OTOH, does it make sense to block writes within khugepaged, like: > > @@ -1652,6 +1653,11 @@ static void collapse_file(struct mm_struct *mm, > > /* Only allocate from the target node */ > > gfp = alloc_hugepage_khugepaged_gfpmask() | __GFP_THISNODE; > > > > + if (deny_write_access(file)) { > > + result = SCAN_BUSY_WRITE; > > + return; > > + } > > The problem is that it denies, rather than blocking. That means that the > writer gets ETXTBSY instead of waiting until khugepaged is done. > Yes, I was thinking about the same problem last night and this morning. Unfortunately, I haven't got a good solution yet. Do you have some suggestions on this? Thanks, Song