On 23 Mar 2026, at 16:13, David Hildenbrand (Arm) wrote: > On 3/23/26 20:59, Zi Yan wrote: >> On 23 Mar 2026, at 15:53, David Hildenbrand (Arm) wrote: >> >>> On 3/23/26 20:47, Zi Yan wrote: >>>> >>>> >>>> My understanding is that collapse_file() is only used for >>>> READ_ONLY_THP_FOR_FS. If FSes with large folio support also use it, >>>> I can replace IS_ENABLE with mapping_large_folio_support(). >>> >>> Otherwise we'd be losing support for THP collapse in files? We'd have to >>> cross fingers that readahead gives us some. >>> >>> So we have to be a bit careful here. We want khugepaged to collapse THPs >>> in filesystems that support large folios even without READ_ONLY_THP_FOR_FS. >> >> Based on[1], collapse_file() only works on read-only fd. So it is not >> as general as all files. If we do what you suggested, the function >> will be collapse read-only folios from FSes with large folio support. > > Right, I think that's the first step to keep the existing use case > working. Long term, I suspect we might want to extend that to writable > files etc. > >> >> BTW, has anyone used/relied on collapse_file() on any FS with large folio >> support? > > I assume so, because for executables you would have to be lucky to get a > PMD THP? So I don't see the non-khugepaged large folio support on par > with khugepaged support.
It is more like turning on READ_ONLY_THP_FOR_FS by default for FS with large folio support instead of removing it. OK, I will give it another try. Best Regards, Yan, Zi

