Re: [PATCH v6 00/14] Remove CONFIG_READ_ONLY_THP_FOR_FS and enable file THP for writable files
On 19 May 2026, at 8:45, Andrew Morton wrote: > On Tue, 19 May 2026 07:39:07 +0800 Zi Yan wrote: > >> On 19 May 2026, at 6:21, Andrew Morton wrote: >> >>> On Sun, 17 May 2026 09:54:02 -0400 Zi Yan wrote: >>> Hi all, This patchset removes READ_ONLY_THP_FOR_FS Kconfig and enables creating file-backed THPs for FSes with large folio support (the supported orders need to include PMD_ORDER) by default, including for writable files. >>> >>> Cool. Sashiko wasn't able to apply this (presumably because of Mike's >>> CI-friendly series). I take it that the AI review from v5 >>> (https://sashiko.dev/#/patchset/[email protected]) >>> was considered? >>> >>> Also, please check that the below were considered: >>> >>> https://lore.kernel.org/[email protected] >>> https://lore.kernel.org/[email protected] >>> https://lore.kernel.org/[email protected] >>> https://lore.kernel.org/[email protected] >>> >>> https://lore.kernel.org/[email protected] >>> https://lore.kernel.org/[email protected] >>> >> >> I addressed all of them, except the second one and I will reply to the >> second one soon. > > Great. > >>> is an in-place replacement of V5 in mm-new. It affects Mike Rapoport's "make MM selftests more CI friendly", since "selftests/mm: khugepaged: use kselftest framework" needs to be updated. I updated it and put it at the end of this cover letter. >>> >>> Helpful, thanks. It was a little complicated because your email client >>> messes with whitespace (it always has!), but I figured it out. >> >> You mean tabs become whitespace? And does all my patches have the whitespace >> issue or the one I put at the bottom? I am trying to figure out the issue. >> BTW, All patches are sent via git send-email using mstmp and >> I copied the bottom one from git format-patch. I wonder which part went >> wrong. > > Your regular patches are OK - but when you informally paste a patch > into the message body the tabs turn into whitespace. I did that before, since I was copying diffs directly from a GUI terminal that converts tabs to whitespaces. Since you mentioned it last time, I always do git format-patch and copy the content from the patch file and it should work. For the patch I pasted in this cover letter, I copied it from the patch file directly using neovim, but somehow tabs from surrounding code are converted to whitespaces (tabs from +/- are not). I noticed it when I checked my original cover letter just now. So my email client does not cause the issue. Anyway, I will be more careful next time. Sorry for the trouble. > > You aren't the only one ;) I usually don't comment... Thank you for reminding me of the issue. Best Regards, Yan, Zi
Re: [PATCH v6 00/14] Remove CONFIG_READ_ONLY_THP_FOR_FS and enable file THP for writable files
On Tue, 19 May 2026 07:39:07 +0800 Zi Yan wrote: > On 19 May 2026, at 6:21, Andrew Morton wrote: > > > On Sun, 17 May 2026 09:54:02 -0400 Zi Yan wrote: > > > >> Hi all, > >> > >> This patchset removes READ_ONLY_THP_FOR_FS Kconfig and enables creating > >> file-backed THPs for FSes with large folio support (the supported orders > >> need to include PMD_ORDER) by default, including for writable files. > > > > Cool. Sashiko wasn't able to apply this (presumably because of Mike's > > CI-friendly series). I take it that the AI review from v5 > > (https://sashiko.dev/#/patchset/[email protected]) > > was considered? > > > > Also, please check that the below were considered: > > > > https://lore.kernel.org/[email protected] > > https://lore.kernel.org/[email protected] > > https://lore.kernel.org/[email protected] > > https://lore.kernel.org/[email protected] > > > > https://lore.kernel.org/[email protected] > > https://lore.kernel.org/[email protected] > > > > I addressed all of them, except the second one and I will reply to the > second one soon. Great. > > > >> is an in-place replacement of V5 in mm-new. It affects Mike Rapoport's > >> "make MM selftests more CI friendly", since "selftests/mm: khugepaged: > >> use kselftest framework" needs to be updated. I updated it and put it at > >> the end of this cover letter. > > > > Helpful, thanks. It was a little complicated because your email client > > messes with whitespace (it always has!), but I figured it out. > > You mean tabs become whitespace? And does all my patches have the whitespace > issue or the one I put at the bottom? I am trying to figure out the issue. > BTW, All patches are sent via git send-email using mstmp and > I copied the bottom one from git format-patch. I wonder which part went > wrong. Your regular patches are OK - but when you informally paste a patch into the message body the tabs turn into whitespace. You aren't the only one ;) I usually don't comment...
Re: [PATCH v6 00/14] Remove CONFIG_READ_ONLY_THP_FOR_FS and enable file THP for writable files
On 19 May 2026, at 6:21, Andrew Morton wrote: > On Sun, 17 May 2026 09:54:02 -0400 Zi Yan wrote: > >> Hi all, >> >> This patchset removes READ_ONLY_THP_FOR_FS Kconfig and enables creating >> file-backed THPs for FSes with large folio support (the supported orders >> need to include PMD_ORDER) by default, including for writable files. > > Cool. Sashiko wasn't able to apply this (presumably because of Mike's > CI-friendly series). I take it that the AI review from v5 > (https://sashiko.dev/#/patchset/[email protected]) > was considered? > > Also, please check that the below were considered: > > https://lore.kernel.org/[email protected] > https://lore.kernel.org/[email protected] > https://lore.kernel.org/[email protected] > https://lore.kernel.org/[email protected] > > https://lore.kernel.org/[email protected] > https://lore.kernel.org/[email protected] > I addressed all of them, except the second one and I will reply to the second one soon. > >> is an in-place replacement of V5 in mm-new. It affects Mike Rapoport's >> "make MM selftests more CI friendly", since "selftests/mm: khugepaged: >> use kselftest framework" needs to be updated. I updated it and put it at >> the end of this cover letter. > > Helpful, thanks. It was a little complicated because your email client > messes with whitespace (it always has!), but I figured it out. You mean tabs become whitespace? And does all my patches have the whitespace issue or the one I put at the bottom? I am trying to figure out the issue. BTW, All patches are sent via git send-email using mstmp and I copied the bottom one from git format-patch. I wonder which part went wrong. Thanks. Best Regards, Yan, Zi
Re: [PATCH v6 00/14] Remove CONFIG_READ_ONLY_THP_FOR_FS and enable file THP for writable files
On Sun, 17 May 2026 09:54:02 -0400 Zi Yan wrote: > Hi all, > > This patchset removes READ_ONLY_THP_FOR_FS Kconfig and enables creating > file-backed THPs for FSes with large folio support (the supported orders > need to include PMD_ORDER) by default, including for writable files. Cool. Sashiko wasn't able to apply this (presumably because of Mike's CI-friendly series). I take it that the AI review from v5 (https://sashiko.dev/#/patchset/[email protected]) was considered? Also, please check that the below were considered: https://lore.kernel.org/[email protected] https://lore.kernel.org/[email protected] https://lore.kernel.org/[email protected] https://lore.kernel.org/[email protected] https://lore.kernel.org/[email protected] https://lore.kernel.org/[email protected] > is an in-place replacement of V5 in mm-new. It affects Mike Rapoport's > "make MM selftests more CI friendly", since "selftests/mm: khugepaged: > use kselftest framework" needs to be updated. I updated it and put it at > the end of this cover letter. Helpful, thanks. It was a little complicated because your email client messes with whitespace (it always has!), but I figured it out. > Changelog > === > >From V5[6]: > 1. added mapping_min_folio_order(mapping) <= PMD_ORDER check to >mapping_pmd_folio_support() in Patch 1 to correctly handle >filesystems whose minimum folio order exceeds PMD_ORDER. Also >improved the kernel-doc comment per David's suggestions. > > 2. cleaned up Patch 11 per David's review: use const for open_opt and >mmap_prot, remove mmap_opt (use MAP_SHARED for both read-only and >read-write mappings), inline file_fault_common() into separate >file_fault_read() and file_fault_write() functions, fix "read only" >typo to "read-only", update usage message to "with PMD-sized large >folio support". Also fixed run_vmtests.sh to use elif test_selected >thp for the SKIP case to avoid spurious [SKIP] output per Nico's >report. > > 3. revised stale comment in Patch 13: removed "There won't be new dirty >pages" and updated "khugepaged only works on read-only fd" to reflect >that writable files are now supported; merged the comment blocks per >David's suggestion. > Here's how v6 altered mm.git: include/linux/pagemap.h | 12 +++ mm/khugepaged.c | 18 --- tools/testing/selftests/mm/khugepaged.c | 35 -- 3 files changed, 26 insertions(+), 39 deletions(-) --- a/include/linux/pagemap.h~b +++ a/include/linux/pagemap.h @@ -514,15 +514,15 @@ static inline bool mapping_large_folio_s } /** - * mapping_pmd_folio_support() - Check if a mapping support PMD-sized folio + * mapping_pmd_folio_support() - Check if a mapping supports PMD-sized folio * @mapping: The address_space * - * Some file supports large folio but does not support as large as PMD order. - * If a PMD-sized pagecache folio is attempted to be created on a filesystem, - * this check needs to be performed first. + * While some mappings support large folios, they might not support PMD-sized + * folios. This function checks whether a mapping supports PMD-sized folios. + * For example, khugepaged needs this information before attempting to + * collapsing THPs. * - * Return: true - PMD-sized folio is supported, false - PMD-sized folio is not - * supported. + * Return: True if PMD-sized folios are supported, otherwise false. */ #ifdef CONFIG_TRANSPARENT_HUGEPAGE static inline bool mapping_pmd_folio_support(const struct address_space *mapping) --- a/mm/khugepaged.c~b +++ a/mm/khugepaged.c @@ -2342,23 +2342,19 @@ static enum scan_result collapse_file(st } else if (folio_test_dirty(folio)) { /* * This page is dirty because it hasn't -* been flushed since first write. There -* won't be new dirty pages. +* been flushed since first write. * -* Trigger async flush here and hope the -* writeback is done when khugepaged -* revisits this page. +* Trigger async flush for read-only files and +* hope the writeback is done when khugepaged +* revisits this page. Writable files can have +* their folios dirty at any time; blindly +* flushing them would cause undesirable +* system-wide writeback. *

