| Seq | Timestamp | Type | Name | Duration |
|---|---|---|---|---|
| 0/0 | 2026/09/22 23:11 | flow | patch-triage |
4mArgs:null Results: {
"EnableConfigs": [
"EROFS_FS",
"EROFS_FS_ZIP",
"F2FS_FS",
"F2FS_FS_COMPRESSION",
"ZRAM",
"ZSMALLOC",
"COMPACTION",
"MD",
"BLK_DEV_MD",
"MD_BITMAP",
"MD_BITMAP_FILE",
"TRANSPARENT_HUGEPAGE",
"HUGETLB_PAGE",
"MIGRATION"
],
"FocusSymbols": [
"erofs_onlinefolio_init",
"erofs_onlinefolio_end",
"z_erofs_readahead",
"f2fs_compress_write_end_io",
"f2fs_write_compressed_pages",
"zs_page_migrate",
"split_huge_pages_pid",
"folio_migrate_flags",
"migrate_folio_unmap",
"add_hugetlb_folio"
],
"KMSANReasoning": "The patch series removes the `PG_private` page flag, transitioning the kernel to check `folio-\u003eprivate != NULL` (or `folio_has_attached_private()`, `page_private()`) instead. It updates core memory management, pagecache, tracing, procfs kpageflags, perf x86 AUX buffers, Xen grant tables, and filesystems (Ceph, EROFS, F2FS, NFS, UBIFS).\n\nKMSAN vs KASAN applicability:\n- No uninitialized memory usage or info-leaks:\n - In `fs/proc/page.c`, removing `kpf_copy_bit(..., KPF_PRIVATE, PG_private)` leaves the corresponding bit zeroed because the return accumulator `u` is initialized to 0. No uninitialized bytes or padding are exposed to userspace.\n - In `include/linux/pagemap.h`, the new `_forward` boolean added to `struct readahead_control` is properly zero-initialized by `DEFINE_READAHEAD` (which uses designated initializers, zeroing unspecified members).\n - In perf x86 events (`bts.c`, `pt.c`, `ring_buffer.c`), `page_private(p)` defaults to 0 on page allocation and is explicitly cleared to 0 on free; reading `1 \u003c\u003c page_private(p)` for order-0 pages evaluates deterministically to 1 without accessing uninitialized state.\n - In `fs/erofs`, `fs/f2fs`, and `drivers/md/md-bitmap.c`, all state attached to folios is explicitly initialized before use.\n- The primary risks of these changes involve page/folio lifecycle management, reference counting (e.g. `folio_attach_private` / `folio_detach_private` pairings), and use-after-free or buffer head leaks, which are directly monitored by KASAN and SLUB debugging rather than KMSAN.\n\nTherefore, a dedicated KMSAN fuzzing session is not justified.",
"NeedsKMSAN": false,
"Reasoning": "The patch eliminates the PG_private page flag and switches private state management to folio-\u003eprivate and folio_has_attached_private across core memory management (THP splitting, hugetlb, folio migration, page writeback, vmscan, zsmalloc) and filesystems (EROFS, F2FS, md-bitmap, ceph, nfs). It adds readahead_folio_last() for reverse folio traversal, alters online folio state tracking and assertions in EROFS, restructures F2FS folio private bits, and modifies zspage assertions in zsmalloc. These extensive MM and filesystem modifications warrant fuzzing.",
"WorthFuzzing": true
} |
| 1/1 | 2026/09/22 23:11 | action | read-patch-diff |
0mArgs:null Results: {
"PatchDiff": "commit 95b7a2d0e4b277882309fe37eaff2a2dd99b8ba9\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate: Tue Sep 22 23:11:17 2026 +0000\n\n syz-cluster: applied patch under review\n\ndiff --git a/Documentation/admin-guide/kdump/vmcoreinfo.rst b/Documentation/admin-guide/kdump/vmcoreinfo.rst\nindex 7663c610fe901..5f1df6d080508 100644\n--- a/Documentation/admin-guide/kdump/vmcoreinfo.rst\n+++ b/Documentation/admin-guide/kdump/vmcoreinfo.rst\n@@ -325,7 +325,7 @@ NR_FREE_PAGES\n On linux-2.6.21 or later, the number of free pages is in\n vm_stat[NR_FREE_PAGES]. Used to get the number of free pages.\n \n-PG_lru|PG_private|PG_swapcache|PG_swapbacked|PG_hwpoison|PG_head_mask\n+PG_lru|PG_swapcache|PG_swapbacked|PG_hwpoison|PG_head_mask\n --------------------------------------------------------------------------\n \n Page attributes. These flags are used to filter various unnecessary for\ndiff --git a/Documentation/filesystems/vfs.rst b/Documentation/filesystems/vfs.rst\nindex d3a93eec3945f..dec7816303c6a 100644\n--- a/Documentation/filesystems/vfs.rst\n+++ b/Documentation/filesystems/vfs.rst\n@@ -649,8 +649,8 @@ Writeback.\n \n The first can be used independently to the others. The VM can try to\n release clean pages in order to reuse them. To do this it can call\n--\u003erelease_folio on clean folios with the private\n-flag set. Clean pages without PagePrivate and with no external references\n+-\u003erelease_folio on clean folios with folio-\u003eprivate set. Clean pages\n+without folio-\u003eprivate set and with no external references\n will be released without notice being given to the address_space.\n \n To achieve this functionality, pages need to be placed on an LRU with\n@@ -674,7 +674,7 @@ filemap_fdatawait_range, to wait for all writeback to complete.\n \n An address_space handler may attach extra information to a page,\n typically using the 'private' field in the 'struct page'. If such\n-information is attached, the PG_Private flag should be set. This will\n+information is attached, non-NULL 'private' field will\n cause various VM routines to make extra calls into the address_space\n handler to deal with that data.\n \ndiff --git a/arch/x86/events/intel/bts.c b/arch/x86/events/intel/bts.c\nindex cbac54cb3a9ec..5849392cf26d5 100644\n--- a/arch/x86/events/intel/bts.c\n+++ b/arch/x86/events/intel/bts.c\n@@ -66,9 +66,6 @@ static struct pmu bts_pmu;\n \n static int buf_nr_pages(struct page *page)\n {\n-\tif (!PagePrivate(page))\n-\t\treturn 1;\n-\n \treturn 1 \u003c\u003c page_private(page);\n }\n \ndiff --git a/arch/x86/events/intel/pt.c b/arch/x86/events/intel/pt.c\nindex 5754cd4055628..49349afee6119 100644\n--- a/arch/x86/events/intel/pt.c\n+++ b/arch/x86/events/intel/pt.c\n@@ -781,8 +781,7 @@ static int topa_insert_pages(struct pt_buffer *buf, int cpu, gfp_t gfp)\n \tstruct page *p;\n \n \tp = virt_to_page(buf-\u003edata_pages[buf-\u003enr_pages]);\n-\tif (PagePrivate(p))\n-\t\torder = page_private(p);\n+\torder = page_private(p);\n \n \tif (topa_table_full(topa)) {\n \t\ttopa = topa_alloc(cpu, gfp);\n@@ -1296,8 +1295,7 @@ static int pt_buffer_try_single(struct pt_buffer *buf, int nr_pages)\n \tif (!intel_pt_validate_hw_cap(PT_CAP_single_range_output))\n \t\tgoto out;\n \n-\tif (PagePrivate(p))\n-\t\torder = page_private(p);\n+\torder = page_private(p);\n \n \tif (1 \u003c\u003c order != nr_pages)\n \t\tgoto out;\ndiff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c\nindex b8325cb09a371..8adf6ddca3d60 100644\n--- a/drivers/md/md-bitmap.c\n+++ b/drivers/md/md-bitmap.c\n@@ -516,7 +516,8 @@ static void end_bitmap_write(struct bio *bio)\n \n static void write_file_page(struct bitmap *bitmap, struct page *page, int wait)\n {\n-\tstruct buffer_head *bh = page_buffers(page);\n+\tstruct folio *folio = page_folio(page);\n+\tstruct buffer_head *bh = folio_buffers(folio);\n \n \twhile (bh \u0026\u0026 bh-\u003eb_blocknr) {\n \t\tatomic_inc(\u0026bitmap-\u003epending_writes);\n@@ -533,19 +534,15 @@ static void write_file_page(struct bitmap *bitmap, struct page *page, int wait)\n \n static void free_buffers(struct page *page)\n {\n-\tstruct buffer_head *bh;\n-\n-\tif (!PagePrivate(page))\n-\t\treturn;\n+\tstruct folio *folio = page_folio(page);\n+\tstruct buffer_head *bh = folio_detach_private(folio);\n \n-\tbh = page_buffers(page);\n \twhile (bh) {\n \t\tstruct buffer_head *next = bh-\u003eb_this_page;\n \t\tfree_buffer_head(bh);\n \t\tbh = next;\n \t}\n-\tdetach_page_private(page);\n-\tput_page(page);\n+\tfolio_put(folio);\n }\n \n /* read a page from a file.\n@@ -560,6 +557,7 @@ static int read_file_page(struct file *file, unsigned long index,\n {\n \tint ret = 0;\n \tstruct inode *inode = file_inode(file);\n+\tstruct folio *folio = page_folio(page);\n \tstruct buffer_head *bh;\n \tsector_t block, blk_cur;\n \tunsigned long blocksize = i_blocksize(inode);\n@@ -567,12 +565,12 @@ static int read_file_page(struct file *file, unsigned long index,\n \tpr_debug(\"read bitmap file (%dB @ %llu)\\n\", (int)PAGE_SIZE,\n \t\t (unsigned long long)index \u003c\u003c PAGE_SHIFT);\n \n-\tbh = alloc_page_buffers(page, blocksize);\n+\tbh = folio_alloc_buffers(folio, blocksize, GFP_NOFS | __GFP_ACCOUNT);\n \tif (!bh) {\n \t\tret = -ENOMEM;\n \t\tgoto out;\n \t}\n-\tattach_page_private(page, bh);\n+\tfolio_attach_private(folio, bh);\n \tblk_cur = index \u003c\u003c (PAGE_SHIFT - inode-\u003ei_blkbits);\n \twhile (bh) {\n \t\tblock = blk_cur;\ndiff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c\nindex 69922be28b54c..993f89f048e21 100644\n--- a/drivers/xen/grant-table.c\n+++ b/drivers/xen/grant-table.c\n@@ -863,10 +863,10 @@ EXPORT_SYMBOL_GPL(gnttab_free_auto_xlat_frames);\n \n int gnttab_pages_set_private(int nr_pages, struct page **pages)\n {\n+#if BITS_PER_LONG \u003c 64\n \tint i;\n \n \tfor (i = 0; i \u003c nr_pages; i++) {\n-#if BITS_PER_LONG \u003c 64\n \t\tstruct xen_page_foreign *foreign;\n \n \t\tforeign = kzalloc_obj(*foreign);\n@@ -874,9 +874,9 @@ int gnttab_pages_set_private(int nr_pages, struct page **pages)\n \t\t\treturn -ENOMEM;\n \n \t\tset_page_private(pages[i], (unsigned long)foreign);\n-#endif\n-\t\tSetPagePrivate(pages[i]);\n \t}\n+#endif\n+\t/* Data is stored in page-\u003eprivate on 64-bit */\n \n \treturn 0;\n }\n@@ -1031,12 +1031,11 @@ void gnttab_pages_clear_private(int nr_pages, struct page **pages)\n \tint i;\n \n \tfor (i = 0; i \u003c nr_pages; i++) {\n-\t\tif (PagePrivate(pages[i])) {\n #if BITS_PER_LONG \u003c 64\n+\t\tif (page_private(pages[i]))\n \t\t\tkfree((void *)page_private(pages[i]));\n #endif\n-\t\t\tClearPagePrivate(pages[i]);\n-\t\t}\n+\t\tset_page_private(pages[i], 0);\n \t}\n }\n EXPORT_SYMBOL_GPL(gnttab_pages_clear_private);\ndiff --git a/fs/buffer.c b/fs/buffer.c\nindex ed966fa73b1ba..020af5dbe2d05 100644\n--- a/fs/buffer.c\n+++ b/fs/buffer.c\n@@ -773,14 +773,6 @@ struct buffer_head *folio_alloc_buffers(struct folio *folio, unsigned long size,\n }\n EXPORT_SYMBOL_GPL(folio_alloc_buffers);\n \n-struct buffer_head *alloc_page_buffers(struct page *page, unsigned long size)\n-{\n-\tgfp_t gfp = GFP_NOFS | __GFP_ACCOUNT;\n-\n-\treturn folio_alloc_buffers(page_folio(page), size, gfp);\n-}\n-EXPORT_SYMBOL_GPL(alloc_page_buffers);\n-\n static inline void link_dev_buffers(struct folio *folio,\n \t\tstruct buffer_head *head)\n {\ndiff --git a/fs/ceph/addr.c b/fs/ceph/addr.c\nindex 657c2cb0f8811..1aca181d28c62 100644\n--- a/fs/ceph/addr.c\n+++ b/fs/ceph/addr.c\n@@ -70,9 +70,7 @@ static int ceph_netfs_check_write_begin(struct file *file, loff_t pos, unsigned\n \n static inline struct ceph_snap_context *page_snap_context(struct page *page)\n {\n-\tif (PagePrivate(page))\n-\t\treturn (void *)page-\u003eprivate;\n-\treturn NULL;\n+\treturn (void *)page_private(page);\n }\n \n /*\n@@ -124,8 +122,8 @@ static bool ceph_dirty_folio(struct address_space *mapping, struct folio *folio)\n \tspin_unlock(\u0026ci-\u003ei_ceph_lock);\n \n \t/*\n-\t * Reference snap context in folio-\u003eprivate. Also set\n-\t * PagePrivate so that we get invalidate_folio callback.\n+\t * Reference snap context in folio-\u003eprivate. Setting folio-\u003eprivate is\n+\t * what gets us the invalidate_folio callback.\n \t */\n \tVM_WARN_ON_FOLIO(folio-\u003eprivate, folio);\n \tfolio_attach_private(folio, snapc);\ndiff --git a/fs/crypto/crypto.c b/fs/crypto/crypto.c\nindex 5286a124b0d98..aced5c50a4601 100644\n--- a/fs/crypto/crypto.c\n+++ b/fs/crypto/crypto.c\n@@ -65,7 +65,6 @@ void fscrypt_free_bounce_page(struct page *bounce_page)\n \tif (!bounce_page)\n \t\treturn;\n \tset_page_private(bounce_page, (unsigned long)NULL);\n-\tClearPagePrivate(bounce_page);\n \tmempool_free(bounce_page, fscrypt_bounce_page_pool);\n }\n EXPORT_SYMBOL(fscrypt_free_bounce_page);\n@@ -210,7 +209,6 @@ struct page *fscrypt_encrypt_pagecache_blocks(struct folio *folio,\n \t\t\treturn ERR_PTR(err);\n \t\t}\n \t}\n-\tSetPagePrivate(ciphertext_page);\n \tset_page_private(ciphertext_page, (unsigned long)folio);\n \treturn ciphertext_page;\n }\ndiff --git a/fs/erofs/data.c b/fs/erofs/data.c\nindex 0885b1f2fc925..f71c7b51bb720 100644\n--- a/fs/erofs/data.c\n+++ b/fs/erofs/data.c\n@@ -239,19 +239,23 @@ int erofs_map_dev(struct super_block *sb, struct erofs_map_dev *map)\n /*\n * bit 30: I/O error occurred on this folio\n * bit 29: CPU has dirty data in D-cache (needs aliasing handling);\n- * bit 0 - 29: remaining parts to complete this folio\n+ * bit 0 - 28: remaining parts to complete this folio, biased by 1 so that\n+ *\t -\u003eprivate stays non-NULL while the folio is attached\n */\n #define EROFS_ONLINEFOLIO_EIO\t\t30\n #define EROFS_ONLINEFOLIO_DIRTY\t\t29\n+#define EROFS_ONLINEFOLIO_COUNT_MASK\t(BIT(EROFS_ONLINEFOLIO_DIRTY) - 1)\n+#define EROFS_ONLINEFOLIO_BIAS\t\t1\n \n void erofs_onlinefolio_init(struct folio *folio)\n {\n \tunion {\n \t\tatomic_t o;\n \t\tvoid *v;\n-\t} u = { .o = ATOMIC_INIT(1) };\n+\t} u = { .o = ATOMIC_INIT(1 + EROFS_ONLINEFOLIO_BIAS) };\n \n-\tfolio-\u003eprivate = u.v;\t/* valid only if file-backed folio is locked */\n+\t/* valid only if file-backed folio is locked */\n+\tfolio_attach_private(folio, u.v);\n }\n \n void erofs_onlinefolio_split(struct folio *folio)\n@@ -265,14 +269,14 @@ void erofs_onlinefolio_end(struct folio *folio, int err, bool dirty)\n \n \tdo {\n \t\torig = atomic_read((atomic_t *)\u0026folio-\u003eprivate);\n-\t\tDBG_BUGON(orig \u003c= 0);\n+\t\tDBG_BUGON((orig \u0026 EROFS_ONLINEFOLIO_COUNT_MASK) \u003c= EROFS_ONLINEFOLIO_BIAS);\n \t\tv = dirty \u003c\u003c EROFS_ONLINEFOLIO_DIRTY;\n \t\tv |= (orig - 1) | (!!err \u003c\u003c EROFS_ONLINEFOLIO_EIO);\n \t} while (atomic_cmpxchg((atomic_t *)\u0026folio-\u003eprivate, orig, v) != orig);\n \n-\tif (v \u0026 (BIT(EROFS_ONLINEFOLIO_DIRTY) - 1))\n+\tif ((v \u0026 EROFS_ONLINEFOLIO_COUNT_MASK) != EROFS_ONLINEFOLIO_BIAS)\n \t\treturn;\n-\tfolio-\u003eprivate = 0;\n+\tfolio_detach_private(folio);\n \tif (v \u0026 BIT(EROFS_ONLINEFOLIO_DIRTY))\n \t\tflush_dcache_folio(folio);\n \tfolio_end_read(folio, !(v \u0026 BIT(EROFS_ONLINEFOLIO_EIO)));\ndiff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c\nindex e1e25ca0d1904..78fd7d980e957 100644\n--- a/fs/erofs/zdata.c\n+++ b/fs/erofs/zdata.c\n@@ -1898,21 +1898,14 @@ static void z_erofs_readahead(struct readahead_control *rac)\n \tstruct inode *realinode = erofs_real_inode(sharedinode, \u0026need_iput);\n \tZ_EROFS_DEFINE_FRONTEND(f, realinode, sharedinode, readahead_pos(rac));\n \tunsigned int nrpages = readahead_count(rac);\n-\tstruct folio *head = NULL, *folio;\n+\tstruct folio *folio;\n \tint err;\n \n \ttrace_erofs_readahead(realinode, readahead_index(rac), nrpages, false);\n \tz_erofs_pcluster_readmore(\u0026f, rac, true);\n-\twhile ((folio = readahead_folio(rac))) {\n-\t\tfolio-\u003eprivate = head;\n-\t\thead = folio;\n-\t}\n-\n-\t/* traverse in reverse order for best metadata I/O performance */\n-\twhile (head) {\n-\t\tfolio = head;\n-\t\thead = folio_get_private(folio);\n \n+\t/* traverse from last to first for best metadata I/O performance */\n+\twhile ((folio = readahead_folio_last(rac))) {\n \t\terr = z_erofs_scan_folio(\u0026f, folio, true);\n \t\tif (err \u0026\u0026 err != -EINTR)\n \t\t\terofs_err(realinode-\u003ei_sb, \"readahead error at folio %lu @ nid %llu\",\ndiff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c\nindex ce88092d9ce26..09d9b8d0fdcce 100644\n--- a/fs/f2fs/compress.c\n+++ b/fs/f2fs/compress.c\n@@ -1064,13 +1064,15 @@ static void cancel_cluster_writeback(struct compress_ctx *cc,\n \n \t/* Cancel writeback and stay locked. */\n \tfor (i = 0; i \u003c cc-\u003ecluster_size; i++) {\n+\t\tstruct folio *folio = page_folio(cc-\u003erpages[i]);\n+\n \t\tif (i \u003c submitted) {\n \t\t\tinode_inc_dirty_pages(cc-\u003einode);\n-\t\t\tlock_page(cc-\u003erpages[i]);\n+\t\t\tfolio_lock(folio);\n \t\t}\n-\t\tclear_page_private_gcing(cc-\u003erpages[i]);\n-\t\tif (folio_test_writeback(page_folio(cc-\u003erpages[i])))\n-\t\t\tend_page_writeback(cc-\u003erpages[i]);\n+\t\tfolio_clear_f2fs_gcing(folio);\n+\t\tif (folio_test_writeback(folio))\n+\t\t\tfolio_end_writeback(folio);\n \t}\n }\n \n@@ -1078,11 +1080,15 @@ static void set_cluster_dirty(struct compress_ctx *cc)\n {\n \tint i;\n \n-\tfor (i = 0; i \u003c cc-\u003ecluster_size; i++)\n-\t\tif (cc-\u003erpages[i]) {\n-\t\t\tset_page_dirty(cc-\u003erpages[i]);\n-\t\t\tset_page_private_gcing(cc-\u003erpages[i]);\n-\t\t}\n+\tfor (i = 0; i \u003c cc-\u003ecluster_size; i++) {\n+\t\tstruct folio *folio;\n+\n+\t\tif (!cc-\u003erpages[i])\n+\t\t\tcontinue;\n+\t\tfolio = page_folio(cc-\u003erpages[i]);\n+\t\tfolio_mark_dirty(folio);\n+\t\tfolio_set_f2fs_gcing(folio);\n+\t}\n }\n \n static int prepare_compress_overwrite(struct compress_ctx *cc,\n@@ -1281,7 +1287,7 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,\n \t\t.op = REQ_OP_WRITE,\n \t\t.op_flags = wbc_to_write_flags(wbc),\n \t\t.old_blkaddr = NEW_ADDR,\n-\t\t.page = NULL,\n+\t\t.folio = NULL,\n \t\t.encrypted_page = NULL,\n \t\t.compressed_page = NULL,\n \t\t.io_type = io_type,\n@@ -1370,7 +1376,7 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,\n \t\tblock_t blkaddr;\n \n \t\tblkaddr = f2fs_data_blkaddr(\u0026dn);\n-\t\tfio.page = cc-\u003erpages[i];\n+\t\tfio.folio = page_folio(cc-\u003erpages[i]);\n \t\tfio.old_blkaddr = blkaddr;\n \n \t\t/* cluster header */\n@@ -1476,9 +1482,12 @@ void f2fs_compress_write_end_io(struct bio *bio, struct folio *folio)\n \t}\n \n \tfor (i = 0; i \u003c cic-\u003enr_rpages; i++) {\n+\t\tstruct folio *rfolio;\n+\n \t\tWARN_ON(!cic-\u003erpages[i]);\n-\t\tclear_page_private_gcing(cic-\u003erpages[i]);\n-\t\tend_page_writeback(cic-\u003erpages[i]);\n+\t\trfolio = page_folio(cic-\u003erpages[i]);\n+\t\tfolio_clear_f2fs_gcing(rfolio);\n+\t\tfolio_end_writeback(rfolio);\n \t}\n \n \tpage_array_free(sbi, cic-\u003erpages, cic-\u003enr_rpages);\ndiff --git a/fs/f2fs/data.c b/fs/f2fs/data.c\nindex 21f396ebe22ca..ca8232a9095f8 100644\n--- a/fs/f2fs/data.c\n+++ b/fs/f2fs/data.c\n@@ -2923,7 +2923,7 @@ bool f2fs_should_update_outplace(struct inode *inode, struct f2fs_io_info *fio)\n \t\treturn true;\n \n \tif (fio) {\n-\t\tif (page_private_gcing(fio-\u003epage))\n+\t\tif (folio_test_f2fs_gcing(fio-\u003efolio))\n \t\t\treturn true;\n \t\tif (unlikely(is_sbi_flag_set(sbi, SBI_CP_DISABLED) \u0026\u0026\n \t\t\tf2fs_is_checkpointed_data(sbi, fio-\u003eold_blkaddr)))\ndiff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h\nindex 9940a6cecf1a2..85937de3d7016 100644\n--- a/fs/f2fs/f2fs.h\n+++ b/fs/f2fs/f2fs.h\n@@ -1357,10 +1357,7 @@ struct f2fs_io_info {\n \tblk_opf_t op_flags;\t/* req_flag_bits */\n \tblock_t new_blkaddr;\t/* new block address to be written */\n \tblock_t old_blkaddr;\t/* old block address before Cow */\n-\tunion {\n-\t\tstruct page *page;\t/* page to be written */\n-\t\tstruct folio *folio;\n-\t};\n+\tstruct folio *folio;\t/* folio to be written */\n \tstruct page *encrypted_page;\t/* encrypted page */\n \tstruct page *compressed_page;\t/* compressed page */\n \tstruct list_head list;\t\t/* serialize IOs */\n@@ -1613,27 +1610,27 @@ static inline void f2fs_set_bit(unsigned int nr, char *addr);\n static inline void f2fs_clear_bit(unsigned int nr, char *addr);\n \n /*\n- * Layout of f2fs page.private:\n+ * Layout of f2fs folio-\u003eprivate:\n *\n * Layout A: lowest bit should be 1\n * | bit0 = 1 | bit1 | bit2 | ... | bit MAX | private data .... |\n- * bit 0\tPAGE_PRIVATE_NOT_POINTER\n- * bit 1\tPAGE_PRIVATE_ONGOING_MIGRATION\n- * bit 2\tPAGE_PRIVATE_INLINE_INODE\n- * bit 3\tPAGE_PRIVATE_REF_RESOURCE\n- * bit 4\tPAGE_PRIVATE_ATOMIC_WRITE\n+ * bit 0\tF2FS_FOLIO_PRIVATE_NOT_POINTER\n+ * bit 1\tF2FS_FOLIO_PRIVATE_ONGOING_MIGRATION\n+ * bit 2\tF2FS_FOLIO_PRIVATE_INLINE_INODE\n+ * bit 3\tF2FS_FOLIO_PRIVATE_REF_RESOURCE\n+ * bit 4\tF2FS_FOLIO_PRIVATE_ATOMIC_WRITE\n * bit 5-\tf2fs private data\n *\n * Layout B: lowest bit should be 0\n- * page.private is a wrapped pointer.\n+ * folio-\u003eprivate is a wrapped pointer.\n */\n enum {\n-\tPAGE_PRIVATE_NOT_POINTER,\t\t/* private contains non-pointer data */\n-\tPAGE_PRIVATE_ONGOING_MIGRATION,\t\t/* data page which is on-going migrating */\n-\tPAGE_PRIVATE_INLINE_INODE,\t\t/* inode page contains inline data */\n-\tPAGE_PRIVATE_REF_RESOURCE,\t\t/* dirty page has referenced resources */\n-\tPAGE_PRIVATE_ATOMIC_WRITE,\t\t/* data page from atomic write path */\n-\tPAGE_PRIVATE_MAX\n+\tF2FS_FOLIO_PRIVATE_NOT_POINTER,\t\t/* private contains non-pointer data */\n+\tF2FS_FOLIO_PRIVATE_ONGOING_MIGRATION,\t\t/* data page which is on-going migrating */\n+\tF2FS_FOLIO_PRIVATE_INLINE_INODE,\t\t/* inode page contains inline data */\n+\tF2FS_FOLIO_PRIVATE_REF_RESOURCE,\t\t/* dirty page has referenced resources */\n+\tF2FS_FOLIO_PRIVATE_ATOMIC_WRITE,\t\t/* data page from atomic write path */\n+\tF2FS_FOLIO_PRIVATE_MAX\n };\n \n /* For compression */\n@@ -2681,86 +2678,68 @@ static inline int inc_valid_block_count(struct f2fs_sb_info *sbi,\n \treturn -ENOSPC;\n }\n \n-#define PAGE_PRIVATE_GET_FUNC(name, flagname) \\\n+#define F2FS_FOLIO_PRIVATE_GET_FUNC(name, flagname) \\\n static inline bool folio_test_f2fs_##name(const struct folio *folio)\t\\\n {\t\t\t\t\t\t\t\t\t\\\n \tunsigned long priv = (unsigned long)folio-\u003eprivate;\t\t\\\n-\tunsigned long v = (1UL \u003c\u003c PAGE_PRIVATE_NOT_POINTER) |\t\t\\\n-\t\t\t (1UL \u003c\u003c PAGE_PRIVATE_##flagname);\t\t\\\n+\tunsigned long v = (1UL \u003c\u003c F2FS_FOLIO_PRIVATE_NOT_POINTER) |\t\\\n+\t\t\t (1UL \u003c\u003c F2FS_FOLIO_PRIVATE_##flagname);\t\\\n \treturn (priv \u0026 v) == v;\t\t\t\t\t\t\\\n-}\t\t\t\t\t\t\t\t\t\\\n-static inline bool page_private_##name(struct page *page) \\\n-{ \\\n-\treturn PagePrivate(page) \u0026\u0026 \\\n-\t\ttest_bit(PAGE_PRIVATE_NOT_POINTER, \u0026page_private(page)) \u0026\u0026 \\\n-\t\ttest_bit(PAGE_PRIVATE_##flagname, \u0026page_private(page)); \\\n }\n \n-#define PAGE_PRIVATE_SET_FUNC(name, flagname) \\\n+#define F2FS_FOLIO_PRIVATE_SET_FUNC(name, flagname) \\\n static inline void folio_set_f2fs_##name(struct folio *folio)\t\t\\\n {\t\t\t\t\t\t\t\t\t\\\n-\tunsigned long v = (1UL \u003c\u003c PAGE_PRIVATE_NOT_POINTER) |\t\t\\\n-\t\t\t (1UL \u003c\u003c PAGE_PRIVATE_##flagname);\t\t\\\n+\tunsigned long v = (1UL \u003c\u003c F2FS_FOLIO_PRIVATE_NOT_POINTER) |\t\\\n+\t\t\t (1UL \u003c\u003c F2FS_FOLIO_PRIVATE_##flagname);\t\\\n \tif (!folio-\u003eprivate)\t\t\t\t\t\t\\\n \t\tfolio_attach_private(folio, (void *)v);\t\t\t\\\n \telse {\t\t\t\t\t\t\t\t\\\n \t\tv |= (unsigned long)folio-\u003eprivate;\t\t\t\\\n \t\tfolio-\u003eprivate = (void *)v;\t\t\t\t\\\n \t}\t\t\t\t\t\t\t\t\\\n-}\t\t\t\t\t\t\t\t\t\\\n-static inline void set_page_private_##name(struct page *page) \\\n-{ \\\n-\tif (!PagePrivate(page)) \\\n-\t\tattach_page_private(page, (void *)0); \\\n-\tset_bit(PAGE_PRIVATE_NOT_POINTER, \u0026page_private(page)); \\\n-\tset_bit(PAGE_PRIVATE_##flagname, \u0026page_private(page)); \\\n }\n \n-#define PAGE_PRIVATE_CLEAR_FUNC(name, flagname) \\\n+#define F2FS_FOLIO_PRIVATE_CLEAR_FUNC(name, flagname) \\\n static inline void folio_clear_f2fs_##name(struct folio *folio)\t\t\\\n {\t\t\t\t\t\t\t\t\t\\\n \tunsigned long v = (unsigned long)folio-\u003eprivate;\t\t\\\n \t\t\t\t\t\t\t\t\t\\\n-\tv \u0026= ~(1UL \u003c\u003c PAGE_PRIVATE_##flagname);\t\t\t\t\\\n-\tif (v == (1UL \u003c\u003c PAGE_PRIVATE_NOT_POINTER))\t\t\t\\\n+\tv \u0026= ~(1UL \u003c\u003c F2FS_FOLIO_PRIVATE_##flagname);\t\t\t\\\n+\tif (v == (1UL \u003c\u003c F2FS_FOLIO_PRIVATE_NOT_POINTER))\t\t\\\n \t\tfolio_detach_private(folio);\t\t\t\t\\\n \telse\t\t\t\t\t\t\t\t\\\n \t\tfolio-\u003eprivate = (void *)v;\t\t\t\t\\\n-}\t\t\t\t\t\t\t\t\t\\\n-static inline void clear_page_private_##name(struct page *page) \\\n-{ \\\n-\tclear_bit(PAGE_PRIVATE_##flagname, \u0026page_private(page)); \\\n-\tif (page_private(page) == BIT(PAGE_PRIVATE_NOT_POINTER)) \\\n-\t\tdetach_page_private(page); \\\n }\n \n-PAGE_PRIVATE_GET_FUNC(nonpointer, NOT_POINTER);\n-PAGE_PRIVATE_GET_FUNC(inline, INLINE_INODE);\n-PAGE_PRIVATE_GET_FUNC(gcing, ONGOING_MIGRATION);\n-PAGE_PRIVATE_GET_FUNC(atomic, ATOMIC_WRITE);\n+F2FS_FOLIO_PRIVATE_GET_FUNC(nonpointer, NOT_POINTER);\n+F2FS_FOLIO_PRIVATE_GET_FUNC(inline, INLINE_INODE);\n+F2FS_FOLIO_PRIVATE_GET_FUNC(gcing, ONGOING_MIGRATION);\n+F2FS_FOLIO_PRIVATE_GET_FUNC(atomic, ATOMIC_WRITE);\n \n-PAGE_PRIVATE_SET_FUNC(reference, REF_RESOURCE);\n-PAGE_PRIVATE_SET_FUNC(inline, INLINE_INODE);\n-PAGE_PRIVATE_SET_FUNC(gcing, ONGOING_MIGRATION);\n-PAGE_PRIVATE_SET_FUNC(atomic, ATOMIC_WRITE);\n+F2FS_FOLIO_PRIVATE_SET_FUNC(reference, REF_RESOURCE);\n+F2FS_FOLIO_PRIVATE_SET_FUNC(inline, INLINE_INODE);\n+F2FS_FOLIO_PRIVATE_SET_FUNC(gcing, ONGOING_MIGRATION);\n+F2FS_FOLIO_PRIVATE_SET_FUNC(atomic, ATOMIC_WRITE);\n \n-PAGE_PRIVATE_CLEAR_FUNC(reference, REF_RESOURCE);\n-PAGE_PRIVATE_CLEAR_FUNC(inline, INLINE_INODE);\n-PAGE_PRIVATE_CLEAR_FUNC(gcing, ONGOING_MIGRATION);\n-PAGE_PRIVATE_CLEAR_FUNC(atomic, ATOMIC_WRITE);\n+F2FS_FOLIO_PRIVATE_CLEAR_FUNC(reference, REF_RESOURCE);\n+F2FS_FOLIO_PRIVATE_CLEAR_FUNC(inline, INLINE_INODE);\n+F2FS_FOLIO_PRIVATE_CLEAR_FUNC(gcing, ONGOING_MIGRATION);\n+F2FS_FOLIO_PRIVATE_CLEAR_FUNC(atomic, ATOMIC_WRITE);\n \n static inline unsigned long folio_get_f2fs_data(struct folio *folio)\n {\n \tunsigned long data = (unsigned long)folio-\u003eprivate;\n \n-\tif (!test_bit(PAGE_PRIVATE_NOT_POINTER, \u0026data))\n+\tif (!test_bit(F2FS_FOLIO_PRIVATE_NOT_POINTER, \u0026data))\n \t\treturn 0;\n-\treturn data \u003e\u003e PAGE_PRIVATE_MAX;\n+\treturn data \u003e\u003e F2FS_FOLIO_PRIVATE_MAX;\n }\n \n static inline void folio_set_f2fs_data(struct folio *folio, unsigned long data)\n {\n-\tdata = (1UL \u003c\u003c PAGE_PRIVATE_NOT_POINTER) | (data \u003c\u003c PAGE_PRIVATE_MAX);\n+\tdata = (1UL \u003c\u003c F2FS_FOLIO_PRIVATE_NOT_POINTER) |\n+\t (data \u003c\u003c F2FS_FOLIO_PRIVATE_MAX);\n \n \tif (!folio_test_private(folio))\n \t\tfolio_attach_private(folio, (void *)data);\ndiff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c\nindex 63b712d3d599e..8c156e1fd37d0 100644\n--- a/fs/f2fs/segment.c\n+++ b/fs/f2fs/segment.c\n@@ -3803,7 +3803,7 @@ static int __get_segment_type_6(struct f2fs_io_info *fio)\n \t\tif (is_inode_flag_set(inode, FI_ALIGNED_WRITE))\n \t\t\treturn CURSEG_COLD_DATA_PINNED;\n \n-\t\tif (page_private_gcing(fio-\u003epage)) {\n+\t\tif (folio_test_f2fs_gcing(fio-\u003efolio)) {\n \t\t\tif (fio-\u003esbi-\u003eam.atgc_enabled \u0026\u0026\n \t\t\t\t(fio-\u003eio_type == FS_DATA_IO) \u0026\u0026\n \t\t\t\t(fio-\u003esbi-\u003egc_mode != GC_URGENT_HIGH) \u0026\u0026\ndiff --git a/fs/nfs/file.c b/fs/nfs/file.c\nindex e1bdd10b35f10..38f830a6467c9 100644\n--- a/fs/nfs/file.c\n+++ b/fs/nfs/file.c\n@@ -484,7 +484,7 @@ static int nfs_write_end(const struct kiocb *iocb,\n * Partially or wholly invalidate a page\n * - Release the private state associated with a page if undergoing complete\n * page invalidation\n- * - Called if either PG_private or PG_fscache is set on the page\n+ * - Called if either folio-\u003eprivate or PG_fscache is set on the page\n * - Caller holds page lock\n */\n static void nfs_invalidate_folio(struct folio *folio, size_t offset,\n@@ -555,7 +555,7 @@ static void nfs_check_dirty_writeback(struct folio *folio,\n * Attempt to clear the private state associated with a page when an error\n * occurs that requires the cached contents of an inode to be written back or\n * destroyed\n- * - Called if either PG_private or fscache is set on the page\n+ * - Called if either page-\u003eprivate or fscache is set on the page\n * - Caller holds page lock\n * - Return 0 if successful, -error otherwise\n */\ndiff --git a/fs/nfs/write.c b/fs/nfs/write.c\nindex 623e7ef1f73d5..b6967b5286691 100644\n--- a/fs/nfs/write.c\n+++ b/fs/nfs/write.c\n@@ -717,7 +717,6 @@ static void nfs_inode_add_request(struct nfs_page *req)\n \tnfs_lock_request(req);\n \tspin_lock(\u0026mapping-\u003ei_private_lock);\n \tset_bit(PG_MAPPED, \u0026req-\u003ewb_flags);\n-\tfolio_set_private(folio);\n \tfolio-\u003eprivate = req;\n \tspin_unlock(\u0026mapping-\u003ei_private_lock);\n \tatomic_long_inc(\u0026nfsi-\u003enrequests);\n@@ -745,7 +744,6 @@ static void nfs_inode_remove_request(struct nfs_page *req)\n \n \t\t\tspin_lock(\u0026mapping-\u003ei_private_lock);\n \t\t\tfolio-\u003eprivate = NULL;\n-\t\t\tfolio_clear_private(folio);\n \t\t\tclear_bit(PG_MAPPED, \u0026req-\u003ewb_head-\u003ewb_flags);\n \t\t\tspin_unlock(\u0026mapping-\u003ei_private_lock);\n \ndiff --git a/fs/proc/page.c b/fs/proc/page.c\nindex 260772b20bd99..f90e1030825e9 100644\n--- a/fs/proc/page.c\n+++ b/fs/proc/page.c\n@@ -232,7 +232,6 @@ u64 stable_page_flags(const struct page *page)\n \n \tu |= kpf_copy_bit(k, KPF_RESERVED,\tPG_reserved);\n \tu |= kpf_copy_bit(k, KPF_OWNER_2,\tPG_owner_2);\n-\tu |= kpf_copy_bit(k, KPF_PRIVATE,\tPG_private);\n \tu |= kpf_copy_bit(k, KPF_PRIVATE_2,\tPG_private_2);\n \tu |= kpf_copy_bit(k, KPF_OWNER_PRIVATE,\tPG_owner_priv_1);\n \tu |= kpf_copy_bit(k, KPF_ARCH,\t\tPG_arch_1);\ndiff --git a/fs/ubifs/file.c b/fs/ubifs/file.c\nindex e73c28b12f97f..aa0298ce451ef 100644\n--- a/fs/ubifs/file.c\n+++ b/fs/ubifs/file.c\n@@ -12,14 +12,14 @@\n * This file implements VFS file and inode operations for regular files, device\n * nodes and symlinks as well as address space operations.\n *\n- * UBIFS uses 2 page flags: @PG_private and @PG_checked. @PG_private is set if\n+ * UBIFS uses folio-\u003eprivate and page flag @PG_checked. folio-\u003eprivate is set if\n * the page is dirty and is used for optimization purposes - dirty pages are\n- * not budgeted so the flag shows that 'ubifs_write_end()' should not release\n+ * not budgeted so it shows that 'ubifs_write_end()' should not release\n * the budget for this page. The @PG_checked flag is set if full budgeting is\n * required for the page e.g., when it corresponds to a file hole or it is\n * beyond the file size. The budgeting is done in 'ubifs_write_begin()', because\n * it is OK to fail in this function, and the budget is released in\n- * 'ubifs_write_end()'. So the @PG_private and @PG_checked flags carry\n+ * 'ubifs_write_end()'. So the folio-\u003eprivate and the @PG_checked flag carry\n * information about how the page was budgeted, to make it possible to release\n * the budget properly.\n *\n@@ -1509,7 +1509,7 @@ static vm_fault_t ubifs_vm_page_mkwrite(struct vm_fault *vmf)\n \t *\n \t * At the moment we do not know whether the folio is dirty or not, so we\n \t * assume that it is not and budget for a new folio. We could look at\n-\t * the @PG_private flag and figure this out, but we may race with write\n+\t * folio-\u003eprivate and figure this out, but we may race with write\n \t * back and the folio state may change by the time we lock it, so this\n \t * would need additional care. We do not bother with this at the\n \t * moment, although it might be good idea to do. Instead, we allocate\ndiff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h\nindex fd2c7115c0542..4b0b7188472b2 100644\n--- a/include/linux/buffer_head.h\n+++ b/include/linux/buffer_head.h\n@@ -175,12 +175,7 @@ static inline unsigned long bh_offset(const struct buffer_head *bh)\n \treturn (unsigned long)(bh)-\u003eb_data \u0026 (page_size(bh-\u003eb_page) - 1);\n }\n \n-/* If we *know* page-\u003eprivate refers to buffer_heads */\n-#define page_buffers(page)\t\t\t\t\t\\\n-\t({\t\t\t\t\t\t\t\\\n-\t\tBUG_ON(!PagePrivate(page));\t\t\t\\\n-\t\t((struct buffer_head *)page_private(page));\t\\\n-\t})\n+/* If we *know* folio-\u003eprivate refers to buffer_heads */\n #define folio_buffers(folio)\t\tfolio_get_private(folio)\n \n void buffer_check_dirty_writeback(struct folio *folio,\n@@ -197,7 +192,6 @@ void folio_set_bh(struct buffer_head *bh, struct folio *folio,\n \t\t unsigned long offset);\n struct buffer_head *folio_alloc_buffers(struct folio *folio, unsigned long size,\n \t\t\t\t\tgfp_t gfp);\n-struct buffer_head *alloc_page_buffers(struct page *page, unsigned long size);\n struct buffer_head *create_empty_buffers(struct folio *folio,\n \t\tunsigned long blocksize, unsigned long b_state);\n void end_buffer_read_sync(struct buffer_head *bh, int uptodate);\ndiff --git a/include/linux/kernel-page-flags.h b/include/linux/kernel-page-flags.h\nindex 196778a087c4d..fe5ab6e50bd70 100644\n--- a/include/linux/kernel-page-flags.h\n+++ b/include/linux/kernel-page-flags.h\n@@ -11,7 +11,6 @@\n #define KPF_RESERVED\t\t32\n #define KPF_MLOCKED\t\t33\n #define KPF_OWNER_2\t\t34\n-#define KPF_PRIVATE\t\t35\n #define KPF_PRIVATE_2\t\t36\n #define KPF_OWNER_PRIVATE\t37\n #define KPF_ARCH\t\t38\ndiff --git a/include/linux/mm.h b/include/linux/mm.h\nindex 66d384da4433b..262d1de5c1161 100644\n--- a/include/linux/mm.h\n+++ b/include/linux/mm.h\n@@ -2048,20 +2048,21 @@ vm_fault_t finish_fault(struct vm_fault *vmf);\n *\n * A pagecache page contains an opaque `private' member, which belongs to the\n * page's address_space. Usually, this is the address of a circular list of\n- * the page's disk buffers. PG_private must be set to tell the VM to call\n- * into the filesystem to release these pages.\n+ * the page's disk buffers. It tells the VM to call into the filesystem to\n+ * release these pages.\n *\n * A folio may belong to an inode's memory mapping. In this case,\n * folio-\u003emapping points to the inode, and folio-\u003eindex is the file\n * offset of the folio, in units of PAGE_SIZE.\n *\n- * If pagecache pages are not associated with an inode, they are said to be\n- * anonymous pages. These may become associated with the swapcache, and in that\n- * case PG_swapcache is set, and page-\u003eprivate is an offset into the swapcache.\n+ * If pagecache folios are not associated with an inode, they are said to be\n+ * anonymous folios. These may become associated with the swapcache, and in that\n+ * case PG_swapcache is set, and folio-\u003eprivate is an offset into the swapcache.\n *\n * In either case (swapcache or inode backed), the pagecache itself holds one\n- * reference to the page. Setting PG_private should also increment the\n- * refcount. The each user mapping also has a reference to the page.\n+ * reference to the folio. Attaching filesystem private data via\n+ * folio_attach_private() also increments the refcount. Each user mapping also\n+ * has a reference to the folio.\n *\n * The pagecache pages are stored in a per-mapping radix tree, which is\n * rooted at mapping-\u003ei_pages, and indexed by offset.\n@@ -3004,9 +3005,9 @@ static inline bool folio_maybe_mapped_shared(struct folio *folio)\n * @folio: the folio\n *\n * Calculate the expected folio refcount, taking references from the pagecache,\n- * swapcache, PG_private and page table mappings into account. Useful in\n- * combination with folio_ref_count() to detect unexpected references (e.g.,\n- * GUP or other temporary references).\n+ * swapcache, private data (folio-\u003eprivate != NULL) and page table mappings into\n+ * account. Useful in combination with folio_ref_count() to detect unexpected\n+ * references (e.g., GUP or other temporary references).\n *\n * Does currently not consider references from the LRU cache. If the folio\n * was isolated from the LRU (which is the case during migration or split),\n@@ -3044,10 +3045,15 @@ static inline int folio_expected_ref_count(const struct folio *folio)\n \tref_count += folio_test_swapcache(folio) \u003c\u003c order;\n \n \tif (!folio_test_anon(folio)) {\n-\t\t/* One reference per page from the pagecache. */\n-\t\tref_count += !!folio-\u003emapping \u003c\u003c order;\n-\t\t/* One reference from PG_private. */\n-\t\tref_count += folio_test_private(folio);\n+\t\t/*\n+\t\t * One reference per page from the pagecache.\n+\t\t * Use data_race() since folio might not be locked.\n+\t\t */\n+\t\tref_count += !!data_race(folio-\u003emapping) \u003c\u003c order;\n+\t\t/*\n+\t\t * One reference from filesystem private data.\n+\t\t */\n+\t\tref_count += folio_has_attached_private(folio);\n \t}\n \n \t/* One reference per page table mapping. */\ndiff --git a/include/linux/mm_types.h b/include/linux/mm_types.h\nindex 5413bd10fff2c..9d6c945ba4104 100644\n--- a/include/linux/mm_types.h\n+++ b/include/linux/mm_types.h\n@@ -108,7 +108,7 @@ struct page {\n \t\t\t};\n \t\t\t/**\n \t\t\t * @private: Mapping-private opaque data.\n-\t\t\t * Usually used for buffer_heads if PagePrivate.\n+\t\t\t * Usually used for buffer_heads.\n \t\t\t * Used for swp_entry_t if swapcache flag set.\n \t\t\t * Indicates order in the buddy system if PageBuddy\n \t\t\t * or on pcp_llist.\n@@ -675,7 +675,7 @@ static inline void ptdesc_pmd_pts_init(struct ptdesc *ptdesc)\n #define STRUCT_PAGE_MAX_SHIFT\t(order_base_2(sizeof(struct page)))\n \n /*\n- * page_private can be used on tail pages. However, PagePrivate is only\n+ * page_private can be used on tail pages. However, it is only\n * checked by the VM on the head page. So page_private on the tail pages\n * should be used for data that's ancillary to the head page (eg attaching\n * buffer heads to tail pages after attaching buffer heads to the head page)\ndiff --git a/include/linux/page-flags.h b/include/linux/page-flags.h\nindex 7080a6a1a79e7..b0ddc652e76cc 100644\n--- a/include/linux/page-flags.h\n+++ b/include/linux/page-flags.h\n@@ -44,10 +44,6 @@\n * Consequently, PG_reserved for a page mapped into user space can indicate\n * the zero page, the vDSO, MMIO pages or device memory.\n *\n- * The PG_private bitflag is set on pagecache pages if they contain filesystem\n- * specific data (which is normally at page-\u003eprivate). It can be used by\n- * private allocations for its own usage.\n- *\n * During initiation of disk I/O, PG_locked is set. This bit is set before I/O\n * and cleared when writeback _starts_ or when read _completes_. PG_writeback\n * is set before writeback starts and cleared when it finishes.\n@@ -105,7 +101,7 @@ enum pageflags {\n \tPG_owner_2,\t\t/* Owner use. If pagecache, fs may use */\n \tPG_arch_1,\n \tPG_reserved,\n-\tPG_private,\t\t/* If pagecache, has fs-private data */\n+\tPG_folio,\t\t/* Do not use: reserved for folio identification */\n \tPG_private_2,\t\t/* If pagecache, has fs aux data */\n \tPG_reclaim,\t\t/* To be reclaimed asap */\n \tPG_swapbacked,\t\t/* Page is backed by RAM/swap */\n@@ -575,9 +571,19 @@ FOLIO_FLAG(swapbacked, FOLIO_HEAD_PAGE)\n /*\n * Private page markings that may be used by the filesystem that owns the page\n * for its own purposes.\n- * - PG_private and PG_private_2 cause release_folio() and co to be invoked\n+ * - folio-\u003eprivate and PG_private_2 cause release_folio() and co to be invoked\n */\n-PAGEFLAG(Private, private, PF_ANY)\n+\n+static __always_inline bool folio_test_private(const struct folio *folio)\n+{\n+\t/*\n+\t * data_race() is added for readers without holding the folio lock.\n+\t * Only the NULL/non-NULL answer is used and both are valid while\n+\t * private is being attached or detached, so the race is benign.\n+\t */\n+\treturn data_race(folio-\u003eprivate);\n+}\n+\n FOLIO_FLAG(private_2, FOLIO_HEAD_PAGE)\n \n /* owner_2 can be set on tail pages for anon memory */\n@@ -1169,7 +1175,7 @@ static __always_inline void __ClearPageAnonExclusive(struct page *page)\n */\n #define PAGE_FLAGS_CHECK_AT_FREE\t\t\t\t\\\n \t(1UL \u003c\u003c PG_lru\t\t| 1UL \u003c\u003c PG_locked\t|\t\\\n-\t 1UL \u003c\u003c PG_private\t| 1UL \u003c\u003c PG_private_2\t|\t\\\n+\t 1UL \u003c\u003c PG_private_2\t|\t\t\t\t\\\n \t 1UL \u003c\u003c PG_writeback\t| 1UL \u003c\u003c PG_reserved\t|\t\\\n \t 1UL \u003c\u003c PG_active \t|\t\t\t\t\\\n \t 1UL \u003c\u003c PG_unevictable\t| __PG_MLOCKED | LRU_GEN_MASK)\n@@ -1193,8 +1199,31 @@ static __always_inline void __ClearPageAnonExclusive(struct page *page)\n \t(0xffUL /* order */\t\t| 1UL \u003c\u003c PG_has_hwpoisoned |\t\\\n \t 1UL \u003c\u003c PG_large_rmappable\t| 1UL \u003c\u003c PG_partially_mapped)\n \n-#define PAGE_FLAGS_PRIVATE\t\t\t\t\\\n-\t(1UL \u003c\u003c PG_private | 1UL \u003c\u003c PG_private_2)\n+/**\n+ * folio_has_attached_private - check if the folio has private data attached\n+ * @folio: The folio to check.\n+ *\n+ * Use this in code that may encounter swapcache or hugetlb folios but only\n+ * wants to detect attached private data.\n+ *\n+ * Return: true if the folio has private data attached.\n+ */\n+static inline bool folio_has_attached_private(const struct folio *folio)\n+{\n+\t/*\n+\t * Swapcache stores swp_entry_t in folio-\u003eswap, a union with\n+\t * folio-\u003eprivate, and hugetlb stores its own flags in folio-\u003eprivate;\n+\t * both are excluded.\n+\t *\n+\t * NOTE: For swapcache, folio-\u003eswap.val PG_swapcache are not set as\n+\t * a whole, so folio_test_swapcache() is not reliable to exclude\n+\t * swapcache. Use folio_test_swapbacked() instead, since it remains set\n+\t * when a folio is added to/removed from swapcache.\n+\t */\n+\n+\treturn folio_test_private(folio) \u0026\u0026 !folio_test_swapbacked(folio) \u0026\u0026\n+\t !folio_test_hugetlb(folio);\n+}\n /**\n * folio_has_private - Determine if folio has private stuff\n * @folio: The folio to be checked\n@@ -1204,7 +1233,7 @@ static __always_inline void __ClearPageAnonExclusive(struct page *page)\n */\n static inline int folio_has_private(const struct folio *folio)\n {\n-\treturn !!(folio-\u003eflags.f \u0026 PAGE_FLAGS_PRIVATE);\n+\treturn folio_has_attached_private(folio) || folio_test_private_2(folio);\n }\n \n #undef PF_ANY\ndiff --git a/include/linux/pagemap.h b/include/linux/pagemap.h\nindex 939f3a5e973f6..bcbb0afe1a681 100644\n--- a/include/linux/pagemap.h\n+++ b/include/linux/pagemap.h\n@@ -594,7 +594,6 @@ static inline void folio_attach_private(struct folio *folio, void *data)\n {\n \tfolio_get(folio);\n \tfolio-\u003eprivate = data;\n-\tfolio_set_private(folio);\n }\n \n /**\n@@ -629,9 +628,8 @@ static inline void *folio_detach_private(struct folio *folio)\n {\n \tvoid *data = folio_get_private(folio);\n \n-\tif (!folio_test_private(folio))\n+\tif (!data)\n \t\treturn NULL;\n-\tfolio_clear_private(folio);\n \tfolio-\u003eprivate = NULL;\n \tfolio_put(folio);\n \n@@ -1415,6 +1413,7 @@ struct readahead_control {\n \tbool dropbehind;\n \tbool _workingset;\n \tunsigned long _pflags;\n+\tbool _forward;\n };\n \n #define DEFINE_READAHEAD(ractl, f, r, m, i)\t\t\t\t\\\n@@ -1479,18 +1478,29 @@ void page_cache_async_readahead(struct address_space *mapping,\n \tpage_cache_async_ra(\u0026ractl, folio, req_count);\n }\n \n+/*\n+ * Adjust readahead_control to ensure next folio comes from\n+ * [_index, _index + _nr_pages) afterwards and reset _batch_count.\n+ */\n+static inline void __readahead_advance(struct readahead_control *rac)\n+{\n+\tif (rac-\u003e_forward)\n+\t\trac-\u003e_index += rac-\u003e_batch_count;\n+\n+\trac-\u003e_nr_pages -= rac-\u003e_batch_count;\n+\trac-\u003e_batch_count = 0;\n+}\n+\n static inline struct folio *__readahead_folio(struct readahead_control *ractl)\n {\n \tstruct folio *folio;\n \n \tBUG_ON(ractl-\u003e_batch_count \u003e ractl-\u003e_nr_pages);\n-\tractl-\u003e_nr_pages -= ractl-\u003e_batch_count;\n-\tractl-\u003e_index += ractl-\u003e_batch_count;\n+\t__readahead_advance(ractl);\n+\tractl-\u003e_forward = true;\n \n-\tif (!ractl-\u003e_nr_pages) {\n-\t\tractl-\u003e_batch_count = 0;\n+\tif (!ractl-\u003e_nr_pages)\n \t\treturn NULL;\n-\t}\n \n \tfolio = xa_load(\u0026ractl-\u003emapping-\u003ei_pages, ractl-\u003e_index);\n \tVM_BUG_ON_FOLIO(!folio_test_locked(folio), folio);\n@@ -1516,6 +1526,39 @@ static inline struct folio *readahead_folio(struct readahead_control *ractl)\n \treturn folio;\n }\n \n+/**\n+ * readahead_folio_last - Get the next folio to read, from the tail.\n+ * @ractl: The current readahead request.\n+ *\n+ * Like readahead_folio(), but walks the range back-to-front. The folio is\n+ * returned locked with its refcount dropped; the caller unlocks it once I/O\n+ * completes. Compound folios are returned once, at their head index.\n+ *\n+ * Context: The folio is locked.\n+ * Return: A pointer to the next folio, or %NULL when done.\n+ */\n+static inline struct folio *readahead_folio_last(struct readahead_control *ractl)\n+{\n+\tstruct folio *folio;\n+\n+\t/* Drop the previously returned batch from the remaining range. */\n+\t__readahead_advance(ractl);\n+\tractl-\u003e_forward = false;\n+\n+\tif (!ractl-\u003e_nr_pages)\n+\t\treturn NULL;\n+\n+\t/* xa_load() follows sibling entries, so a tail index returns the head */\n+\tfolio = xa_load(\u0026ractl-\u003emapping-\u003ei_pages,\n+\t\t\tractl-\u003e_index + ractl-\u003e_nr_pages - 1);\n+\tVM_WARN_ON_ONCE_FOLIO(!folio_test_locked(folio), folio);\n+\n+\tractl-\u003e_batch_count = folio_nr_pages(folio);\n+\n+\tfolio_put(folio);\n+\treturn folio;\n+}\n+\n static inline unsigned int __readahead_batch(struct readahead_control *rac,\n \t\tstruct page **array, unsigned int array_sz)\n {\n@@ -1524,9 +1567,8 @@ static inline unsigned int __readahead_batch(struct readahead_control *rac,\n \tstruct folio *folio;\n \n \tBUG_ON(rac-\u003e_batch_count \u003e rac-\u003e_nr_pages);\n-\trac-\u003e_nr_pages -= rac-\u003e_batch_count;\n-\trac-\u003e_index += rac-\u003e_batch_count;\n-\trac-\u003e_batch_count = 0;\n+\t__readahead_advance(rac);\n+\trac-\u003e_forward = true;\n \n \txas_set(\u0026xas, rac-\u003e_index);\n \trcu_read_lock();\ndiff --git a/include/trace/events/mmflags.h b/include/trace/events/mmflags.h\nindex ef9aa388b84f7..3c153b3ad8450 100644\n--- a/include/trace/events/mmflags.h\n+++ b/include/trace/events/mmflags.h\n@@ -144,7 +144,7 @@ TRACE_DEFINE_ENUM(___GFP_LAST_BIT);\n \tDEF_PAGEFLAG_NAME(owner_2),\t\t\t\t\t\\\n \tDEF_PAGEFLAG_NAME(arch_1),\t\t\t\t\t\\\n \tDEF_PAGEFLAG_NAME(reserved),\t\t\t\t\t\\\n-\tDEF_PAGEFLAG_NAME(private),\t\t\t\t\t\\\n+\tDEF_PAGEFLAG_NAME(folio),\t\t\t\t\t\\\n \tDEF_PAGEFLAG_NAME(private_2),\t\t\t\t\t\\\n \tDEF_PAGEFLAG_NAME(writeback),\t\t\t\t\t\\\n \tDEF_PAGEFLAG_NAME(head),\t\t\t\t\t\\\ndiff --git a/include/trace/events/pagemap.h b/include/trace/events/pagemap.h\nindex 36c3a90f0acca..5d47b774633a4 100644\n--- a/include/trace/events/pagemap.h\n+++ b/include/trace/events/pagemap.h\n@@ -22,7 +22,7 @@\n \t(folio_test_swapcache(folio)\t? PAGEMAP_SWAPCACHE : 0) | \\\n \t(folio_test_swapbacked(folio)\t? PAGEMAP_SWAPBACKED : 0) | \\\n \t(folio_test_mappedtodisk(folio)\t? PAGEMAP_MAPPEDDISK : 0) | \\\n-\t(folio_test_private(folio)\t? PAGEMAP_BUFFERS : 0) \\\n+\t(folio_has_attached_private(folio)\t? PAGEMAP_BUFFERS : 0) \\\n \t)\n \n TRACE_EVENT(mm_lru_insertion,\ndiff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c\nindex 9fe92161715e0..061b5cb222266 100644\n--- a/kernel/events/ring_buffer.c\n+++ b/kernel/events/ring_buffer.c\n@@ -630,11 +630,10 @@ static struct page *rb_alloc_aux_page(int node, int order)\n \t\t/*\n \t\t * Communicate the allocation size to the driver:\n \t\t * if we managed to secure a high-order allocation,\n-\t\t * set its first page's private to this order;\n-\t\t * !PagePrivate(page) means it's just a normal page.\n+\t\t * set its first page's private to this order, otherwise page's\n+\t\t * private remains zero.\n \t\t */\n \t\tsplit_page(page, order);\n-\t\tSetPagePrivate(page);\n \t\tset_page_private(page, order);\n \t}\n \n@@ -645,7 +644,7 @@ static void rb_free_aux_page(struct perf_buffer *rb, int idx)\n {\n \tstruct page *page = virt_to_page(rb-\u003eaux_pages[idx]);\n \n-\tClearPagePrivate(page);\n+\tset_page_private(page, 0);\n \t__free_page(page);\n }\n \ndiff --git a/kernel/vmcore_info.c b/kernel/vmcore_info.c\nindex 8614430ca212a..5a417f8a922ab 100644\n--- a/kernel/vmcore_info.c\n+++ b/kernel/vmcore_info.c\n@@ -216,7 +216,6 @@ static int __init crash_save_vmcoreinfo_init(void)\n \tVMCOREINFO_LENGTH(free_area.free_list, MIGRATE_TYPES);\n \tVMCOREINFO_NUMBER(NR_FREE_PAGES);\n \tVMCOREINFO_NUMBER(PG_lru);\n-\tVMCOREINFO_NUMBER(PG_private);\n \tVMCOREINFO_NUMBER(PG_swapcache);\n \tVMCOREINFO_NUMBER(PG_swapbacked);\n #define PAGE_SLAB_MAPCOUNT_VALUE\t(PGTY_slab \u003c\u003c 24)\ndiff --git a/mm/huge_memory.c b/mm/huge_memory.c\nindex 30b7c63b0e359..8aa2daba37391 100644\n--- a/mm/huge_memory.c\n+++ b/mm/huge_memory.c\n@@ -4846,7 +4846,7 @@ static int split_huge_pages_pid(int pid, unsigned long vaddr_start,\n \t\t * will try to drop it before split and then check if the folio\n \t\t * can be split or not. So skip the check here.\n \t\t */\n-\t\tif (!folio_test_private(folio) \u0026\u0026\n+\t\tif (!folio_has_attached_private(folio) \u0026\u0026\n \t\t folio_expected_ref_count(folio) != folio_ref_count(folio))\n \t\t\tgoto next;\n \ndiff --git a/mm/hugetlb.c b/mm/hugetlb.c\nindex 2003439ea13c6..7b27c3c5c3e58 100644\n--- a/mm/hugetlb.c\n+++ b/mm/hugetlb.c\n@@ -1446,11 +1446,8 @@ void add_hugetlb_folio(struct hstate *h, struct folio *folio,\n \t}\n \n \t__folio_set_hugetlb(folio);\n-\tfolio_change_private(folio, NULL);\n-\t/*\n-\t * We have to set hugetlb_vmemmap_optimized again as above\n-\t * folio_change_private(folio, NULL) cleared it.\n-\t */\n+\t/* Clear all folio-\u003eprivate flags except hugetlb_vmemmap_optimized. */\n+\tfolio-\u003eprivate = NULL;\n \tfolio_set_hugetlb_vmemmap_optimized(folio);\n \n \tarch_clear_hugetlb_flags(folio);\ndiff --git a/mm/migrate.c b/mm/migrate.c\nindex a369d0c95c386..7e3a81f069744 100644\n--- a/mm/migrate.c\n+++ b/mm/migrate.c\n@@ -835,7 +835,6 @@ void folio_migrate_flags(struct folio *newfolio, struct folio *folio)\n \t */\n \tif (folio_test_swapcache(folio))\n \t\tfolio_clear_swapcache(folio);\n-\tfolio_clear_private(folio);\n \n \t/* page-\u003eprivate contains hugetlb specific flags */\n \tif (!folio_test_hugetlb(folio))\n@@ -1327,7 +1326,7 @@ static int migrate_folio_unmap(new_folio_t get_new_folio,\n \t * free the metadata, so the page can be freed.\n \t */\n \tif (!src-\u003emapping) {\n-\t\tif (folio_test_private(src)) {\n+\t\tif (folio_has_attached_private(src)) {\n \t\t\ttry_to_free_buffers(src);\n \t\t\tgoto out;\n \t\t}\ndiff --git a/mm/page-writeback.c b/mm/page-writeback.c\nindex eeab25d6ce364..499a35473e4f3 100644\n--- a/mm/page-writeback.c\n+++ b/mm/page-writeback.c\n@@ -2705,7 +2705,7 @@ bool filemap_dirty_folio(struct address_space *mapping, struct folio *folio)\n \tif (folio_test_set_dirty(folio))\n \t\treturn false;\n \n-\t__folio_mark_dirty(folio, mapping, !folio_test_private(folio));\n+\t__folio_mark_dirty(folio, mapping, !folio_has_attached_private(folio));\n \n \tif (mapping-\u003ehost) {\n \t\t/* !PageAnon \u0026\u0026 !swapper_space */\ndiff --git a/mm/vmscan.c b/mm/vmscan.c\nindex 80041e2b8049c..dd6261c862794 100644\n--- a/mm/vmscan.c\n+++ b/mm/vmscan.c\n@@ -1029,7 +1029,7 @@ static void folio_check_dirty_writeback(struct folio *folio,\n \t*writeback = folio_test_writeback(folio);\n \n \t/* Verify dirty/writeback state if the filesystem supports it */\n-\tif (!folio_test_private(folio))\n+\tif (!folio_has_attached_private(folio))\n \t\treturn;\n \n \tmapping = folio_mapping(folio);\ndiff --git a/mm/zpdesc.h b/mm/zpdesc.h\nindex b8258dc78548d..4fd81c2e80769 100644\n--- a/mm/zpdesc.h\n+++ b/mm/zpdesc.h\n@@ -26,8 +26,8 @@\n * with memcg_data.\n *\n * Page flags used:\n- * * PG_private identifies the first component page.\n * * PG_locked is used by page migration code.\n+ * The first component page has zpdesc-\u003ezspage-\u003efirst_zpdesc == zpdesc\n */\n struct zpdesc {\n \tunsigned long flags;\ndiff --git a/mm/zsmalloc.c b/mm/zsmalloc.c\nindex 11be37c431718..7ef80e0da6267 100644\n--- a/mm/zsmalloc.c\n+++ b/mm/zsmalloc.c\n@@ -290,11 +290,6 @@ struct zs_pool {\n \tatomic_t compaction_in_progress;\n };\n \n-static inline void zpdesc_set_first(struct zpdesc *zpdesc)\n-{\n-\tSetPagePrivate(zpdesc_page(zpdesc));\n-}\n-\n static inline void zpdesc_inc_zone_page_state(struct zpdesc *zpdesc)\n {\n \tinc_zone_page_state(zpdesc_page(zpdesc), NR_ZSPAGES);\n@@ -476,11 +471,6 @@ static void record_obj(unsigned long handle, unsigned long obj)\n \tWRITE_ONCE(*(unsigned long *)handle, obj);\n }\n \n-static inline bool __maybe_unused is_first_zpdesc(struct zpdesc *zpdesc)\n-{\n-\treturn PagePrivate(zpdesc_page(zpdesc));\n-}\n-\n /* Protected by class-\u003elock */\n static inline int get_zspage_inuse(struct zspage *zspage)\n {\n@@ -496,7 +486,8 @@ static struct zpdesc *get_first_zpdesc(struct zspage *zspage)\n {\n \tstruct zpdesc *first_zpdesc = zspage-\u003efirst_zpdesc;\n \n-\tVM_BUG_ON_PAGE(!is_first_zpdesc(first_zpdesc), zpdesc_page(first_zpdesc));\n+\t/* the first zpdesc must point back to this zspage */\n+\tVM_WARN_ON_ONCE_PAGE(first_zpdesc-\u003ezspage != zspage, zpdesc_page(first_zpdesc));\n \treturn first_zpdesc;\n }\n \n@@ -838,7 +829,8 @@ static inline bool obj_allocated(struct zpdesc *zpdesc, void *obj,\n \tstruct zspage *zspage = get_zspage(zpdesc);\n \n \tif (unlikely(ZsHugePage(zspage))) {\n-\t\tVM_BUG_ON_PAGE(!is_first_zpdesc(zpdesc), zpdesc_page(zpdesc));\n+\t\t/* only first zpdesc holds the handle */\n+\t\tVM_WARN_ON_ONCE_PAGE(zspage-\u003efirst_zpdesc != zpdesc, zpdesc_page(zpdesc));\n \t\thandle = zpdesc-\u003ehandle;\n \t} else\n \t\thandle = *(unsigned long *)obj;\n@@ -853,9 +845,6 @@ static inline bool obj_allocated(struct zpdesc *zpdesc, void *obj,\n \n static void reset_zpdesc(struct zpdesc *zpdesc)\n {\n-\tstruct page *page = zpdesc_page(zpdesc);\n-\n-\tClearPagePrivate(page);\n \tzpdesc-\u003ezspage = NULL;\n \tzpdesc-\u003enext = NULL;\n \t/* PageZsmalloc is sticky until the page is freed to the buddy. */\n@@ -1006,8 +995,8 @@ static void create_page_chain(struct size_class *class, struct zspage *zspage,\n \t * 1. all pages are linked together using zpdesc-\u003enext\n \t * 2. each sub-page point to zspage using zpdesc-\u003ezspage\n \t *\n-\t * we set PG_private to identify the first zpdesc (i.e. no other zpdesc\n-\t * has this flag set).\n+\t * The first zpdesc has its zspage-\u003efirst_zpdesc set to itself, no\n+\t * other zpdesc has this set.\n \t */\n \tfor (i = 0; i \u003c nr_zpdescs; i++) {\n \t\tzpdesc = zpdescs[i];\n@@ -1015,7 +1004,6 @@ static void create_page_chain(struct size_class *class, struct zspage *zspage,\n \t\tzpdesc-\u003enext = NULL;\n \t\tif (i == 0) {\n \t\t\tzspage-\u003efirst_zpdesc = zpdesc;\n-\t\t\tzpdesc_set_first(zpdesc);\n \t\t\tif (unlikely(class-\u003eobjs_per_zspage == 1 \u0026\u0026\n \t\t\t\t\tclass-\u003epages_per_zspage == 1))\n \t\t\t\tSetZsHugePage(zspage);\ndiff --git a/tools/mm/page-types.c b/tools/mm/page-types.c\nindex 7fc5a8be5997f..47e4781c5fc38 100644\n--- a/tools/mm/page-types.c\n+++ b/tools/mm/page-types.c\n@@ -73,7 +73,6 @@\n #define KPF_RESERVED\t\t32\n #define KPF_MLOCKED\t\t33\n #define KPF_OWNER_2\t\t34\n-#define KPF_PRIVATE\t\t35\n #define KPF_PRIVATE_2\t\t36\n #define KPF_OWNER_PRIVATE\t37\n #define KPF_ARCH\t\t38\n@@ -131,7 +130,6 @@ static const char * const page_flag_names[] = {\n \t[KPF_RESERVED]\t\t= \"r:reserved\",\n \t[KPF_MLOCKED]\t\t= \"m:mlocked\",\n \t[KPF_OWNER_2]\t\t= \"d:owner_2\",\n-\t[KPF_PRIVATE]\t\t= \"P:private\",\n \t[KPF_PRIVATE_2]\t\t= \"p:private_2\",\n \t[KPF_OWNER_PRIVATE]\t= \"O:owner_private\",\n \t[KPF_ARCH]\t\t= \"h:arch\",\n"
} |
| 2/1 | 2026/09/22 23:11 | agent | patch-evaluator |
3mModel:core Args: null Results: {
"EnableConfigs": [
"EROFS_FS",
"EROFS_FS_ZIP",
"F2FS_FS",
"F2FS_FS_COMPRESSION",
"ZRAM",
"ZSMALLOC",
"COMPACTION",
"MD",
"BLK_DEV_MD",
"MD_BITMAP",
"MD_BITMAP_FILE",
"TRANSPARENT_HUGEPAGE",
"HUGETLB_PAGE",
"MIGRATION"
],
"FocusSymbols": [
"erofs_onlinefolio_init",
"erofs_onlinefolio_end",
"z_erofs_readahead",
"f2fs_compress_write_end_io",
"f2fs_write_compressed_pages",
"zs_page_migrate",
"split_huge_pages_pid",
"folio_migrate_flags",
"migrate_folio_unmap",
"add_hugetlb_folio"
],
"Reasoning": "The patch eliminates the PG_private page flag and switches private state management to folio-\u003eprivate and folio_has_attached_private across core memory management (THP splitting, hugetlb, folio migration, page writeback, vmscan, zsmalloc) and filesystems (EROFS, F2FS, md-bitmap, ceph, nfs). It adds readahead_folio_last() for reverse folio traversal, alters online folio state tracking and assertions in EROFS, restructures F2FS folio private bits, and modifies zspage assertions in zsmalloc. These extensive MM and filesystem modifications warrant fuzzing.",
"WorthFuzzing": true
}Instruction: You are an expert Linux kernel maintainer and security engineer.
Your job is to review a provided patch series and evaluate whether it warrants fuzzing with syzkaller.
IMPORTANT: The changes have ALREADY been applied and committed as the HEAD commit in
your workspace. Do NOT rely on internal assumptions. You must actively use your code access
tools to inspect the actual source code, callers, and surrounding context.
================================================================================
1. CORE TRIAGE PHILOSOPHY
================================================================================
The goal of patch fuzzing is to discover crashes, regressions, exposed latent bugs,
and newly triggered assertions introduced by the patch series.
- REACHABILITY IS THE PRIMARY GATE:
Fuzzing can only discover bugs in code that can actually execute in standard virtualized
environments (GCE or QEMU, utilizing software-emulated devices like USB gadgets, netdev, tun/tap).
If the modified code is structurally unreachable (see Section 2), it MUST NOT be fuzzed,
regardless of whether it adds assertions or complex logic.
- DO NOT BLINDLY TRUST "NO FUNCTIONAL CHANGE" (NFCI) OR "REFACTORING" CLAIMS:
Patch authors routinely label changes as "cleanups", "refactorings", or state
"No functional change intended". Do NOT take these claims at face value.
Code refactorings that rearrange logic, introduce helper functions, or alter state management
in core subsystems frequently introduce subtle semantic shifts or uncover latent kernel bugs.
If reachable executable code is modified or refactored, it MUST be fuzzed.
- NEW OR MODIFIED ASSERTIONS IN REACHABLE CODE MUST BE FUZZED:
When a patch introduces or modifies runtime checks or assertions (e.g., WARN_ON*, VM_WARN_ON*,
BUG_ON*, lockdep_assert*) in reachable code paths, it enforces new or stricter invariants.
Even if the author believes the invariant always holds, fuzzing is essential to verify whether
an unusual sequence of operations can violate it.
================================================================================
2. WHEN TO RETURN WorthFuzzing=false (NEGATIVE CRITERIA)
================================================================================
Return WorthFuzzing=false ONLY IF all modified code falls strictly into one or more of these categories:
- Non-kernel and non-executable changes:
* Modifications to Documentation/, comments, or spelling fixes.
* User-space directories, self-tests, samples, or scripts (e.g., tools/, samples/, scripts/, usr/)
that do not affect the compiled kernel image (vmlinux) or kernel modules.
* Purely decorative logging (e.g., message strings in pr_err, printk, dev_info) or tracepoints
that do not alter control flow or data structures.
* Build system or Kconfig changes that do not alter compiled C logic.
- Structurally unreachable hardware:
* Vendor-specific PCIe switches, SmartNICs, or GPU drivers (e.g., mlxsw, pds_core, qed,
ionic, amdgpu) requiring physical ASIC/PCIe cards not emulated in standard QEMU.
- Unreachable execution paths:
* Driver teardown callbacks (.remove, .shutdown, pci_unregister_driver) executed only during
physical PCI hot-unplug or manual sysfs driver unbinding.
* Code paths exclusive to architectures other than the target architecture.
================================================================================
3. WHEN TO RETURN WorthFuzzing=true (POSITIVE CRITERIA)
================================================================================
Return WorthFuzzing=true whenever the patch touches reachable executable code, including:
- Core Subsystems:
* Any logic modifications in memory management (mm/), synchronization/locking (kernel/locking/),
BPF, scheduler, core networking, VFS, or syscall handling.
- Refactorings and Code Cleanups:
* Any restructuring of reachable data structures, helper abstractions, or algorithm flows.
- Runtime Assertions and Defensive Checks:
* Any introduction or alteration of assertions (WARN_ON*, VM_WARN_ON*, BUG_ON*, etc.) in reachable paths.
- Reachable Drivers and Protocols:
* Drivers accessible via virtual buses (virtio, USB gadget, loopback, netlink, binder, sockets, etc.).
================================================================================
4. EXTRACTING FocusSymbols (PREVENTING DILUTION)
================================================================================
When WorthFuzzing=true, you must extract specific kernel functions into FocusSymbols to guide the fuzzer:
- AVOID UBIQUITOUS LIFECYCLE HOT-PATHS:
Do NOT list generic, ubiquitous functions called by almost every program in the corpus
(including, but not limited to: general memory allocators and deallocators, page fault
and trap handlers, or core synchronization primitives; this is not an exhaustive list).
Listing ubiquitous functions causes the fuzzer to classify thousands of unrelated tests as "focused",
which severely dilutes fuzzing effort away from the actual changes.
- TARGET SPECIFIC FEATURE LOGIC AND ENTRYPOINTS:
List functions that specifically implement the logic being added or altered, or direct API entrypoints
for the subsystem feature under review.
- HANDLING STATIC INLINE FUNCTIONS IN HEADERS (.h):
Compiler-inlined static functions (such as static inlines in mm/*.h or include/linux/*.h) lack
distinct symbol addresses in vmlinux and cannot be targeted directly by symbol coverage filters.
If the changes are primarily in static inline helpers, identify non-static, feature-specific caller
functions in .c files that exercise them (avoiding ubiquitous lifecycle wrappers).
================================================================================
5. IDENTIFYING EnableConfigs
================================================================================
Identify any specific CONFIG_ options required to properly compile and reach the modified code:
- Inspect Kconfig files and #ifdef guards; do not make assumptions.
- Check "depends on" lines in Kconfig to include any non-standard parent subsystem configs needed.
- Strip any 'CONFIG_' prefix (e.g., return "NET_IPV4" instead of "CONFIG_NET_IPV4").
Prefer calling several tools at the same time to save round-trips.
Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.
Prompt: Target architecture: amd64
For your convenience, here is the diff of the changes:
commit 95b7a2d0e4b277882309fe37eaff2a2dd99b8ba9
Author: syz-cluster <triage@syzkaller.com>
Date: Tue Sep 22 23:11:17 2026 +0000
syz-cluster: applied patch under review
diff --git a/Documentation/admin-guide/kdump/vmcoreinfo.rst b/Documentation/admin-guide/kdump/vmcoreinfo.rst
index 7663c610fe901..5f1df6d080508 100644
--- a/Documentation/admin-guide/kdump/vmcoreinfo.rst
+++ b/Documentation/admin-guide/kdump/vmcoreinfo.rst
@@ -325,7 +325,7 @@ NR_FREE_PAGES
On linux-2.6.21 or later, the number of free pages is in
vm_stat[NR_FREE_PAGES]. Used to get the number of free pages.
-PG_lru|PG_private|PG_swapcache|PG_swapbacked|PG_hwpoison|PG_head_mask
+PG_lru|PG_swapcache|PG_swapbacked|PG_hwpoison|PG_head_mask
--------------------------------------------------------------------------
Page attributes. These flags are used to filter various unnecessary for
diff --git a/Documentation/filesystems/vfs.rst b/Documentation/filesystems/vfs.rst
index d3a93eec3945f..dec7816303c6a 100644
--- a/Documentation/filesystems/vfs.rst
+++ b/Documentation/filesystems/vfs.rst
@@ -649,8 +649,8 @@ Writeback.
The first can be used independently to the others. The VM can try to
release clean pages in order to reuse them. To do this it can call
-->release_folio on clean folios with the private
-flag set. Clean pages without PagePrivate and with no external references
+->release_folio on clean folios with folio->private set. Clean pages
+without folio->private set and with no external references
will be released without notice being given to the address_space.
To achieve this functionality, pages need to be placed on an LRU with
@@ -674,7 +674,7 @@ filemap_fdatawait_range, to wait for all writeback to complete.
An address_space handler may attach extra information to a page,
typically using the 'private' field in the 'struct page'. If such
-information is attached, the PG_Private flag should be set. This will
+information is attached, non-NULL 'private' field will
cause various VM routines to make extra calls into the address_space
handler to deal with that data.
diff --git a/arch/x86/events/intel/bts.c b/arch/x86/events/intel/bts.c
index cbac54cb3a9ec..5849392cf26d5 100644
--- a/arch/x86/events/intel/bts.c
+++ b/arch/x86/events/intel/bts.c
@@ -66,9 +66,6 @@ static struct pmu bts_pmu;
static int buf_nr_pages(struct page *page)
{
- if (!PagePrivate(page))
- return 1;
-
return 1 << page_private(page);
}
diff --git a/arch/x86/events/intel/pt.c b/arch/x86/events/intel/pt.c
index 5754cd4055628..49349afee6119 100644
--- a/arch/x86/events/intel/pt.c
+++ b/arch/x86/events/intel/pt.c
@@ -781,8 +781,7 @@ static int topa_insert_pages(struct pt_buffer *buf, int cpu, gfp_t gfp)
struct page *p;
p = virt_to_page(buf->data_pages[buf->nr_pages]);
- if (PagePrivate(p))
- order = page_private(p);
+ order = page_private(p);
if (topa_table_full(topa)) {
topa = topa_alloc(cpu, gfp);
@@ -1296,8 +1295,7 @@ static int pt_buffer_try_single(struct pt_buffer *buf, int nr_pages)
if (!intel_pt_validate_hw_cap(PT_CAP_single_range_output))
goto out;
- if (PagePrivate(p))
- order = page_private(p);
+ order = page_private(p);
if (1 << order != nr_pages)
goto out;
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index b8325cb09a371..8adf6ddca3d60 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -516,7 +516,8 @@ static void end_bitmap_write(struct bio *bio)
static void write_file_page(struct bitmap *bitmap, struct page *page, int wait)
{
- struct buffer_head *bh = page_buffers(page);
+ struct folio *folio = page_folio(page);
+ struct buffer_head *bh = folio_buffers(folio);
while (bh && bh->b_blocknr) {
atomic_inc(&bitmap->pending_writes);
@@ -533,19 +534,15 @@ static void write_file_page(struct bitmap *bitmap, struct page *page, int wait)
static void free_buffers(struct page *page)
{
- struct buffer_head *bh;
-
- if (!PagePrivate(page))
- return;
+ struct folio *folio = page_folio(page);
+ struct buffer_head *bh = folio_detach_private(folio);
- bh = page_buffers(page);
while (bh) {
struct buffer_head *next = bh->b_this_page;
free_buffer_head(bh);
bh = next;
}
- detach_page_private(page);
- put_page(page);
+ folio_put(folio);
}
/* read a page from a file.
@@ -560,6 +557,7 @@ static int read_file_page(struct file *file, unsigned long index,
{
int ret = 0;
struct inode *inode = file_inode(file);
+ struct folio *folio = page_folio(page);
struct buffer_head *bh;
sector_t block, blk_cur;
unsigned long blocksize = i_blocksize(inode);
@@ -567,12 +565,12 @@ static int read_file_page(struct file *file, unsigned long index,
pr_debug("read bitmap file (%dB @ %llu)\n", (int)PAGE_SIZE,
(unsigned long long)index << PAGE_SHIFT);
- bh = alloc_page_buffers(page, blocksize);
+ bh = folio_alloc_buffers(folio, blocksize, GFP_NOFS | __GFP_ACCOUNT);
if (!bh) {
ret = -ENOMEM;
goto out;
}
- attach_page_private(page, bh);
+ folio_attach_private(folio, bh);
blk_cur = index << (PAGE_SHIFT - inode->i_blkbits);
while (bh) {
block = blk_cur;
diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
index 69922be28b54c..993f89f048e21 100644
--- a/drivers/xen/grant-table.c
+++ b/drivers/xen/grant-table.c
@@ -863,10 +863,10 @@ EXPORT_SYMBOL_GPL(gnttab_free_auto_xlat_frames);
int gnttab_pages_set_private(int nr_pages, struct page **pages)
{
+#if BITS_PER_LONG < 64
int i;
for (i = 0; i < nr_pages; i++) {
-#if BITS_PER_LONG < 64
struct xen_page_foreign *foreign;
foreign = kzalloc_obj(*foreign);
@@ -874,9 +874,9 @@ int gnttab_pages_set_private(int nr_pages, struct page **pages)
return -ENOMEM;
set_page_private(pages[i], (unsigned long)foreign);
-#endif
- SetPagePrivate(pages[i]);
}
+#endif
+ /* Data is stored in page->private on 64-bit */
return 0;
}
@@ -1031,12 +1031,11 @@ void gnttab_pages_clear_private(int nr_pages, struct page **pages)
int i;
for (i = 0; i < nr_pages; i++) {
- if (PagePrivate(pages[i])) {
#if BITS_PER_LONG < 64
+ if (page_private(pages[i]))
kfree((void *)page_private(pages[i]));
#endif
- ClearPagePrivate(pages[i]);
- }
+ set_page_private(pages[i], 0);
}
}
EXPORT_SYMBOL_GPL(gnttab_pages_clear_private);
diff --git a/fs/buffer.c b/fs/buffer.c
index ed966fa73b1ba..020af5dbe2d05 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -773,14 +773,6 @@ struct buffer_head *folio_alloc_buffers(struct folio *folio, unsigned long size,
}
EXPORT_SYMBOL_GPL(folio_alloc_buffers);
-struct buffer_head *alloc_page_buffers(struct page *page, unsigned long size)
-{
- gfp_t gfp = GFP_NOFS | __GFP_ACCOUNT;
-
- return folio_alloc_buffers(page_folio(page), size, gfp);
-}
-EXPORT_SYMBOL_GPL(alloc_page_buffers);
-
static inline void link_dev_buffers(struct folio *folio,
struct buffer_head *head)
{
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index 657c2cb0f8811..1aca181d28c62 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -70,9 +70,7 @@ static int ceph_netfs_check_write_begin(struct file *file, loff_t pos, unsigned
static inline struct ceph_snap_context *page_snap_context(struct page *page)
{
- if (PagePrivate(page))
- return (void *)page->private;
- return NULL;
+ return (void *)page_private(page);
}
/*
@@ -124,8 +122,8 @@ static bool ceph_dirty_folio(struct address_space *mapping, struct folio *folio)
spin_unlock(&ci->i_ceph_lock);
/*
- * Reference snap context in folio->private. Also set
- * PagePrivate so that we get invalidate_folio callback.
+ * Reference snap context in folio->private. Setting folio->private is
+ * what gets us the invalidate_folio callback.
*/
VM_WARN_ON_FOLIO(folio->private, folio);
folio_attach_private(folio, snapc);
diff --git a/fs/crypto/crypto.c b/fs/crypto/crypto.c
index 5286a124b0d98..aced5c50a4601 100644
--- a/fs/crypto/crypto.c
+++ b/fs/crypto/crypto.c
@@ -65,7 +65,6 @@ void fscrypt_free_bounce_page(struct page *bounce_page)
if (!bounce_page)
return;
set_page_private(bounce_page, (unsigned long)NULL);
- ClearPagePrivate(bounce_page);
mempool_free(bounce_page, fscrypt_bounce_page_pool);
}
EXPORT_SYMBOL(fscrypt_free_bounce_page);
@@ -210,7 +209,6 @@ struct page *fscrypt_encrypt_pagecache_blocks(struct folio *folio,
return ERR_PTR(err);
}
}
- SetPagePrivate(ciphertext_page);
set_page_private(ciphertext_page, (unsigned long)folio);
return ciphertext_page;
}
diff --git a/fs/erofs/data.c b/fs/erofs/data.c
index 0885b1f2fc925..f71c7b51bb720 100644
--- a/fs/erofs/data.c
+++ b/fs/erofs/data.c
@@ -239,19 +239,23 @@ int erofs_map_dev(struct super_block *sb, struct erofs_map_dev *map)
/*
* bit 30: I/O error occurred on this folio
* bit 29: CPU has dirty data in D-cache (needs aliasing handling);
- * bit 0 - 29: remaining parts to complete this folio
+ * bit 0 - 28: remaining parts to complete this folio, biased by 1 so that
+ * ->private stays non-NULL while the folio is attached
*/
#define EROFS_ONLINEFOLIO_EIO 30
#define EROFS_ONLINEFOLIO_DIRTY 29
+#define EROFS_ONLINEFOLIO_COUNT_MASK (BIT(EROFS_ONLINEFOLIO_DIRTY) - 1)
+#define EROFS_ONLINEFOLIO_BIAS 1
void erofs_onlinefolio_init(struct folio *folio)
{
union {
atomic_t o;
void *v;
- } u = { .o = ATOMIC_INIT(1) };
+ } u = { .o = ATOMIC_INIT(1 + EROFS_ONLINEFOLIO_BIAS) };
- folio->private = u.v; /* valid only if file-backed folio is locked */
+ /* valid only if file-backed folio is locked */
+ folio_attach_private(folio, u.v);
}
void erofs_onlinefolio_split(struct folio *folio)
@@ -265,14 +269,14 @@ void erofs_onlinefolio_end(struct folio *folio, int err, bool dirty)
do {
orig = atomic_read((atomic_t *)&folio->private);
- DBG_BUGON(orig <= 0);
+ DBG_BUGON((orig & EROFS_ONLINEFOLIO_COUNT_MASK) <= EROFS_ONLINEFOLIO_BIAS);
v = dirty << EROFS_ONLINEFOLIO_DIRTY;
v |= (orig - 1) | (!!err << EROFS_ONLINEFOLIO_EIO);
} while (atomic_cmpxchg((atomic_t *)&folio->private, orig, v) != orig);
- if (v & (BIT(EROFS_ONLINEFOLIO_DIRTY) - 1))
+ if ((v & EROFS_ONLINEFOLIO_COUNT_MASK) != EROFS_ONLINEFOLIO_BIAS)
return;
- folio->private = 0;
+ folio_detach_private(folio);
if (v & BIT(EROFS_ONLINEFOLIO_DIRTY))
flush_dcache_folio(folio);
folio_end_read(folio, !(v & BIT(EROFS_ONLINEFOLIO_EIO)));
diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c
index e1e25ca0d1904..78fd7d980e957 100644
--- a/fs/erofs/zdata.c
+++ b/fs/erofs/zdata.c
@@ -1898,21 +1898,14 @@ static void z_erofs_readahead(struct readahead_control *rac)
struct inode *realinode = erofs_real_inode(sharedinode, &need_iput);
Z_EROFS_DEFINE_FRONTEND(f, realinode, sharedinode, readahead_pos(rac));
unsigned int nrpages = readahead_count(rac);
- struct folio *head = NULL, *folio;
+ struct folio *folio;
int err;
trace_erofs_readahead(realinode, readahead_index(rac), nrpages, false);
z_erofs_pcluster_readmore(&f, rac, true);
- while ((folio = readahead_folio(rac))) {
- folio->private = head;
- head = folio;
- }
-
- /* traverse in reverse order for best metadata I/O performance */
- while (head) {
- folio = head;
- head = folio_get_private(folio);
+ /* traverse from last to first for best metadata I/O performance */
+ while ((folio = readahead_folio_last(rac))) {
err = z_erofs_scan_folio(&f, folio, true);
if (err && err != -EINTR)
erofs_err(realinode->i_sb, "readahead error at folio %lu @ nid %llu",
diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
index ce88092d9ce26..09d9b8d0fdcce 100644
--- a/fs/f2fs/compress.c
+++ b/fs/f2fs/compress.c
@@ -1064,13 +1064,15 @@ static void cancel_cluster_writeback(struct compress_ctx *cc,
/* Cancel writeback and stay locked. */
for (i = 0; i < cc->cluster_size; i++) {
+ struct folio *folio = page_folio(cc->rpages[i]);
+
if (i < submitted) {
inode_inc_dirty_pages(cc->inode);
- lock_page(cc->rpages[i]);
+ folio_lock(folio);
}
- clear_page_private_gcing(cc->rpages[i]);
- if (folio_test_writeback(page_folio(cc->rpages[i])))
- end_page_writeback(cc->rpages[i]);
+ folio_clear_f2fs_gcing(folio);
+ if (folio_test_writeback(folio))
+ folio_end_writeback(folio);
}
}
@@ -1078,11 +1080,15 @@ static void set_cluster_dirty(struct compress_ctx *cc)
{
int i;
- for (i = 0; i < cc->cluster_size; i++)
- if (cc->rpages[i]) {
- set_page_dirty(cc->rpages[i]);
- set_page_private_gcing(cc->rpages[i]);
- }
+ for (i = 0; i < cc->cluster_size; i++) {
+ struct folio *folio;
+
+ if (!cc->rpages[i])
+ continue;
+ folio = page_folio(cc->rpages[i]);
+ folio_mark_dirty(folio);
+ folio_set_f2fs_gcing(folio);
+ }
}
static int prepare_compress_overwrite(struct compress_ctx *cc,
@@ -1281,7 +1287,7 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,
.op = REQ_OP_WRITE,
.op_flags = wbc_to_write_flags(wbc),
.old_blkaddr = NEW_ADDR,
- .page = NULL,
+ .folio = NULL,
.encrypted_page = NULL,
.compressed_page = NULL,
.io_type = io_type,
@@ -1370,7 +1376,7 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,
block_t blkaddr;
blkaddr = f2fs_data_blkaddr(&dn);
- fio.page = cc->rpages[i];
+ fio.folio = page_folio(cc->rpages[i]);
fio.old_blkaddr = blkaddr;
/* cluster header */
@@ -1476,9 +1482,12 @@ void f2fs_compress_write_end_io(struct bio *bio, struct folio *folio)
}
for (i = 0; i < cic->nr_rpages; i++) {
+ struct folio *rfolio;
+
WARN_ON(!cic->rpages[i]);
- clear_page_private_gcing(cic->rpages[i]);
- end_page_writeback(cic->rpages[i]);
+ rfolio = page_folio(cic->rpages[i]);
+ folio_clear_f2fs_gcing(rfolio);
+ folio_end_writeback(rfolio);
}
page_array_free(sbi, cic->rpages, cic->nr_rpages);
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 21f396ebe22ca..ca8232a9095f8 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -2923,7 +2923,7 @@ bool f2fs_should_update_outplace(struct inode *inode, struct f2fs_io_info *fio)
return true;
if (fio) {
- if (page_private_gcing(fio->page))
+ if (folio_test_f2fs_gcing(fio->folio))
return true;
if (unlikely(is_sbi_flag_set(sbi, SBI_CP_DISABLED) &&
f2fs_is_checkpointed_data(sbi, fio->old_blkaddr)))
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 9940a6cecf1a2..85937de3d7016 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1357,10 +1357,7 @@ struct f2fs_io_info {
blk_opf_t op_flags; /* req_flag_bits */
block_t new_blkaddr; /* new block address to be written */
block_t old_blkaddr; /* old block address before Cow */
- union {
- struct page *page; /* page to be written */
- struct folio *folio;
- };
+ struct folio *folio; /* folio to be written */
struct page *encrypted_page; /* encrypted page */
struct page *compressed_page; /* compressed page */
struct list_head list; /* serialize IOs */
@@ -1613,27 +1610,27 @@ static inline void f2fs_set_bit(unsigned int nr, char *addr);
static inline void f2fs_clear_bit(unsigned int nr, char *addr);
/*
- * Layout of f2fs page.private:
+ * Layout of f2fs folio->private:
*
* Layout A: lowest bit should be 1
* | bit0 = 1 | bit1 | bit2 | ... | bit MAX | private data .... |
- * bit 0 PAGE_PRIVATE_NOT_POINTER
- * bit 1 PAGE_PRIVATE_ONGOING_MIGRATION
- * bit 2 PAGE_PRIVATE_INLINE_INODE
- * bit 3 PAGE_PRIVATE_REF_RESOURCE
- * bit 4 PAGE_PRIVATE_ATOMIC_WRITE
+ * bit 0 F2FS_FOLIO_PRIVATE_NOT_POINTER
+ * bit 1 F2FS_FOLIO_PRIVATE_ONGOING_MIGRATION
+ * bit 2 F2FS_FOLIO_PRIVATE_INLINE_INODE
+ * bit 3 F2FS_FOLIO_PRIVATE_REF_RESOURCE
+ * bit 4 F2FS_FOLIO_PRIVATE_ATOMIC_WRITE
* bit 5- f2fs private data
*
* Layout B: lowest bit should be 0
- * page.private is a wrapped pointer.
+ * folio->private is a wrapped pointer.
*/
enum {
- PAGE_PRIVATE_NOT_POINTER, /* private contains non-pointer data */
- PAGE_PRIVATE_ONGOING_MIGRATION, /* data page which is on-going migrating */
- PAGE_PRIVATE_INLINE_INODE, /* inode page contains inline data */
- PAGE_PRIVATE_REF_RESOURCE, /* dirty page has referenced resources */
- PAGE_PRIVATE_ATOMIC_WRITE, /* data page from atomic write path */
- PAGE_PRIVATE_MAX
+ F2FS_FOLIO_PRIVATE_NOT_POINTER, /* private contains non-pointer data */
+ F2FS_FOLIO_PRIVATE_ONGOING_MIGRATION, /* data page which is on-going migrating */
+ F2FS_FOLIO_PRIVATE_INLINE_INODE, /* inode page contains inline data */
+ F2FS_FOLIO_PRIVATE_REF_RESOURCE, /* dirty page has referenced resources */
+ F2FS_FOLIO_PRIVATE_ATOMIC_WRITE, /* data page from atomic write path */
+ F2FS_FOLIO_PRIVATE_MAX
};
/* For compression */
@@ -2681,86 +2678,68 @@ static inline int inc_valid_block_count(struct f2fs_sb_info *sbi,
return -ENOSPC;
}
-#define PAGE_PRIVATE_GET_FUNC(name, flagname) \
+#define F2FS_FOLIO_PRIVATE_GET_FUNC(name, flagname) \
static inline bool folio_test_f2fs_##name(const struct folio *folio) \
{ \
unsigned long priv = (unsigned long)folio->private; \
- unsigned long v = (1UL << PAGE_PRIVATE_NOT_POINTER) | \
- (1UL << PAGE_PRIVATE_##flagname); \
+ unsigned long v = (1UL << F2FS_FOLIO_PRIVATE_NOT_POINTER) | \
+ (1UL << F2FS_FOLIO_PRIVATE_##flagname); \
return (priv & v) == v; \
-} \
-static inline bool page_private_##name(struct page *page) \
-{ \
- return PagePrivate(page) && \
- test_bit(PAGE_PRIVATE_NOT_POINTER, &page_private(page)) && \
- test_bit(PAGE_PRIVATE_##flagname, &page_private(page)); \
}
-#define PAGE_PRIVATE_SET_FUNC(name, flagname) \
+#define F2FS_FOLIO_PRIVATE_SET_FUNC(name, flagname) \
static inline void folio_set_f2fs_##name(struct folio *folio) \
{ \
- unsigned long v = (1UL << PAGE_PRIVATE_NOT_POINTER) | \
- (1UL << PAGE_PRIVATE_##flagname); \
+ unsigned long v = (1UL << F2FS_FOLIO_PRIVATE_NOT_POINTER) | \
+ (1UL << F2FS_FOLIO_PRIVATE_##flagname); \
if (!folio->private) \
folio_attach_private(folio, (void *)v); \
else { \
v |= (unsigned long)folio->private; \
folio->private = (void *)v; \
} \
-} \
-static inline void set_page_private_##name(struct page *page) \
-{ \
- if (!PagePrivate(page)) \
- attach_page_private(page, (void *)0); \
- set_bit(PAGE_PRIVATE_NOT_POINTER, &page_private(page)); \
- set_bit(PAGE_PRIVATE_##flagname, &page_private(page)); \
}
-#define PAGE_PRIVATE_CLEAR_FUNC(name, flagname) \
+#define F2FS_FOLIO_PRIVATE_CLEAR_FUNC(name, flagname) \
static inline void folio_clear_f2fs_##name(struct folio *folio) \
{ \
unsigned long v = (unsigned long)folio->private; \
\
- v &= ~(1UL << PAGE_PRIVATE_##flagname); \
- if (v == (1UL << PAGE_PRIVATE_NOT_POINTER)) \
+ v &= ~(1UL << F2FS_FOLIO_PRIVATE_##flagname); \
+ if (v == (1UL << F2FS_FOLIO_PRIVATE_NOT_POINTER)) \
folio_detach_private(folio); \
else \
folio->private = (void *)v; \
-} \
-static inline void clear_page_private_##name(struct page *page) \
-{ \
- clear_bit(PAGE_PRIVATE_##flagname, &page_private(page)); \
- if (page_private(page) == BIT(PAGE_PRIVATE_NOT_POINTER)) \
- detach_page_private(page); \
}
-PAGE_PRIVATE_GET_FUNC(nonpointer, NOT_POINTER);
-PAGE_PRIVATE_GET_FUNC(inline, INLINE_INODE);
-PAGE_PRIVATE_GET_FUNC(gcing, ONGOING_MIGRATION);
-PAGE_PRIVATE_GET_FUNC(atomic, ATOMIC_WRITE);
+F2FS_FOLIO_PRIVATE_GET_FUNC(nonpointer, NOT_POINTER);
+F2FS_FOLIO_PRIVATE_GET_FUNC(inline, INLINE_INODE);
+F2FS_FOLIO_PRIVATE_GET_FUNC(gcing, ONGOING_MIGRATION);
+F2FS_FOLIO_PRIVATE_GET_FUNC(atomic, ATOMIC_WRITE);
-PAGE_PRIVATE_SET_FUNC(reference, REF_RESOURCE);
-PAGE_PRIVATE_SET_FUNC(inline, INLINE_INODE);
-PAGE_PRIVATE_SET_FUNC(gcing, ONGOING_MIGRATION);
-PAGE_PRIVATE_SET_FUNC(atomic, ATOMIC_WRITE);
+F2FS_FOLIO_PRIVATE_SET_FUNC(reference, REF_RESOURCE);
+F2FS_FOLIO_PRIVATE_SET_FUNC(inline, INLINE_INODE);
+F2FS_FOLIO_PRIVATE_SET_FUNC(gcing, ONGOING_MIGRATION);
+F2FS_FOLIO_PRIVATE_SET_FUNC(atomic, ATOMIC_WRITE);
-PAGE_PRIVATE_CLEAR_FUNC(reference, REF_RESOURCE);
-PAGE_PRIVATE_CLEAR_FUNC(inline, INLINE_INODE);
-PAGE_PRIVATE_CLEAR_FUNC(gcing, ONGOING_MIGRATION);
-PAGE_PRIVATE_CLEAR_FUNC(atomic, ATOMIC_WRITE);
+F2FS_FOLIO_PRIVATE_CLEAR_FUNC(reference, REF_RESOURCE);
+F2FS_FOLIO_PRIVATE_CLEAR_FUNC(inline, INLINE_INODE);
+F2FS_FOLIO_PRIVATE_CLEAR_FUNC(gcing, ONGOING_MIGRATION);
+F2FS_FOLIO_PRIVATE_CLEAR_FUNC(atomic, ATOMIC_WRITE);
static inline unsigned long folio_get_f2fs_data(struct folio *folio)
{
unsigned long data = (unsigned long)folio->private;
- if (!test_bit(PAGE_PRIVATE_NOT_POINTER, &data))
+ if (!test_bit(F2FS_FOLIO_PRIVATE_NOT_POINTER, &data))
return 0;
- return data >> PAGE_PRIVATE_MAX;
+ return data >> F2FS_FOLIO_PRIVATE_MAX;
}
static inline void folio_set_f2fs_data(struct folio *folio, unsigned long data)
{
- data = (1UL << PAGE_PRIVATE_NOT_POINTER) | (data << PAGE_PRIVATE_MAX);
+ data = (1UL << F2FS_FOLIO_PRIVATE_NOT_POINTER) |
+ (data << F2FS_FOLIO_PRIVATE_MAX);
if (!folio_test_private(folio))
folio_attach_private(folio, (void *)data);
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 63b712d3d599e..8c156e1fd37d0 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -3803,7 +3803,7 @@ static int __get_segment_type_6(struct f2fs_io_info *fio)
if (is_inode_flag_set(inode, FI_ALIGNED_WRITE))
return CURSEG_COLD_DATA_PINNED;
- if (page_private_gcing(fio->page)) {
+ if (folio_test_f2fs_gcing(fio->folio)) {
if (fio->sbi->am.atgc_enabled &&
(fio->io_type == FS_DATA_IO) &&
(fio->sbi->gc_mode != GC_URGENT_HIGH) &&
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index e1bdd10b35f10..38f830a6467c9 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -484,7 +484,7 @@ static int nfs_write_end(const struct kiocb *iocb,
* Partially or wholly invalidate a page
* - Release the private state associated with a page if undergoing complete
* page invalidation
- * - Called if either PG_private or PG_fscache is set on the page
+ * - Called if either folio->private or PG_fscache is set on the page
* - Caller holds page lock
*/
static void nfs_invalidate_folio(struct folio *folio, size_t offset,
@@ -555,7 +555,7 @@ static void nfs_check_dirty_writeback(struct folio *folio,
* Attempt to clear the private state associated with a page when an error
* occurs that requires the cached contents of an inode to be written back or
* destroyed
- * - Called if either PG_private or fscache is set on the page
+ * - Called if either page->private or fscache is set on the page
* - Caller holds page lock
* - Return 0 if successful, -error otherwise
*/
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index 623e7ef1f73d5..b6967b5286691 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -717,7 +717,6 @@ static void nfs_inode_add_request(struct nfs_page *req)
nfs_lock_request(req);
spin_lock(&mapping->i_private_lock);
set_bit(PG_MAPPED, &req->wb_flags);
- folio_set_private(folio);
folio->private = req;
spin_unlock(&mapping->i_private_lock);
atomic_long_inc(&nfsi->nrequests);
@@ -745,7 +744,6 @@ static void nfs_inode_remove_request(struct nfs_page *req)
spin_lock(&mapping->i_private_lock);
folio->private = NULL;
- folio_clear_private(folio);
clear_bit(PG_MAPPED, &req->wb_head->wb_flags);
spin_unlock(&mapping->i_private_lock);
diff --git a/fs/proc/page.c b/fs/proc/page.c
index 260772b20bd99..f90e1030825e9 100644
--- a/fs/proc/page.c
+++ b/fs/proc/page.c
@@ -232,7 +232,6 @@ u64 stable_page_flags(const struct page *page)
u |= kpf_copy_bit(k, KPF_RESERVED, PG_reserved);
u |= kpf_copy_bit(k, KPF_OWNER_2, PG_owner_2);
- u |= kpf_copy_bit(k, KPF_PRIVATE, PG_private);
u |= kpf_copy_bit(k, KPF_PRIVATE_2, PG_private_2);
u |= kpf_copy_bit(k, KPF_OWNER_PRIVATE, PG_owner_priv_1);
u |= kpf_copy_bit(k, KPF_ARCH, PG_arch_1);
diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
index e73c28b12f97f..aa0298ce451ef 100644
--- a/fs/ubifs/file.c
+++ b/fs/ubifs/file.c
@@ -12,14 +12,14 @@
* This file implements VFS file and inode operations for regular files, device
* nodes and symlinks as well as address space operations.
*
- * UBIFS uses 2 page flags: @PG_private and @PG_checked. @PG_private is set if
+ * UBIFS uses folio->private and page flag @PG_checked. folio->private is set if
* the page is dirty and is used for optimization purposes - dirty pages are
- * not budgeted so the flag shows that 'ubifs_write_end()' should not release
+ * not budgeted so it shows that 'ubifs_write_end()' should not release
* the budget for this page. The @PG_checked flag is set if full budgeting is
* required for the page e.g., when it corresponds to a file hole or it is
* beyond the file size. The budgeting is done in 'ubifs_write_begin()', because
* it is OK to fail in this function, and the budget is released in
- * 'ubifs_write_end()'. So the @PG_private and @PG_checked flags carry
+ * 'ubifs_write_end()'. So the folio->private and the @PG_checked flag carry
* information about how the page was budgeted, to make it possible to release
* the budget properly.
*
@@ -1509,7 +1509,7 @@ static vm_fault_t ubifs_vm_page_mkwrite(struct vm_fault *vmf)
*
* At the moment we do not know whether the folio is dirty or not, so we
* assume that it is not and budget for a new folio. We could look at
- * the @PG_private flag and figure this out, but we may race with write
+ * folio->private and figure this out, but we may race with write
* back and the folio state may change by the time we lock it, so this
* would need additional care. We do not bother with this at the
* moment, although it might be good idea to do. Instead, we allocate
diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h
index fd2c7115c0542..4b0b7188472b2 100644
--- a/include/linux/buffer_head.h
+++ b/include/linux/buffer_head.h
@@ -175,12 +175,7 @@ static inline unsigned long bh_offset(const struct buffer_head *bh)
return (unsigned long)(bh)->b_data & (page_size(bh->b_page) - 1);
}
-/* If we *know* page->private refers to buffer_heads */
-#define page_buffers(page) \
- ({ \
- BUG_ON(!PagePrivate(page)); \
- ((struct buffer_head *)page_private(page)); \
- })
+/* If we *know* folio->private refers to buffer_heads */
#define folio_buffers(folio) folio_get_private(folio)
void buffer_check_dirty_writeback(struct folio *folio,
@@ -197,7 +192,6 @@ void folio_set_bh(struct buffer_head *bh, struct folio *folio,
unsigned long offset);
struct buffer_head *folio_alloc_buffers(struct folio *folio, unsigned long size,
gfp_t gfp);
-struct buffer_head *alloc_page_buffers(struct page *page, unsigned long size);
struct buffer_head *create_empty_buffers(struct folio *folio,
unsigned long blocksize, unsigned long b_state);
void end_buffer_read_sync(struct buffer_head *bh, int uptodate);
diff --git a/include/linux/kernel-page-flags.h b/include/linux/kernel-page-flags.h
index 196778a087c4d..fe5ab6e50bd70 100644
--- a/include/linux/kernel-page-flags.h
+++ b/include/linux/kernel-page-flags.h
@@ -11,7 +11,6 @@
#define KPF_RESERVED 32
#define KPF_MLOCKED 33
#define KPF_OWNER_2 34
-#define KPF_PRIVATE 35
#define KPF_PRIVATE_2 36
#define KPF_OWNER_PRIVATE 37
#define KPF_ARCH 38
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 66d384da4433b..262d1de5c1161 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -2048,20 +2048,21 @@ vm_fault_t finish_fault(struct vm_fault *vmf);
*
* A pagecache page contains an opaque `private' member, which belongs to the
* page's address_space. Usually, this is the address of a circular list of
- * the page's disk buffers. PG_private must be set to tell the VM to call
- * into the filesystem to release these pages.
+ * the page's disk buffers. It tells the VM to call into the filesystem to
+ * release these pages.
*
* A folio may belong to an inode's memory mapping. In this case,
* folio->mapping points to the inode, and folio->index is the file
* offset of the folio, in units of PAGE_SIZE.
*
- * If pagecache pages are not associated with an inode, they are said to be
- * anonymous pages. These may become associated with the swapcache, and in that
- * case PG_swapcache is set, and page->private is an offset into the swapcache.
+ * If pagecache folios are not associated with an inode, they are said to be
+ * anonymous folios. These may become associated with the swapcache, and in that
+ * case PG_swapcache is set, and folio->private is an offset into the swapcache.
*
* In either case (swapcache or inode backed), the pagecache itself holds one
- * reference to the page. Setting PG_private should also increment the
- * refcount. The each user mapping also has a reference to the page.
+ * reference to the folio. Attaching filesystem private data via
+ * folio_attach_private() also increments the refcount. Each user mapping also
+ * has a reference to the folio.
*
* The pagecache pages are stored in a per-mapping radix tree, which is
* rooted at mapping->i_pages, and indexed by offset.
@@ -3004,9 +3005,9 @@ static inline bool folio_maybe_mapped_shared(struct folio *folio)
* @folio: the folio
*
* Calculate the expected folio refcount, taking references from the pagecache,
- * swapcache, PG_private and page table mappings into account. Useful in
- * combination with folio_ref_count() to detect unexpected references (e.g.,
- * GUP or other temporary references).
+ * swapcache, private data (folio->private != NULL) and page table mappings into
+ * account. Useful in combination with folio_ref_count() to detect unexpected
+ * references (e.g., GUP or other temporary references).
*
* Does currently not consider references from the LRU cache. If the folio
* was isolated from the LRU (which is the case during migration or split),
@@ -3044,10 +3045,15 @@ static inline int folio_expected_ref_count(const struct folio *folio)
ref_count += folio_test_swapcache(folio) << order;
if (!folio_test_anon(folio)) {
- /* One reference per page from the pagecache. */
- ref_count += !!folio->mapping << order;
- /* One reference from PG_private. */
- ref_count += folio_test_private(folio);
+ /*
+ * One reference per page from the pagecache.
+ * Use data_race() since folio might not be locked.
+ */
+ ref_count += !!data_race(folio->mapping) << order;
+ /*
+ * One reference from filesystem private data.
+ */
+ ref_count += folio_has_attached_private(folio);
}
/* One reference per page table mapping. */
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index 5413bd10fff2c..9d6c945ba4104 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -108,7 +108,7 @@ struct page {
};
/**
* @private: Mapping-private opaque data.
- * Usually used for buffer_heads if PagePrivate.
+ * Usually used for buffer_heads.
* Used for swp_entry_t if swapcache flag set.
* Indicates order in the buddy system if PageBuddy
* or on pcp_llist.
@@ -675,7 +675,7 @@ static inline void ptdesc_pmd_pts_init(struct ptdesc *ptdesc)
#define STRUCT_PAGE_MAX_SHIFT (order_base_2(sizeof(struct page)))
/*
- * page_private can be used on tail pages. However, PagePrivate is only
+ * page_private can be used on tail pages. However, it is only
* checked by the VM on the head page. So page_private on the tail pages
* should be used for data that's ancillary to the head page (eg attaching
* buffer heads to tail pages after attaching buffer heads to the head page)
diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index 7080a6a1a79e7..b0ddc652e76cc 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -44,10 +44,6 @@
* Consequently, PG_reserved for a page mapped into user space can indicate
* the zero page, the vDSO, MMIO pages or device memory.
*
- * The PG_private bitflag is set on pagecache pages if they contain filesystem
- * specific data (which is normally at page->private). It can be used by
- * private allocations for its own usage.
- *
* During initiation of disk I/O, PG_locked is set. This bit is set before I/O
* and cleared when writeback _starts_ or when read _completes_. PG_writeback
* is set before writeback starts and cleared when it finishes.
@@ -105,7 +101,7 @@ enum pageflags {
PG_owner_2, /* Owner use. If pagecache, fs may use */
PG_arch_1,
PG_reserved,
- PG_private, /* If pagecache, has fs-private data */
+ PG_folio, /* Do not use: reserved for folio identification */
PG_private_2, /* If pagecache, has fs aux data */
PG_reclaim, /* To be reclaimed asap */
PG_swapbacked, /* Page is backed by RAM/swap */
@@ -575,9 +571,19 @@ FOLIO_FLAG(swapbacked, FOLIO_HEAD_PAGE)
/*
* Private page markings that may be used by the filesystem that owns the page
* for its own purposes.
- * - PG_private and PG_private_2 cause release_folio() and co to be invoked
+ * - folio->private and PG_private_2 cause release_folio() and co to be invoked
*/
-PAGEFLAG(Private, private, PF_ANY)
+
+static __always_inline bool folio_test_private(const struct folio *folio)
+{
+ /*
+ * data_race() is added for readers without holding the folio lock.
+ * Only the NULL/non-NULL answer is used and both are valid while
+ * private is being attached or detached, so the race is benign.
+ */
+ return data_race(folio->private);
+}
+
FOLIO_FLAG(private_2, FOLIO_HEAD_PAGE)
/* owner_2 can be set on tail pages for anon memory */
@@ -1169,7 +1175,7 @@ static __always_inline void __ClearPageAnonExclusive(struct page *page)
*/
#define PAGE_FLAGS_CHECK_AT_FREE \
(1UL << PG_lru | 1UL << PG_locked | \
- 1UL << PG_private | 1UL << PG_private_2 | \
+ 1UL << PG_private_2 | \
1UL << PG_writeback | 1UL << PG_reserved | \
1UL << PG_active | \
1UL << PG_unevictable | __PG_MLOCKED | LRU_GEN_MASK)
@@ -1193,8 +1199,31 @@ static __always_inline void __ClearPageAnonExclusive(struct page *page)
(0xffUL /* order */ | 1UL << PG_has_hwpoisoned | \
1UL << PG_large_rmappable | 1UL << PG_partially_mapped)
-#define PAGE_FLAGS_PRIVATE \
- (1UL << PG_private | 1UL << PG_private_2)
+/**
+ * folio_has_attached_private - check if the folio has private data attached
+ * @folio: The folio to check.
+ *
+ * Use this in code that may encounter swapcache or hugetlb folios but only
+ * wants to detect attached private data.
+ *
+ * Return: true if the folio has private data attached.
+ */
+static inline bool folio_has_attached_private(const struct folio *folio)
+{
+ /*
+ * Swapcache stores swp_entry_t in folio->swap, a union with
+ * folio->private, and hugetlb stores its own flags in folio->private;
+ * both are excluded.
+ *
+ * NOTE: For swapcache, folio->swap.val PG_swapcache are not set as
+ * a whole, so folio_test_swapcache() is not reliable to exclude
+ * swapcache. Use folio_test_swapbacked() instead, since it remains set
+ * when a folio is added to/removed from swapcache.
+ */
+
+ return folio_test_private(folio) && !folio_test_swapbacked(folio) &&
+ !folio_test_hugetlb(folio);
+}
/**
* folio_has_private - Determine if folio has private stuff
* @folio: The folio to be checked
@@ -1204,7 +1233,7 @@ static __always_inline void __ClearPageAnonExclusive(struct page *page)
*/
static inline int folio_has_private(const struct folio *folio)
{
- return !!(folio->flags.f & PAGE_FLAGS_PRIVATE);
+ return folio_has_attached_private(folio) || folio_test_private_2(folio);
}
#undef PF_ANY
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 939f3a5e973f6..bcbb0afe1a681 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -594,7 +594,6 @@ static inline void folio_attach_private(struct folio *folio, void *data)
{
folio_get(folio);
folio->private = data;
- folio_set_private(folio);
}
/**
@@ -629,9 +628,8 @@ static inline void *folio_detach_private(struct folio *folio)
{
void *data = folio_get_private(folio);
- if (!folio_test_private(folio))
+ if (!data)
return NULL;
- folio_clear_private(folio);
folio->private = NULL;
folio_put(folio);
@@ -1415,6 +1413,7 @@ struct readahead_control {
bool dropbehind;
bool _workingset;
unsigned long _pflags;
+ bool _forward;
};
#define DEFINE_READAHEAD(ractl, f, r, m, i) \
@@ -1479,18 +1478,29 @@ void page_cache_async_readahead(struct address_space *mapping,
page_cache_async_ra(&ractl, folio, req_count);
}
+/*
+ * Adjust readahead_control to ensure next folio comes from
+ * [_index, _index + _nr_pages) afterwards and reset _batch_count.
+ */
+static inline void __readahead_advance(struct readahead_control *rac)
+{
+ if (rac->_forward)
+ rac->_index += rac->_batch_count;
+
+ rac->_nr_pages -= rac->_batch_count;
+ rac->_batch_count = 0;
+}
+
static inline struct folio *__readahead_folio(struct readahead_control *ractl)
{
struct folio *folio;
BUG_ON(ractl->_batch_count > ractl->_nr_pages);
- ractl->_nr_pages -= ractl->_batch_count;
- ractl->_index += ractl->_batch_count;
+ __readahead_advance(ractl);
+ ractl->_forward = true;
- if (!ractl->_nr_pages) {
- ractl->_batch_count = 0;
+ if (!ractl->_nr_pages)
return NULL;
- }
folio = xa_load(&ractl->mapping->i_pages, ractl->_index);
VM_BUG_ON_FOLIO(!folio_test_locked(folio), folio);
@@ -1516,6 +1526,39 @@ static inline struct folio *readahead_folio(struct readahead_control *ractl)
return folio;
}
+/**
+ * readahead_folio_last - Get the next folio to read, from the tail.
+ * @ractl: The current readahead request.
+ *
+ * Like readahead_folio(), but walks the range back-to-front. The folio is
+ * returned locked with its refcount dropped; the caller unlocks it once I/O
+ * completes. Compound folios are returned once, at their head index.
+ *
+ * Context: The folio is locked.
+ * Return: A pointer to the next folio, or %NULL when done.
+ */
+static inline struct folio *readahead_folio_last(struct readahead_control *ractl)
+{
+ struct folio *folio;
+
+ /* Drop the previously returned batch from the remaining range. */
+ __readahead_advance(ractl);
+ ractl->_forward = false;
+
+ if (!ractl->_nr_pages)
+ return NULL;
+
+ /* xa_load() follows sibling entries, so a tail index returns the head */
+ folio = xa_load(&ractl->mapping->i_pages,
+ ractl->_index + ractl->_nr_pages - 1);
+ VM_WARN_ON_ONCE_FOLIO(!folio_test_locked(folio), folio);
+
+ ractl->_batch_count = folio_nr_pages(folio);
+
+ folio_put(folio);
+ return folio;
+}
+
static inline unsigned int __readahead_batch(struct readahead_control *rac,
struct page **array, unsigned int array_sz)
{
@@ -1524,9 +1567,8 @@ static inline unsigned int __readahead_batch(struct readahead_control *rac,
struct folio *folio;
BUG_ON(rac->_batch_count > rac->_nr_pages);
- rac->_nr_pages -= rac->_batch_count;
- rac->_index += rac->_batch_count;
- rac->_batch_count = 0;
+ __readahead_advance(rac);
+ rac->_forward = true;
xas_set(&xas, rac->_index);
rcu_read_lock();
diff --git a/include/trace/events/mmflags.h b/include/trace/events/mmflags.h
index ef9aa388b84f7..3c153b3ad8450 100644
--- a/include/trace/events/mmflags.h
+++ b/include/trace/events/mmflags.h
@@ -144,7 +144,7 @@ TRACE_DEFINE_ENUM(___GFP_LAST_BIT);
DEF_PAGEFLAG_NAME(owner_2), \
DEF_PAGEFLAG_NAME(arch_1), \
DEF_PAGEFLAG_NAME(reserved), \
- DEF_PAGEFLAG_NAME(private), \
+ DEF_PAGEFLAG_NAME(folio), \
DEF_PAGEFLAG_NAME(private_2), \
DEF_PAGEFLAG_NAME(writeback), \
DEF_PAGEFLAG_NAME(head), \
diff --git a/include/trace/events/pagemap.h b/include/trace/events/pagemap.h
index 36c3a90f0acca..5d47b774633a4 100644
--- a/include/trace/events/pagemap.h
+++ b/include/trace/events/pagemap.h
@@ -22,7 +22,7 @@
(folio_test_swapcache(folio) ? PAGEMAP_SWAPCACHE : 0) | \
(folio_test_swapbacked(folio) ? PAGEMAP_SWAPBACKED : 0) | \
(folio_test_mappedtodisk(folio) ? PAGEMAP_MAPPEDDISK : 0) | \
- (folio_test_private(folio) ? PAGEMAP_BUFFERS : 0) \
+ (folio_has_attached_private(folio) ? PAGEMAP_BUFFERS : 0) \
)
TRACE_EVENT(mm_lru_insertion,
diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c
index 9fe92161715e0..061b5cb222266 100644
--- a/kernel/events/ring_buffer.c
+++ b/kernel/events/ring_buffer.c
@@ -630,11 +630,10 @@ static struct page *rb_alloc_aux_page(int node, int order)
/*
* Communicate the allocation size to the driver:
* if we managed to secure a high-order allocation,
- * set its first page's private to this order;
- * !PagePrivate(page) means it's just a normal page.
+ * set its first page's private to this order, otherwise page's
+ * private remains zero.
*/
split_page(page, order);
- SetPagePrivate(page);
set_page_private(page, order);
}
@@ -645,7 +644,7 @@ static void rb_free_aux_page(struct perf_buffer *rb, int idx)
{
struct page *page = virt_to_page(rb->aux_pages[idx]);
- ClearPagePrivate(page);
+ set_page_private(page, 0);
__free_page(page);
}
diff --git a/kernel/vmcore_info.c b/kernel/vmcore_info.c
index 8614430ca212a..5a417f8a922ab 100644
--- a/kernel/vmcore_info.c
+++ b/kernel/vmcore_info.c
@@ -216,7 +216,6 @@ static int __init crash_save_vmcoreinfo_init(void)
VMCOREINFO_LENGTH(free_area.free_list, MIGRATE_TYPES);
VMCOREINFO_NUMBER(NR_FREE_PAGES);
VMCOREINFO_NUMBER(PG_lru);
- VMCOREINFO_NUMBER(PG_private);
VMCOREINFO_NUMBER(PG_swapcache);
VMCOREINFO_NUMBER(PG_swapbacked);
#define PAGE_SLAB_MAPCOUNT_VALUE (PGTY_slab << 24)
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 30b7c63b0e359..8aa2daba37391 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -4846,7 +4846,7 @@ static int split_huge_pages_pid(int pid, unsigned long vaddr_start,
* will try to drop it before split and then check if the folio
* can be split or not. So skip the check here.
*/
- if (!folio_test_private(folio) &&
+ if (!folio_has_attached_private(folio) &&
folio_expected_ref_count(folio) != folio_ref_count(folio))
goto next;
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 2003439ea13c6..7b27c3c5c3e58 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1446,11 +1446,8 @@ void add_hugetlb_folio(struct hstate *h, struct folio *folio,
}
__folio_set_hugetlb(folio);
- folio_change_private(folio, NULL);
- /*
- * We have to set hugetlb_vmemmap_optimized again as above
- * folio_change_private(folio, NULL) cleared it.
- */
+ /* Clear all folio->private flags except hugetlb_vmemmap_optimized. */
+ folio->private = NULL;
folio_set_hugetlb_vmemmap_optimized(folio);
arch_clear_hugetlb_flags(folio);
diff --git a/mm/migrate.c b/mm/migrate.c
index a369d0c95c386..7e3a81f069744 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -835,7 +835,6 @@ void folio_migrate_flags(struct folio *newfolio, struct folio *folio)
*/
if (folio_test_swapcache(folio))
folio_clear_swapcache(folio);
- folio_clear_private(folio);
/* page->private contains hugetlb specific flags */
if (!folio_test_hugetlb(folio))
@@ -1327,7 +1326,7 @@ static int migrate_folio_unmap(new_folio_t get_new_folio,
* free the metadata, so the page can be freed.
*/
if (!src->mapping) {
- if (folio_test_private(src)) {
+ if (folio_has_attached_private(src)) {
try_to_free_buffers(src);
goto out;
}
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index eeab25d6ce364..499a35473e4f3 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -2705,7 +2705,7 @@ bool filemap_dirty_folio(struct address_space *mapping, struct folio *folio)
if (folio_test_set_dirty(folio))
return false;
- __folio_mark_dirty(folio, mapping, !folio_test_private(folio));
+ __folio_mark_dirty(folio, mapping, !folio_has_attached_private(folio));
if (mapping->host) {
/* !PageAnon && !swapper_space */
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 80041e2b8049c..dd6261c862794 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1029,7 +1029,7 @@ static void folio_check_dirty_writeback(struct folio *folio,
*writeback = folio_test_writeback(folio);
/* Verify dirty/writeback state if the filesystem supports it */
- if (!folio_test_private(folio))
+ if (!folio_has_attached_private(folio))
return;
mapping = folio_mapping(folio);
diff --git a/mm/zpdesc.h b/mm/zpdesc.h
index b8258dc78548d..4fd81c2e80769 100644
--- a/mm/zpdesc.h
+++ b/mm/zpdesc.h
@@ -26,8 +26,8 @@
* with memcg_data.
*
* Page flags used:
- * * PG_private identifies the first component page.
* * PG_locked is used by page migration code.
+ * The first component page has zpdesc->zspage->first_zpdesc == zpdesc
*/
struct zpdesc {
unsigned long flags;
diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index 11be37c431718..7ef80e0da6267 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -290,11 +290,6 @@ struct zs_pool {
atomic_t compaction_in_progress;
};
-static inline void zpdesc_set_first(struct zpdesc *zpdesc)
-{
- SetPagePrivate(zpdesc_page(zpdesc));
-}
-
static inline void zpdesc_inc_zone_page_state(struct zpdesc *zpdesc)
{
inc_zone_page_state(zpdesc_page(zpdesc), NR_ZSPAGES);
@@ -476,11 +471,6 @@ static void record_obj(unsigned long handle, unsigned long obj)
WRITE_ONCE(*(unsigned long *)handle, obj);
}
-static inline bool __maybe_unused is_first_zpdesc(struct zpdesc *zpdesc)
-{
- return PagePrivate(zpdesc_page(zpdesc));
-}
-
/* Protected by class->lock */
static inline int get_zspage_inuse(struct zspage *zspage)
{
@@ -496,7 +486,8 @@ static struct zpdesc *get_first_zpdesc(struct zspage *zspage)
{
struct zpdesc *first_zpdesc = zspage->first_zpdesc;
- VM_BUG_ON_PAGE(!is_first_zpdesc(first_zpdesc), zpdesc_page(first_zpdesc));
+ /* the first zpdesc must point back to this zspage */
+ VM_WARN_ON_ONCE_PAGE(first_zpdesc->zspage != zspage, zpdesc_page(first_zpdesc));
return first_zpdesc;
}
@@ -838,7 +829,8 @@ static inline bool obj_allocated(struct zpdesc *zpdesc, void *obj,
struct zspage *zspage = get_zspage(zpdesc);
if (unlikely(ZsHugePage(zspage))) {
- VM_BUG_ON_PAGE(!is_first_zpdesc(zpdesc), zpdesc_page(zpdesc));
+ /* only first zpdesc holds the handle */
+ VM_WARN_ON_ONCE_PAGE(zspage->first_zpdesc != zpdesc, zpdesc_page(zpdesc));
handle = zpdesc->handle;
} else
handle = *(unsigned long *)obj;
@@ -853,9 +845,6 @@ static inline bool obj_allocated(struct zpdesc *zpdesc, void *obj,
static void reset_zpdesc(struct zpdesc *zpdesc)
{
- struct page *page = zpdesc_page(zpdesc);
-
- ClearPagePrivate(page);
zpdesc->zspage = NULL;
zpdesc->next = NULL;
/* PageZsmalloc is sticky until the page is freed to the buddy. */
@@ -1006,8 +995,8 @@ static void create_page_chain(struct size_class *class, struct zspage *zspage,
* 1. all pages are linked together using zpdesc->next
* 2. each sub-page point to zspage using zpdesc->zspage
*
- * we set PG_private to identify the first zpdesc (i.e. no other zpdesc
- * has this flag set).
+ * The first zpdesc has its zspage->first_zpdesc set to itself, no
+ * other zpdesc has this set.
*/
for (i = 0; i < nr_zpdescs; i++) {
zpdesc = zpdescs[i];
@@ -1015,7 +1004,6 @@ static void create_page_chain(struct size_class *class, struct zspage *zspage,
zpdesc->next = NULL;
if (i == 0) {
zspage->first_zpdesc = zpdesc;
- zpdesc_set_first(zpdesc);
if (unlikely(class->objs_per_zspage == 1 &&
class->pages_per_zspage == 1))
SetZsHugePage(zspage);
diff --git a/tools/mm/page-types.c b/tools/mm/page-types.c
index 7fc5a8be5997f..47e4781c5fc38 100644
--- a/tools/mm/page-types.c
+++ b/tools/mm/page-types.c
@@ -73,7 +73,6 @@
#define KPF_RESERVED 32
#define KPF_MLOCKED 33
#define KPF_OWNER_2 34
-#define KPF_PRIVATE 35
#define KPF_PRIVATE_2 36
#define KPF_OWNER_PRIVATE 37
#define KPF_ARCH 38
@@ -131,7 +130,6 @@ static const char * const page_flag_names[] = {
[KPF_RESERVED] = "r:reserved",
[KPF_MLOCKED] = "m:mlocked",
[KPF_OWNER_2] = "d:owner_2",
- [KPF_PRIVATE] = "P:private",
[KPF_PRIVATE_2] = "p:private_2",
[KPF_OWNER_PRIVATE] = "O:owner_private",
[KPF_ARCH] = "h:arch",
|
| 3/2 | 2026/09/22 23:11 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 21393 output: 32 thoughts: 934 Thoughts: **Patch Triage: PG_private Removal and Folio Abstraction** Alright, let's break this down. They've removed the `PG_private` flag and are switching to `folio->private` and related functions. I need to be methodical. First, the instructions: it's AMD64, the changes are in HEAD, and the core triage philosophy is REACHABILITY FIRST. Got it. No blind trust of refactoring claims, and if reachable code changes, it gets fuzzed. New or modified assertions in reachable code? Fuzzing time. When do I say it's *not* worth fuzzing? Only if *all* the changes are strictly negative: non-kernel, non-executable, unreachable hardware, or unreachable paths. Otherwise, it's worth fuzzing if it touches core subsystems, refactors reachable code, or adds runtime assertions. Focus on specific feature logic, not hot-path allocators/deallocators. Avoid static inlines by checking their call sites. Enable the provided kernel configs. Now, the files. Okay, it's a *lot* of files, many in core memory management: `mm/huge_memory.c`, `mm/hugetlb.c`, `mm/migrate.c`, `mm/page-writeback.c`, `mm/vmscan.c`, `mm/zsmalloc.c`, etc. Plus, a bunch of filesystems – f2fs, erofs, ceph, nfs, buffer.c – and the perf ring buffer too. This is a fundamental change to how `PG_private` is handled. It's a complete reorganization, replacing a bit with `folio_test_private`, `folio_has_attached_private`, etc. Readahead, erofs, f2fs, zsmalloc, all touched. This is clearly a `WorthFuzzing=true` scenario. Core MM and filesystems are definitely being touched. I should probably dig into the git commit history to get the full picture. |
| 4/2 | 2026/09/22 23:11 | tool | grepper |
0mArgs:{
"Expression": "PG_folio",
"PathPrefix": "include/linux/page-flags.h"
}Results: {
"Output": "include/linux/page-flags.h=89=enum pageflags {\n--\ninclude/linux/page-flags.h-103-\tPG_reserved,\ninclude/linux/page-flags.h:104:\tPG_folio,\t\t/* Do not use: reserved for folio identification */\ninclude/linux/page-flags.h-105-\tPG_private_2,\t\t/* If pagecache, has fs aux data */\n"
} |
| 5/2 | 2026/09/22 23:11 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 22905 output: 20 thoughts: 27 Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience: **Analyzing the Latest Commit** Right, before I dive too deep, I should quickly orient myself with the changes. I'm going to quickly check the most recent commit. My first inclination is to use `git log -n 1`. It’s the fastest way to get a quick summary. If I need more, I'll go right to the commit message or the diff itself. Knowing the *what* and ideally the *why* of the last modification is crucial before I even start digging into the codebase. I need context, and these are the most direct routes to it. It’s about building a mental model of the situation before engaging in more thorough code review or debugging. No point in making assumptions without a quick sanity check. |
| 6/2 | 2026/09/22 23:11 | tool | grepper |
0mArgs:{
"Expression": "readahead_folio_last"
}Results: {
"Output": "fs/erofs/zdata.c=1894=static void z_erofs_readahead(struct readahead_control *rac)\n--\nfs/erofs/zdata.c-1907-\t/* traverse from last to first for best metadata I/O performance */\nfs/erofs/zdata.c:1908:\twhile ((folio = readahead_folio_last(rac))) {\nfs/erofs/zdata.c-1909-\t\terr = z_erofs_scan_folio(\u0026f, folio, true);\n--\ninclude/linux/pagemap.h=1520=static inline struct folio *readahead_folio(struct readahead_control *ractl)\n--\ninclude/linux/pagemap.h-1529-/**\ninclude/linux/pagemap.h:1530: * readahead_folio_last - Get the next folio to read, from the tail.\ninclude/linux/pagemap.h-1531- * @ractl: The current readahead request.\n--\ninclude/linux/pagemap.h-1539- */\ninclude/linux/pagemap.h:1540:static inline struct folio *readahead_folio_last(struct readahead_control *ractl)\ninclude/linux/pagemap.h-1541-{\n"
} |
| 7/2 | 2026/09/22 23:11 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 23464 output: 21 thoughts: 494 Thoughts: **Kernel Folio Usage Deep Dive** Okay, let's take a look at the landscape of folio usage across the kernel, focusing on some recent additions and established functions. I've been tracing the introduction and use of `readahead_folio_last`, introduced in `include/linux/pagemap.h` and primarily used within `fs/erofs/zdata.c:z_erofs_readahead`. I see it also used in `fs/erofs/data.c` with functions like `erofs_onlinefolio_init` and `erofs_onlinefolio_end`. My attention then shifted to the f2fs filesystem. I saw a cluster of folio-related functions cropping up in the compression and data management areas: `fs/f2fs/compress.c` with functions such as `cancel_cluster_writeback`, `set_cluster_dirty`, `f2fs_write_compressed_pages`, `f2fs_compress_write_end_io`. In `fs/f2fs/data.c` I see `f2fs_should_update_outplace`, and in `fs/f2fs/segment.c` there's a reference to `__get_segment_type_6`. The memory management side also warrants further examination. In `mm/huge_memory.c`, I see `split_huge_pages_pid`, while `mm/hugetlb.c` includes `add_hugetlb_folio`. In `mm/migrate.c`, the `folio_migrate_flags` and `migrate_folio_unmap` functions look interesting. The writeback path uses `filemap_dirty_folio` in `mm/page-writeback.c`. `folio_check_dirty_writeback` is present in `mm/vmscan.c`. Zooming in on zsmalloc, it looks like `mm/zsmalloc.c` is using several new folio functions like `get_first_zpdesc`, `obj_allocated`, `reset_zpdesc`, and `create_page_chain`. Diving into storage drivers, `drivers/md/md-bitmap.c` caught my eye with functions such as `write_file_page`, `free_buffers`, and `read_file_page`. On the network side, I noted the inclusion of folio in `fs/nfs/write.c`, where I saw `nfs_inode_add_request` and `nfs_inode_remove_request`. In `fs/ceph/addr.c`, I'm looking at `page_snap_context` and `ceph_dirty_folio`. Now, I'm going to shift my focus to a couple of folio-related variables that might be interesting. I'll need to check the usage of `folio_expected_ref_count` and `folio_has_attached_private`. `folio_has_attached_private` is a static inline function, defined in `include/linux/page-flags.h`, so I'll need to expand my search to identify everywhere it's actively used. |
| 8/2 | 2026/09/22 23:11 | tool | grepper |
0mArgs:{
"Expression": "folio_has_attached_private"
}Results: {
"Output": "include/linux/mm.h=3036=static inline int folio_expected_ref_count(const struct folio *folio)\n--\ninclude/linux/mm.h-3055-\t\t */\ninclude/linux/mm.h:3056:\t\tref_count += folio_has_attached_private(folio);\ninclude/linux/mm.h-3057-\t}\n--\ninclude/linux/page-flags.h=1159=static __always_inline void __ClearPageAnonExclusive(struct page *page)\n--\ninclude/linux/page-flags.h-1202-/**\ninclude/linux/page-flags.h:1203: * folio_has_attached_private - check if the folio has private data attached\ninclude/linux/page-flags.h-1204- * @folio: The folio to check.\n--\ninclude/linux/page-flags.h-1210- */\ninclude/linux/page-flags.h:1211:static inline bool folio_has_attached_private(const struct folio *folio)\ninclude/linux/page-flags.h-1212-{\n--\ninclude/linux/page-flags.h=1234=static inline int folio_has_private(const struct folio *folio)\ninclude/linux/page-flags.h-1235-{\ninclude/linux/page-flags.h:1236:\treturn folio_has_attached_private(folio) || folio_test_private_2(folio);\ninclude/linux/page-flags.h-1237-}\n--\ninclude/trace/events/pagemap.h-24-\t(folio_test_mappedtodisk(folio)\t? PAGEMAP_MAPPEDDISK : 0) | \\\ninclude/trace/events/pagemap.h:25:\t(folio_has_attached_private(folio)\t? PAGEMAP_BUFFERS : 0) \\\ninclude/trace/events/pagemap.h-26-\t)\n--\nmm/huge_memory.c=4775=static int split_huge_pages_pid(int pid, unsigned long vaddr_start,\n--\nmm/huge_memory.c-4848-\t\t */\nmm/huge_memory.c:4849:\t\tif (!folio_has_attached_private(folio) \u0026\u0026\nmm/huge_memory.c-4850-\t\t folio_expected_ref_count(folio) != folio_ref_count(folio))\n--\nmm/migrate.c=1212=static int migrate_folio_unmap(new_folio_t get_new_folio,\n--\nmm/migrate.c-1328-\tif (!src-\u003emapping) {\nmm/migrate.c:1329:\t\tif (folio_has_attached_private(src)) {\nmm/migrate.c-1330-\t\t\ttry_to_free_buffers(src);\n--\nmm/page-writeback.c=2703=bool filemap_dirty_folio(struct address_space *mapping, struct folio *folio)\n--\nmm/page-writeback.c-2707-\nmm/page-writeback.c:2708:\t__folio_mark_dirty(folio, mapping, !folio_has_attached_private(folio));\nmm/page-writeback.c-2709-\n--\nmm/vmscan.c=1009=static void folio_check_dirty_writeback(struct folio *folio,\n--\nmm/vmscan.c-1031-\t/* Verify dirty/writeback state if the filesystem supports it */\nmm/vmscan.c:1032:\tif (!folio_has_attached_private(folio))\nmm/vmscan.c-1033-\t\treturn;\n"
} |
| 9/2 | 2026/09/22 23:11 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 25573 output: 19 thoughts: 37 Thoughts: Okay, let's break this down. **Analyzing the Usage of `folio_has_private`** Alright, I see that the function `folio_has_private(folio)` is being used in multiple sections of the codebase. My immediate thought is to trace its invocations to fully grasp its role and implications. The next logical step is to pinpoint every instance where `folio_has_private` is called. Understanding the context of these calls will shed light on how this function impacts the overall workflow and what potential dependencies exist. From there I can determine its relevance. |
| 10/2 | 2026/09/22 23:11 | tool | grepper |
0mArgs:{
"Expression": "folio_has_private"
}Results: {
"Output": "fs/fuse/dev.c=1123=static int fuse_try_move_folio(struct fuse_copy_state *cs, struct folio **foliop)\n--\nfs/fuse/dev.c-1169-\t\tgoto out_fallback_unlock;\nfs/fuse/dev.c:1170:\tif (WARN_ON(folio_has_private(oldfolio)))\nfs/fuse/dev.c-1171-\t\tgoto out_fallback_unlock;\n--\ninclude/linux/page-flags.h=1211=static inline bool folio_has_attached_private(const struct folio *folio)\n--\ninclude/linux/page-flags.h-1227-/**\ninclude/linux/page-flags.h:1228: * folio_has_private - Determine if folio has private stuff\ninclude/linux/page-flags.h-1229- * @folio: The folio to be checked\n--\ninclude/linux/page-flags.h-1233- */\ninclude/linux/page-flags.h:1234:static inline int folio_has_private(const struct folio *folio)\ninclude/linux/page-flags.h-1235-{\n--\nmm/internal.h=665=static inline bool folio_needs_release(struct folio *folio)\n--\nmm/internal.h-668-\nmm/internal.h:669:\treturn folio_has_private(folio) ||\nmm/internal.h-670-\t\t(mapping \u0026\u0026 mapping_release_always(mapping));\n--\nmm/migrate_device.c=542=static bool migrate_vma_check_page(struct page *page, struct page *fault_page)\n--\nmm/migrate_device.c-558-\tif (folio_mapping(folio))\nmm/migrate_device.c:559:\t\textra += 1 + folio_has_private(folio);\nmm/migrate_device.c-560-\n--\nmm/truncate.c=325=long mapping_evict_folio(struct address_space *mapping, struct folio *folio)\n--\nmm/truncate.c-333-\tif (folio_ref_count(folio) \u003e\nmm/truncate.c:334:\t\t\tfolio_nr_pages(folio) + folio_has_private(folio) + 1)\nmm/truncate.c-335-\t\treturn 0;\n--\nmm/truncate.c=622=int folio_unmap_invalidate(struct address_space *mapping, struct folio *folio,\n--\nmm/truncate.c-646-\nmm/truncate.c:647:\tBUG_ON(folio_has_private(folio));\nmm/truncate.c-648-\t__filemap_remove_folio(folio, NULL);\n"
} |
| 11/2 | 2026/09/22 23:11 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 26437 output: 50 thoughts: 1015 Thoughts: **Focusing the Fuzzer's Efforts** Okay, so I've been looking at this code and the impact of these changes. I can see that `folio_has_private` now has a more complex check, which is being used in a few key places like `folio_unmap_invalidate`, `folio_needs_release`, and in the logic for marking folios dirty. That's a definite red flag. Given that this is `WorthFuzzing`, which it clearly is – it's touching core memory management, filesystems, and buffer heads, all complex and prone to subtle bugs – I need to carefully select my `FocusSymbols` to guide the fuzzer. The goal is to avoid diluting the fuzzing effort with irrelevant functions, as per rule 4. I need to hone in on the specific feature logic or entrypoints. I've got to avoid those ubiquitous lifecycle hot-paths. So, that means skipping the generic allocators, deallocators, page fault handlers, and core synchronization primitives. Now, let's go function by function. I see assertions being added too, always a sign that we're pushing boundaries. Let's see what we can do. In `fs/erofs/data.c`, `erofs_onlinefolio_init` and `erofs_onlinefolio_end` seem like good targets. The `z_erofs_readahead` which uses `readahead_folio_last`, is another one. The f2fs file system has a lot of touching, so I'll put: `cancel_cluster_writeback`, `set_cluster_dirty`, `f2fs_write_compressed_pages`, `f2fs_compress_write_end_io`, `f2fs_should_update_outplace`, and `__get_segment_type_6` as targets. In the `md-bitmap.c` file, `write_file_page`, `free_buffers`, and `read_file_page` stand out as relevant functions. Now, for `mm/zsmalloc.c`, I've got `get_first_zpdesc`, `obj_allocated`, `reset_zpdesc`, and `create_page_chain`, and then I will search for the callers of those inline functions. |
| 12/2 | 2026/09/22 23:12 | tool | grepper |
0mArgs:{
"Expression": "(create_page_chain|reset_zpdesc|obj_allocated|get_first_zpdesc)",
"PathPrefix": "mm/zsmalloc.c"
}Results: {
"Output": "mm/zsmalloc.c=480=static inline void mod_zspage_inuse(struct zspage *zspage, int val)\n--\nmm/zsmalloc.c-484-\nmm/zsmalloc.c:485:static struct zpdesc *get_first_zpdesc(struct zspage *zspage)\nmm/zsmalloc.c-486-{\n--\nmm/zsmalloc.c=587=static int zs_stats_size_show(struct seq_file *s, void *v)\n--\nmm/zsmalloc.c-592-\tint objs_per_zspage;\nmm/zsmalloc.c:593:\tunsigned long obj_allocated, obj_used, pages_used, freeable;\nmm/zsmalloc.c-594-\tunsigned long total_objs = 0, total_used_objs = 0, total_pages = 0;\n--\nmm/zsmalloc.c-600-\t\t\t\"50%\", \"60%\", \"70%\", \"80%\", \"90%\", \"99%\", \"100%\",\nmm/zsmalloc.c:601:\t\t\t\"obj_allocated\", \"obj_used\", \"pages_used\",\nmm/zsmalloc.c-602-\t\t\t\"pages_per_zspage\", \"freeable\");\n--\nmm/zsmalloc.c-618-\nmm/zsmalloc.c:619:\t\tobj_allocated = class_stat_read(class, ZS_OBJS_ALLOCATED);\nmm/zsmalloc.c-620-\t\tobj_used = class_stat_read(class, ZS_OBJS_INUSE);\n--\nmm/zsmalloc.c-624-\t\tobjs_per_zspage = class-\u003eobjs_per_zspage;\nmm/zsmalloc.c:625:\t\tpages_used = obj_allocated / objs_per_zspage *\nmm/zsmalloc.c-626-\t\t\t\tclass-\u003epages_per_zspage;\n--\nmm/zsmalloc.c-628-\t\tseq_printf(s, \"%13lu %10lu %10lu %16d %8lu\\n\",\nmm/zsmalloc.c:629:\t\t\t obj_allocated, obj_used, pages_used,\nmm/zsmalloc.c-630-\t\t\t class-\u003epages_per_zspage, freeable);\nmm/zsmalloc.c-631-\nmm/zsmalloc.c:632:\t\ttotal_objs += obj_allocated;\nmm/zsmalloc.c-633-\t\ttotal_used_objs += obj_used;\n--\nmm/zsmalloc.c=820=static unsigned long handle_to_obj(unsigned long handle)\n--\nmm/zsmalloc.c-824-\nmm/zsmalloc.c:825:static inline bool obj_allocated(struct zpdesc *zpdesc, void *obj,\nmm/zsmalloc.c-826-\t\t\t\t unsigned long *phandle)\n--\nmm/zsmalloc.c-845-\nmm/zsmalloc.c:846:static void reset_zpdesc(struct zpdesc *zpdesc)\nmm/zsmalloc.c-847-{\n--\nmm/zsmalloc.c=853=static int trylock_zspage(struct zspage *zspage)\n--\nmm/zsmalloc.c-856-\nmm/zsmalloc.c:857:\tfor (cursor = get_first_zpdesc(zspage); cursor != NULL; cursor =\nmm/zsmalloc.c-858-\t\t\t\t\tget_next_zpdesc(cursor)) {\n--\nmm/zsmalloc.c-866-unlock:\nmm/zsmalloc.c:867:\tfor (cursor = get_first_zpdesc(zspage); cursor != fail; cursor =\nmm/zsmalloc.c-868-\t\t\t\t\tget_next_zpdesc(cursor))\n--\nmm/zsmalloc.c=890=static inline void __free_zspage_lockless(struct zspage *zspage)\n--\nmm/zsmalloc.c-896-\nmm/zsmalloc.c:897:\tnext = zpdesc = get_first_zpdesc(zspage);\nmm/zsmalloc.c-898-\tdo {\n--\nmm/zsmalloc.c-900-\t\tnext = get_next_zpdesc(zpdesc);\nmm/zsmalloc.c:901:\t\treset_zpdesc(zpdesc);\nmm/zsmalloc.c-902-\t\tzpdesc_unlock(zpdesc);\n--\nmm/zsmalloc.c=941=static void init_zspage(struct size_class *class, struct zspage *zspage)\n--\nmm/zsmalloc.c-944-\tunsigned long off = 0;\nmm/zsmalloc.c:945:\tstruct zpdesc *zpdesc = get_first_zpdesc(zspage);\nmm/zsmalloc.c-946-\n--\nmm/zsmalloc.c-984-\nmm/zsmalloc.c:985:static void create_page_chain(struct size_class *class, struct zspage *zspage,\nmm/zsmalloc.c-986-\t\t\t\tstruct zpdesc *zpdescs[])\n--\nmm/zsmalloc.c=1020=static struct zspage *alloc_zspage(struct zs_pool *pool,\n--\nmm/zsmalloc.c-1056-\nmm/zsmalloc.c:1057:\tcreate_page_chain(class, zspage, zpdescs);\nmm/zsmalloc.c-1058-\tinit_zspage(class, zspage);\n--\nmm/zsmalloc.c=1255=static unsigned long obj_malloc(struct zs_pool *pool,\n--\nmm/zsmalloc.c-1272-\tm_offset = offset_in_page(offset);\nmm/zsmalloc.c:1273:\tm_zpdesc = get_first_zpdesc(zspage);\nmm/zsmalloc.c-1274-\n--\nmm/zsmalloc.c=1562=static unsigned long find_alloced_obj(struct size_class *class,\n--\nmm/zsmalloc.c-1573-\twhile (offset \u003c PAGE_SIZE) {\nmm/zsmalloc.c:1574:\t\tif (obj_allocated(zpdesc, addr + offset, \u0026handle))\nmm/zsmalloc.c-1575-\t\t\tbreak;\n--\nmm/zsmalloc.c=1588=static void migrate_zspage(struct zs_pool *pool, struct zspage *src_zspage,\n--\nmm/zsmalloc.c-1593-\tint obj_idx = 0;\nmm/zsmalloc.c:1594:\tstruct zpdesc *s_zpdesc = get_first_zpdesc(src_zspage);\nmm/zsmalloc.c-1595-\tstruct size_class *class = pool-\u003esize_class[src_zspage-\u003eclass];\n--\nmm/zsmalloc.c=1679=static void lock_zspage(struct zspage *zspage)\n--\nmm/zsmalloc.c-1692-\t\tzspage_read_lock(zspage);\nmm/zsmalloc.c:1693:\t\tzpdesc = get_first_zpdesc(zspage);\nmm/zsmalloc.c-1694-\t\tif (zpdesc_trylock(zpdesc))\n--\nmm/zsmalloc.c=1717=static void replace_sub_page(struct size_class *class, struct zspage *zspage,\n--\nmm/zsmalloc.c-1724-\nmm/zsmalloc.c:1725:\tzpdesc = get_first_zpdesc(zspage);\nmm/zsmalloc.c-1726-\tdo {\n--\nmm/zsmalloc.c-1733-\nmm/zsmalloc.c:1734:\tcreate_page_chain(class, zspage, zpdescs);\nmm/zsmalloc.c-1735-\tfirst_obj_offset = get_first_obj_offset(oldzpdesc);\n--\nmm/zsmalloc.c=1742=static bool zs_page_isolate(struct page *page, isolate_mode_t mode)\n--\nmm/zsmalloc.c-1746-\t * (see free_zspage()). But if the page was already destroyed\nmm/zsmalloc.c:1747:\t * (see reset_zpdesc()), refuse isolation here.\nmm/zsmalloc.c-1748-\t */\n--\nmm/zsmalloc.c=1752=static int zs_page_migrate(struct page *newpage, struct page *page,\n--\nmm/zsmalloc.c-1826-\t\t\t\t\taddr += class-\u003esize) {\nmm/zsmalloc.c:1827:\t\tif (obj_allocated(zpdesc, addr, \u0026handle)) {\nmm/zsmalloc.c-1828-\n--\nmm/zsmalloc.c-1852-\nmm/zsmalloc.c:1853:\treset_zpdesc(zpdesc);\nmm/zsmalloc.c-1854-\tzpdesc_put(zpdesc);\n--\nmm/zsmalloc.c=1920=static void SetZsPageMovable(struct zs_pool *pool, struct zspage *zspage)\nmm/zsmalloc.c-1921-{\nmm/zsmalloc.c:1922:\tstruct zpdesc *zpdesc = get_first_zpdesc(zspage);\nmm/zsmalloc.c-1923-\n--\nmm/zsmalloc.c=1939=static unsigned long zs_can_compact(struct size_class *class)\n--\nmm/zsmalloc.c-1941-\tunsigned long obj_wasted;\nmm/zsmalloc.c:1942:\tunsigned long obj_allocated = class_stat_read(class, ZS_OBJS_ALLOCATED);\nmm/zsmalloc.c-1943-\tunsigned long obj_used = class_stat_read(class, ZS_OBJS_INUSE);\nmm/zsmalloc.c-1944-\nmm/zsmalloc.c:1945:\tif (obj_allocated \u003c= obj_used)\nmm/zsmalloc.c-1946-\t\treturn 0;\nmm/zsmalloc.c-1947-\nmm/zsmalloc.c:1948:\tobj_wasted = obj_allocated - obj_used;\nmm/zsmalloc.c-1949-\tobj_wasted /= class-\u003eobjs_per_zspage;\n"
} |
| 13/2 | 2026/09/22 23:12 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 30751 output: 32 thoughts: 43 Thoughts: Okay, let's break this down. **Analyzing `zs_page_migrate` in the Context of zsmalloc** Right, so `zs_page_migrate`... that's a key function in zsmalloc, and the code's telling me it's either non-static, meaning it's externally visible, or it's being *used* in `movable_operations`, specifically within the zsmalloc implementation. This immediately flags a couple of things. If it's exported, that implies a level of inter-module dependency, potentially for something like a user-space utility or perhaps a device driver interacting with the zsmalloc pool. If it's used inside `movable_operations`, that suggests it's crucial for the allocation and migration logic within zsmalloc itself, which makes sense. I need to dive into `zs_page_migrate` to understand its role. It's almost certainly involved in moving pages around within the zsmalloc pool. I'll need to look at its input parameters, what resources it accesses, and how it interacts with other zsmalloc components to build a mental model of how it works. |
| 14/2 | 2026/09/22 23:12 | tool | grepper |
0mArgs:{
"Expression": "zs_page_migrate",
"PathPrefix": "mm/zsmalloc.c"
}Results: {
"Output": "mm/zsmalloc.c=1742=static bool zs_page_isolate(struct page *page, isolate_mode_t mode)\n--\nmm/zsmalloc.c-1751-\nmm/zsmalloc.c:1752:static int zs_page_migrate(struct page *newpage, struct page *page,\nmm/zsmalloc.c-1753-\t\tenum migrate_mode mode)\n--\nmm/zsmalloc.c=1863=const struct movable_operations zsmalloc_mops = {\nmm/zsmalloc.c-1864-\t.isolate_page = zs_page_isolate,\nmm/zsmalloc.c:1865:\t.migrate_page = zs_page_migrate,\nmm/zsmalloc.c-1866-\t.putback_page = zs_page_putback,\n"
} |
| 15/2 | 2026/09/22 23:12 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 31296 output: 27 thoughts: 842 Thoughts: **Focusing on Key zsmalloc Operations and Avoiding Ubiquitous Functions** Okay, so I need to identify good focus symbols for these zsmalloc movable operations, specifically `zs_page_migrate` and `zs_page_isolate`, alongside `zs_malloc`, `zs_free`, and `zs_compact`. I need to ensure I'm not listing functions that are overly generic, as per the guidelines. Let's see… I've been looking at several files to see how similar code changes behave: `mm/migrate.c` shows `folio_migrate_flags` and `migrate_folio_unmap`. `mm/page-writeback.c` has `filemap_dirty_folio`. Then `mm/vmscan.c` shows `folio_check_dirty_writeback`, `mm/huge_memory.c` has `split_huge_pages_pid`, and `mm/hugetlb.c` shows `add_hugetlb_folio`. `drivers/md/md-bitmap.c` includes `read_file_page`, `free_buffers`, and `write_file_page`. I've checked `fs/erofs/data.c` and `fs/erofs/zdata.c`, finding `erofs_onlinefolio_init`, `erofs_onlinefolio_end`, and `z_erofs_readahead`. In `fs/f2fs/compress.c`, there's `f2fs_write_compressed_pages`, `cancel_cluster_writeback`, `set_cluster_dirty`, and `f2fs_compress_write_end_io`. Then there are `nfs_inode_add_request`, `nfs_inode_remove_request` in `fs/nfs/write.c`. And `ceph_dirty_folio` in `fs/ceph/addr.c`. Finally, in `kernel/events/ring_buffer.c`, I saw `rb_alloc_aux_page` and `rb_free_aux_page`. Now, according to the guideline on FocusSymbols, I need to remember: avoid generic lifecycle functions; instead, focus on specific feature logic and entry points. So, is `filemap_dirty_folio` too ubiquitous? Yes, it's likely called for any dirty folio in the page cache, making it too generic. But what about `z_erofs_readahead`? Ah, that's perfect! It's very specific to erofs readahead and it was changed directly to use the new `readahead_folio_last`. Same with `erofs_onlinefolio_init` and `erofs_onlinefolio_end` - very erofs-specific, changed logic and added assertions. `f2fs_write_compressed_pages` and `f2fs_compress_write_end_io` are definitely specific to f2fs compression - good candidates. Of course, `zs_page_migrate` is crucial as it specifically exercises the `obj_allocated` / `reset_zpdesc` / `first_zpdesc` checks during page migration within zsmalloc. `split_huge_pages_pid` is specific to the split_huge_pages debugfs/syscall interface. And `migrate_folio_unmap` seems specific to page migration. `read_file_page` and `free_buffers` in `md-bitmap.c`... `free_buffers` is static. Alright, let me check that... |
| 16/2 | 2026/09/22 23:12 | tool | grepper |
0mArgs:{
"Expression": "free_buffers",
"PathPrefix": "drivers/md/"
}Results: {
"Output": "drivers/md/md-bitmap.c=517=static void write_file_page(struct bitmap *bitmap, struct page *page, int wait)\n--\ndrivers/md/md-bitmap.c-534-\ndrivers/md/md-bitmap.c:535:static void free_buffers(struct page *page)\ndrivers/md/md-bitmap.c-536-{\n--\ndrivers/md/md-bitmap.c=621=static int read_file_page(struct file *file, unsigned long index,\n--\ndrivers/md/md-bitmap.c-625-}\ndrivers/md/md-bitmap.c:626:static void free_buffers(struct page *page)\ndrivers/md/md-bitmap.c-627-{\n--\ndrivers/md/md-bitmap.c=1067=static void md_bitmap_file_unmap(struct bitmap_storage *store)\n--\ndrivers/md/md-bitmap.c-1075-\t\tif (map[pages] != sb_page) /* 0 is sb_page, release it below */\ndrivers/md/md-bitmap.c:1076:\t\t\tfree_buffers(map[pages]);\ndrivers/md/md-bitmap.c-1077-\tkfree(map);\n--\ndrivers/md/md-bitmap.c-1080-\tif (sb_page)\ndrivers/md/md-bitmap.c:1081:\t\tfree_buffers(sb_page);\ndrivers/md/md-bitmap.c-1082-\n"
} |
| 17/2 | 2026/09/22 23:12 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 33303 output: 32 thoughts: 65 Thoughts: **Analyzing Potential Optimization Opportunities** Okay, let's break this down. First, I need to understand the scope and potential impact of some variables within these file. I'm focusing on optimization possibilities within the `md-bitmap.c` and `fs/erofs/zdata.c` files. Right now, I'm specifically thinking about `free_buffers` in `md-bitmap.c`. Since it's declared `static`, I immediately know the scope is limited to that particular translation unit. This could be a good starting point for analysis, particularly if this value can be more tightly controlled or optimized within that local context. Now, I need to evaluate the potential for similar optimizations in the `zdata` section. I need to check the declaration of `z_erofs_readahead` in `fs/erofs/zdata.c` to see if it is defined as `static`. Knowing if this variable has local or global scope is essential for determining if I can make any performance improvements there. The same considerations apply here as with the `free_buffers` variable. |
| 18/2 | 2026/09/22 23:12 | tool | grepper |
0mArgs:{
"Expression": "z_erofs_readahead",
"PathPrefix": "fs/erofs/"
}Results: {
"Output": "fs/erofs/zdata.c=1866=static int z_erofs_read_folio(struct file *file, struct folio *folio)\n--\nfs/erofs/zdata.c-1893-\nfs/erofs/zdata.c:1894:static void z_erofs_readahead(struct readahead_control *rac)\nfs/erofs/zdata.c-1895-{\n--\nfs/erofs/zdata.c=1925=const struct address_space_operations z_erofs_aops = {\nfs/erofs/zdata.c-1926-\t.read_folio = z_erofs_read_folio,\nfs/erofs/zdata.c:1927:\t.readahead = z_erofs_readahead,\nfs/erofs/zdata.c-1928-};\n"
} |
| 19/2 | 2026/09/22 23:12 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 33859 output: 32 thoughts: 234 Thoughts: **Understanding EROFS Readahead and Static Functions** Okay, so I'm looking at `z_erofs_readahead`, the readahead AOP within `fs/erofs/zdata.c`. Even though it's declared `static`, which usually means it's limited in scope to the file, it still has a symbol in the kernel's `kallsyms` and vmlinux symbol table. That's a key observation. It throws me off for a moment. I need to re-familiarize myself with the rules. Hang on, what does rule 4 say exactly? "HANDLING STATIC INLINE FUNCTIONS IN HEADERS (.h)..." Ah, yes, it’s about *inline* static functions *in headers*. It says those lack distinct symbol addresses and can't be directly targeted by symbol coverage filters. It specifically calls out ".h" files, emphasizing that the compiler inlines them. It also suggests that if changes are within inlined helpers, I should find non-static, feature-specific caller functions in ".c" files to exercise them. That’s because the non-inlined static functions *in .c files*, like this one, *do* have symbols. It's a critical distinction. So, since `z_erofs_readahead` is static, but *not* inline, in a .c file, it *should* have a symbol. I'll double-check `erofs_onlinefolio_init` and `erofs_onlinefolio_end`, just to be sure, and see if I have those right. |
| 20/2 | 2026/09/22 23:12 | tool | grepper |
0mArgs:{
"Expression": "erofs_onlinefolio_init",
"PathPrefix": "fs/erofs/"
}Results: {
"Output": "fs/erofs/data.c=197=int erofs_map_dev(struct super_block *sb, struct erofs_map_dev *map)\n--\nfs/erofs/data.c-249-\nfs/erofs/data.c:250:void erofs_onlinefolio_init(struct folio *folio)\nfs/erofs/data.c-251-{\n--\nfs/erofs/fileio.c=89=static int erofs_fileio_scan_folio(struct erofs_fileio *io,\n--\nfs/erofs/fileio.c-96-\nfs/erofs/fileio.c:97:\terofs_onlinefolio_init(folio);\nfs/erofs/fileio.c-98-\twhile (cur \u003c end) {\n--\nfs/erofs/fileio.c=198=int erofs_read_meta_folio(struct file *file, struct folio *folio)\n--\nfs/erofs/fileio.c-212-\t\t(io.dev.m_dif-\u003efsoff + io.dev.m_pa) \u003e\u003e 9;\nfs/erofs/fileio.c:213:\terofs_onlinefolio_init(folio);\nfs/erofs/fileio.c-214-\tbio_add_folio_nofail(\u0026io.rq-\u003ebio, folio, folio_size(folio), 0);\n--\nfs/erofs/internal.h=419=int erofs_map_blocks(struct inode *inode, struct erofs_map_blocks *map);\nfs/erofs/internal.h:420:void erofs_onlinefolio_init(struct folio *folio);\nfs/erofs/internal.h-421-void erofs_onlinefolio_split(struct folio *folio);\n--\nfs/erofs/zdata.c=1010=static int z_erofs_scan_folio(struct z_erofs_frontend *f,\n--\nfs/erofs/zdata.c-1021-\ttight = (bs == PAGE_SIZE);\nfs/erofs/zdata.c:1022:\terofs_onlinefolio_init(folio);\nfs/erofs/zdata.c-1023-\tdo {\n"
} |
| 21/2 | 2026/09/22 23:12 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 35030 output: 32 thoughts: 51 Thoughts: Here's my summary, as if I were thinking it: **Digging into EROFS Online Folio Handling** Okay, so I'm looking at how EROFS handles online folio initialization and cleanup. I remember seeing `erofs_onlinefolio_init` and `erofs_onlinefolio_end` exported in `internal.h`. Naturally, they're implemented in `fs/erofs/data.c`. Now, let's zoom in on `erofs_onlinefolio_end` specifically. I want to understand exactly what happens there. I need to refresh my understanding of the cleanup process to see if there's anything I can improve. |
| 22/2 | 2026/09/22 23:12 | tool | grepper |
0mArgs:{
"Expression": "erofs_onlinefolio_end",
"PathPrefix": "fs/erofs/"
}Results: {
"Output": "fs/erofs/data.c=261=void erofs_onlinefolio_split(struct folio *folio)\n--\nfs/erofs/data.c-265-\nfs/erofs/data.c:266:void erofs_onlinefolio_end(struct folio *folio, int err, bool dirty)\nfs/erofs/data.c-267-{\n--\nfs/erofs/fileio.c=22=static void erofs_fileio_ki_complete(struct kiocb *iocb, long ret)\n--\nfs/erofs/fileio.c-32-\t\t\tDBG_BUGON(folio_test_uptodate(fi.folio));\nfs/erofs/fileio.c:33:\t\t\terofs_onlinefolio_end(fi.folio, ret \u003c 0, false);\nfs/erofs/fileio.c-34-\t\t}\n--\nfs/erofs/fileio.c=89=static int erofs_fileio_scan_folio(struct erofs_fileio *io,\n--\nfs/erofs/fileio.c-152-\t}\nfs/erofs/fileio.c:153:\terofs_onlinefolio_end(folio, err, false);\nfs/erofs/fileio.c-154-\treturn err;\n--\nfs/erofs/internal.h=421=void erofs_onlinefolio_split(struct folio *folio);\nfs/erofs/internal.h:422:void erofs_onlinefolio_end(struct folio *folio, int err, bool dirty);\nfs/erofs/internal.h-423-struct inode *erofs_iget(struct super_block *sb, erofs_nid_t nid);\n--\nfs/erofs/zdata.c=1010=static int z_erofs_scan_folio(struct z_erofs_frontend *f,\n--\nfs/erofs/zdata.c-1097-\t} while ((end = cur) \u003e 0);\nfs/erofs/zdata.c:1098:\terofs_onlinefolio_end(folio, err, false);\nfs/erofs/zdata.c-1099-\treturn err;\n--\nfs/erofs/zdata.c=1153=static void z_erofs_fill_other_copies(struct z_erofs_backend *be, int err)\n--\nfs/erofs/zdata.c-1187-\t\tkunmap_local(dst);\nfs/erofs/zdata.c:1188:\t\terofs_onlinefolio_end(page_folio(bvi-\u003ebvec.page), err, true);\nfs/erofs/zdata.c-1189-\t\tlist_del(p);\n--\nfs/erofs/zdata.c=1254=static int z_erofs_decompress_pcluster(struct z_erofs_backend *be, bool eio)\n--\nfs/erofs/zdata.c-1359-\t\tif (!z_erofs_is_shortlived_page(page)) {\nfs/erofs/zdata.c:1360:\t\t\terofs_onlinefolio_end(page_folio(page), err, true);\nfs/erofs/zdata.c-1361-\t\t\tcontinue;\n"
} |
| 23/2 | 2026/09/22 23:12 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 36077 output: 37 thoughts: 120 Thoughts: **Analyzing EROFS and F2FS for Potential Optimization** Okay, so I'm looking at these EROFS functions, specifically `erofs_onlinefolio_init` and `erofs_onlinefolio_end`. The fact that they have non-static linkage is immediately interesting – they're globally accessible, which means they could potentially be called or interacted with from outside the core EROFS code. That opens up possibilities for external modules or subsystems to leverage these functions. And `z_erofs_readahead` is the specific function in erofs using `readahead_folio_last`. Now, I'm shifting my focus to F2FS as a point of comparison. I want to see how F2FS handles similar operations, particularly compression and write operations. The functions that are relevant here are `f2fs_write_compressed_pages` and `f2fs_compress_write_end_io`. The goal here is to check if these F2FS equivalents are also non-static. If they are, that gives us an interesting parallel to investigate. If they *aren't*, it might suggest a design difference that could be worth exploring. Understanding F2FS's choices here will give me some insight into possible optimization strategies for EROFS or identify potential performance bottlenecks. |
| 24/2 | 2026/09/22 23:12 | tool | grepper |
0mArgs:{
"Expression": "f2fs_compress_write_end_io",
"PathPrefix": "fs/f2fs/"
}Results: {
"Output": "fs/f2fs/compress.c=1275=static int f2fs_write_compressed_pages(struct compress_ctx *cc,\n--\nfs/f2fs/compress.c-1465-\nfs/f2fs/compress.c:1466:void f2fs_compress_write_end_io(struct bio *bio, struct folio *folio)\nfs/f2fs/compress.c-1467-{\n--\nfs/f2fs/data.c=333=static void f2fs_write_end_bio(struct bio *bio)\n--\nfs/f2fs/data.c-346-\t\tif (f2fs_is_compressed_page(folio)) {\nfs/f2fs/data.c:347:\t\t\tf2fs_compress_write_end_io(bio, folio);\nfs/f2fs/data.c-348-\t\t\tcontinue;\n--\nfs/f2fs/f2fs.h=4708=int f2fs_truncate_partial_cluster(struct inode *inode, u64 from, bool lock);\nfs/f2fs/f2fs.h:4709:void f2fs_compress_write_end_io(struct bio *bio, struct folio *folio);\nfs/f2fs/f2fs.h-4710-bool f2fs_is_compress_backend_ready(struct inode *inode);\n"
} |
| 25/2 | 2026/09/22 23:12 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 36865 output: 35 thoughts: 45 Thoughts: Okay, let's see. My mind is immediately drawn to the `f2fs_compress_write_end_io` function. Wait a minute... that one isn't declared static! That's interesting, I should remember that. Now, let's pivot to the related function, `f2fs_write_compressed_pages`. Ah, that one *is* static. Hmm, what does that imply? Let me examine the callers of that function and see what's going on within its scope. I need to understand the relationship between these functions, and whether this difference in static/non-static declaration has significance within the F2FS file system compression logic. Let's dig in and figure out why. |
| 26/2 | 2026/09/22 23:12 | tool | grepper |
0mArgs:{
"Expression": "f2fs_write_compressed_pages",
"PathPrefix": "fs/f2fs/"
}Results: {
"Output": "fs/f2fs/compress.c=1220=int f2fs_truncate_partial_cluster(struct inode *inode, u64 from, bool lock)\n--\nfs/f2fs/compress.c-1274-\nfs/f2fs/compress.c:1275:static int f2fs_write_compressed_pages(struct compress_ctx *cc,\nfs/f2fs/compress.c-1276-\t\t\t\t\tint *submitted,\n--\nfs/f2fs/compress.c=1593=int f2fs_write_multi_pages(struct compress_ctx *cc,\n--\nfs/f2fs/compress.c-1610-\nfs/f2fs/compress.c:1611:\t\terr = f2fs_write_compressed_pages(cc, submitted,\nfs/f2fs/compress.c-1612-\t\t\t\t\t\t\twbc, io_type);\n"
} |
| 27/2 | 2026/09/22 23:12 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 37335 output: 29 thoughts: 197 Thoughts: Okay, let me think this through. **Investigating Potential Data Corruption Vectors in f2fs with Zsmalloc and Related Code** Right, so `f2fs_write_multi_pages` is calling `f2fs_write_compressed_pages`. That's the starting point. Now, where else might data be getting handled that could lead to issues? I need to think about potential interactions and dependencies, especially when memory compression is involved. First, that `zs_page_migrate` function in `mm/zsmalloc.c` catches my eye. It's marked as `static`, which usually means it's localized, but then I remember that its *addresses* are in `zsmalloc_mops`. I need to understand *how* it's used through those function pointers, especially if it's involved in moving compressed pages around. This could be a critical area. Next, I'm thinking about how pages are *created* and *replaced* within the zsmalloc context. The `create_page_chain` function in `mm/zsmalloc.c` is called by both `alloc_zspage` and `replace_sub_page`. This means it could be part of a critical path, particularly if the chain manipulation or replacement process goes wrong. It warrants a closer look. Then, there are those inline `folio_detach_private` and `folio_attach_private` functions, found in `include/linux/pagemap.h`. Being inline, they're probably used all over the place, potentially in subtle ways. I'll need to remember how they function in the context of page ownership and metadata. I must know how and when the private data is detached and attached. Finally, I need to zoom out a bit and look at file systems that interact with the disk. I need to consider `write_file_page`, `free_buffers`, and `read_file_page` within `drivers/md/md-bitmap.c`. The fact that this file is linked with the concept of a bitmap has me curious. I'll need to check `md_bitmap_file_unmap` and `read_file_page`. I should be aware of any potential race conditions or inconsistencies during the file mapping and unmapping, especially with compressed data. Essentially, I must focus on any potential bitmap manipulation issues in conjunction with compressed data writes. |
| 28/2 | 2026/09/22 23:12 | tool | grepper |
0mArgs:{
"Expression": "read_file_page",
"PathPrefix": "drivers/md/"
}Results: {
"Output": "drivers/md/md-bitmap.c=535=static void free_buffers(struct page *page)\n--\ndrivers/md/md-bitmap.c-554- */\ndrivers/md/md-bitmap.c:555:static int read_file_page(struct file *file, unsigned long index,\ndrivers/md/md-bitmap.c-556-\t\tstruct bitmap *bitmap, unsigned long count, struct page *page)\n--\ndrivers/md/md-bitmap.c=618=static void write_file_page(struct bitmap *bitmap, struct page *page, int wait)\n--\ndrivers/md/md-bitmap.c-620-}\ndrivers/md/md-bitmap.c:621:static int read_file_page(struct file *file, unsigned long index,\ndrivers/md/md-bitmap.c-622-\t\tstruct bitmap *bitmap, unsigned long count, struct page *page)\n--\ndrivers/md/md-bitmap.c=817=static int md_bitmap_read_sb(struct bitmap *bitmap)\n--\ndrivers/md/md-bitmap.c-862-\ndrivers/md/md-bitmap.c:863:\t\terr = read_file_page(bitmap-\u003estorage.file, 0,\ndrivers/md/md-bitmap.c-864-\t\t\t\tbitmap, bytes, sb_page);\n--\ndrivers/md/md-bitmap.c=1321=static int md_bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)\n--\ndrivers/md/md-bitmap.c-1370-\t\tif (file)\ndrivers/md/md-bitmap.c:1371:\t\t\tret = read_file_page(file, i, bitmap, count, page);\ndrivers/md/md-bitmap.c-1372-\t\telse\n"
} |
| 29/2 | 2026/09/22 23:12 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 38528 output: 27 thoughts: 19 Thoughts: Okay, let's dive into this. Here's how I'd approach this task, as if these were my internal thoughts: **Checking `folio_migrate_flags` in `mm/migrate.c`** Alright, time to get my hands dirty. I need to refresh my memory on how folio migration works. The first thing I'm going to do is zero in on the `folio_migrate_flags` variable. It's in `mm/migrate.c`, so that's where I need to start. I know this structure holds some critical control information for the migration process, but I want to make sure I'm crystal clear on *which* flags are relevant to whatever issue I'm looking at. I'll need to review what they represent, how they're set, and how they're interpreted throughout the migration flow. This is probably going to involve tracing through some key functions like `migrate_folio`, `migrate_pages`, and potentially even some of the reclaim/oom handlers if there's any hint of that playing a role. I need to consider which flags are relevant depending on whether it's a synchronous migration, an asynchronous migration, whether it's related to NUMA balancing or some other constraint. This will likely provide clues about potential race conditions or synchronization issues, especially if the current problem involves contention around page migration. I'll also be mentally keeping track of any changes I've seen in recent patches, particularly around atomic operations or memory barriers, which could influence how those flags are handled and interpreted. |
| 30/2 | 2026/09/22 23:12 | tool | grepper |
0mArgs:{
"Expression": "folio_migrate_flags",
"PathPrefix": "mm/"
}Results: {
"Output": "mm/migrate.c=739=int migrate_huge_page_move_mapping(struct address_space *mapping,\n--\nmm/migrate.c-774- */\nmm/migrate.c:775:void folio_migrate_flags(struct folio *newfolio, struct folio *folio)\nmm/migrate.c-776-{\n--\nmm/migrate.c-862-}\nmm/migrate.c:863:EXPORT_SYMBOL(folio_migrate_flags);\nmm/migrate.c-864-\n--\nmm/migrate.c=869=static int __migrate_folio(struct address_space *mapping, struct folio *dst,\n--\nmm/migrate.c-889-\nmm/migrate.c:890:\tfolio_migrate_flags(dst, src);\nmm/migrate.c-891-\treturn 0;\n--\nmm/migrate_device.c=1109=static void __migrate_device_pages(unsigned long *src_pfns,\n--\nmm/migrate_device.c-1251-\t\t\telse\nmm/migrate_device.c:1252:\t\t\t\tfolio_migrate_flags(newfolio, folio);\nmm/migrate_device.c-1253-\t\t}\n"
} |
| 31/2 | 2026/09/22 23:12 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 39214 output: 29 thoughts: 42 Thoughts: Okay, here's my take on those thoughts, framed as an expert's internal monologue: **Investigating Potential Dependencies for Folio Migration** Alright, so `folio_migrate_flags` is an *exported* symbol, meaning it's intended to be used outside of mm/migrate.c. That's a good starting point. This suggests it's likely a flag that other parts of the kernel might set or check during the migration process. Now, let's see where *else* this might come up. I'm going to quickly check `split_huge_pages_pid` in `mm/huge_memory.c`. Given that we're talking about migration, huge pages, and potentially splitting them... it's a likely point of interest. There could be some interaction there that I'll need to understand better. I need to figure out the interplay between folio migration, the process IDs related to splitting huge pages, and what this might mean for potential issues or optimizations. Let's see what that function does... |
| 32/2 | 2026/09/22 23:12 | tool | grepper |
0mArgs:{
"Expression": "split_huge_pages_pid",
"PathPrefix": "mm/"
}Results: {
"Output": "mm/huge_memory.c=4761=static inline bool vma_not_suitable_for_thp_split(struct vm_area_struct *vma)\n--\nmm/huge_memory.c-4774-\nmm/huge_memory.c:4775:static int split_huge_pages_pid(int pid, unsigned long vaddr_start,\nmm/huge_memory.c-4776-\t\t\t\tunsigned long vaddr_end, unsigned int new_order,\n--\nmm/huge_memory.c=4962=static ssize_t split_huge_pages_write(struct file *file, const char __user *buf,\n--\nmm/huge_memory.c-5028-\nmm/huge_memory.c:5029:\tret = split_huge_pages_pid(pid, vaddr_start, vaddr_end, new_order,\nmm/huge_memory.c-5030-\t\t\tin_folio_offset);\n"
} |
| 33/2 | 2026/09/22 23:12 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 39753 output: 28 thoughts: 48 Thoughts: Okay, here's my interpretation of those thoughts, tailored for an expert audience, presented in the first person: **Analyzing the Split Huge Pages and Migration Mechanisms** Okay, so I'm looking at `split_huge_pages_write`. That's the critical debugfs file handler for controlling huge page splitting, specifically when interacting with `/sys/kernel/debug/split_huge_pages`. Right, so I immediately think of the implications for testing and debugging huge page management. Any change there could seriously impact performance and memory utilization. I need to keep in mind any potential race conditions here. Then, my mind jumps to `migrate_folio_unmap` within `mm/migrate.c`. That's where the *real* work gets done, isn't it? Folio migration means moving the *actual* memory content and the associated metadata, but this is the *unmapping* stage. I wonder how the splitting interacts with the migration strategy and if there might be potential inconsistencies or double frees. Are there safeguards in place, or is it expected the caller has taken the proper locks? I need to look closer at the locking strategy within the folio migration code! A proper understanding of both those modules, in this context, is important. |
| 34/2 | 2026/09/22 23:13 | tool | grepper |
0mArgs:{
"Expression": "migrate_folio_unmap",
"PathPrefix": "mm/"
}Results: {
"Output": "mm/migrate.c=1199=static void migrate_folio_done(struct folio *src,\n--\nmm/migrate.c-1211-/* Obtain the lock on page, remove all ptes. */\nmm/migrate.c:1212:static int migrate_folio_unmap(new_folio_t get_new_folio,\nmm/migrate.c-1213-\t\tfree_folio_t put_new_folio, unsigned long private,\n--\nmm/migrate.c=1362=static int migrate_folio_move(free_folio_t put_new_folio, unsigned long private,\n--\nmm/migrate.c-1460-/*\nmm/migrate.c:1461: * Counterpart of migrate_folio_unmap() and migrate_folio_move() for hugetlb\nmm/migrate.c-1462- * folio migration.\n--\nmm/migrate.c=1810=static int migrate_pages_batch(struct list_head *from,\n--\nmm/migrate.c-1916-\nmm/migrate.c:1917:\t\t\trc = migrate_folio_unmap(get_new_folio, put_new_folio,\nmm/migrate.c-1918-\t\t\t\t\tprivate, folio, \u0026dst, mode, ret_folios);\n"
} |
| 35/2 | 2026/09/22 23:13 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 40418 output: 30 thoughts: 47 Thoughts: Okay, here's my interpretation of that thought process, tailored for an expert audience: **Analyzing Memory Migration and Dirty Page Handling** Alright, my immediate focus is on memory migration within the kernel, specifically concerning `migrate_pages_batch` and `migrate_folio_unmap` functions, found within `mm/migrate.c`. I need to understand how these routines interact, and where potential inefficiencies or issues might exist. Given the context, I want to cross-reference their behavior against the mechanics of dirty page management. To that end, my next step is to examine the `folio_check_dirty_writeback` function. This function resides in `mm/vmscan.c` and is the likely candidate for coordinating how dirty folios are handled during migration. By understanding this function I can understand when dirty pages are written back, and how this relates to my migration efforts. I'll be particularly interested in whether `migrate_pages_batch` or `migrate_folio_unmap` has any interactions with the folio state which can cause or exacerbate writeback, and whether these could be optimized. |
| 36/2 | 2026/09/22 23:13 | tool | grepper |
0mArgs:{
"Expression": "folio_check_dirty_writeback",
"PathPrefix": "mm/"
}Results: {
"Output": "mm/vmscan.c=942=static enum folio_references folio_check_references(struct folio *folio,\n--\nmm/vmscan.c-1008-/* Check if a folio is dirty or under writeback */\nmm/vmscan.c:1009:static void folio_check_dirty_writeback(struct folio *folio,\nmm/vmscan.c-1010-\t\t\t\t bool *dirty, bool *writeback)\n--\nmm/vmscan.c=1132=static unsigned int shrink_folio_list(struct list_head *folio_list,\n--\nmm/vmscan.c-1198-\t\t */\nmm/vmscan.c:1199:\t\tfolio_check_dirty_writeback(folio, \u0026dirty, \u0026writeback);\nmm/vmscan.c-1200-\t\tif (dirty || writeback)\n"
} |
| 37/2 | 2026/09/22 23:13 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 40948 output: 29 thoughts: 69 Thoughts: Here's my analysis of those code references: **Diving into Memory Management - Page Reclaim and HugeTLB Folios** Okay, so `shrink_folio_list`. Right, that's tucked away in `mm/vmscan.c`. It's a core component of page reclaim, and I know it's a performance-critical path, even if the surrounding logic, like `folio_check_dirty_writeback`, is more specific. The fact that it's a hot path is definitely something to keep in mind, we really don't want to choke the machine with it. Now, I'm thinking we should move over to `mm/hugetlb.c`. Specifically, I'm going to take a look at `add_hugetlb_folio`. Let's see how that routine handles folios in the context of HugeTLB. It'll be interesting to understand the interplay between these two memory management areas. I suspect there will be some interesting overlap, with `shrink_folio_list` getting involved. I have a feeling this is where we'll find some insights. |
| 38/2 | 2026/09/22 23:13 | tool | grepper |
0mArgs:{
"Expression": "add_hugetlb_folio",
"PathPrefix": "mm/"
}Results: {
"Output": "mm/hugetlb.c=1391=void remove_hugetlb_folio(struct hstate *h, struct folio *folio,\n--\nmm/hugetlb.c-1429-\nmm/hugetlb.c:1430:void add_hugetlb_folio(struct hstate *h, struct folio *folio,\nmm/hugetlb.c-1431-\t\t bool adjust_surplus)\n--\nmm/hugetlb.c=1457=static void __update_and_free_hugetlb_folio(struct hstate *h,\n--\nmm/hugetlb.c-1486-\t\t */\nmm/hugetlb.c:1487:\t\tadd_hugetlb_folio(h, folio, true);\nmm/hugetlb.c-1488-\t\tspin_unlock_irq(\u0026hugetlb_lock);\n--\nmm/hugetlb.c=1583=static void bulk_vmemmap_restore_error(struct hstate *h,\n--\nmm/hugetlb.c-1619-\t\t\t\tspin_lock_irq(\u0026hugetlb_lock);\nmm/hugetlb.c:1620:\t\t\t\tadd_hugetlb_folio(h, folio, true);\nmm/hugetlb.c-1621-\t\t\t\tspin_unlock_irq(\u0026hugetlb_lock);\n--\nmm/hugetlb.c=1964=int dissolve_free_hugetlb_folio(struct folio *folio)\n--\nmm/hugetlb.c-1986-\t\t * here would leave it on the free list and, on vmemmap restore\nmm/hugetlb.c:1987:\t\t * failure, the add_hugetlb_folio() rollback corrupts that list.\nmm/hugetlb.c-1988-\t\t */\n--\nmm/hugetlb.c-2036-\t\t\t\tspin_lock_irq(\u0026hugetlb_lock);\nmm/hugetlb.c:2037:\t\t\t\tadd_hugetlb_folio(h, folio, adjust_surplus);\nmm/hugetlb.c-2038-\t\t\t\tif (!adjust_surplus)\n--\nmm/hugetlb.c=4022=long demote_pool_huge_page(struct hstate *src, nodemask_t *nodes_allowed,\n--\nmm/hugetlb.c-4101-\t\t\tlist_del(\u0026folio-\u003elru);\nmm/hugetlb.c:4102:\t\t\tadd_hugetlb_folio(src, folio, false);\nmm/hugetlb.c-4103-\n--\nmm/hugetlb.c-4109-\t\t\tlist_del(\u0026folio-\u003elru);\nmm/hugetlb.c:4110:\t\t\tadd_hugetlb_folio(src, folio, true);\nmm/hugetlb.c-4111-\n--\nmm/hugetlb_internal.h=95=extern void remove_hugetlb_folio(struct hstate *h, struct folio *folio,\nmm/hugetlb_internal.h-96-\t\t\t\t bool adjust_surplus);\nmm/hugetlb_internal.h:97:extern void add_hugetlb_folio(struct hstate *h, struct folio *folio,\nmm/hugetlb_internal.h-98-\t\t\t bool adjust_surplus);\n"
} |
| 39/2 | 2026/09/22 23:13 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 42128 output: 34 thoughts: 38 Thoughts: Here's a breakdown of my thought process: **Diving into the Filesystem Encryption Code** Okay, so I need to understand how page cache blocks are handled during encryption and decryption, and how the kernel manages those temporary bounce pages. I'm going to start by examining two crucial functions in `fs/crypto/crypto.c`. Specifically, I need to check how `fscrypt_encrypt_pagecache_blocks` is implemented, which would likely handle the actual encryption process when writing to the page cache, and then how `fscrypt_free_bounce_page` works, since this likely handles the memory that's allocated for the "bounce pages." I'm expecting to find the nitty-gritty details of the block-level transformations and any related memory management in this area. It's a key part of ensuring data integrity and performance for filesystem encryption. |
| 40/2 | 2026/09/22 23:13 | tool | grepper |
0mArgs:{
"Expression": "fscrypt_encrypt_pagecache_blocks",
"PathPrefix": "fs/crypto/"
}Results: {
"Output": "fs/crypto/crypto.c=45=static struct page *fscrypt_alloc_bounce_page(gfp_t gfp_flags)\n--\nfs/crypto/crypto.c-60- *\nfs/crypto/crypto.c:61: * Free a bounce page that was allocated by fscrypt_encrypt_pagecache_blocks().\nfs/crypto/crypto.c-62- */\n--\nfs/crypto/crypto.c=101=static int fscrypt_crypt_data_unit(const struct fscrypt_inode_info *ci,\n--\nfs/crypto/crypto.c-148-/**\nfs/crypto/crypto.c:149: * fscrypt_encrypt_pagecache_blocks() - Encrypt data from a pagecache folio\nfs/crypto/crypto.c-150- * @folio: the locked pagecache folio containing the data to encrypt\n--\nfs/crypto/crypto.c-172- */\nfs/crypto/crypto.c:173:struct page *fscrypt_encrypt_pagecache_blocks(struct folio *folio,\nfs/crypto/crypto.c-174-\t\tsize_t len, size_t offs, gfp_t gfp_flags)\n--\nfs/crypto/crypto.c-214-}\nfs/crypto/crypto.c:215:EXPORT_SYMBOL(fscrypt_encrypt_pagecache_blocks);\nfs/crypto/crypto.c-216-\n"
} |
| 41/2 | 2026/09/22 23:13 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 42745 output: 20 thoughts: 233 Thoughts: **Analyzing the Scope of This Patch** Okay, let's dive into this patch and understand its full implications. First things first, I need to get a handle on what's been touched. It looks like the modified code affects quite a few different areas, and I want to be absolutely thorough in my assessment. I see: * `EROFS_FS` and `F2FS_FS` in the filesystems. * `ZSMALLOC` which suggests memory management is involved. * `MD_BITMAP`, interesting, that has an impact on storage. * `HUGETLB_PAGE` and `TRANSPARENT_HUGEPAGE`, which are relevant to huge page handling. I'll need to pay close attention to the implications here. * `MIGRATION`, also related to memory management. * `FS_ENCRYPTION`, potentially security implications to consider. * `PERF_EVENTS` in kernel events, could affect tracing or profiling. * `NFS_FS` and `CEPH_FS`, networking file systems as well. But wait a minute, I can't just rely on those identifiers alone. To be truly effective, I need to get the precise Kconfig options. I need to consult the Kconfig files for each of these areas, so I need to go and look in fs/erofs/Kconfig, fs/f2fs/Kconfig, mm/Kconfig, and so on. Understanding the exact configuration options is key to understanding the scope and potential side effects of this change. Once I have the detailed configuration information, then I can really start to evaluate the patch with confidence. |
| 42/2 | 2026/09/22 23:13 | tool | grepper |
0mArgs:{
"Expression": "config EROFS_FS"
}Results: {
"Output": "fs/erofs/Kconfig-2-\nfs/erofs/Kconfig:3:config EROFS_FS\nfs/erofs/Kconfig-4-\ttristate \"EROFS filesystem support\"\n--\nfs/erofs/Kconfig-49-\nfs/erofs/Kconfig:50:config EROFS_FS_DEBUG\nfs/erofs/Kconfig-51-\tbool \"EROFS debugging feature\"\n--\nfs/erofs/Kconfig-59-\nfs/erofs/Kconfig:60:config EROFS_FS_XATTR\nfs/erofs/Kconfig-61-\tbool \"EROFS extended attributes\"\n--\nfs/erofs/Kconfig-70-\nfs/erofs/Kconfig:71:config EROFS_FS_POSIX_ACL\nfs/erofs/Kconfig-72-\tbool \"EROFS Access Control Lists\"\n--\nfs/erofs/Kconfig-84-\nfs/erofs/Kconfig:85:config EROFS_FS_SECURITY\nfs/erofs/Kconfig-86-\tbool \"EROFS Security Labels\"\n--\nfs/erofs/Kconfig-97-\nfs/erofs/Kconfig:98:config EROFS_FS_BACKED_BY_FILE\nfs/erofs/Kconfig-99-\tbool \"File-backed EROFS filesystem support\"\n--\nfs/erofs/Kconfig-111-\nfs/erofs/Kconfig:112:config EROFS_FS_ZIP\nfs/erofs/Kconfig-113-\tbool \"EROFS Data Compression Support\"\n--\nfs/erofs/Kconfig-121-\nfs/erofs/Kconfig:122:config EROFS_FS_ZIP_LZMA\nfs/erofs/Kconfig-123-\tbool \"EROFS LZMA compressed data support\"\n--\nfs/erofs/Kconfig-133-\nfs/erofs/Kconfig:134:config EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS\nfs/erofs/Kconfig-135-\tint \"EROFS LZMA default maximum decompression streams\" if SMP\n--\nfs/erofs/Kconfig-150-\nfs/erofs/Kconfig:151:config EROFS_FS_ZIP_DEFLATE\nfs/erofs/Kconfig-152-\tbool \"EROFS DEFLATE compressed data support\"\n--\nfs/erofs/Kconfig-161-\nfs/erofs/Kconfig:162:config EROFS_FS_ZIP_ZSTD\nfs/erofs/Kconfig-163-\tbool \"EROFS Zstandard compressed data support\"\n--\nfs/erofs/Kconfig-172-\nfs/erofs/Kconfig:173:config EROFS_FS_ZIP_ACCEL\nfs/erofs/Kconfig-174-\tbool \"EROFS hardware decompression support\"\n--\nfs/erofs/Kconfig-186-\nfs/erofs/Kconfig:187:config EROFS_FS_PCPU_KTHREAD\nfs/erofs/Kconfig-188-\tbool \"EROFS per-cpu decompression kthread workers\"\n--\nfs/erofs/Kconfig-195-\nfs/erofs/Kconfig:196:config EROFS_FS_PCPU_KTHREAD_HIPRI\nfs/erofs/Kconfig-197-\tbool \"EROFS high priority per-CPU kthread workers\"\n--\nfs/erofs/Kconfig-205-\nfs/erofs/Kconfig:206:config EROFS_FS_PAGE_CACHE_SHARE\nfs/erofs/Kconfig-207-\tbool \"EROFS page cache share support (experimental)\"\n"
} |
| 43/2 | 2026/09/22 23:13 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 44282 output: 29 thoughts: 12 Thoughts: Here's my take on the process, considering I'm examining `fs/erofs/Makefile`: **Diving into the EROFS Build Configuration** Okay, so I'm looking at the `fs/erofs/Makefile`. I immediately need to understand the build process for EROFS. I'm thinking about the dependencies here, the flags being used, and how it all ties into the kernel's overall build system. I need to quickly grasp how the EROFS module is compiled, linked, and potentially integrated with the broader filesystem infrastructure. I'm expecting to see things like object file definitions, compiler flags (`-I`, `-D`, `-O`, etc.), dependencies on specific kernel headers or libraries, and potentially rules for generating or manipulating EROFS-specific tools or utilities. I'll be keeping an eye out for any conditional compilation directives that might be based on kernel versions or configuration options. Ultimately, I'm trying to develop a clear mental model of the EROFS build flow and identify any potential areas for optimization, customization, or debugging. |
| 44/2 | 2026/09/22 23:13 | tool | grepper |
0mArgs:{
"Expression": "zdata\\.o",
"PathPrefix": "fs/erofs/"
}Results: {
"Output": "fs/erofs/Makefile=5=erofs-$(CONFIG_EROFS_FS_XATTR) += xattr.o\nfs/erofs/Makefile:6:erofs-$(CONFIG_EROFS_FS_ZIP) += decompressor.o zmap.o zdata.o zutil.o\nfs/erofs/Makefile-7-erofs-$(CONFIG_EROFS_FS_ZIP_LZMA) += decompressor_lzma.o\n"
} |
| 45/2 | 2026/09/22 23:13 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 44666 output: 29 thoughts: 41 Thoughts: Okay, here's my interpretation of those thoughts, tailored for an expert audience, presented in the first person: **Erofs and F2fs Considerations for Compressed Data** Alright, let's see, the inclusion of `CONFIG_EROFS_FS` and `CONFIG_EROFS_FS_ZIP` for the build configuration related to `zdata.o`... I'm immediately thinking this is about incorporating compressed data support, likely for read-only filesystem implementations. Specifically, `EROFS` seems to be the focus here with potential zip or similar compression support baked right into the filesystem. I wonder what specific data compression algorithm is being leveraged, or if this is the framework for including multiple methods. Then, there's the mention of `fs/f2fs/compress.c`. This is intriguing! F2FS is a log-structured filesystem, so it's a completely different architecture compared to EROFS. I'm guessing this might mean we're seeing integration or cross-pollination of compression techniques here. It's possible that someone is implementing compression support that may be applied in either EROFS or F2FS implementations. More probably, maybe someone is researching alternative compression modules in either the EROFS/F2FS contexts, or even working to move compression modules over to F2FS from EROFS. I should investigate the commit history and changes around these configurations, because compression on these file systems would influence performance in different ways. The implications here involve a lot of factors to consider, including CPU load, flash wear, and decompression speed. This warrants further investigation to understand the scope and rationale for these changes. |
| 46/2 | 2026/09/22 23:13 | tool | grepper |
0mArgs:{
"Expression": "compress\\.o",
"PathPrefix": "fs/f2fs/"
}Results: {
"Output": "fs/f2fs/Makefile=10=f2fs-$(CONFIG_FS_VERITY) += verity.o\nfs/f2fs/Makefile:11:f2fs-$(CONFIG_F2FS_FS_COMPRESSION) += compress.o\nfs/f2fs/Makefile-12-f2fs-$(CONFIG_F2FS_IOSTAT) += iostat.o\n"
} |
| 47/2 | 2026/09/22 23:13 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 45184 output: 25 thoughts: 45 Thoughts: Here's my take on those thoughts: **F2FS and Zsmalloc Considerations** Okay, so I'm looking at these kernel configuration options: `CONFIG_F2FS_FS` and `CONFIG_F2FS_FS_COMPRESSION`. Pretty standard stuff for enabling the F2FS filesystem and its compression capabilities. I need to make sure those are properly set for the intended environment. Then I see `CONFIG_ZSMALLOC`, which catches my attention. I know that's about memory management. Given that I'm looking at filesystem-related configurations, I need to understand how zsmalloc might interplay here. Is it being used for F2FS metadata? General memory allocation for the filesystem? I really need to check `mm/Makefile` to see how zsmalloc is integrated and used within the memory management subsystem and if it influences or connects to F2FS. This is a critical point to clarify its role. |
| 48/2 | 2026/09/22 23:13 | tool | grepper |
0mArgs:{
"Expression": "zsmalloc",
"PathPrefix": "mm/"
}Results: {
"Output": "mm/Kconfig=133=config ZSMALLOC_STAT\nmm/Kconfig:134:\tbool \"Export zsmalloc statistics\"\nmm/Kconfig-135-\tselect DEBUG_FS\nmm/Kconfig-136-\thelp\nmm/Kconfig:137:\t This option enables code in the zsmalloc to collect various\nmm/Kconfig:138:\t statistics about what's happening in zsmalloc and exports that\nmm/Kconfig-139-\t information to userspace via debugfs.\n--\nmm/Kconfig=142=config ZSMALLOC_CHAIN_SIZE\n--\nmm/Kconfig-154-\t per zspage. This can also result in different configurations of\nmm/Kconfig:155:\t the pool, as zsmalloc merges size classes with similar\nmm/Kconfig-156-\t characteristics.\nmm/Kconfig-157-\nmm/Kconfig:158:\t For more information, see zsmalloc documentation.\nmm/Kconfig-159-\n--\nmm/Makefile=119=obj-$(CONFIG_MEMORY_ISOLATION) += page_isolation.o\nmm/Makefile:120:obj-$(CONFIG_ZSMALLOC)\t+= zsmalloc.o\nmm/Makefile-121-obj-$(CONFIG_GENERIC_EARLY_IOREMAP) += early_ioremap.o\n--\nmm/migrate.c=55=static const struct movable_operations *offline_movable_ops;\nmm/migrate.c:56:static const struct movable_operations *zsmalloc_movable_ops;\nmm/migrate.c-57-\nmm/migrate.c=58=int set_movable_ops(const struct movable_operations *ops, enum pagetype type)\n--\nmm/migrate.c-69-\t\tbreak;\nmm/migrate.c:70:\tcase PGTY_zsmalloc:\nmm/migrate.c:71:\t\tif (zsmalloc_movable_ops \u0026\u0026 ops)\nmm/migrate.c-72-\t\t\treturn -EBUSY;\nmm/migrate.c:73:\t\tzsmalloc_movable_ops = ops;\nmm/migrate.c-74-\t\tbreak;\n--\nmm/migrate.c=82=static const struct movable_operations *page_movable_ops(struct page *page)\n--\nmm/migrate.c-94-\tif (PageZsmalloc(page))\nmm/migrate.c:95:\t\treturn zsmalloc_movable_ops;\nmm/migrate.c-96-\n--\nmm/zpdesc.h-1-/* SPDX-License-Identifier: GPL-2.0 */\nmm/zpdesc.h:2:/* zpdesc.h: zsmalloc pool memory descriptor\nmm/zpdesc.h-3- *\n--\nmm/zpdesc.h-13-/*\nmm/zpdesc.h:14: * struct zpdesc -\tMemory descriptor for zsmalloc pool memory.\nmm/zpdesc.h:15: * @flags:\t\tPage flags, mostly unused by zsmalloc.\nmm/zpdesc.h-16- * @lru:\t\tIndirectly used by page migration.\nmm/zpdesc.h-17- * @movable_ops:\tUsed by page migration.\nmm/zpdesc.h:18: * @next:\t\tNext zpdesc in a zspage in zsmalloc pool.\nmm/zpdesc.h:19: * @handle:\t\tFor huge zspage in zsmalloc pool.\nmm/zpdesc.h-20- * @zspage:\t\tPoints to the zspage this zpdesc is a part of.\nmm/zpdesc.h:21: * @first_obj_offset:\tFirst object offset in zsmalloc pool.\nmm/zpdesc.h-22- * @_refcount:\t\tThe number of references to this zpdesc.\n--\nmm/zpdesc.h=32=struct zpdesc {\n--\nmm/zpdesc.h-42-\t * Only the lower 24 bits are available for offset, limiting a page\nmm/zpdesc.h:43:\t * to 16 MiB. The upper 8 bits are reserved for PGTY_zsmalloc.\nmm/zpdesc.h-44-\t *\n--\nmm/zpdesc.h=63=static_assert(sizeof(struct zpdesc) \u003c= sizeof(struct page));\n--\nmm/zpdesc.h-81- *\nmm/zpdesc.h:82: * Zpdescs are descriptors for zsmalloc memory. The memory itself is allocated\nmm/zpdesc.h:83: * as folios that contain the zsmalloc objects, and zpdesc uses specific\nmm/zpdesc.h-84- * fields in the first struct page of the folio - those fields are now accessed\n--\nmm/zpdesc.h=155=static inline void __zpdesc_set_movable(struct zpdesc *zpdesc)\n--\nmm/zpdesc.h-159-\nmm/zpdesc.h:160:static inline void __zpdesc_set_zsmalloc(struct zpdesc *zpdesc)\nmm/zpdesc.h-161-{\n--\nmm/zsmalloc.c-3-/*\nmm/zsmalloc.c:4: * zsmalloc memory allocator\nmm/zsmalloc.c-5- *\n--\nmm/zsmalloc.c-42-#include \u003clinux/debugfs.h\u003e\nmm/zsmalloc.c:43:#include \u003clinux/zsmalloc.h\u003e\nmm/zsmalloc.c-44-#include \u003clinux/fs.h\u003e\n--\nmm/zsmalloc.c=169=static_assert(ZS_OBJ_IDX_BITS \u003e= ZS_PAGES_PER_ZSPAGE_BITS,\nmm/zsmalloc.c:170:\t \"zsmalloc: ZS_MIN_ALLOC_SIZE would exceed ZS_MAX_ALLOC_SIZE\");\nmm/zsmalloc.c-171-\n--\nmm/zsmalloc.c=522=static struct size_class *zspage_class(struct zs_pool *pool,\n--\nmm/zsmalloc.c-528-/*\nmm/zsmalloc.c:529: * zsmalloc divides the pool into various size classes where each\nmm/zsmalloc.c-530- * class maintains a list of zspages where each zspage is divided\n--\nmm/zsmalloc.c=570=static void __init zs_stat_init(void)\n--\nmm/zsmalloc.c-576-\nmm/zsmalloc.c:577:\tzs_stat_root = debugfs_create_dir(\"zsmalloc\", NULL);\nmm/zsmalloc.c-578-}\n--\nmm/zsmalloc.c=1020=static struct zspage *alloc_zspage(struct zs_pool *pool,\n--\nmm/zsmalloc.c-1050-\t\t}\nmm/zsmalloc.c:1051:\t\t__zpdesc_set_zsmalloc(zpdesc);\nmm/zsmalloc.c-1052-\n--\nmm/zsmalloc.c=1093=static bool zspage_empty(struct zspage *zspage)\n--\nmm/zsmalloc.c-1098-/**\nmm/zsmalloc.c:1099: * zs_lookup_class_index() - Returns index of the zsmalloc \u0026size_class\nmm/zsmalloc.c-1100- * that hold objects of the provided size.\nmm/zsmalloc.c:1101: * @pool: zsmalloc pool to use\nmm/zsmalloc.c-1102- * @size: object size\n--\nmm/zsmalloc.c-1105- *\nmm/zsmalloc.c:1106: * Return: the index of the zsmalloc \u0026size_class that hold objects of the\nmm/zsmalloc.c-1107- * provided size.\n--\nmm/zsmalloc.c=1234=EXPORT_SYMBOL_GPL(zs_obj_write);\n--\nmm/zsmalloc.c-1237- * zs_huge_class_size() - Returns the size (in bytes) of the first huge\nmm/zsmalloc.c:1238: * zsmalloc \u0026size_class.\nmm/zsmalloc.c:1239: * @pool: zsmalloc pool to use\nmm/zsmalloc.c-1240- *\n--\nmm/zsmalloc.c-1246- *\nmm/zsmalloc.c:1247: * Return: the size (in bytes) of the first huge zsmalloc \u0026size_class.\nmm/zsmalloc.c-1248- */\n--\nmm/zsmalloc.c=1752=static int zs_page_migrate(struct page *newpage, struct page *page,\n--\nmm/zsmalloc.c-1811-\t/* We're committed, tell the world that this is a Zsmalloc page. */\nmm/zsmalloc.c:1812:\t__zpdesc_set_zsmalloc(newzpdesc);\nmm/zsmalloc.c-1813-\n--\nmm/zsmalloc.c=1859=static void zs_page_putback(struct page *page)\n--\nmm/zsmalloc.c-1862-\nmm/zsmalloc.c:1863:const struct movable_operations zsmalloc_mops = {\nmm/zsmalloc.c-1864-\t.isolate_page = zs_page_isolate,\n--\nmm/zsmalloc.c=2019=unsigned long zs_compact(struct zs_pool *pool)\n--\nmm/zsmalloc.c-2028-\t * will increase pool-\u003elock contention, which will impact other\nmm/zsmalloc.c:2029:\t * zsmalloc operations that need pool-\u003elock.\nmm/zsmalloc.c-2030-\t */\n--\nmm/zsmalloc.c=2109=static int calculate_zspage_chain_size(int class_size)\n--\nmm/zsmalloc.c-2134- * This function must be called before anything when using\nmm/zsmalloc.c:2135: * the zsmalloc allocator.\nmm/zsmalloc.c-2136- *\n--\nmm/zsmalloc.c=2140=struct zs_pool *zs_create_pool(const char *name)\n--\nmm/zsmalloc.c-2196-\t\t/*\nmm/zsmalloc.c:2197:\t\t * size_class is used for normal zsmalloc operation such\nmm/zsmalloc.c-2198-\t\t * as alloc/free for that size. Although it is natural that we\n--\nmm/zsmalloc.c=2306=static int __init zs_init(void)\n--\nmm/zsmalloc.c-2314-#ifdef CONFIG_COMPACTION\nmm/zsmalloc.c:2315:\trc = set_movable_ops(\u0026zsmalloc_mops, PGTY_zsmalloc);\nmm/zsmalloc.c-2316-\tif (rc) {\n--\nmm/zsmalloc.c=2325=static void __exit zs_exit(void)\n--\nmm/zsmalloc.c-2327-#ifdef CONFIG_COMPACTION\nmm/zsmalloc.c:2328:\tset_movable_ops(NULL, PGTY_zsmalloc);\nmm/zsmalloc.c-2329-#endif\n--\nmm/zsmalloc.c=2338=MODULE_AUTHOR(\"Nitin Gupta \u003cngupta@vflare.org\u003e\");\nmm/zsmalloc.c:2339:MODULE_DESCRIPTION(\"zsmalloc memory allocator\");\n--\nmm/zswap.c-38-#include \u003clinux/list_lru.h\u003e\nmm/zswap.c:39:#include \u003clinux/zsmalloc.h\u003e\nmm/zswap.c-40-\n--\nmm/zswap.c=182=static struct shrinker *zswap_shrinker;\n--\nmm/zswap.c-197- * pool_idx - id of the zswap_pool that the entry's data is in.\nmm/zswap.c:198: * handle - zsmalloc allocation handle that stores the compressed page data\nmm/zswap.c-199- * objcg - the obj_cgroup that the compressed memory is charged to\n--\nmm/zswap.c=223=static unsigned int nr_zswap_trees[MAX_SWAPFILES];\nmm/zswap.c-224-\nmm/zswap.c:225:/* pool counter to provide unique names to zsmalloc */\nmm/zswap.c-226-static atomic_t zswap_pools_count = ATOMIC_INIT(0);\n--\nmm/zswap.c=296=static struct zswap_pool *zswap_pool_create(char *compressor)\n--\nmm/zswap.c-309-\nmm/zswap.c:310:\t/* unique name for each pool specifically required by zsmalloc */\nmm/zswap.c-311-\tsnprintf(name, 38, \"zswap%x\", atomic_inc_return(\u0026zswap_pools_count));\n--\nmm/zswap.c=768=static void zswap_entry_cache_free(struct zswap_entry *entry)\n--\nmm/zswap.c-773-/*\nmm/zswap.c:774: * Carries out the common pattern of freeing an entry's zsmalloc allocation,\nmm/zswap.c-775- * freeing the entry itself, and decrementing the number of stored pages.\n--\nmm/zswap.c=939=static bool zswap_decompress(struct zswap_entry *entry, struct folio *folio)\n--\nmm/zswap.c-941-\tstruct zswap_pool *pool = zswap_entry_pool(entry);\nmm/zswap.c:942:\tstruct scatterlist input[2]; /* zsmalloc returns an SG list 1-2 entries */\nmm/zswap.c-943-\tstruct scatterlist output;\n"
} |
| 49/2 | 2026/09/22 23:13 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 48999 output: 29 thoughts: 56 Thoughts: Okay, let's break this down. **Investigating Dependencies for `zsmalloc` and Compaction within the Kernel** Right, so I need to figure out the dependencies here. First, it's pretty clear that if `CONFIG_ZSMALLOC` is set, we're building `zsmalloc.o`. That's the core. Then, `CONFIG_COMPACTION`… that enables the page migration functionality that zsmalloc uses, yeah? That makes sense. I have a hunch it is not as simple as that. I am not trying to make any assumptions. Let's dig deeper. Where else is this functionality used? I know that `drivers/md/md-bitmap.c` is important in this space. I am going to have to do the leg work to determine what config options enable that. What are the dependencies there? Let's check. |
| 50/2 | 2026/09/22 23:13 | tool | grepper |
0mArgs:{
"Expression": "md-bitmap\\.o",
"PathPrefix": "drivers/md/"
}Results: {
"Output": "drivers/md/Makefile=30=md-mod-y\t+= md.o\ndrivers/md/Makefile:31:md-mod-$(CONFIG_MD_BITMAP)\t+= md-bitmap.o\ndrivers/md/Makefile-32-md-mod-$(CONFIG_MD_LLBITMAP)\t+= md-llbitmap.o\n"
} |
| 51/2 | 2026/09/22 23:13 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 49361 output: 28 thoughts: 29 Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience: **Analyzing the `CONFIG_MD_BITMAP` Kconfig Setting** Alright, let's dive into this. The presence of `CONFIG_MD_BITMAP` immediately flags my attention. I need to understand its scope and implications within the MD (Multiple Device) framework. My first instinct is to confirm its dependencies. Time to navigate to `drivers/md/Kconfig`. I'll be looking for upstream dependencies, potentially relating to block device support, journaling, or specific filesystem features that might require or benefit from bitmaps. I expect to find relationships with settings like `CONFIG_BLK_DEV`, `CONFIG_FS_JNL`, and possibly even filesystem-specific configurations depending on how the bitmap metadata is handled. Knowing the dependencies will dictate where to begin troubleshooting or feature extension. |
| 52/2 | 2026/09/22 23:13 | tool | grepper |
0mArgs:{
"Expression": "config MD_BITMAP",
"PathPrefix": "drivers/md/"
}Results: {
"Output": "drivers/md/Kconfig=15=config BLK_DEV_MD\n--\ndrivers/md/Kconfig-39-\ndrivers/md/Kconfig:40:config MD_BITMAP\ndrivers/md/Kconfig-41-\tbool \"MD RAID bitmap support\"\n--\ndrivers/md/Kconfig=66=config MD_AUTODETECT\n--\ndrivers/md/Kconfig-79-\ndrivers/md/Kconfig:80:config MD_BITMAP_FILE\ndrivers/md/Kconfig-81-\tbool \"MD bitmap file support (deprecated)\"\n"
} |
| 53/2 | 2026/09/22 23:13 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 49744 output: 31 thoughts: 31 Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience: **Diving into the Bitmap Driver** Right, so I need to get a handle on how this bitmap driver works. Specifically, I'm thinking about the low-level file I/O operations, the interactions with the underlying storage. My focus is going to be on `read_file_page` and `write_file_page` within `drivers/md/md-bitmap.c`. Those are the core functions to examine. They are the crucial building blocks for understanding *how* the bitmap metadata is retrieved, updated, and persisted to storage. Understanding these functions will offer insight into how the RAID array handles data integrity, and how the driver deals with both successful and failed I/O requests. Let's see how efficiently these functions manage page-level operations. We’re dealing with the nitty-gritty of bitmap management here, so the implications are significant regarding performance and data consistency, especially considering potential power failures or sector errors. Let's dig in and see what secrets they hold. |
| 54/2 | 2026/09/22 23:13 | tool | grepper |
0mArgs:{
"Expression": "CONFIG_MD_BITMAP_FILE",
"PathPrefix": "drivers/md/"
}Results: {
"Output": "drivers/md/md-bitmap.c=502=static void md_bitmap_file_kick(struct bitmap *bitmap);\ndrivers/md/md-bitmap.c-503-\ndrivers/md/md-bitmap.c:504:#ifdef CONFIG_MD_BITMAP_FILE\ndrivers/md/md-bitmap.c-505-static void end_bitmap_write(struct bio *bio)\n--\ndrivers/md/md-bitmap.c=555=static int read_file_page(struct file *file, unsigned long index,\n--\ndrivers/md/md-bitmap.c-616-}\ndrivers/md/md-bitmap.c:617:#else /* CONFIG_MD_BITMAP_FILE */\ndrivers/md/md-bitmap.c-618-static void write_file_page(struct bitmap *bitmap, struct page *page, int wait)\n--\ndrivers/md/md-bitmap.c=626=static void free_buffers(struct page *page)\n--\ndrivers/md/md-bitmap.c-629-}\ndrivers/md/md-bitmap.c:630:#endif /* CONFIG_MD_BITMAP_FILE */\ndrivers/md/md-bitmap.c-631-\n--\ndrivers/md/md.c=7802=static int set_bitmap_file(struct mddev *mddev, int fd)\n--\ndrivers/md/md.c-7824-\ndrivers/md/md.c:7825:\t\tif (!IS_ENABLED(CONFIG_MD_BITMAP_FILE)) {\ndrivers/md/md.c-7826-\t\t\tpr_warn(\"%s: bitmap files not supported by this kernel\\n\",\n"
} |
| 55/2 | 2026/09/22 23:13 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 50448 output: 31 thoughts: 2091 Thoughts: **Analysis of Targeted Kernel Features** Right, let's break this down. First, I see `#ifdef CONFIG_MD_BITMAP_FILE` wrapping specific functions: `write_file_page`, `free_buffers`, and `read_file_page`. That tells me we're dealing with `MD_BITMAP_FILE` which depends on `MD_BITMAP`, and also the `BLK_DEV_MD`. Ok, next I should check the other files and their corresponding configuration options. `fs/f2fs/compress.c` uses `CONFIG_F2FS_FS` and `CONFIG_F2FS_FS_COMPRESSION`. `fs/erofs/` relies on `CONFIG_EROFS_FS`, and `CONFIG_EROFS_FS_ZIP`. In `mm/zsmalloc.c`, it's `CONFIG_ZSMALLOC`, and then `fs/crypto/crypto.c` is using `CONFIG_FS_ENCRYPTION`. Also, `mm/huge_memory.c` has `CONFIG_TRANSPARENT_HUGEPAGE`, followed by `mm/hugetlb.c` using `CONFIG_HUGETLB_PAGE`, and finally, `mm/migrate.c` has `CONFIG_MIGRATION`. Now, the important part: identifying the specific, non-ubiquitous kernel functions that have been directly modified or added. Let's make sure that these are the entrypoints we want. Here is what I came up with: - `erofs_onlinefolio_init` - `erofs_onlinefolio_end` - `z_erofs_readahead` - `f2fs_compress_write_end_io` - `f2fs_write_compressed_pages` - `zs_page_migrate` - `split_huge_pages_pid` - `folio_migrate_flags` - `migrate_folio_unmap` I also need to verify static vs. non-static functions. `read_file_page` and `free_buffers` are static functions in `drivers/md/md-bitmap.c`. Also, `erofs_onlinefolio_init` and `erofs_onlinefolio_end` are non-static. The `z_erofs_readahead` is a static function, but is a member of `z_erofs_aops.readahead`. Similarly, `f2fs_write_compressed_pages` is static. Also, `f2fs_compress_write_end_io` is non-static. `folio_migrate_flags` is non-static, and exported. Additionally, `migrate_folio_unmap` is static, as is `zs_page_migrate`. One last one that is good is `add_hugetlb_folio` which is non-static. The patch notes say to note static inlines in .h files, since those do not have symbols in vmlinux. Instead, I need to identify caller functions that use them. So, for example, `readahead_folio_last` called by `z_erofs_readahead`, and `folio_has_attached_private` is called by `split_huge_pages_pid` and a few others. And, `folio_attach_private` and `folio_detach_private` are used by functions like `erofs_onlinefolio_init` and `erofs_onlinefolio_end`. And, finally, these are also used in functions from the f2fs and zsmalloc files. I also must avoid ubiquitous lifecycle hot-paths. So, `filemap_dirty_folio` is probably not what I want since it may be called very frequently. Instead, the list above is better: - `erofs_onlinefolio_init` - `erofs_onlinefolio_end` - `z_erofs_readahead` - `f2fs_compress_write_end_io` - `f2fs_write_compressed_pages` - `zs_page_migrate` - `split_huge_pages_pid` - `folio_migrate_flags` - `migrate_folio_unmap` I confirmed `split_huge_pages_pid`, since that is the THP splitting debugfs interface. Also, I'll need to remember that `add_hugetlb_folio` was specifically modified in `mm/hugetlb.c`. As for those static functions in `md-bitmap.c`, I'll look at the callers. I need to be sure to get the correct calling functions. Specifically, `free_buffers` is called from `md_bitmap_file_unmap` and in some error paths. And `read_ |
| 56/2 | 2026/09/22 23:13 | tool | grepper |
0mArgs:{
"Expression": "config BLK_DEV_MD",
"PathPrefix": "drivers/md/"
}Results: {
"Output": "drivers/md/Kconfig=13=if MD\ndrivers/md/Kconfig-14-\ndrivers/md/Kconfig:15:config BLK_DEV_MD\ndrivers/md/Kconfig-16-\ttristate \"RAID support\"\n"
} |
| 57/2 | 2026/09/22 23:13 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 53669 output: 29 thoughts: 20 Thoughts: Here's a summary of my thought process, tailored for an expert like you: **Investigating `MD_BITMAP_FILE` in `drivers/md/Kconfig`** Okay, I'm zeroing in on this `MD_BITMAP_FILE` option. The immediate context suggests we're dealing with the bitmap file functionality within the Linux MD (Multiple Device) driver, and the first place to look to understand its configuration options is undoubtedly the `Kconfig` file. That's where all the build-time configuration settings are defined. I expect to find a detailed description there, its dependencies, default values (if any), and possibly associated tristate options. Understanding its placement within the Kconfig hierarchy is key too; it will give me insights into what other MD features it might rely on or interact with. Knowing its build-time characteristics will likely give me a good understanding of what it impacts, and where to delve next. Let's see what we can learn. |
| 58/2 | 2026/09/22 23:13 | tool | grepper |
0mArgs:{
"Expression": "MD_BITMAP_FILE",
"PathPrefix": "drivers/md/"
}Results: {
"Output": "drivers/md/Kconfig=66=config MD_AUTODETECT\n--\ndrivers/md/Kconfig-79-\ndrivers/md/Kconfig:80:config MD_BITMAP_FILE\ndrivers/md/Kconfig-81-\tbool \"MD bitmap file support (deprecated)\"\n--\ndrivers/md/md-bitmap.c=502=static void md_bitmap_file_kick(struct bitmap *bitmap);\ndrivers/md/md-bitmap.c-503-\ndrivers/md/md-bitmap.c:504:#ifdef CONFIG_MD_BITMAP_FILE\ndrivers/md/md-bitmap.c-505-static void end_bitmap_write(struct bio *bio)\n--\ndrivers/md/md-bitmap.c=555=static int read_file_page(struct file *file, unsigned long index,\n--\ndrivers/md/md-bitmap.c-616-}\ndrivers/md/md-bitmap.c:617:#else /* CONFIG_MD_BITMAP_FILE */\ndrivers/md/md-bitmap.c-618-static void write_file_page(struct bitmap *bitmap, struct page *page, int wait)\n--\ndrivers/md/md-bitmap.c=626=static void free_buffers(struct page *page)\n--\ndrivers/md/md-bitmap.c-629-}\ndrivers/md/md-bitmap.c:630:#endif /* CONFIG_MD_BITMAP_FILE */\ndrivers/md/md-bitmap.c-631-\n--\ndrivers/md/md.c=7802=static int set_bitmap_file(struct mddev *mddev, int fd)\n--\ndrivers/md/md.c-7824-\ndrivers/md/md.c:7825:\t\tif (!IS_ENABLED(CONFIG_MD_BITMAP_FILE)) {\ndrivers/md/md.c-7826-\t\t\tpr_warn(\"%s: bitmap files not supported by this kernel\\n\",\n"
} |
| 59/2 | 2026/09/22 23:13 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 54409 output: 33 thoughts: 20 Thoughts: Okay, here's my take on those lines in `drivers/md/Kconfig`: **Analyzing Kconfig's RAID Configuration** Right, let's zero in on lines 80-85 of `drivers/md/Kconfig`. I need to understand how the RAID configuration options are presented and handled in the kernel build system. I'm assuming, given the location of this file, that this section likely deals with setting the default state of features or perhaps defining dependencies between options for the Multiple Device (MD) code. I expect to see `config` statements defining the individual RAID levels, along with possibly `depends on` clauses that control their visibility based on other configuration choices. I will be looking closely for any use of `select` or `default` which might reveal which RAID levels are included by default, or which are chosen to be present when others are disabled. Essentially, I'm trying to mentally parse the logic flow of these few lines to immediately grasp the implications for a particular RAID setup. This information will inform my strategy for modifying the RAID configurations for a custom project. |
| 60/2 | 2026/09/22 23:13 | tool | read-file |
0mArgs:{
"File": "drivers/md/Kconfig",
"FirstLine": 75,
"LineCount": 20
}Results: {
"Contents": " 75:\t\t a several-second delay in the boot time due to various\n 76:\t\t synchronisation steps that are part of this step.\n 77:\t\n 78:\t\t If unsure, say Y.\n 79:\t\n 80:\tconfig MD_BITMAP_FILE\n 81:\t\tbool \"MD bitmap file support (deprecated)\"\n 82:\t\tdefault y\n 83:\t\tdepends on MD_BITMAP\n 84:\t\thelp\n 85:\t\t If you say Y here, support for write intent bitmaps in files on an\n 86:\t\t external file system is enabled. This is an alternative to the internal\n 87:\t\t bitmaps near the MD superblock, and very problematic code that abuses\n 88:\t\t various kernel APIs and can only work with files on a file system not\n 89:\t\t actually sitting on the MD device.\n 90:\t\n 91:\tconfig MD_LINEAR\n 92:\t\ttristate \"Linear (append) mode\"\n 93:\t\tdepends on BLK_DEV_MD\n 94:\t\thelp\n"
} |
| 61/2 | 2026/09/22 23:13 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 54967 output: 28 thoughts: 51 Thoughts: Okay, let's see. My mind is immediately tracing dependencies here. **Dependency Deep Dive: Bitmap Files and Zsmalloc** I'm starting with `MD_BITMAP_FILE`. It relies on `MD_BITMAP`, which itself is contingent on `BLK_DEV_MD`. That whole tree is nested under the `if MD` condition, naturally. Makes sense for managing the bitmap files for RAID, I suppose. Now, where does `ZSMALLOC` fit into all this? I need to check `mm/Kconfig` to see if there's any link or interaction I might need to consider. Gotta map out the full picture. |
| 62/2 | 2026/09/22 23:14 | tool | grepper |
0mArgs:{
"Expression": "config ZSMALLOC\\b",
"PathPrefix": "mm/"
}Results: {
"Output": "mm/Kconfig=114=config ZSWAP_COMPRESSOR_DEFAULT\n--\nmm/Kconfig-124-\nmm/Kconfig:125:config ZSMALLOC\nmm/Kconfig-126-\ttristate\n"
} |
| 63/2 | 2026/09/22 23:14 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 55256 output: 20 thoughts: 22 Thoughts: Okay, let's break this down. Here's how I'd approach that question, given my expertise: **Analyzing the Selection of `ZSMALLOC`** Hmm, so `ZSMALLOC` has no explicit prompt. That's immediately intriguing. In my experience, the absence of a direct prompt usually indicates one of a few things, or a combination thereof. It could be due to a default setting in the system or library, an implicit selection based on data characteristics, or even an oversight in the design. The real question I need to answer, as an expert, is: who *or what* is choosing to invoke `ZSMALLOC`? Is it an automated part of a process or a manual selection? If it is a manual selection, the user is assuming that the calling of ZSMALLOC is obvious, or that the relevant information is elsewhere. If it is an automated part of the system, what factors determine this seemingly unprompted allocation choice? Are there thresholds, data types, system load conditions, or other parameters that trigger its use? I need to understand the decision-making process here. This lack of a prompt is a key piece of information that points to an important question to be answered, with all the relevant implications. |
| 64/2 | 2026/09/22 23:14 | tool | grepper |
0mArgs:{
"Expression": "select ZSMALLOC\\b"
}Results: {
"Output": "drivers/block/zram/Kconfig=2=config ZRAM\n--\ndrivers/block/zram/Kconfig-4-\tdepends on BLOCK \u0026\u0026 SYSFS \u0026\u0026 MMU\ndrivers/block/zram/Kconfig:5:\tselect ZSMALLOC\ndrivers/block/zram/Kconfig-6-\thelp\n--\nmm/Kconfig=22=config ZSWAP\n--\nmm/Kconfig-25-\tselect CRYPTO\nmm/Kconfig:26:\tselect ZSMALLOC\nmm/Kconfig-27-\thelp\n"
} |
| 65/2 | 2026/09/22 23:14 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 55698 output: 35 thoughts: 64 Thoughts: Okay, here's my interpretation of those thoughts, tailored for an expert audience, as if they were my own: **ZSWAP/ZRAM and F2FS Compression: Connecting the Dots** Alright, so I see a clear relationship here. We're looking at memory management and how it interacts with compression, specifically within the context of the kernel. The use of `ZSWAP` or `ZRAM` directly triggers the selection of `ZSMALLOC`. No surprises there; `ZSMALLOC` has become the standard for compressed RAM in many modern systems. But the next part is key: `CONFIG_COMPACTION` enabling `set_movable_ops(&zsmalloc_mops, PGTY_zsmalloc)`. This tells me we're looking at a memory compaction scheme that's been specifically tailored for, or at least integrated with, `ZSMALLOC`. When compaction is active, the kernel is making `ZSMALLOC` the memory operation method for pages allocated for the `PGTY_zsmalloc` page type. This suggests that memory compaction is being optimized for compressed pages. Compaction has been designed to work together with zsmalloc, to compact memory. Now, where does this fit in with the broader picture? I need to consider `F2FS_FS_COMPRESSION`. My hunch is that this is the missing piece of the puzzle. We're probably looking at how compression is handled, specifically in the F2FS file system, and how that interacts with in-memory compression and memory compaction. I should probably dig into the F2FS code to see how it's leveraging `ZSMALLOC` and whether compaction is being used to optimize performance when dealing with compressed data in the filesystem. Does F2FS write compressed data? How does it benefit from compressed memory? |
| 66/2 | 2026/09/22 23:14 | tool | grepper |
0mArgs:{
"Expression": "config F2FS_FS_COMPRESSION",
"PathPrefix": "fs/f2fs/"
}Results: {
"Output": "fs/f2fs/Kconfig=87=config F2FS_FAULT_INJECTION\n--\nfs/f2fs/Kconfig-94-\nfs/f2fs/Kconfig:95:config F2FS_FS_COMPRESSION\nfs/f2fs/Kconfig-96-\tbool \"F2FS compression feature\"\n"
} |
| 67/2 | 2026/09/22 23:14 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 56271 output: 35 thoughts: 20 Thoughts: Here's a summary of my thought process: **Diving into the F2FS Configuration** Okay, time to get my hands dirty. I need to understand something about the F2FS filesystem configuration, and the natural place to start is the Kconfig file. Let's navigate directly to the `fs/f2fs/Kconfig` file and zero in on line 95. That's usually where the core configuration options are defined or where a specific grouping of them begins. My instinct tells me that something interesting, likely related to a specific feature or optimization, is going to be described there. I'll need to absorb the surrounding context too, of course, but line 95 is my initial target. This is where I expect to find the information to get started. Let's see what's there. |
| 68/2 | 2026/09/22 23:14 | tool | read-file |
0mArgs:{
"File": "fs/f2fs/Kconfig",
"FirstLine": 90,
"LineCount": 20
}Results: {
"Contents": " 90:\t\thelp\n 91:\t\t Test F2FS to inject faults such as ENOMEM, ENOSPC, and so on.\n 92:\t\n 93:\t\t If unsure, say N.\n 94:\t\n 95:\tconfig F2FS_FS_COMPRESSION\n 96:\t\tbool \"F2FS compression feature\"\n 97:\t\tdepends on F2FS_FS\n 98:\t\thelp\n 99:\t\t Enable filesystem-level compression on f2fs regular files,\n 100:\t\t multiple back-end compression algorithms are supported.\n 101:\t\n 102:\tconfig F2FS_FS_LZO\n 103:\t\tbool \"LZO compression support\"\n 104:\t\tdepends on F2FS_FS_COMPRESSION\n 105:\t\tdefault y\n 106:\t\thelp\n 107:\t\t Support LZO compress algorithm, if unsure, say Y.\n 108:\t\n 109:\tconfig F2FS_FS_LZORLE\n"
} |
| 69/2 | 2026/09/22 23:14 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 56773 output: 363 thoughts: 697 Thoughts: **Reviewing the Scope of the Changes** Okay, let's break this down. First, the relevant configurations: `F2FS_FS` and its compression variant, `EROFS_FS` and `EROFS_FS_ZIP`, then the memory-related flags: `ZRAM`, `ZSWAP`, and indirectly `ZSMALLOC` with `COMPACTION`. The block device aspects are covered by `MD`, `BLK_DEV_MD`, `MD_BITMAP`, and `MD_BITMAP_FILE`. Finally, there are the huge page configurations: `TRANSPARENT_HUGEPAGE`, `HUGETLB_PAGE`, and `MIGRATION`. Now, looking at the focused symbols, the function calls and variables of interest are: `erofs_onlinefolio_init`, `erofs_onlinefolio_end`, `z_erofs_readahead`, `f2fs_write_compressed_pages`, `f2fs_compress_write_end_io`, `zs_page_migrate`, `split_huge_pages_pid`, `folio_migrate_flags`, `migrate_folio_unmap`, and `add_hugetlb_folio`. These are all targeted functions or callers that directly engage with the changes in logic and assertions. I don't see any of the commonly used core routines here, which is a good sign that the scope is somewhat contained. Let's do a quick sanity check of the `set-results`: the configurations listed align with what I considered initially. The "FocusSymbols" are also correct, representing the functions that directly interact with the code changes. The "WorthFuzzing" flag is set to true. The reasoning is sound: the patch effectively repurposes the `PG_private` flag, renaming it to `PG_folio`, which impacts how private page/folio information is maintained across key memory management subsystems: THP splitting, hugetlb, folio migration, page writeback, and reclaim, as well as several filesystems, namely, EROFS, F2FS, and md-bitmap. This is a significant change touching core MM, VFS, and filesystems and introduces assertions. This area needs to be fuzzed thoroughly to uncover any latent regressions and possible invariant violations. Alright, I'm ready to call `set-results`. |
| 70/2 | 2026/09/22 23:14 | tool | set-results |
0mArgs:{
"EnableConfigs": [
"EROFS_FS",
"EROFS_FS_ZIP",
"F2FS_FS",
"F2FS_FS_COMPRESSION",
"ZRAM",
"ZSMALLOC",
"COMPACTION",
"MD",
"BLK_DEV_MD",
"MD_BITMAP",
"MD_BITMAP_FILE",
"TRANSPARENT_HUGEPAGE",
"HUGETLB_PAGE",
"MIGRATION"
],
"FocusSymbols": [
"erofs_onlinefolio_init",
"erofs_onlinefolio_end",
"z_erofs_readahead",
"f2fs_compress_write_end_io",
"f2fs_write_compressed_pages",
"zs_page_migrate",
"split_huge_pages_pid",
"folio_migrate_flags",
"migrate_folio_unmap",
"add_hugetlb_folio"
],
"Reasoning": "The patch eliminates the PG_private page flag and switches private state management to folio-\u003eprivate and folio_has_attached_private across core memory management (THP splitting, hugetlb, folio migration, page writeback, vmscan, zsmalloc) and filesystems (EROFS, F2FS, md-bitmap, ceph, nfs). It adds readahead_folio_last() for reverse folio traversal, alters online folio state tracking and assertions in EROFS, restructures F2FS folio private bits, and modifies zspage assertions in zsmalloc. These extensive MM and filesystem modifications warrant fuzzing.",
"WorthFuzzing": true
}Results: {
"EnableConfigs": [
"EROFS_FS",
"EROFS_FS_ZIP",
"F2FS_FS",
"F2FS_FS_COMPRESSION",
"ZRAM",
"ZSMALLOC",
"COMPACTION",
"MD",
"BLK_DEV_MD",
"MD_BITMAP",
"MD_BITMAP_FILE",
"TRANSPARENT_HUGEPAGE",
"HUGETLB_PAGE",
"MIGRATION"
],
"FocusSymbols": [
"erofs_onlinefolio_init",
"erofs_onlinefolio_end",
"z_erofs_readahead",
"f2fs_compress_write_end_io",
"f2fs_write_compressed_pages",
"zs_page_migrate",
"split_huge_pages_pid",
"folio_migrate_flags",
"migrate_folio_unmap",
"add_hugetlb_folio"
],
"Reasoning": "The patch eliminates the PG_private page flag and switches private state management to folio-\u003eprivate and folio_has_attached_private across core memory management (THP splitting, hugetlb, folio migration, page writeback, vmscan, zsmalloc) and filesystems (EROFS, F2FS, md-bitmap, ceph, nfs). It adds readahead_folio_last() for reverse folio traversal, alters online folio state tracking and assertions in EROFS, restructures F2FS folio private bits, and modifies zspage assertions in zsmalloc. These extensive MM and filesystem modifications warrant fuzzing.",
"WorthFuzzing": true
} |
| 71/1 | 2026/09/22 23:14 | action | If |
1mArgs:{
"WorthFuzzing": true
}Results: null |
| 72/2 | 2026/09/22 23:14 | agent | kmsan-evaluator |
1mModel:core Args: null Results: {
"KMSANReasoning": "The patch series removes the `PG_private` page flag, transitioning the kernel to check `folio-\u003eprivate != NULL` (or `folio_has_attached_private()`, `page_private()`) instead. It updates core memory management, pagecache, tracing, procfs kpageflags, perf x86 AUX buffers, Xen grant tables, and filesystems (Ceph, EROFS, F2FS, NFS, UBIFS).\n\nKMSAN vs KASAN applicability:\n- No uninitialized memory usage or info-leaks:\n - In `fs/proc/page.c`, removing `kpf_copy_bit(..., KPF_PRIVATE, PG_private)` leaves the corresponding bit zeroed because the return accumulator `u` is initialized to 0. No uninitialized bytes or padding are exposed to userspace.\n - In `include/linux/pagemap.h`, the new `_forward` boolean added to `struct readahead_control` is properly zero-initialized by `DEFINE_READAHEAD` (which uses designated initializers, zeroing unspecified members).\n - In perf x86 events (`bts.c`, `pt.c`, `ring_buffer.c`), `page_private(p)` defaults to 0 on page allocation and is explicitly cleared to 0 on free; reading `1 \u003c\u003c page_private(p)` for order-0 pages evaluates deterministically to 1 without accessing uninitialized state.\n - In `fs/erofs`, `fs/f2fs`, and `drivers/md/md-bitmap.c`, all state attached to folios is explicitly initialized before use.\n- The primary risks of these changes involve page/folio lifecycle management, reference counting (e.g. `folio_attach_private` / `folio_detach_private` pairings), and use-after-free or buffer head leaks, which are directly monitored by KASAN and SLUB debugging rather than KMSAN.\n\nTherefore, a dedicated KMSAN fuzzing session is not justified.",
"NeedsKMSAN": false
}Instruction: You are an expert Linux kernel security engineer specializing in kernel memory
error detectors (KASAN and KMSAN). Your job is to review the provided patch series and
determine if the code changes justify spawning a dedicated KMSAN (KernelMemorySanitizer)
fuzzing session in addition to standard KASAN fuzzing.
CRITICAL DISTINCTION BETWEEN KASAN AND KMSAN:
- Standard KASAN kernel builds (upstream-apparmor-kasan.config) already enable
a comprehensive suite of debugging tools and sanitizers, including KASAN
(out-of-bounds accesses, use-after-free, double free, invalid free), LOCKDEP
(locking bugs and deadlocks), UB-sanitizers, and memory corruption checks.
- KMSAN (KernelMemorySanitizer) detects reads of UNINITIALIZED memory (stack, heap,
or page allocations) and kernel-to-user memory info-leaks.
Rule: THERE IS NO SENSE IN RUNNING A KMSAN SESSION IF A BUG CAN BE CAUGHT BY KASAN,
LOCKDEP, OR OTHER STANDARD BUG DETECTORS.
A dedicated KMSAN fuzzing session incurs significant resource costs. You must ONLY
set NeedsKMSAN=true if the code changes introduce or expose UNINITIALIZED MEMORY risks
that are detected ONLY by KMSAN.
Look holistically at the patch series and surrounding code. Even if no direct
uninitialized field accesses or new buffer allocations are added in the diff itself,
a patch may alter control flow, bounds checking, or data length calculations in ways
that change how the rest of the code operates on existing buffers (e.g. allowing
uninitialized stack/heap memory to be read, copied to user space, or used in control
flow). Do not hesitate to use your code access tools to inspect the surrounding code,
called functions, and callers.
Set NeedsKMSAN=true ONLY IF the patch introduces or modifies:
1. Kernel structures sent to user space (via copy_to_user, put_user, netlink skb
attributes, ioctl output arguments, socket options, or BPF buffers) where fields
or structure padding might not be fully initialized/zeroed.
2. Conditional logic or branching that depends on potentially uninitialized variables
or struct fields.
3. Allocation or initialization of complex data structures where uninitialized fields
could be read later in reachable code paths.
4. Bounds checks, lengths, or logic in a way that allows surrounding code to access
uninitialized bytes of existing buffers.
Set NeedsKMSAN=false IF:
- The code changes primarily risk out-of-bounds access, array overflows, NULL pointer
dereferences, locking deadlocks, or use-after-free bugs (these are already caught
by KASAN, LOCKDEP, or standard bug detectors).
- All stack/heap structures touched or introduced by the patch are fully zeroed
or initialized (e.g. using = {0}, memset, kzalloc) before being read or copied.
- The patch does not introduce any risk of uninitialized memory usage or info-leaks.
Use your code access tools to inspect the surrounding code if necessary, then provide
detailed KMSANReasoning contrasting KASAN vs KMSAN applicability for this patch.
Prefer calling several tools at the same time to save round-trips.
Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.
Prompt: Target architecture: amd64
For your convenience, here is the diff of the changes:
commit 95b7a2d0e4b277882309fe37eaff2a2dd99b8ba9
Author: syz-cluster <triage@syzkaller.com>
Date: Tue Sep 22 23:11:17 2026 +0000
syz-cluster: applied patch under review
diff --git a/Documentation/admin-guide/kdump/vmcoreinfo.rst b/Documentation/admin-guide/kdump/vmcoreinfo.rst
index 7663c610fe901..5f1df6d080508 100644
--- a/Documentation/admin-guide/kdump/vmcoreinfo.rst
+++ b/Documentation/admin-guide/kdump/vmcoreinfo.rst
@@ -325,7 +325,7 @@ NR_FREE_PAGES
On linux-2.6.21 or later, the number of free pages is in
vm_stat[NR_FREE_PAGES]. Used to get the number of free pages.
-PG_lru|PG_private|PG_swapcache|PG_swapbacked|PG_hwpoison|PG_head_mask
+PG_lru|PG_swapcache|PG_swapbacked|PG_hwpoison|PG_head_mask
--------------------------------------------------------------------------
Page attributes. These flags are used to filter various unnecessary for
diff --git a/Documentation/filesystems/vfs.rst b/Documentation/filesystems/vfs.rst
index d3a93eec3945f..dec7816303c6a 100644
--- a/Documentation/filesystems/vfs.rst
+++ b/Documentation/filesystems/vfs.rst
@@ -649,8 +649,8 @@ Writeback.
The first can be used independently to the others. The VM can try to
release clean pages in order to reuse them. To do this it can call
-->release_folio on clean folios with the private
-flag set. Clean pages without PagePrivate and with no external references
+->release_folio on clean folios with folio->private set. Clean pages
+without folio->private set and with no external references
will be released without notice being given to the address_space.
To achieve this functionality, pages need to be placed on an LRU with
@@ -674,7 +674,7 @@ filemap_fdatawait_range, to wait for all writeback to complete.
An address_space handler may attach extra information to a page,
typically using the 'private' field in the 'struct page'. If such
-information is attached, the PG_Private flag should be set. This will
+information is attached, non-NULL 'private' field will
cause various VM routines to make extra calls into the address_space
handler to deal with that data.
diff --git a/arch/x86/events/intel/bts.c b/arch/x86/events/intel/bts.c
index cbac54cb3a9ec..5849392cf26d5 100644
--- a/arch/x86/events/intel/bts.c
+++ b/arch/x86/events/intel/bts.c
@@ -66,9 +66,6 @@ static struct pmu bts_pmu;
static int buf_nr_pages(struct page *page)
{
- if (!PagePrivate(page))
- return 1;
-
return 1 << page_private(page);
}
diff --git a/arch/x86/events/intel/pt.c b/arch/x86/events/intel/pt.c
index 5754cd4055628..49349afee6119 100644
--- a/arch/x86/events/intel/pt.c
+++ b/arch/x86/events/intel/pt.c
@@ -781,8 +781,7 @@ static int topa_insert_pages(struct pt_buffer *buf, int cpu, gfp_t gfp)
struct page *p;
p = virt_to_page(buf->data_pages[buf->nr_pages]);
- if (PagePrivate(p))
- order = page_private(p);
+ order = page_private(p);
if (topa_table_full(topa)) {
topa = topa_alloc(cpu, gfp);
@@ -1296,8 +1295,7 @@ static int pt_buffer_try_single(struct pt_buffer *buf, int nr_pages)
if (!intel_pt_validate_hw_cap(PT_CAP_single_range_output))
goto out;
- if (PagePrivate(p))
- order = page_private(p);
+ order = page_private(p);
if (1 << order != nr_pages)
goto out;
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index b8325cb09a371..8adf6ddca3d60 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -516,7 +516,8 @@ static void end_bitmap_write(struct bio *bio)
static void write_file_page(struct bitmap *bitmap, struct page *page, int wait)
{
- struct buffer_head *bh = page_buffers(page);
+ struct folio *folio = page_folio(page);
+ struct buffer_head *bh = folio_buffers(folio);
while (bh && bh->b_blocknr) {
atomic_inc(&bitmap->pending_writes);
@@ -533,19 +534,15 @@ static void write_file_page(struct bitmap *bitmap, struct page *page, int wait)
static void free_buffers(struct page *page)
{
- struct buffer_head *bh;
-
- if (!PagePrivate(page))
- return;
+ struct folio *folio = page_folio(page);
+ struct buffer_head *bh = folio_detach_private(folio);
- bh = page_buffers(page);
while (bh) {
struct buffer_head *next = bh->b_this_page;
free_buffer_head(bh);
bh = next;
}
- detach_page_private(page);
- put_page(page);
+ folio_put(folio);
}
/* read a page from a file.
@@ -560,6 +557,7 @@ static int read_file_page(struct file *file, unsigned long index,
{
int ret = 0;
struct inode *inode = file_inode(file);
+ struct folio *folio = page_folio(page);
struct buffer_head *bh;
sector_t block, blk_cur;
unsigned long blocksize = i_blocksize(inode);
@@ -567,12 +565,12 @@ static int read_file_page(struct file *file, unsigned long index,
pr_debug("read bitmap file (%dB @ %llu)\n", (int)PAGE_SIZE,
(unsigned long long)index << PAGE_SHIFT);
- bh = alloc_page_buffers(page, blocksize);
+ bh = folio_alloc_buffers(folio, blocksize, GFP_NOFS | __GFP_ACCOUNT);
if (!bh) {
ret = -ENOMEM;
goto out;
}
- attach_page_private(page, bh);
+ folio_attach_private(folio, bh);
blk_cur = index << (PAGE_SHIFT - inode->i_blkbits);
while (bh) {
block = blk_cur;
diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
index 69922be28b54c..993f89f048e21 100644
--- a/drivers/xen/grant-table.c
+++ b/drivers/xen/grant-table.c
@@ -863,10 +863,10 @@ EXPORT_SYMBOL_GPL(gnttab_free_auto_xlat_frames);
int gnttab_pages_set_private(int nr_pages, struct page **pages)
{
+#if BITS_PER_LONG < 64
int i;
for (i = 0; i < nr_pages; i++) {
-#if BITS_PER_LONG < 64
struct xen_page_foreign *foreign;
foreign = kzalloc_obj(*foreign);
@@ -874,9 +874,9 @@ int gnttab_pages_set_private(int nr_pages, struct page **pages)
return -ENOMEM;
set_page_private(pages[i], (unsigned long)foreign);
-#endif
- SetPagePrivate(pages[i]);
}
+#endif
+ /* Data is stored in page->private on 64-bit */
return 0;
}
@@ -1031,12 +1031,11 @@ void gnttab_pages_clear_private(int nr_pages, struct page **pages)
int i;
for (i = 0; i < nr_pages; i++) {
- if (PagePrivate(pages[i])) {
#if BITS_PER_LONG < 64
+ if (page_private(pages[i]))
kfree((void *)page_private(pages[i]));
#endif
- ClearPagePrivate(pages[i]);
- }
+ set_page_private(pages[i], 0);
}
}
EXPORT_SYMBOL_GPL(gnttab_pages_clear_private);
diff --git a/fs/buffer.c b/fs/buffer.c
index ed966fa73b1ba..020af5dbe2d05 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -773,14 +773,6 @@ struct buffer_head *folio_alloc_buffers(struct folio *folio, unsigned long size,
}
EXPORT_SYMBOL_GPL(folio_alloc_buffers);
-struct buffer_head *alloc_page_buffers(struct page *page, unsigned long size)
-{
- gfp_t gfp = GFP_NOFS | __GFP_ACCOUNT;
-
- return folio_alloc_buffers(page_folio(page), size, gfp);
-}
-EXPORT_SYMBOL_GPL(alloc_page_buffers);
-
static inline void link_dev_buffers(struct folio *folio,
struct buffer_head *head)
{
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index 657c2cb0f8811..1aca181d28c62 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -70,9 +70,7 @@ static int ceph_netfs_check_write_begin(struct file *file, loff_t pos, unsigned
static inline struct ceph_snap_context *page_snap_context(struct page *page)
{
- if (PagePrivate(page))
- return (void *)page->private;
- return NULL;
+ return (void *)page_private(page);
}
/*
@@ -124,8 +122,8 @@ static bool ceph_dirty_folio(struct address_space *mapping, struct folio *folio)
spin_unlock(&ci->i_ceph_lock);
/*
- * Reference snap context in folio->private. Also set
- * PagePrivate so that we get invalidate_folio callback.
+ * Reference snap context in folio->private. Setting folio->private is
+ * what gets us the invalidate_folio callback.
*/
VM_WARN_ON_FOLIO(folio->private, folio);
folio_attach_private(folio, snapc);
diff --git a/fs/crypto/crypto.c b/fs/crypto/crypto.c
index 5286a124b0d98..aced5c50a4601 100644
--- a/fs/crypto/crypto.c
+++ b/fs/crypto/crypto.c
@@ -65,7 +65,6 @@ void fscrypt_free_bounce_page(struct page *bounce_page)
if (!bounce_page)
return;
set_page_private(bounce_page, (unsigned long)NULL);
- ClearPagePrivate(bounce_page);
mempool_free(bounce_page, fscrypt_bounce_page_pool);
}
EXPORT_SYMBOL(fscrypt_free_bounce_page);
@@ -210,7 +209,6 @@ struct page *fscrypt_encrypt_pagecache_blocks(struct folio *folio,
return ERR_PTR(err);
}
}
- SetPagePrivate(ciphertext_page);
set_page_private(ciphertext_page, (unsigned long)folio);
return ciphertext_page;
}
diff --git a/fs/erofs/data.c b/fs/erofs/data.c
index 0885b1f2fc925..f71c7b51bb720 100644
--- a/fs/erofs/data.c
+++ b/fs/erofs/data.c
@@ -239,19 +239,23 @@ int erofs_map_dev(struct super_block *sb, struct erofs_map_dev *map)
/*
* bit 30: I/O error occurred on this folio
* bit 29: CPU has dirty data in D-cache (needs aliasing handling);
- * bit 0 - 29: remaining parts to complete this folio
+ * bit 0 - 28: remaining parts to complete this folio, biased by 1 so that
+ * ->private stays non-NULL while the folio is attached
*/
#define EROFS_ONLINEFOLIO_EIO 30
#define EROFS_ONLINEFOLIO_DIRTY 29
+#define EROFS_ONLINEFOLIO_COUNT_MASK (BIT(EROFS_ONLINEFOLIO_DIRTY) - 1)
+#define EROFS_ONLINEFOLIO_BIAS 1
void erofs_onlinefolio_init(struct folio *folio)
{
union {
atomic_t o;
void *v;
- } u = { .o = ATOMIC_INIT(1) };
+ } u = { .o = ATOMIC_INIT(1 + EROFS_ONLINEFOLIO_BIAS) };
- folio->private = u.v; /* valid only if file-backed folio is locked */
+ /* valid only if file-backed folio is locked */
+ folio_attach_private(folio, u.v);
}
void erofs_onlinefolio_split(struct folio *folio)
@@ -265,14 +269,14 @@ void erofs_onlinefolio_end(struct folio *folio, int err, bool dirty)
do {
orig = atomic_read((atomic_t *)&folio->private);
- DBG_BUGON(orig <= 0);
+ DBG_BUGON((orig & EROFS_ONLINEFOLIO_COUNT_MASK) <= EROFS_ONLINEFOLIO_BIAS);
v = dirty << EROFS_ONLINEFOLIO_DIRTY;
v |= (orig - 1) | (!!err << EROFS_ONLINEFOLIO_EIO);
} while (atomic_cmpxchg((atomic_t *)&folio->private, orig, v) != orig);
- if (v & (BIT(EROFS_ONLINEFOLIO_DIRTY) - 1))
+ if ((v & EROFS_ONLINEFOLIO_COUNT_MASK) != EROFS_ONLINEFOLIO_BIAS)
return;
- folio->private = 0;
+ folio_detach_private(folio);
if (v & BIT(EROFS_ONLINEFOLIO_DIRTY))
flush_dcache_folio(folio);
folio_end_read(folio, !(v & BIT(EROFS_ONLINEFOLIO_EIO)));
diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c
index e1e25ca0d1904..78fd7d980e957 100644
--- a/fs/erofs/zdata.c
+++ b/fs/erofs/zdata.c
@@ -1898,21 +1898,14 @@ static void z_erofs_readahead(struct readahead_control *rac)
struct inode *realinode = erofs_real_inode(sharedinode, &need_iput);
Z_EROFS_DEFINE_FRONTEND(f, realinode, sharedinode, readahead_pos(rac));
unsigned int nrpages = readahead_count(rac);
- struct folio *head = NULL, *folio;
+ struct folio *folio;
int err;
trace_erofs_readahead(realinode, readahead_index(rac), nrpages, false);
z_erofs_pcluster_readmore(&f, rac, true);
- while ((folio = readahead_folio(rac))) {
- folio->private = head;
- head = folio;
- }
-
- /* traverse in reverse order for best metadata I/O performance */
- while (head) {
- folio = head;
- head = folio_get_private(folio);
+ /* traverse from last to first for best metadata I/O performance */
+ while ((folio = readahead_folio_last(rac))) {
err = z_erofs_scan_folio(&f, folio, true);
if (err && err != -EINTR)
erofs_err(realinode->i_sb, "readahead error at folio %lu @ nid %llu",
diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
index ce88092d9ce26..09d9b8d0fdcce 100644
--- a/fs/f2fs/compress.c
+++ b/fs/f2fs/compress.c
@@ -1064,13 +1064,15 @@ static void cancel_cluster_writeback(struct compress_ctx *cc,
/* Cancel writeback and stay locked. */
for (i = 0; i < cc->cluster_size; i++) {
+ struct folio *folio = page_folio(cc->rpages[i]);
+
if (i < submitted) {
inode_inc_dirty_pages(cc->inode);
- lock_page(cc->rpages[i]);
+ folio_lock(folio);
}
- clear_page_private_gcing(cc->rpages[i]);
- if (folio_test_writeback(page_folio(cc->rpages[i])))
- end_page_writeback(cc->rpages[i]);
+ folio_clear_f2fs_gcing(folio);
+ if (folio_test_writeback(folio))
+ folio_end_writeback(folio);
}
}
@@ -1078,11 +1080,15 @@ static void set_cluster_dirty(struct compress_ctx *cc)
{
int i;
- for (i = 0; i < cc->cluster_size; i++)
- if (cc->rpages[i]) {
- set_page_dirty(cc->rpages[i]);
- set_page_private_gcing(cc->rpages[i]);
- }
+ for (i = 0; i < cc->cluster_size; i++) {
+ struct folio *folio;
+
+ if (!cc->rpages[i])
+ continue;
+ folio = page_folio(cc->rpages[i]);
+ folio_mark_dirty(folio);
+ folio_set_f2fs_gcing(folio);
+ }
}
static int prepare_compress_overwrite(struct compress_ctx *cc,
@@ -1281,7 +1287,7 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,
.op = REQ_OP_WRITE,
.op_flags = wbc_to_write_flags(wbc),
.old_blkaddr = NEW_ADDR,
- .page = NULL,
+ .folio = NULL,
.encrypted_page = NULL,
.compressed_page = NULL,
.io_type = io_type,
@@ -1370,7 +1376,7 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,
block_t blkaddr;
blkaddr = f2fs_data_blkaddr(&dn);
- fio.page = cc->rpages[i];
+ fio.folio = page_folio(cc->rpages[i]);
fio.old_blkaddr = blkaddr;
/* cluster header */
@@ -1476,9 +1482,12 @@ void f2fs_compress_write_end_io(struct bio *bio, struct folio *folio)
}
for (i = 0; i < cic->nr_rpages; i++) {
+ struct folio *rfolio;
+
WARN_ON(!cic->rpages[i]);
- clear_page_private_gcing(cic->rpages[i]);
- end_page_writeback(cic->rpages[i]);
+ rfolio = page_folio(cic->rpages[i]);
+ folio_clear_f2fs_gcing(rfolio);
+ folio_end_writeback(rfolio);
}
page_array_free(sbi, cic->rpages, cic->nr_rpages);
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 21f396ebe22ca..ca8232a9095f8 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -2923,7 +2923,7 @@ bool f2fs_should_update_outplace(struct inode *inode, struct f2fs_io_info *fio)
return true;
if (fio) {
- if (page_private_gcing(fio->page))
+ if (folio_test_f2fs_gcing(fio->folio))
return true;
if (unlikely(is_sbi_flag_set(sbi, SBI_CP_DISABLED) &&
f2fs_is_checkpointed_data(sbi, fio->old_blkaddr)))
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 9940a6cecf1a2..85937de3d7016 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1357,10 +1357,7 @@ struct f2fs_io_info {
blk_opf_t op_flags; /* req_flag_bits */
block_t new_blkaddr; /* new block address to be written */
block_t old_blkaddr; /* old block address before Cow */
- union {
- struct page *page; /* page to be written */
- struct folio *folio;
- };
+ struct folio *folio; /* folio to be written */
struct page *encrypted_page; /* encrypted page */
struct page *compressed_page; /* compressed page */
struct list_head list; /* serialize IOs */
@@ -1613,27 +1610,27 @@ static inline void f2fs_set_bit(unsigned int nr, char *addr);
static inline void f2fs_clear_bit(unsigned int nr, char *addr);
/*
- * Layout of f2fs page.private:
+ * Layout of f2fs folio->private:
*
* Layout A: lowest bit should be 1
* | bit0 = 1 | bit1 | bit2 | ... | bit MAX | private data .... |
- * bit 0 PAGE_PRIVATE_NOT_POINTER
- * bit 1 PAGE_PRIVATE_ONGOING_MIGRATION
- * bit 2 PAGE_PRIVATE_INLINE_INODE
- * bit 3 PAGE_PRIVATE_REF_RESOURCE
- * bit 4 PAGE_PRIVATE_ATOMIC_WRITE
+ * bit 0 F2FS_FOLIO_PRIVATE_NOT_POINTER
+ * bit 1 F2FS_FOLIO_PRIVATE_ONGOING_MIGRATION
+ * bit 2 F2FS_FOLIO_PRIVATE_INLINE_INODE
+ * bit 3 F2FS_FOLIO_PRIVATE_REF_RESOURCE
+ * bit 4 F2FS_FOLIO_PRIVATE_ATOMIC_WRITE
* bit 5- f2fs private data
*
* Layout B: lowest bit should be 0
- * page.private is a wrapped pointer.
+ * folio->private is a wrapped pointer.
*/
enum {
- PAGE_PRIVATE_NOT_POINTER, /* private contains non-pointer data */
- PAGE_PRIVATE_ONGOING_MIGRATION, /* data page which is on-going migrating */
- PAGE_PRIVATE_INLINE_INODE, /* inode page contains inline data */
- PAGE_PRIVATE_REF_RESOURCE, /* dirty page has referenced resources */
- PAGE_PRIVATE_ATOMIC_WRITE, /* data page from atomic write path */
- PAGE_PRIVATE_MAX
+ F2FS_FOLIO_PRIVATE_NOT_POINTER, /* private contains non-pointer data */
+ F2FS_FOLIO_PRIVATE_ONGOING_MIGRATION, /* data page which is on-going migrating */
+ F2FS_FOLIO_PRIVATE_INLINE_INODE, /* inode page contains inline data */
+ F2FS_FOLIO_PRIVATE_REF_RESOURCE, /* dirty page has referenced resources */
+ F2FS_FOLIO_PRIVATE_ATOMIC_WRITE, /* data page from atomic write path */
+ F2FS_FOLIO_PRIVATE_MAX
};
/* For compression */
@@ -2681,86 +2678,68 @@ static inline int inc_valid_block_count(struct f2fs_sb_info *sbi,
return -ENOSPC;
}
-#define PAGE_PRIVATE_GET_FUNC(name, flagname) \
+#define F2FS_FOLIO_PRIVATE_GET_FUNC(name, flagname) \
static inline bool folio_test_f2fs_##name(const struct folio *folio) \
{ \
unsigned long priv = (unsigned long)folio->private; \
- unsigned long v = (1UL << PAGE_PRIVATE_NOT_POINTER) | \
- (1UL << PAGE_PRIVATE_##flagname); \
+ unsigned long v = (1UL << F2FS_FOLIO_PRIVATE_NOT_POINTER) | \
+ (1UL << F2FS_FOLIO_PRIVATE_##flagname); \
return (priv & v) == v; \
-} \
-static inline bool page_private_##name(struct page *page) \
-{ \
- return PagePrivate(page) && \
- test_bit(PAGE_PRIVATE_NOT_POINTER, &page_private(page)) && \
- test_bit(PAGE_PRIVATE_##flagname, &page_private(page)); \
}
-#define PAGE_PRIVATE_SET_FUNC(name, flagname) \
+#define F2FS_FOLIO_PRIVATE_SET_FUNC(name, flagname) \
static inline void folio_set_f2fs_##name(struct folio *folio) \
{ \
- unsigned long v = (1UL << PAGE_PRIVATE_NOT_POINTER) | \
- (1UL << PAGE_PRIVATE_##flagname); \
+ unsigned long v = (1UL << F2FS_FOLIO_PRIVATE_NOT_POINTER) | \
+ (1UL << F2FS_FOLIO_PRIVATE_##flagname); \
if (!folio->private) \
folio_attach_private(folio, (void *)v); \
else { \
v |= (unsigned long)folio->private; \
folio->private = (void *)v; \
} \
-} \
-static inline void set_page_private_##name(struct page *page) \
-{ \
- if (!PagePrivate(page)) \
- attach_page_private(page, (void *)0); \
- set_bit(PAGE_PRIVATE_NOT_POINTER, &page_private(page)); \
- set_bit(PAGE_PRIVATE_##flagname, &page_private(page)); \
}
-#define PAGE_PRIVATE_CLEAR_FUNC(name, flagname) \
+#define F2FS_FOLIO_PRIVATE_CLEAR_FUNC(name, flagname) \
static inline void folio_clear_f2fs_##name(struct folio *folio) \
{ \
unsigned long v = (unsigned long)folio->private; \
\
- v &= ~(1UL << PAGE_PRIVATE_##flagname); \
- if (v == (1UL << PAGE_PRIVATE_NOT_POINTER)) \
+ v &= ~(1UL << F2FS_FOLIO_PRIVATE_##flagname); \
+ if (v == (1UL << F2FS_FOLIO_PRIVATE_NOT_POINTER)) \
folio_detach_private(folio); \
else \
folio->private = (void *)v; \
-} \
-static inline void clear_page_private_##name(struct page *page) \
-{ \
- clear_bit(PAGE_PRIVATE_##flagname, &page_private(page)); \
- if (page_private(page) == BIT(PAGE_PRIVATE_NOT_POINTER)) \
- detach_page_private(page); \
}
-PAGE_PRIVATE_GET_FUNC(nonpointer, NOT_POINTER);
-PAGE_PRIVATE_GET_FUNC(inline, INLINE_INODE);
-PAGE_PRIVATE_GET_FUNC(gcing, ONGOING_MIGRATION);
-PAGE_PRIVATE_GET_FUNC(atomic, ATOMIC_WRITE);
+F2FS_FOLIO_PRIVATE_GET_FUNC(nonpointer, NOT_POINTER);
+F2FS_FOLIO_PRIVATE_GET_FUNC(inline, INLINE_INODE);
+F2FS_FOLIO_PRIVATE_GET_FUNC(gcing, ONGOING_MIGRATION);
+F2FS_FOLIO_PRIVATE_GET_FUNC(atomic, ATOMIC_WRITE);
-PAGE_PRIVATE_SET_FUNC(reference, REF_RESOURCE);
-PAGE_PRIVATE_SET_FUNC(inline, INLINE_INODE);
-PAGE_PRIVATE_SET_FUNC(gcing, ONGOING_MIGRATION);
-PAGE_PRIVATE_SET_FUNC(atomic, ATOMIC_WRITE);
+F2FS_FOLIO_PRIVATE_SET_FUNC(reference, REF_RESOURCE);
+F2FS_FOLIO_PRIVATE_SET_FUNC(inline, INLINE_INODE);
+F2FS_FOLIO_PRIVATE_SET_FUNC(gcing, ONGOING_MIGRATION);
+F2FS_FOLIO_PRIVATE_SET_FUNC(atomic, ATOMIC_WRITE);
-PAGE_PRIVATE_CLEAR_FUNC(reference, REF_RESOURCE);
-PAGE_PRIVATE_CLEAR_FUNC(inline, INLINE_INODE);
-PAGE_PRIVATE_CLEAR_FUNC(gcing, ONGOING_MIGRATION);
-PAGE_PRIVATE_CLEAR_FUNC(atomic, ATOMIC_WRITE);
+F2FS_FOLIO_PRIVATE_CLEAR_FUNC(reference, REF_RESOURCE);
+F2FS_FOLIO_PRIVATE_CLEAR_FUNC(inline, INLINE_INODE);
+F2FS_FOLIO_PRIVATE_CLEAR_FUNC(gcing, ONGOING_MIGRATION);
+F2FS_FOLIO_PRIVATE_CLEAR_FUNC(atomic, ATOMIC_WRITE);
static inline unsigned long folio_get_f2fs_data(struct folio *folio)
{
unsigned long data = (unsigned long)folio->private;
- if (!test_bit(PAGE_PRIVATE_NOT_POINTER, &data))
+ if (!test_bit(F2FS_FOLIO_PRIVATE_NOT_POINTER, &data))
return 0;
- return data >> PAGE_PRIVATE_MAX;
+ return data >> F2FS_FOLIO_PRIVATE_MAX;
}
static inline void folio_set_f2fs_data(struct folio *folio, unsigned long data)
{
- data = (1UL << PAGE_PRIVATE_NOT_POINTER) | (data << PAGE_PRIVATE_MAX);
+ data = (1UL << F2FS_FOLIO_PRIVATE_NOT_POINTER) |
+ (data << F2FS_FOLIO_PRIVATE_MAX);
if (!folio_test_private(folio))
folio_attach_private(folio, (void *)data);
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 63b712d3d599e..8c156e1fd37d0 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -3803,7 +3803,7 @@ static int __get_segment_type_6(struct f2fs_io_info *fio)
if (is_inode_flag_set(inode, FI_ALIGNED_WRITE))
return CURSEG_COLD_DATA_PINNED;
- if (page_private_gcing(fio->page)) {
+ if (folio_test_f2fs_gcing(fio->folio)) {
if (fio->sbi->am.atgc_enabled &&
(fio->io_type == FS_DATA_IO) &&
(fio->sbi->gc_mode != GC_URGENT_HIGH) &&
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index e1bdd10b35f10..38f830a6467c9 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -484,7 +484,7 @@ static int nfs_write_end(const struct kiocb *iocb,
* Partially or wholly invalidate a page
* - Release the private state associated with a page if undergoing complete
* page invalidation
- * - Called if either PG_private or PG_fscache is set on the page
+ * - Called if either folio->private or PG_fscache is set on the page
* - Caller holds page lock
*/
static void nfs_invalidate_folio(struct folio *folio, size_t offset,
@@ -555,7 +555,7 @@ static void nfs_check_dirty_writeback(struct folio *folio,
* Attempt to clear the private state associated with a page when an error
* occurs that requires the cached contents of an inode to be written back or
* destroyed
- * - Called if either PG_private or fscache is set on the page
+ * - Called if either page->private or fscache is set on the page
* - Caller holds page lock
* - Return 0 if successful, -error otherwise
*/
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index 623e7ef1f73d5..b6967b5286691 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -717,7 +717,6 @@ static void nfs_inode_add_request(struct nfs_page *req)
nfs_lock_request(req);
spin_lock(&mapping->i_private_lock);
set_bit(PG_MAPPED, &req->wb_flags);
- folio_set_private(folio);
folio->private = req;
spin_unlock(&mapping->i_private_lock);
atomic_long_inc(&nfsi->nrequests);
@@ -745,7 +744,6 @@ static void nfs_inode_remove_request(struct nfs_page *req)
spin_lock(&mapping->i_private_lock);
folio->private = NULL;
- folio_clear_private(folio);
clear_bit(PG_MAPPED, &req->wb_head->wb_flags);
spin_unlock(&mapping->i_private_lock);
diff --git a/fs/proc/page.c b/fs/proc/page.c
index 260772b20bd99..f90e1030825e9 100644
--- a/fs/proc/page.c
+++ b/fs/proc/page.c
@@ -232,7 +232,6 @@ u64 stable_page_flags(const struct page *page)
u |= kpf_copy_bit(k, KPF_RESERVED, PG_reserved);
u |= kpf_copy_bit(k, KPF_OWNER_2, PG_owner_2);
- u |= kpf_copy_bit(k, KPF_PRIVATE, PG_private);
u |= kpf_copy_bit(k, KPF_PRIVATE_2, PG_private_2);
u |= kpf_copy_bit(k, KPF_OWNER_PRIVATE, PG_owner_priv_1);
u |= kpf_copy_bit(k, KPF_ARCH, PG_arch_1);
diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
index e73c28b12f97f..aa0298ce451ef 100644
--- a/fs/ubifs/file.c
+++ b/fs/ubifs/file.c
@@ -12,14 +12,14 @@
* This file implements VFS file and inode operations for regular files, device
* nodes and symlinks as well as address space operations.
*
- * UBIFS uses 2 page flags: @PG_private and @PG_checked. @PG_private is set if
+ * UBIFS uses folio->private and page flag @PG_checked. folio->private is set if
* the page is dirty and is used for optimization purposes - dirty pages are
- * not budgeted so the flag shows that 'ubifs_write_end()' should not release
+ * not budgeted so it shows that 'ubifs_write_end()' should not release
* the budget for this page. The @PG_checked flag is set if full budgeting is
* required for the page e.g., when it corresponds to a file hole or it is
* beyond the file size. The budgeting is done in 'ubifs_write_begin()', because
* it is OK to fail in this function, and the budget is released in
- * 'ubifs_write_end()'. So the @PG_private and @PG_checked flags carry
+ * 'ubifs_write_end()'. So the folio->private and the @PG_checked flag carry
* information about how the page was budgeted, to make it possible to release
* the budget properly.
*
@@ -1509,7 +1509,7 @@ static vm_fault_t ubifs_vm_page_mkwrite(struct vm_fault *vmf)
*
* At the moment we do not know whether the folio is dirty or not, so we
* assume that it is not and budget for a new folio. We could look at
- * the @PG_private flag and figure this out, but we may race with write
+ * folio->private and figure this out, but we may race with write
* back and the folio state may change by the time we lock it, so this
* would need additional care. We do not bother with this at the
* moment, although it might be good idea to do. Instead, we allocate
diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h
index fd2c7115c0542..4b0b7188472b2 100644
--- a/include/linux/buffer_head.h
+++ b/include/linux/buffer_head.h
@@ -175,12 +175,7 @@ static inline unsigned long bh_offset(const struct buffer_head *bh)
return (unsigned long)(bh)->b_data & (page_size(bh->b_page) - 1);
}
-/* If we *know* page->private refers to buffer_heads */
-#define page_buffers(page) \
- ({ \
- BUG_ON(!PagePrivate(page)); \
- ((struct buffer_head *)page_private(page)); \
- })
+/* If we *know* folio->private refers to buffer_heads */
#define folio_buffers(folio) folio_get_private(folio)
void buffer_check_dirty_writeback(struct folio *folio,
@@ -197,7 +192,6 @@ void folio_set_bh(struct buffer_head *bh, struct folio *folio,
unsigned long offset);
struct buffer_head *folio_alloc_buffers(struct folio *folio, unsigned long size,
gfp_t gfp);
-struct buffer_head *alloc_page_buffers(struct page *page, unsigned long size);
struct buffer_head *create_empty_buffers(struct folio *folio,
unsigned long blocksize, unsigned long b_state);
void end_buffer_read_sync(struct buffer_head *bh, int uptodate);
diff --git a/include/linux/kernel-page-flags.h b/include/linux/kernel-page-flags.h
index 196778a087c4d..fe5ab6e50bd70 100644
--- a/include/linux/kernel-page-flags.h
+++ b/include/linux/kernel-page-flags.h
@@ -11,7 +11,6 @@
#define KPF_RESERVED 32
#define KPF_MLOCKED 33
#define KPF_OWNER_2 34
-#define KPF_PRIVATE 35
#define KPF_PRIVATE_2 36
#define KPF_OWNER_PRIVATE 37
#define KPF_ARCH 38
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 66d384da4433b..262d1de5c1161 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -2048,20 +2048,21 @@ vm_fault_t finish_fault(struct vm_fault *vmf);
*
* A pagecache page contains an opaque `private' member, which belongs to the
* page's address_space. Usually, this is the address of a circular list of
- * the page's disk buffers. PG_private must be set to tell the VM to call
- * into the filesystem to release these pages.
+ * the page's disk buffers. It tells the VM to call into the filesystem to
+ * release these pages.
*
* A folio may belong to an inode's memory mapping. In this case,
* folio->mapping points to the inode, and folio->index is the file
* offset of the folio, in units of PAGE_SIZE.
*
- * If pagecache pages are not associated with an inode, they are said to be
- * anonymous pages. These may become associated with the swapcache, and in that
- * case PG_swapcache is set, and page->private is an offset into the swapcache.
+ * If pagecache folios are not associated with an inode, they are said to be
+ * anonymous folios. These may become associated with the swapcache, and in that
+ * case PG_swapcache is set, and folio->private is an offset into the swapcache.
*
* In either case (swapcache or inode backed), the pagecache itself holds one
- * reference to the page. Setting PG_private should also increment the
- * refcount. The each user mapping also has a reference to the page.
+ * reference to the folio. Attaching filesystem private data via
+ * folio_attach_private() also increments the refcount. Each user mapping also
+ * has a reference to the folio.
*
* The pagecache pages are stored in a per-mapping radix tree, which is
* rooted at mapping->i_pages, and indexed by offset.
@@ -3004,9 +3005,9 @@ static inline bool folio_maybe_mapped_shared(struct folio *folio)
* @folio: the folio
*
* Calculate the expected folio refcount, taking references from the pagecache,
- * swapcache, PG_private and page table mappings into account. Useful in
- * combination with folio_ref_count() to detect unexpected references (e.g.,
- * GUP or other temporary references).
+ * swapcache, private data (folio->private != NULL) and page table mappings into
+ * account. Useful in combination with folio_ref_count() to detect unexpected
+ * references (e.g., GUP or other temporary references).
*
* Does currently not consider references from the LRU cache. If the folio
* was isolated from the LRU (which is the case during migration or split),
@@ -3044,10 +3045,15 @@ static inline int folio_expected_ref_count(const struct folio *folio)
ref_count += folio_test_swapcache(folio) << order;
if (!folio_test_anon(folio)) {
- /* One reference per page from the pagecache. */
- ref_count += !!folio->mapping << order;
- /* One reference from PG_private. */
- ref_count += folio_test_private(folio);
+ /*
+ * One reference per page from the pagecache.
+ * Use data_race() since folio might not be locked.
+ */
+ ref_count += !!data_race(folio->mapping) << order;
+ /*
+ * One reference from filesystem private data.
+ */
+ ref_count += folio_has_attached_private(folio);
}
/* One reference per page table mapping. */
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index 5413bd10fff2c..9d6c945ba4104 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -108,7 +108,7 @@ struct page {
};
/**
* @private: Mapping-private opaque data.
- * Usually used for buffer_heads if PagePrivate.
+ * Usually used for buffer_heads.
* Used for swp_entry_t if swapcache flag set.
* Indicates order in the buddy system if PageBuddy
* or on pcp_llist.
@@ -675,7 +675,7 @@ static inline void ptdesc_pmd_pts_init(struct ptdesc *ptdesc)
#define STRUCT_PAGE_MAX_SHIFT (order_base_2(sizeof(struct page)))
/*
- * page_private can be used on tail pages. However, PagePrivate is only
+ * page_private can be used on tail pages. However, it is only
* checked by the VM on the head page. So page_private on the tail pages
* should be used for data that's ancillary to the head page (eg attaching
* buffer heads to tail pages after attaching buffer heads to the head page)
diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index 7080a6a1a79e7..b0ddc652e76cc 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -44,10 +44,6 @@
* Consequently, PG_reserved for a page mapped into user space can indicate
* the zero page, the vDSO, MMIO pages or device memory.
*
- * The PG_private bitflag is set on pagecache pages if they contain filesystem
- * specific data (which is normally at page->private). It can be used by
- * private allocations for its own usage.
- *
* During initiation of disk I/O, PG_locked is set. This bit is set before I/O
* and cleared when writeback _starts_ or when read _completes_. PG_writeback
* is set before writeback starts and cleared when it finishes.
@@ -105,7 +101,7 @@ enum pageflags {
PG_owner_2, /* Owner use. If pagecache, fs may use */
PG_arch_1,
PG_reserved,
- PG_private, /* If pagecache, has fs-private data */
+ PG_folio, /* Do not use: reserved for folio identification */
PG_private_2, /* If pagecache, has fs aux data */
PG_reclaim, /* To be reclaimed asap */
PG_swapbacked, /* Page is backed by RAM/swap */
@@ -575,9 +571,19 @@ FOLIO_FLAG(swapbacked, FOLIO_HEAD_PAGE)
/*
* Private page markings that may be used by the filesystem that owns the page
* for its own purposes.
- * - PG_private and PG_private_2 cause release_folio() and co to be invoked
+ * - folio->private and PG_private_2 cause release_folio() and co to be invoked
*/
-PAGEFLAG(Private, private, PF_ANY)
+
+static __always_inline bool folio_test_private(const struct folio *folio)
+{
+ /*
+ * data_race() is added for readers without holding the folio lock.
+ * Only the NULL/non-NULL answer is used and both are valid while
+ * private is being attached or detached, so the race is benign.
+ */
+ return data_race(folio->private);
+}
+
FOLIO_FLAG(private_2, FOLIO_HEAD_PAGE)
/* owner_2 can be set on tail pages for anon memory */
@@ -1169,7 +1175,7 @@ static __always_inline void __ClearPageAnonExclusive(struct page *page)
*/
#define PAGE_FLAGS_CHECK_AT_FREE \
(1UL << PG_lru | 1UL << PG_locked | \
- 1UL << PG_private | 1UL << PG_private_2 | \
+ 1UL << PG_private_2 | \
1UL << PG_writeback | 1UL << PG_reserved | \
1UL << PG_active | \
1UL << PG_unevictable | __PG_MLOCKED | LRU_GEN_MASK)
@@ -1193,8 +1199,31 @@ static __always_inline void __ClearPageAnonExclusive(struct page *page)
(0xffUL /* order */ | 1UL << PG_has_hwpoisoned | \
1UL << PG_large_rmappable | 1UL << PG_partially_mapped)
-#define PAGE_FLAGS_PRIVATE \
- (1UL << PG_private | 1UL << PG_private_2)
+/**
+ * folio_has_attached_private - check if the folio has private data attached
+ * @folio: The folio to check.
+ *
+ * Use this in code that may encounter swapcache or hugetlb folios but only
+ * wants to detect attached private data.
+ *
+ * Return: true if the folio has private data attached.
+ */
+static inline bool folio_has_attached_private(const struct folio *folio)
+{
+ /*
+ * Swapcache stores swp_entry_t in folio->swap, a union with
+ * folio->private, and hugetlb stores its own flags in folio->private;
+ * both are excluded.
+ *
+ * NOTE: For swapcache, folio->swap.val PG_swapcache are not set as
+ * a whole, so folio_test_swapcache() is not reliable to exclude
+ * swapcache. Use folio_test_swapbacked() instead, since it remains set
+ * when a folio is added to/removed from swapcache.
+ */
+
+ return folio_test_private(folio) && !folio_test_swapbacked(folio) &&
+ !folio_test_hugetlb(folio);
+}
/**
* folio_has_private - Determine if folio has private stuff
* @folio: The folio to be checked
@@ -1204,7 +1233,7 @@ static __always_inline void __ClearPageAnonExclusive(struct page *page)
*/
static inline int folio_has_private(const struct folio *folio)
{
- return !!(folio->flags.f & PAGE_FLAGS_PRIVATE);
+ return folio_has_attached_private(folio) || folio_test_private_2(folio);
}
#undef PF_ANY
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 939f3a5e973f6..bcbb0afe1a681 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -594,7 +594,6 @@ static inline void folio_attach_private(struct folio *folio, void *data)
{
folio_get(folio);
folio->private = data;
- folio_set_private(folio);
}
/**
@@ -629,9 +628,8 @@ static inline void *folio_detach_private(struct folio *folio)
{
void *data = folio_get_private(folio);
- if (!folio_test_private(folio))
+ if (!data)
return NULL;
- folio_clear_private(folio);
folio->private = NULL;
folio_put(folio);
@@ -1415,6 +1413,7 @@ struct readahead_control {
bool dropbehind;
bool _workingset;
unsigned long _pflags;
+ bool _forward;
};
#define DEFINE_READAHEAD(ractl, f, r, m, i) \
@@ -1479,18 +1478,29 @@ void page_cache_async_readahead(struct address_space *mapping,
page_cache_async_ra(&ractl, folio, req_count);
}
+/*
+ * Adjust readahead_control to ensure next folio comes from
+ * [_index, _index + _nr_pages) afterwards and reset _batch_count.
+ */
+static inline void __readahead_advance(struct readahead_control *rac)
+{
+ if (rac->_forward)
+ rac->_index += rac->_batch_count;
+
+ rac->_nr_pages -= rac->_batch_count;
+ rac->_batch_count = 0;
+}
+
static inline struct folio *__readahead_folio(struct readahead_control *ractl)
{
struct folio *folio;
BUG_ON(ractl->_batch_count > ractl->_nr_pages);
- ractl->_nr_pages -= ractl->_batch_count;
- ractl->_index += ractl->_batch_count;
+ __readahead_advance(ractl);
+ ractl->_forward = true;
- if (!ractl->_nr_pages) {
- ractl->_batch_count = 0;
+ if (!ractl->_nr_pages)
return NULL;
- }
folio = xa_load(&ractl->mapping->i_pages, ractl->_index);
VM_BUG_ON_FOLIO(!folio_test_locked(folio), folio);
@@ -1516,6 +1526,39 @@ static inline struct folio *readahead_folio(struct readahead_control *ractl)
return folio;
}
+/**
+ * readahead_folio_last - Get the next folio to read, from the tail.
+ * @ractl: The current readahead request.
+ *
+ * Like readahead_folio(), but walks the range back-to-front. The folio is
+ * returned locked with its refcount dropped; the caller unlocks it once I/O
+ * completes. Compound folios are returned once, at their head index.
+ *
+ * Context: The folio is locked.
+ * Return: A pointer to the next folio, or %NULL when done.
+ */
+static inline struct folio *readahead_folio_last(struct readahead_control *ractl)
+{
+ struct folio *folio;
+
+ /* Drop the previously returned batch from the remaining range. */
+ __readahead_advance(ractl);
+ ractl->_forward = false;
+
+ if (!ractl->_nr_pages)
+ return NULL;
+
+ /* xa_load() follows sibling entries, so a tail index returns the head */
+ folio = xa_load(&ractl->mapping->i_pages,
+ ractl->_index + ractl->_nr_pages - 1);
+ VM_WARN_ON_ONCE_FOLIO(!folio_test_locked(folio), folio);
+
+ ractl->_batch_count = folio_nr_pages(folio);
+
+ folio_put(folio);
+ return folio;
+}
+
static inline unsigned int __readahead_batch(struct readahead_control *rac,
struct page **array, unsigned int array_sz)
{
@@ -1524,9 +1567,8 @@ static inline unsigned int __readahead_batch(struct readahead_control *rac,
struct folio *folio;
BUG_ON(rac->_batch_count > rac->_nr_pages);
- rac->_nr_pages -= rac->_batch_count;
- rac->_index += rac->_batch_count;
- rac->_batch_count = 0;
+ __readahead_advance(rac);
+ rac->_forward = true;
xas_set(&xas, rac->_index);
rcu_read_lock();
diff --git a/include/trace/events/mmflags.h b/include/trace/events/mmflags.h
index ef9aa388b84f7..3c153b3ad8450 100644
--- a/include/trace/events/mmflags.h
+++ b/include/trace/events/mmflags.h
@@ -144,7 +144,7 @@ TRACE_DEFINE_ENUM(___GFP_LAST_BIT);
DEF_PAGEFLAG_NAME(owner_2), \
DEF_PAGEFLAG_NAME(arch_1), \
DEF_PAGEFLAG_NAME(reserved), \
- DEF_PAGEFLAG_NAME(private), \
+ DEF_PAGEFLAG_NAME(folio), \
DEF_PAGEFLAG_NAME(private_2), \
DEF_PAGEFLAG_NAME(writeback), \
DEF_PAGEFLAG_NAME(head), \
diff --git a/include/trace/events/pagemap.h b/include/trace/events/pagemap.h
index 36c3a90f0acca..5d47b774633a4 100644
--- a/include/trace/events/pagemap.h
+++ b/include/trace/events/pagemap.h
@@ -22,7 +22,7 @@
(folio_test_swapcache(folio) ? PAGEMAP_SWAPCACHE : 0) | \
(folio_test_swapbacked(folio) ? PAGEMAP_SWAPBACKED : 0) | \
(folio_test_mappedtodisk(folio) ? PAGEMAP_MAPPEDDISK : 0) | \
- (folio_test_private(folio) ? PAGEMAP_BUFFERS : 0) \
+ (folio_has_attached_private(folio) ? PAGEMAP_BUFFERS : 0) \
)
TRACE_EVENT(mm_lru_insertion,
diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c
index 9fe92161715e0..061b5cb222266 100644
--- a/kernel/events/ring_buffer.c
+++ b/kernel/events/ring_buffer.c
@@ -630,11 +630,10 @@ static struct page *rb_alloc_aux_page(int node, int order)
/*
* Communicate the allocation size to the driver:
* if we managed to secure a high-order allocation,
- * set its first page's private to this order;
- * !PagePrivate(page) means it's just a normal page.
+ * set its first page's private to this order, otherwise page's
+ * private remains zero.
*/
split_page(page, order);
- SetPagePrivate(page);
set_page_private(page, order);
}
@@ -645,7 +644,7 @@ static void rb_free_aux_page(struct perf_buffer *rb, int idx)
{
struct page *page = virt_to_page(rb->aux_pages[idx]);
- ClearPagePrivate(page);
+ set_page_private(page, 0);
__free_page(page);
}
diff --git a/kernel/vmcore_info.c b/kernel/vmcore_info.c
index 8614430ca212a..5a417f8a922ab 100644
--- a/kernel/vmcore_info.c
+++ b/kernel/vmcore_info.c
@@ -216,7 +216,6 @@ static int __init crash_save_vmcoreinfo_init(void)
VMCOREINFO_LENGTH(free_area.free_list, MIGRATE_TYPES);
VMCOREINFO_NUMBER(NR_FREE_PAGES);
VMCOREINFO_NUMBER(PG_lru);
- VMCOREINFO_NUMBER(PG_private);
VMCOREINFO_NUMBER(PG_swapcache);
VMCOREINFO_NUMBER(PG_swapbacked);
#define PAGE_SLAB_MAPCOUNT_VALUE (PGTY_slab << 24)
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 30b7c63b0e359..8aa2daba37391 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -4846,7 +4846,7 @@ static int split_huge_pages_pid(int pid, unsigned long vaddr_start,
* will try to drop it before split and then check if the folio
* can be split or not. So skip the check here.
*/
- if (!folio_test_private(folio) &&
+ if (!folio_has_attached_private(folio) &&
folio_expected_ref_count(folio) != folio_ref_count(folio))
goto next;
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 2003439ea13c6..7b27c3c5c3e58 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1446,11 +1446,8 @@ void add_hugetlb_folio(struct hstate *h, struct folio *folio,
}
__folio_set_hugetlb(folio);
- folio_change_private(folio, NULL);
- /*
- * We have to set hugetlb_vmemmap_optimized again as above
- * folio_change_private(folio, NULL) cleared it.
- */
+ /* Clear all folio->private flags except hugetlb_vmemmap_optimized. */
+ folio->private = NULL;
folio_set_hugetlb_vmemmap_optimized(folio);
arch_clear_hugetlb_flags(folio);
diff --git a/mm/migrate.c b/mm/migrate.c
index a369d0c95c386..7e3a81f069744 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -835,7 +835,6 @@ void folio_migrate_flags(struct folio *newfolio, struct folio *folio)
*/
if (folio_test_swapcache(folio))
folio_clear_swapcache(folio);
- folio_clear_private(folio);
/* page->private contains hugetlb specific flags */
if (!folio_test_hugetlb(folio))
@@ -1327,7 +1326,7 @@ static int migrate_folio_unmap(new_folio_t get_new_folio,
* free the metadata, so the page can be freed.
*/
if (!src->mapping) {
- if (folio_test_private(src)) {
+ if (folio_has_attached_private(src)) {
try_to_free_buffers(src);
goto out;
}
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index eeab25d6ce364..499a35473e4f3 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -2705,7 +2705,7 @@ bool filemap_dirty_folio(struct address_space *mapping, struct folio *folio)
if (folio_test_set_dirty(folio))
return false;
- __folio_mark_dirty(folio, mapping, !folio_test_private(folio));
+ __folio_mark_dirty(folio, mapping, !folio_has_attached_private(folio));
if (mapping->host) {
/* !PageAnon && !swapper_space */
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 80041e2b8049c..dd6261c862794 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1029,7 +1029,7 @@ static void folio_check_dirty_writeback(struct folio *folio,
*writeback = folio_test_writeback(folio);
/* Verify dirty/writeback state if the filesystem supports it */
- if (!folio_test_private(folio))
+ if (!folio_has_attached_private(folio))
return;
mapping = folio_mapping(folio);
diff --git a/mm/zpdesc.h b/mm/zpdesc.h
index b8258dc78548d..4fd81c2e80769 100644
--- a/mm/zpdesc.h
+++ b/mm/zpdesc.h
@@ -26,8 +26,8 @@
* with memcg_data.
*
* Page flags used:
- * * PG_private identifies the first component page.
* * PG_locked is used by page migration code.
+ * The first component page has zpdesc->zspage->first_zpdesc == zpdesc
*/
struct zpdesc {
unsigned long flags;
diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index 11be37c431718..7ef80e0da6267 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -290,11 +290,6 @@ struct zs_pool {
atomic_t compaction_in_progress;
};
-static inline void zpdesc_set_first(struct zpdesc *zpdesc)
-{
- SetPagePrivate(zpdesc_page(zpdesc));
-}
-
static inline void zpdesc_inc_zone_page_state(struct zpdesc *zpdesc)
{
inc_zone_page_state(zpdesc_page(zpdesc), NR_ZSPAGES);
@@ -476,11 +471,6 @@ static void record_obj(unsigned long handle, unsigned long obj)
WRITE_ONCE(*(unsigned long *)handle, obj);
}
-static inline bool __maybe_unused is_first_zpdesc(struct zpdesc *zpdesc)
-{
- return PagePrivate(zpdesc_page(zpdesc));
-}
-
/* Protected by class->lock */
static inline int get_zspage_inuse(struct zspage *zspage)
{
@@ -496,7 +486,8 @@ static struct zpdesc *get_first_zpdesc(struct zspage *zspage)
{
struct zpdesc *first_zpdesc = zspage->first_zpdesc;
- VM_BUG_ON_PAGE(!is_first_zpdesc(first_zpdesc), zpdesc_page(first_zpdesc));
+ /* the first zpdesc must point back to this zspage */
+ VM_WARN_ON_ONCE_PAGE(first_zpdesc->zspage != zspage, zpdesc_page(first_zpdesc));
return first_zpdesc;
}
@@ -838,7 +829,8 @@ static inline bool obj_allocated(struct zpdesc *zpdesc, void *obj,
struct zspage *zspage = get_zspage(zpdesc);
if (unlikely(ZsHugePage(zspage))) {
- VM_BUG_ON_PAGE(!is_first_zpdesc(zpdesc), zpdesc_page(zpdesc));
+ /* only first zpdesc holds the handle */
+ VM_WARN_ON_ONCE_PAGE(zspage->first_zpdesc != zpdesc, zpdesc_page(zpdesc));
handle = zpdesc->handle;
} else
handle = *(unsigned long *)obj;
@@ -853,9 +845,6 @@ static inline bool obj_allocated(struct zpdesc *zpdesc, void *obj,
static void reset_zpdesc(struct zpdesc *zpdesc)
{
- struct page *page = zpdesc_page(zpdesc);
-
- ClearPagePrivate(page);
zpdesc->zspage = NULL;
zpdesc->next = NULL;
/* PageZsmalloc is sticky until the page is freed to the buddy. */
@@ -1006,8 +995,8 @@ static void create_page_chain(struct size_class *class, struct zspage *zspage,
* 1. all pages are linked together using zpdesc->next
* 2. each sub-page point to zspage using zpdesc->zspage
*
- * we set PG_private to identify the first zpdesc (i.e. no other zpdesc
- * has this flag set).
+ * The first zpdesc has its zspage->first_zpdesc set to itself, no
+ * other zpdesc has this set.
*/
for (i = 0; i < nr_zpdescs; i++) {
zpdesc = zpdescs[i];
@@ -1015,7 +1004,6 @@ static void create_page_chain(struct size_class *class, struct zspage *zspage,
zpdesc->next = NULL;
if (i == 0) {
zspage->first_zpdesc = zpdesc;
- zpdesc_set_first(zpdesc);
if (unlikely(class->objs_per_zspage == 1 &&
class->pages_per_zspage == 1))
SetZsHugePage(zspage);
diff --git a/tools/mm/page-types.c b/tools/mm/page-types.c
index 7fc5a8be5997f..47e4781c5fc38 100644
--- a/tools/mm/page-types.c
+++ b/tools/mm/page-types.c
@@ -73,7 +73,6 @@
#define KPF_RESERVED 32
#define KPF_MLOCKED 33
#define KPF_OWNER_2 34
-#define KPF_PRIVATE 35
#define KPF_PRIVATE_2 36
#define KPF_OWNER_PRIVATE 37
#define KPF_ARCH 38
@@ -131,7 +130,6 @@ static const char * const page_flag_names[] = {
[KPF_RESERVED] = "r:reserved",
[KPF_MLOCKED] = "m:mlocked",
[KPF_OWNER_2] = "d:owner_2",
- [KPF_PRIVATE] = "P:private",
[KPF_PRIVATE_2] = "p:private_2",
[KPF_OWNER_PRIVATE] = "O:owner_private",
[KPF_ARCH] = "h:arch",
|
| 73/3 | 2026/09/22 23:14 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 20605 output: 32 thoughts: 1343 Thoughts: **KMSAN Fuzzing Session Justification** Okay, let's break this down. My goal is to determine if this patch series warrants a dedicated KMSAN fuzzing session. The guiding principle is to identify changes that introduce or modify kernel code paths where uninitialized memory reads or leaks are possible. So, first, I need to understand what KMSAN actually looks for, and then how this patch alters things. KMSAN flags potential issues around reads of uninitialized memory in the kernel space. Specifically, it highlights changes that interact with user space, conditional logic tied to uninitialized variables, allocation of complex data structures with uninitialized fields, and bounds/length checks that might allow reading beyond the intended buffer bounds. If the patch only deals with bugs that KASAN, LOCKDEP or other bug detectors already catch, or if the patched code is fully initialized and doesn't introduce any new risks, a KMSAN session isn't needed. So, what's this patch doing? It looks like it's removing the `PG_private` page flag and replacing it with a `folio->private` pointer or similar constructs like `folio_has_attached_private()`. Instead of a specific bit in the `page` structure, we're using the `private` pointer in the `folio` structure. Now, let's step through the code changes. I need to see if any of these modifications create a path for uninitialized memory to creep into user-space-facing structures. The initial replacements in `include/linux/page-flags.h` seem straightforward: `PG_private` becomes `PG_folio` (which is reserved for folio identification). The `folio_test_private` function now checks the `folio->private` pointer using `data_race`. The MD bitmap changes in `drivers/md/md-bitmap.c` look like a simple replacement of the `PagePrivate`, `alloc_page_buffers` with folio-based functions. Similarly, modifications in `arch/x86/events/intel/bts.c` and `arch/x86/events/intel/pt.c` appear to be straightforward adaptations, replacing the old `PagePrivate(page)` with `page_private(page)` and `folio->private`. Xen grant table, Ceph, and Crypto changes look like mostly direct replacements from the page to folio interface, using functions like `folio_attach_private`, `folio_detach_private`, `folio_set_private` etc. The EROFS changes are interesting: they're biasing the `->private` field to ensure it is not zero in `erofs_onlinefolio_init` and `erofs_onlinefolio_end`, to avoid any unintentional use of uninitialized values. Same thing with `readahead_folio_last(rac)` function, previously it had to set `folio->private = head` on reverse order traversal. The F2FS changes convert to folio equivalents, and the NFS changes seem to be primarily comment updates with removal of `folio_set_private` calls. Now, that `/proc/kpageflags` change is what I need to focus on. I see `KPF_PRIVATE` is being removed from the bit copy in `fs/proc/page.c`. That's a red flag! But, let's trace this. Specifically, the line `u |= kpf_copy_bit(k, KPF_PRIVATE, PG_private);` is *removed* from the `stable_page_flags` function. This means the bit representing `PG_private` (bit 35) is no longer copied into the `u64` that's presented to user space. It looks like the `u` is initialized to 0. Is this *really* just a removal, or are we introducing a situation where uninitialized memory can leak? The value is not being copied anymore, which by default is zero. If the bit was never set it is 0, so that part should be fine. I'm going to have to dig further to see if there's any scenario where this change, combined with other changes, could allow uninitialized data related to the private flag to leak via `/proc/kpageflags`. I'll need to analyze exactly what the `stable_page_flags` function does in context of these modifications, specifically focusing on how the `private` field of a `folio` is handled. Perhaps more than a full KMSAN session, this might warrant targeted analysis around the `/proc/kpageflags` interface. I need to make sure this removal isn't creating an info-leak vulnerability by making `KPF_PRIVATE` default to 0. |
| 74/3 | 2026/09/22 23:14 | tool | grepper |
0mArgs:{
"Expression": "stable_page_flags",
"PathPrefix": "fs/proc/page.c"
}Results: {
"Output": "fs/proc/page.c=61=static ssize_t kpage_read(struct file *file, char __user *buf,\n--\nfs/proc/page.c-89-\t\t\tcase KPAGE_FLAGS:\nfs/proc/page.c:90:\t\t\t\tinfo = stable_page_flags(page);\nfs/proc/page.c-91-\t\t\t\tbreak;\n--\nfs/proc/page.c=141=static inline u64 kpf_copy_bit(u64 kflags, int ubit, int kbit)\n--\nfs/proc/page.c-145-\nfs/proc/page.c:146:u64 stable_page_flags(const struct page *page)\nfs/proc/page.c-147-{\n--\nfs/proc/page.c-246-}\nfs/proc/page.c:247:EXPORT_SYMBOL_GPL(stable_page_flags);\nfs/proc/page.c-248-\n"
} |
| 75/3 | 2026/09/22 23:14 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 23229 output: 35 thoughts: 32 Thoughts: Here's my take: **Peeking into `fs/proc/page.c` for `u` Initialization** Alright, let's dive into the guts of the kernel and examine how this `u` variable is initialized within the `fs/proc/page.c` file. I need to refresh my memory on the specific context, so I'll zero in on lines 146 through 246. That should give me a solid understanding of the initialization process for `u` and its role within this particular part of the virtual filesystem related to the `/proc` interface and its presentation of memory information. I'm hoping to understand the nuances of how this variable is set up in memory. Let's see what the code reveals! |
| 76/3 | 2026/09/22 23:14 | tool | read-file |
0mArgs:{
"File": "fs/proc/page.c",
"FirstLine": 146,
"LineCount": 40
}Results: {
"Contents": " 146:\tu64 stable_page_flags(const struct page *page)\n 147:\t{\n 148:\t\tconst struct folio *folio;\n 149:\t\tstruct page_snapshot ps;\n 150:\t\tunsigned long k;\n 151:\t\tu64 u = 0;\n 152:\t\n 153:\t\t/*\n 154:\t\t * pseudo flag: KPF_NOPAGE\n 155:\t\t * it differentiates a memory hole from a page with no flags\n 156:\t\t */\n 157:\t\tif (!page)\n 158:\t\t\treturn BIT_ULL(KPF_NOPAGE);\n 159:\t\n 160:\t\tsnapshot_page(\u0026ps, page);\n 161:\t\tfolio = \u0026ps.folio_snapshot;\n 162:\t\tk = folio-\u003eflags.f;\n 163:\t\n 164:\t\t/*\n 165:\t\t * pseudo flags for the well known (anonymous) memory mapped pages\n 166:\t\t */\n 167:\t\tif (folio_mapped(folio))\n 168:\t\t\tu |= BIT_ULL(KPF_MMAP);\n 169:\t\tif (folio_test_anon(folio)) {\n 170:\t\t\tu |= BIT_ULL(KPF_ANON);\n 171:\t\t\tif (folio_test_ksm(folio))\n 172:\t\t\t\tu |= BIT_ULL(KPF_KSM);\n 173:\t\t}\n 174:\t\n 175:\t\t/*\n 176:\t\t * compound pages: export both head/tail info\n 177:\t\t * they together define a compound page's start/end pos and order\n 178:\t\t */\n 179:\t\tif (ps.idx == 0)\n 180:\t\t\tu |= kpf_copy_bit(k, KPF_COMPOUND_HEAD, PG_head);\n 181:\t\telse\n 182:\t\t\tu |= BIT_ULL(KPF_COMPOUND_TAIL);\n 183:\t\tif (folio_test_hugetlb(folio))\n 184:\t\t\tu |= BIT_ULL(KPF_HUGE);\n 185:\t\telse if (folio_test_large(folio) \u0026\u0026\n"
} |
| 77/3 | 2026/09/22 23:14 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 24046 output: 33 thoughts: 152 Thoughts: **Analyzing the Patch's Impact on Readahead Control** Okay, so `u` is initialized to zero; that's straightforward and fully understood. Now, I need to see the broader implications of this patch. Let's dig into the affected areas, specifically `include/linux/pagemap.h`. I see changes related to `readahead_folio_last`, `__readahead_advance`, and especially the `struct readahead_control`. The core of this seems to revolve around the readahead mechanism. My immediate focus is how `struct readahead_control` is initialized everywhere it's used. In that header file, I'm noticing a new member, `_forward`, added to the structure. This is a key detail. Now, where is this struct actually *created* and populated? I need to track down all instances of `struct readahead_control` initialization. `DEFINE_READAHEAD` is the obvious starting point. I'll need to scrutinize that macro, and then search for all other direct instantiations of the `readahead_control` structure throughout the codebase. Understanding these initializations will reveal how this new `_forward` member is being used and what impact it's having on the readahead process. |
| 78/3 | 2026/09/22 23:14 | tool | grepper |
0mArgs:{
"Expression": "readahead_control",
"PathPrefix": "include/linux/pagemap.h"
}Results: {
"Output": "include/linux/pagemap.h=1377=static inline bool filemap_range_needs_writeback(struct address_space *mapping,\n--\ninclude/linux/pagemap.h-1389-/**\ninclude/linux/pagemap.h:1390: * struct readahead_control - Describes a readahead request.\ninclude/linux/pagemap.h-1391- *\n--\ninclude/linux/pagemap.h-1404- */\ninclude/linux/pagemap.h:1405:struct readahead_control {\ninclude/linux/pagemap.h-1406-\tstruct file *file;\n--\ninclude/linux/pagemap.h-1419-#define DEFINE_READAHEAD(ractl, f, r, m, i)\t\t\t\t\\\ninclude/linux/pagemap.h:1420:\tstruct readahead_control ractl = {\t\t\t\t\\\ninclude/linux/pagemap.h-1421-\t\t.file = f,\t\t\t\t\t\t\\\n--\ninclude/linux/pagemap.h-1428-\ninclude/linux/pagemap.h:1429:void page_cache_ra_unbounded(struct readahead_control *,\ninclude/linux/pagemap.h-1430-\t\tunsigned long nr_to_read, unsigned long lookahead_count);\ninclude/linux/pagemap.h:1431:void page_cache_sync_ra(struct readahead_control *, unsigned long req_count);\ninclude/linux/pagemap.h:1432:void page_cache_async_ra(struct readahead_control *, struct folio *,\ninclude/linux/pagemap.h-1433-\t\tunsigned long req_count);\ninclude/linux/pagemap.h:1434:void readahead_expand(struct readahead_control *ractl,\ninclude/linux/pagemap.h-1435-\t\t loff_t new_start, size_t new_len);\n--\ninclude/linux/pagemap.h=1473=void page_cache_async_readahead(struct address_space *mapping,\n--\ninclude/linux/pagemap.h-1481-/*\ninclude/linux/pagemap.h:1482: * Adjust readahead_control to ensure next folio comes from\ninclude/linux/pagemap.h-1483- * [_index, _index + _nr_pages) afterwards and reset _batch_count.\ninclude/linux/pagemap.h-1484- */\ninclude/linux/pagemap.h:1485:static inline void __readahead_advance(struct readahead_control *rac)\ninclude/linux/pagemap.h-1486-{\n--\ninclude/linux/pagemap.h-1493-\ninclude/linux/pagemap.h:1494:static inline struct folio *__readahead_folio(struct readahead_control *ractl)\ninclude/linux/pagemap.h-1495-{\n--\ninclude/linux/pagemap.h-1519- */\ninclude/linux/pagemap.h:1520:static inline struct folio *readahead_folio(struct readahead_control *ractl)\ninclude/linux/pagemap.h-1521-{\n--\ninclude/linux/pagemap.h-1539- */\ninclude/linux/pagemap.h:1540:static inline struct folio *readahead_folio_last(struct readahead_control *ractl)\ninclude/linux/pagemap.h-1541-{\n--\ninclude/linux/pagemap.h-1561-\ninclude/linux/pagemap.h:1562:static inline unsigned int __readahead_batch(struct readahead_control *rac,\ninclude/linux/pagemap.h-1563-\t\tstruct page **array, unsigned int array_sz)\n--\ninclude/linux/pagemap.h-1592- */\ninclude/linux/pagemap.h:1593:static inline loff_t readahead_pos(const struct readahead_control *rac)\ninclude/linux/pagemap.h-1594-{\n--\ninclude/linux/pagemap.h-1601- */\ninclude/linux/pagemap.h:1602:static inline size_t readahead_length(const struct readahead_control *rac)\ninclude/linux/pagemap.h-1603-{\n--\ninclude/linux/pagemap.h-1610- */\ninclude/linux/pagemap.h:1611:static inline pgoff_t readahead_index(const struct readahead_control *rac)\ninclude/linux/pagemap.h-1612-{\n--\ninclude/linux/pagemap.h-1619- */\ninclude/linux/pagemap.h:1620:static inline unsigned int readahead_count(const struct readahead_control *rac)\ninclude/linux/pagemap.h-1621-{\n--\ninclude/linux/pagemap.h-1628- */\ninclude/linux/pagemap.h:1629:static inline size_t readahead_batch_length(const struct readahead_control *rac)\ninclude/linux/pagemap.h-1630-{\n"
} |
| 79/3 | 2026/09/22 23:14 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 25864 output: 38 thoughts: 27 Thoughts: Okay, here's my attempt at summarizing the thought process, as requested, aimed at an expert audience and in the first person: **Diving into the Pagemap Header** Alright, I need to get a handle on how this function interacts with the page cache. My immediate instinct is to check the core definitions that are likely at play. Let's zero in on `include/linux/pagemap.h`, and specifically lines 1405 through 1440. That range usually covers crucial structures and macros related to page mapping or perhaps some essential inline functions for page operations. I'm hoping to refresh my memory on the data structures involved—specifically, how the page cache is organized and how it interacts with the underlying physical memory. I'm expecting to find declarations, like struct page definitions or perhaps related helper macros for manipulating page flags within that range. A quick scan of those lines will likely clarify if there are any specific locks in play and how they are handled. This will immediately make it clearer whether this might be a potential concurrency bottleneck or if it's more straightforward page management. |
| 80/3 | 2026/09/22 23:14 | tool | read-file |
0mArgs:{
"File": "include/linux/pagemap.h",
"FirstLine": 1405,
"LineCount": 40
}Results: {
"Contents": "1405:\tstruct readahead_control {\n1406:\t\tstruct file *file;\n1407:\t\tstruct address_space *mapping;\n1408:\t\tstruct file_ra_state *ra;\n1409:\t/* private: use the readahead_* accessors instead */\n1410:\t\tpgoff_t _index;\n1411:\t\tunsigned int _nr_pages;\n1412:\t\tunsigned int _batch_count;\n1413:\t\tbool dropbehind;\n1414:\t\tbool _workingset;\n1415:\t\tunsigned long _pflags;\n1416:\t\tbool _forward;\n1417:\t};\n1418:\t\n1419:\t#define DEFINE_READAHEAD(ractl, f, r, m, i)\t\t\t\t\\\n1420:\t\tstruct readahead_control ractl = {\t\t\t\t\\\n1421:\t\t\t.file = f,\t\t\t\t\t\t\\\n1422:\t\t\t.mapping = m,\t\t\t\t\t\t\\\n1423:\t\t\t.ra = r,\t\t\t\t\t\t\\\n1424:\t\t\t._index = i,\t\t\t\t\t\t\\\n1425:\t\t}\n1426:\t\n1427:\t#define VM_READAHEAD_PAGES\t(SZ_128K / PAGE_SIZE)\n1428:\t\n1429:\tvoid page_cache_ra_unbounded(struct readahead_control *,\n1430:\t\t\tunsigned long nr_to_read, unsigned long lookahead_count);\n1431:\tvoid page_cache_sync_ra(struct readahead_control *, unsigned long req_count);\n1432:\tvoid page_cache_async_ra(struct readahead_control *, struct folio *,\n1433:\t\t\tunsigned long req_count);\n1434:\tvoid readahead_expand(struct readahead_control *ractl,\n1435:\t\t\t loff_t new_start, size_t new_len);\n1436:\t\n1437:\t/**\n1438:\t * page_cache_sync_readahead - generic file readahead\n1439:\t * @mapping: address_space which holds the pagecache and I/O vectors\n1440:\t * @ra: file_ra_state which holds the readahead state\n1441:\t * @file: Used by the filesystem for authentication.\n1442:\t * @index: Index of first page to be read.\n1443:\t * @req_count: Total number of pages being read by the caller.\n1444:\t *\n"
} |
| 81/3 | 2026/09/22 23:14 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 26824 output: 21 thoughts: 61 Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience: **Analyzing Read-Ahead Structure Initialization** Right, so in this `DEFINE_READAHEAD` macro, we're leveraging designated initializers within the struct definition. That's good, that's clean. The real implication here is that any fields I *don't* explicitly set – like `_forward` or `_batch_count` – are going to be zeroed out automatically, thanks to C's default initialization for unspecified members in designated initializer lists. This is precisely the behavior I expect and, frankly, what I rely on to avoid uninitialized memory issues and potential subtle bugs. It provides a level of safety that's critical in these low-level data structures. Now, that's helpful in this specific instance, but it makes me wonder: where else are we creating instances of `struct readahead_control` throughout the code? I need to quickly scan the codebase to identify other instantiation points. Understanding all the places where this struct is populated is important, and finding all the ways it's initialized is the next logical step. If other locations rely on similar initialization schemes, I need to ensure they are also doing this safely, to avoid introducing unexpected behavior. |
| 82/3 | 2026/09/22 23:14 | tool | grepper |
0mArgs:{
"Expression": "struct readahead_control "
}Results: {
"Output": "Documentation/filesystems/iomap/operations.rst=207=iomap_read_folio_ctx``:\n--\nDocumentation/filesystems/iomap/operations.rst-213- struct folio *cur_folio;\nDocumentation/filesystems/iomap/operations.rst:214: struct readahead_control *rac;\nDocumentation/filesystems/iomap/operations.rst-215- void *read_ctx;\n--\nDocumentation/filesystems/locking.rst=245=prototypes::\n--\nDocumentation/filesystems/locking.rst-249-\tbool (*dirty_folio)(struct address_space *, struct folio *folio);\nDocumentation/filesystems/locking.rst:250:\tvoid (*readahead)(struct readahead_control *);\nDocumentation/filesystems/locking.rst-251-\tint (*write_begin)(const struct kiocb *, struct address_space *mapping,\n--\nDocumentation/filesystems/netfs_library.rst=460=for it to intervene at various times::\nDocumentation/filesystems/netfs_library.rst-461-\nDocumentation/filesystems/netfs_library.rst:462:\tvoid netfs_readahead(struct readahead_control *);\nDocumentation/filesystems/netfs_library.rst-463-\tint netfs_read_folio(struct file *, struct folio *);\n--\nDocumentation/filesystems/vfs.rst=749=cache in your filesystem. The following members are defined:\n--\nDocumentation/filesystems/vfs.rst-756-\t\tbool (*dirty_folio)(struct address_space *, struct folio *);\nDocumentation/filesystems/vfs.rst:757:\t\tvoid (*readahead)(struct readahead_control *);\nDocumentation/filesystems/vfs.rst-758-\t\tint (*write_begin)(const struct kiocb *, struct address_space *mapping,\n--\nblock/fops.c=493=static int blkdev_read_folio(struct file *file, struct folio *folio)\n--\nblock/fops.c-497-\nblock/fops.c:498:static void blkdev_readahead(struct readahead_control *rac)\nblock/fops.c-499-{\n--\nblock/fops.c=513=static int blkdev_read_folio(struct file *file, struct folio *folio)\n--\nblock/fops.c-518-\nblock/fops.c:519:static void blkdev_readahead(struct readahead_control *rac)\nblock/fops.c-520-{\n--\nfs/btrfs/extent_io.c=99=struct btrfs_bio_ctrl {\n--\nfs/btrfs/extent_io.c-135-\nfs/btrfs/extent_io.c:136:\tstruct readahead_control *ractl;\nfs/btrfs/extent_io.c-137-\n--\nfs/btrfs/extent_io.c=998=static struct extent_map *get_extent_map(struct btrfs_inode *inode,\n--\nfs/btrfs/extent_io.c-1027-\nfs/btrfs/extent_io.c:1028:static void btrfs_readahead_expand(struct readahead_control *ractl,\nfs/btrfs/extent_io.c-1029-\t\t\t\t const struct extent_map *em)\n--\nfs/btrfs/extent_io.c=2961=int btrfs_writepages(struct address_space *mapping, struct writeback_control *wbc)\n--\nfs/btrfs/extent_io.c-2980-\nfs/btrfs/extent_io.c:2981:void btrfs_readahead(struct readahead_control *rac)\nfs/btrfs/extent_io.c-2982-{\n--\nfs/btrfs/extent_io.h=287=void btrfs_btree_wait_writeback_range(struct btrfs_fs_info *fs_info, u64 start, u64 end);\nfs/btrfs/extent_io.h:288:void btrfs_readahead(struct readahead_control *rac);\nfs/btrfs/extent_io.h-289-int set_folio_extent_mapped(struct folio *folio);\n--\nfs/erofs/data.c=398=static int erofs_read_folio(struct file *file, struct folio *folio)\n--\nfs/erofs/data.c-415-\nfs/erofs/data.c:416:static void erofs_readahead(struct readahead_control *rac)\nfs/erofs/data.c-417-{\n--\nfs/erofs/fileio.c=157=static int erofs_fileio_read_folio(struct file *file, struct folio *folio)\n--\nfs/erofs/fileio.c-171-\nfs/erofs/fileio.c:172:static void erofs_fileio_readahead(struct readahead_control *rac)\nfs/erofs/fileio.c-173-{\n--\nfs/erofs/zdata.c=1814=static void z_erofs_pcluster_readmore(struct z_erofs_frontend *f,\nfs/erofs/zdata.c:1815:\t\tstruct readahead_control *rac, bool backmost)\nfs/erofs/zdata.c-1816-{\n--\nfs/erofs/zdata.c=1866=static int z_erofs_read_folio(struct file *file, struct folio *folio)\n--\nfs/erofs/zdata.c-1893-\nfs/erofs/zdata.c:1894:static void z_erofs_readahead(struct readahead_control *rac)\nfs/erofs/zdata.c-1895-{\n--\nfs/exfat/inode.c=244=static int exfat_read_folio(struct file *file, struct folio *folio)\n--\nfs/exfat/inode.c-254-\nfs/exfat/inode.c:255:static void exfat_readahead(struct readahead_control *rac)\nfs/exfat/inode.c-256-{\n--\nfs/ext2/inode.c=891=static int ext2_read_folio(struct file *file, struct folio *folio)\n--\nfs/ext2/inode.c-895-\nfs/ext2/inode.c:896:static void ext2_readahead(struct readahead_control *rac)\nfs/ext2/inode.c-897-{\n--\nfs/ext4/ext4.h=3863=int ext4_read_folio(struct file *file, struct folio *folio);\nfs/ext4/ext4.h:3864:void ext4_readahead(struct readahead_control *rac);\nfs/ext4/ext4.h-3865-int __init ext4_init_verity_caches(void);\n--\nfs/ext4/readpage.c=137=static int ext4_mpage_readpages(struct inode *inode, struct fsverity_info *vi,\nfs/ext4/readpage.c:138:\t\tstruct readahead_control *rac, struct folio *folio)\nfs/ext4/readpage.c-139-{\n--\nfs/ext4/readpage.c=321=int ext4_read_folio(struct file *file, struct folio *folio)\n--\nfs/ext4/readpage.c-341-\nfs/ext4/readpage.c:342:void ext4_readahead(struct readahead_control *rac)\nfs/ext4/readpage.c-343-{\n--\nfs/f2fs/data.c=2200=static inline loff_t f2fs_readpage_limit(struct inode *inode)\n--\nfs/f2fs/data.c-2207-\nfs/f2fs/data.c:2208:static inline blk_opf_t f2fs_ra_op_flags(struct readahead_control *rac)\nfs/f2fs/data.c-2209-{\n--\nfs/f2fs/data.c=2213=static int f2fs_read_single_page(struct inode *inode, struct fsverity_info *vi,\n--\nfs/f2fs/data.c-2217-\t\t\t\t sector_t *last_block_in_bio,\nfs/f2fs/data.c:2218:\t\t\t\t struct readahead_control *rac)\nfs/f2fs/data.c-2219-{\n--\nfs/f2fs/data.c=2317=int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret,\nfs/f2fs/data.c-2318-\t\t\t\tunsigned nr_pages, sector_t *last_block_in_bio,\nfs/f2fs/data.c:2319:\t\t\t\tstruct readahead_control *rac, bool for_write)\nfs/f2fs/data.c-2320-{\n--\nfs/f2fs/data.c=2516=static int f2fs_read_data_large_folio(struct inode *inode,\nfs/f2fs/data.c-2517-\t\tstruct fsverity_info *vi,\nfs/f2fs/data.c:2518:\t\tstruct readahead_control *rac, struct folio *folio)\nfs/f2fs/data.c-2519-{\n--\nfs/f2fs/data.c=2668=static int f2fs_mpage_readpages(struct inode *inode, struct fsverity_info *vi,\nfs/f2fs/data.c:2669:\t\tstruct readahead_control *rac, struct folio *folio)\nfs/f2fs/data.c-2670-{\n--\nfs/f2fs/data.c=2796=static int f2fs_read_data_folio(struct file *file, struct folio *folio)\n--\nfs/f2fs/data.c-2821-\nfs/f2fs/data.c:2822:static void f2fs_readahead(struct readahead_control *rac)\nfs/f2fs/data.c-2823-{\n--\nfs/f2fs/f2fs.h=4732=int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret,\nfs/f2fs/f2fs.h-4733-\t\t\t\tunsigned nr_pages, sector_t *last_block_in_bio,\nfs/f2fs/f2fs.h:4734:\t\t\t\tstruct readahead_control *rac, bool for_write);\nfs/f2fs/f2fs.h-4735-struct decompress_io_ctx *f2fs_alloc_dic(struct compress_ctx *cc);\n--\nfs/fat/inode.c=203=static int fat_read_folio(struct file *file, struct folio *folio)\n--\nfs/fat/inode.c-207-\nfs/fat/inode.c:208:static void fat_readahead(struct readahead_control *rac)\nfs/fat/inode.c-209-{\n--\nfs/fuse/file.c=916=static int fuse_handle_readahead(struct folio *folio,\nfs/fuse/file.c:917:\t\t\t\t struct readahead_control *rac,\nfs/fuse/file.c-918-\t\t\t\t struct fuse_fill_read_data *data, loff_t pos,\n--\nfs/fuse/file.c=1057=static void fuse_send_readpages(struct fuse_io_args *ia, struct file *file,\n--\nfs/fuse/file.c-1092-\nfs/fuse/file.c:1093:static void fuse_readahead(struct readahead_control *rac)\nfs/fuse/file.c-1094-{\n--\nfs/gfs2/aops.c=450=ssize_t gfs2_internal_read(struct gfs2_inode *ip, char *buf, loff_t *pos,\n--\nfs/gfs2/aops.c-492-\nfs/gfs2/aops.c:493:static void gfs2_readahead(struct readahead_control *rac)\nfs/gfs2/aops.c-494-{\n--\nfs/hpfs/file.c=165=static int hpfs_read_folio(struct file *file, struct folio *folio)\n--\nfs/hpfs/file.c-169-\nfs/hpfs/file.c:170:static void hpfs_readahead(struct readahead_control *rac)\nfs/hpfs/file.c-171-{\n--\nfs/iomap/buffered-io.c=728=void iomap_readahead(const struct iomap_ops *ops,\n--\nfs/iomap/buffered-io.c-730-{\nfs/iomap/buffered-io.c:731:\tstruct readahead_control *rac = ctx-\u003erac;\nfs/iomap/buffered-io.c-732-\tstruct iomap_iter iter = {\n--\nfs/isofs/inode.c=1148=static int isofs_read_folio(struct file *file, struct folio *folio)\n--\nfs/isofs/inode.c-1152-\nfs/isofs/inode.c:1153:static void isofs_readahead(struct readahead_control *rac)\nfs/isofs/inode.c-1154-{\n--\nfs/jfs/inode.c=279=static int jfs_read_folio(struct file *file, struct folio *folio)\n--\nfs/jfs/inode.c-283-\nfs/jfs/inode.c:284:static void jfs_readahead(struct readahead_control *rac)\nfs/jfs/inode.c-285-{\n--\nfs/mpage.c=150=static void do_mpage_readpage(struct mpage_readpage_args *args)\n--\nfs/mpage.c-357- */\nfs/mpage.c:358:void mpage_readahead(struct readahead_control *rac, get_block_t get_block)\nfs/mpage.c-359-{\n--\nfs/netfs/buffered_read.c=23=static void netfs_rreq_expand(struct netfs_io_request *rreq,\nfs/netfs/buffered_read.c:24:\t\t\t struct readahead_control *ractl)\nfs/netfs/buffered_read.c-25-{\n--\nfs/netfs/buffered_read.c=81=static ssize_t netfs_prepare_read_iterator(struct netfs_io_subrequest *subreq,\nfs/netfs/buffered_read.c:82:\t\t\t\t\t struct readahead_control *ractl)\nfs/netfs/buffered_read.c-83-{\n--\nfs/netfs/buffered_read.c=211=static void netfs_read_to_pagecache(struct netfs_io_request *rreq,\nfs/netfs/buffered_read.c:212:\t\t\t\t struct readahead_control *ractl)\nfs/netfs/buffered_read.c-213-{\n--\nfs/netfs/buffered_read.c-337- */\nfs/netfs/buffered_read.c:338:void netfs_readahead(struct readahead_control *ractl)\nfs/netfs/buffered_read.c-339-{\n--\nfs/netfs/rolling_buffer.c=120=ssize_t rolling_buffer_load_from_ra(struct rolling_buffer *roll,\nfs/netfs/rolling_buffer.c:121:\t\t\t\t struct readahead_control *ractl,\nfs/netfs/rolling_buffer.c-122-\t\t\t\t struct folio_batch *put_batch)\n--\nfs/nfs/fscache.c=244=int nfs_netfs_read_folio(struct file *file, struct folio *folio)\n--\nfs/nfs/fscache.c-251-\nfs/nfs/fscache.c:252:int nfs_netfs_readahead(struct readahead_control *ractl)\nfs/nfs/fscache.c-253-{\n--\nfs/nfs/fscache.h=98=extern void nfs_fscache_release_file(struct inode *, struct file *);\nfs/nfs/fscache.h:99:extern int nfs_netfs_readahead(struct readahead_control *ractl);\nfs/nfs/fscache.h-100-extern int nfs_netfs_read_folio(struct file *file, struct folio *folio);\n--\nfs/nfs/fscache.h=176=static inline void nfs_fscache_release_file(struct inode *inode, struct file *file) {}\nfs/nfs/fscache.h:177:static inline int nfs_netfs_readahead(struct readahead_control *ractl)\nfs/nfs/fscache.h-178-{\n--\nfs/nfs/read.c=390=int nfs_read_folio(struct file *file, struct folio *folio)\n--\nfs/nfs/read.c-428-\nfs/nfs/read.c:429:void nfs_readahead(struct readahead_control *ractl)\nfs/nfs/read.c-430-{\n--\nfs/nilfs2/inode.c=149=static int nilfs_read_folio(struct file *file, struct folio *folio)\n--\nfs/nilfs2/inode.c-153-\nfs/nilfs2/inode.c:154:static void nilfs_readahead(struct readahead_control *rac)\nfs/nilfs2/inode.c-155-{\n--\nfs/ntfs/aops.c=133=static sector_t ntfs_bmap(struct address_space *mapping, sector_t block)\n--\nfs/ntfs/aops.c-231-\nfs/ntfs/aops.c:232:static void ntfs_readahead(struct readahead_control *rac)\nfs/ntfs/aops.c-233-{\n--\nfs/ntfs3/inode.c=826=static int ntfs_read_folio(struct file *file, struct folio *folio)\n--\nfs/ntfs3/inode.c-859-\nfs/ntfs3/inode.c:860:static void ntfs_readahead(struct readahead_control *rac)\nfs/ntfs3/inode.c-861-{\n--\nfs/ocfs2/aops.c=264=static int ocfs2_read_folio(struct file *file, struct folio *folio)\n--\nfs/ocfs2/aops.c-335- */\nfs/ocfs2/aops.c:336:static void ocfs2_readahead(struct readahead_control *rac)\nfs/ocfs2/aops.c-337-{\n--\nfs/omfs/file.c=287=static int omfs_read_folio(struct file *file, struct folio *folio)\n--\nfs/omfs/file.c-291-\nfs/omfs/file.c:292:static void omfs_readahead(struct readahead_control *rac)\nfs/omfs/file.c-293-{\n--\nfs/orangefs/inode.c=215=static int orangefs_launder_folio(struct folio *);\nfs/orangefs/inode.c-216-\nfs/orangefs/inode.c:217:static void orangefs_readahead(struct readahead_control *rac)\nfs/orangefs/inode.c-218-{\n--\nfs/qnx6/inode.c=98=static int qnx6_read_folio(struct file *file, struct folio *folio)\n--\nfs/qnx6/inode.c-102-\nfs/qnx6/inode.c:103:static void qnx6_readahead(struct readahead_control *rac)\nfs/qnx6/inode.c-104-{\n--\nfs/squashfs/file.c=505=static int squashfs_readahead_fragment(struct inode *inode, struct page **page,\n--\nfs/squashfs/file.c-573-\nfs/squashfs/file.c:574:static void squashfs_readahead(struct readahead_control *ractl)\nfs/squashfs/file.c-575-{\n--\nfs/udf/inode.c=222=static int udf_read_folio(struct file *file, struct folio *folio)\n--\nfs/udf/inode.c-233-\nfs/udf/inode.c:234:static void udf_readahead(struct readahead_control *rac)\nfs/udf/inode.c-235-{\n--\nfs/zonefs/file.c=118=static int zonefs_read_folio(struct file *unused, struct folio *folio)\n--\nfs/zonefs/file.c-123-\nfs/zonefs/file.c:124:static void zonefs_readahead(struct readahead_control *rac)\nfs/zonefs/file.c-125-{\n--\ninclude/linux/fs.h=401=struct address_space_operations {\n--\ninclude/linux/fs.h-409-\ninclude/linux/fs.h:410:\tvoid (*readahead)(struct readahead_control *);\ninclude/linux/fs.h-411-\n--\ninclude/linux/iomap.h=580=struct iomap_read_folio_ctx {\n--\ninclude/linux/iomap.h-582-\tstruct folio\t\t*cur_folio;\ninclude/linux/iomap.h:583:\tstruct readahead_control *rac;\ninclude/linux/iomap.h-584-\tvoid\t\t\t*read_ctx;\n--\ninclude/linux/iomap.h=771=static inline void iomap_bio_read_folio(struct folio *folio,\n--\ninclude/linux/iomap.h-781-\ninclude/linux/iomap.h:782:static inline void iomap_bio_readahead(struct readahead_control *rac,\ninclude/linux/iomap.h-783-\t\tconst struct iomap_ops *ops)\n--\ninclude/linux/mpage.h=16=struct readahead_control;\ninclude/linux/mpage.h-17-\ninclude/linux/mpage.h:18:void mpage_readahead(struct readahead_control *, get_block_t get_block);\ninclude/linux/mpage.h-19-int mpage_read_folio(struct folio *folio, get_block_t get_block);\n--\ninclude/linux/netfs.h=408=struct readahead_control;\ninclude/linux/netfs.h:409:void netfs_readahead(struct readahead_control *);\ninclude/linux/netfs.h-410-int netfs_read_folio(struct file *, struct folio *);\n--\ninclude/linux/nfs_fs.h=646=int nfs_read_folio(struct file *, struct folio *);\ninclude/linux/nfs_fs.h:647:void nfs_readahead(struct readahead_control *);\ninclude/linux/nfs_fs.h-648-\n--\ninclude/linux/pagemap.h=1377=static inline bool filemap_range_needs_writeback(struct address_space *mapping,\n--\ninclude/linux/pagemap.h-1389-/**\ninclude/linux/pagemap.h:1390: * struct readahead_control - Describes a readahead request.\ninclude/linux/pagemap.h-1391- *\n--\ninclude/linux/pagemap.h-1404- */\ninclude/linux/pagemap.h:1405:struct readahead_control {\ninclude/linux/pagemap.h-1406-\tstruct file *file;\n--\ninclude/linux/pagemap.h-1419-#define DEFINE_READAHEAD(ractl, f, r, m, i)\t\t\t\t\\\ninclude/linux/pagemap.h:1420:\tstruct readahead_control ractl = {\t\t\t\t\\\ninclude/linux/pagemap.h-1421-\t\t.file = f,\t\t\t\t\t\t\\\n--\ninclude/linux/pagemap.h-1428-\ninclude/linux/pagemap.h:1429:void page_cache_ra_unbounded(struct readahead_control *,\ninclude/linux/pagemap.h-1430-\t\tunsigned long nr_to_read, unsigned long lookahead_count);\ninclude/linux/pagemap.h:1431:void page_cache_sync_ra(struct readahead_control *, unsigned long req_count);\ninclude/linux/pagemap.h:1432:void page_cache_async_ra(struct readahead_control *, struct folio *,\ninclude/linux/pagemap.h-1433-\t\tunsigned long req_count);\ninclude/linux/pagemap.h:1434:void readahead_expand(struct readahead_control *ractl,\ninclude/linux/pagemap.h-1435-\t\t loff_t new_start, size_t new_len);\n--\ninclude/linux/pagemap.h=1473=void page_cache_async_readahead(struct address_space *mapping,\n--\ninclude/linux/pagemap.h-1484- */\ninclude/linux/pagemap.h:1485:static inline void __readahead_advance(struct readahead_control *rac)\ninclude/linux/pagemap.h-1486-{\n--\ninclude/linux/pagemap.h-1493-\ninclude/linux/pagemap.h:1494:static inline struct folio *__readahead_folio(struct readahead_control *ractl)\ninclude/linux/pagemap.h-1495-{\n--\ninclude/linux/pagemap.h-1519- */\ninclude/linux/pagemap.h:1520:static inline struct folio *readahead_folio(struct readahead_control *ractl)\ninclude/linux/pagemap.h-1521-{\n--\ninclude/linux/pagemap.h-1539- */\ninclude/linux/pagemap.h:1540:static inline struct folio *readahead_folio_last(struct readahead_control *ractl)\ninclude/linux/pagemap.h-1541-{\n--\ninclude/linux/pagemap.h-1561-\ninclude/linux/pagemap.h:1562:static inline unsigned int __readahead_batch(struct readahead_control *rac,\ninclude/linux/pagemap.h-1563-\t\tstruct page **array, unsigned int array_sz)\n--\ninclude/linux/pagemap.h-1592- */\ninclude/linux/pagemap.h:1593:static inline loff_t readahead_pos(const struct readahead_control *rac)\ninclude/linux/pagemap.h-1594-{\n--\ninclude/linux/pagemap.h-1601- */\ninclude/linux/pagemap.h:1602:static inline size_t readahead_length(const struct readahead_control *rac)\ninclude/linux/pagemap.h-1603-{\n--\ninclude/linux/pagemap.h-1610- */\ninclude/linux/pagemap.h:1611:static inline pgoff_t readahead_index(const struct readahead_control *rac)\ninclude/linux/pagemap.h-1612-{\n--\ninclude/linux/pagemap.h-1619- */\ninclude/linux/pagemap.h:1620:static inline unsigned int readahead_count(const struct readahead_control *rac)\ninclude/linux/pagemap.h-1621-{\n--\ninclude/linux/pagemap.h-1628- */\ninclude/linux/pagemap.h:1629:static inline size_t readahead_batch_length(const struct readahead_control *rac)\ninclude/linux/pagemap.h-1630-{\n--\ninclude/linux/rolling_buffer.h=48=ssize_t rolling_buffer_load_from_ra(struct rolling_buffer *roll,\ninclude/linux/rolling_buffer.h:49:\t\t\t\t struct readahead_control *ractl,\ninclude/linux/rolling_buffer.h-50-\t\t\t\t struct folio_batch *put_batch);\n--\nmm/internal.h=597=int folio_unmap_invalidate(struct address_space *mapping, struct folio *folio,\n--\nmm/internal.h-599-\nmm/internal.h:600:void page_cache_ra_order(struct readahead_control *, struct file_ra_state *);\nmm/internal.h:601:void force_page_cache_ra(struct readahead_control *, unsigned long nr);\nmm/internal.h-602-static inline void force_page_cache_readahead(struct address_space *mapping,\n--\nmm/readahead.c=147=EXPORT_SYMBOL_GPL(file_ra_state_init);\n--\nmm/readahead.c-159- */\nmm/readahead.c:160:static void read_pages(struct readahead_control *rac)\nmm/readahead.c-161-{\n--\nmm/readahead.c-194-\nmm/readahead.c:195:static struct folio *ractl_alloc_folio(struct readahead_control *ractl,\nmm/readahead.c-196-\t\t\t\t gfp_t gfp_mask, unsigned int order)\n--\nmm/readahead.c-221- */\nmm/readahead.c:222:void page_cache_ra_unbounded(struct readahead_control *ractl,\nmm/readahead.c-223-\t\tunsigned long nr_to_read, unsigned long lookahead_size)\n--\nmm/readahead.c=318=EXPORT_SYMBOL_GPL(page_cache_ra_unbounded);\n--\nmm/readahead.c-325- */\nmm/readahead.c:326:static void do_page_cache_ra(struct readahead_control *ractl,\nmm/readahead.c-327-\t\tunsigned long nr_to_read, unsigned long lookahead_size)\n--\nmm/readahead.c-355- */\nmm/readahead.c:356:void force_page_cache_ra(struct readahead_control *ractl,\nmm/readahead.c-357-\t\tunsigned long nr_to_read)\n--\nmm/readahead.c=408=static unsigned long get_next_ra_size(struct file_ra_state *ra,\n--\nmm/readahead.c-458-\nmm/readahead.c:459:static inline int ra_alloc_folio(struct readahead_control *ractl, pgoff_t index,\nmm/readahead.c-460-\t\tpgoff_t mark, unsigned int order, gfp_t gfp)\n--\nmm/readahead.c-480-\nmm/readahead.c:481:void page_cache_ra_order(struct readahead_control *ractl,\nmm/readahead.c-482-\t\tstruct file_ra_state *ra)\n--\nmm/readahead.c-561-\nmm/readahead.c:562:static unsigned long ractl_max_pages(struct readahead_control *ractl,\nmm/readahead.c-563-\t\tunsigned long req_size)\n--\nmm/readahead.c-576-\nmm/readahead.c:577:void page_cache_sync_ra(struct readahead_control *ractl,\nmm/readahead.c-578-\t\tunsigned long req_count)\n--\nmm/readahead.c=651=EXPORT_SYMBOL_GPL(page_cache_sync_ra);\nmm/readahead.c-652-\nmm/readahead.c:653:void page_cache_async_ra(struct readahead_control *ractl,\nmm/readahead.c-654-\t\tstruct folio *folio, unsigned long req_count)\n--\nmm/readahead.c=762=COMPAT_SYSCALL_DEFINE4(readahead, int, fd, compat_arg_u64_dual(offset), size_t, count)\n--\nmm/readahead.c-785- */\nmm/readahead.c:786:void readahead_expand(struct readahead_control *ractl,\nmm/readahead.c-787-\t\t loff_t new_start, size_t new_len)\n"
} |
| 83/3 | 2026/09/22 23:14 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 35661 output: 34 thoughts: 42 Thoughts: Here's my summary, as though I'm thinking through this process: **Diving into Read-Ahead Initialization** Okay, so I need to understand how `ractl` gets initialized in the readahead code. My first instinct is to zero in on the core of the readahead logic, which I know is in `mm/readahead.c`. Specifically, I'll drill down into the interaction between `page_cache_sync_ra` and `page_cache_async_ra`. That should give me the entry point I need. I'm thinking those routines will likely show me how the `ractl` structure, or whatever analogous control structure they are using, gets set up initially. Let's dig in and see what those functions reveal! |
| 84/3 | 2026/09/22 23:14 | tool | read-file |
0mArgs:{
"File": "mm/readahead.c",
"FirstLine": 570,
"LineCount": 90
}Results: {
"Contents": " 570:\t\t * be up to the optimal hardware IO size\n 571:\t\t */\n 572:\t\tif (req_size \u003e max_pages \u0026\u0026 bdi-\u003eio_pages \u003e max_pages)\n 573:\t\t\tmax_pages = min(req_size, bdi-\u003eio_pages);\n 574:\t\treturn max_pages;\n 575:\t}\n 576:\t\n 577:\tvoid page_cache_sync_ra(struct readahead_control *ractl,\n 578:\t\t\tunsigned long req_count)\n 579:\t{\n 580:\t\tpgoff_t index = readahead_index(ractl);\n 581:\t\tbool do_forced_ra = ractl-\u003efile \u0026\u0026 (ractl-\u003efile-\u003ef_mode \u0026 FMODE_RANDOM);\n 582:\t\tstruct file_ra_state *ra = ractl-\u003era;\n 583:\t\tunsigned long max_pages, contig_count;\n 584:\t\tpgoff_t prev_index, miss;\n 585:\t\n 586:\t\ttrace_page_cache_sync_ra(ractl-\u003emapping-\u003ehost, index, ra, req_count);\n 587:\t\t/*\n 588:\t\t * Even if readahead is disabled, issue this request as readahead\n 589:\t\t * as we'll need it to satisfy the requested range. The forced\n 590:\t\t * readahead will do the right thing and limit the read to just the\n 591:\t\t * requested range, which we'll set to 1 page for this case.\n 592:\t\t */\n 593:\t\tif (!ra-\u003era_pages || blk_cgroup_congested()) {\n 594:\t\t\tif (!ractl-\u003efile)\n 595:\t\t\t\treturn;\n 596:\t\t\treq_count = 1;\n 597:\t\t\tdo_forced_ra = true;\n 598:\t\t}\n 599:\t\n 600:\t\t/* be dumb */\n 601:\t\tif (do_forced_ra) {\n 602:\t\t\tforce_page_cache_ra(ractl, req_count);\n 603:\t\t\treturn;\n 604:\t\t}\n 605:\t\n 606:\t\tmax_pages = ractl_max_pages(ractl, req_count);\n 607:\t\tprev_index = (unsigned long long)ra-\u003eprev_pos \u003e\u003e PAGE_SHIFT;\n 608:\t\t/*\n 609:\t\t * A start of file, oversized read, or sequential cache miss:\n 610:\t\t * trivial case: (index - prev_index) == 1\n 611:\t\t * unaligned reads: (index - prev_index) == 0\n 612:\t\t */\n 613:\t\tif (!index || req_count \u003e max_pages || index - prev_index \u003c= 1UL) {\n 614:\t\t\tra-\u003estart = index;\n 615:\t\t\tra-\u003esize = get_init_ra_size(req_count, max_pages);\n 616:\t\t\tra-\u003easync_size = ra-\u003esize \u003e req_count ? ra-\u003esize - req_count :\n 617:\t\t\t\t\t\t\t\tra-\u003esize \u003e\u003e 1;\n 618:\t\t\tgoto readit;\n 619:\t\t}\n 620:\t\n 621:\t\t/*\n 622:\t\t * Query the page cache and look for the traces(cached history pages)\n 623:\t\t * that a sequential stream would leave behind.\n 624:\t\t */\n 625:\t\trcu_read_lock();\n 626:\t\tmiss = page_cache_prev_miss(ractl-\u003emapping, index - 1, max_pages);\n 627:\t\trcu_read_unlock();\n 628:\t\tcontig_count = index - miss - 1;\n 629:\t\t/*\n 630:\t\t * Standalone, small random read. Read as is, and do not pollute the\n 631:\t\t * readahead state.\n 632:\t\t */\n 633:\t\tif (contig_count \u003c= req_count) {\n 634:\t\t\tdo_page_cache_ra(ractl, req_count, 0);\n 635:\t\t\treturn;\n 636:\t\t}\n 637:\t\t/*\n 638:\t\t * File cached from the beginning:\n 639:\t\t * it is a strong indication of long-run stream (or whole-file-read)\n 640:\t\t */\n 641:\t\tif (miss == ULONG_MAX)\n 642:\t\t\tcontig_count *= 2;\n 643:\t\tra-\u003estart = index;\n 644:\t\tra-\u003esize = min(contig_count + req_count, max_pages);\n 645:\t\tra-\u003easync_size = 1;\n 646:\treadit:\n 647:\t\tra-\u003eorder = 0;\n 648:\t\tractl-\u003e_index = ra-\u003estart;\n 649:\t\tpage_cache_ra_order(ractl, ra);\n 650:\t}\n 651:\tEXPORT_SYMBOL_GPL(page_cache_sync_ra);\n 652:\t\n 653:\tvoid page_cache_async_ra(struct readahead_control *ractl,\n 654:\t\t\tstruct folio *folio, unsigned long req_count)\n 655:\t{\n 656:\t\tunsigned long max_pages;\n 657:\t\tstruct file_ra_state *ra = ractl-\u003era;\n 658:\t\tpgoff_t index = readahead_index(ractl);\n 659:\t\tpgoff_t expected, start, end, aligned_end, align;\n"
} |
| 85/3 | 2026/09/22 23:14 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 37383 output: 19 thoughts: 29 Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience: **Investigating `page_cache_sync_ra` and `page_cache_async_ra` Call Sites** Right, let's dive into this. I need to understand the usage patterns of `page_cache_sync_ra` and `page_cache_async_ra`. The usual approach, of course, is to check the call sites directly. I want a clear picture of *where* these functions are being invoked. Understanding their context within the IO flow is essential for determining performance implications. Are they predominantly used in synchronous or asynchronous IO paths? Are there specific filesystems or workloads that lean more heavily on one over the other? I need to build a mental model of their roles to see if there's any obvious optimization potential, or if there is a problem somewhere. |
| 86/3 | 2026/09/22 23:14 | tool | grepper |
0mArgs:{
"Expression": "DEFINE_READAHEAD"
}Results: {
"Output": "fs/f2fs/file.c=4794=static int redirty_blocks(struct inode *inode, pgoff_t page_idx, int len)\nfs/f2fs/file.c-4795-{\nfs/f2fs/file.c:4796:\tDEFINE_READAHEAD(ractl, NULL, NULL, inode-\u003ei_mapping, page_idx);\nfs/f2fs/file.c-4797-\tstruct address_space *mapping = inode-\u003ei_mapping;\n--\nfs/verity/pagecache.c=42=void generic_readahead_merkle_tree(struct inode *inode, pgoff_t index,\n--\nfs/verity/pagecache.c-51-\t (!IS_ERR(folio) \u0026\u0026 !folio_test_uptodate(folio))) {\nfs/verity/pagecache.c:52:\t\tDEFINE_READAHEAD(ractl, NULL, NULL, inode-\u003ei_mapping, index);\nfs/verity/pagecache.c-53-\n--\ninclude/linux/pagemap.h=1405=struct readahead_control {\n--\ninclude/linux/pagemap.h-1418-\ninclude/linux/pagemap.h:1419:#define DEFINE_READAHEAD(ractl, f, r, m, i)\t\t\t\t\\\ninclude/linux/pagemap.h-1420-\tstruct readahead_control ractl = {\t\t\t\t\\\n--\ninclude/linux/pagemap.h=1451=void page_cache_sync_readahead(struct address_space *mapping,\n--\ninclude/linux/pagemap.h-1454-{\ninclude/linux/pagemap.h:1455:\tDEFINE_READAHEAD(ractl, file, ra, mapping, index);\ninclude/linux/pagemap.h-1456-\tpage_cache_sync_ra(\u0026ractl, req_count);\n--\ninclude/linux/pagemap.h=1473=void page_cache_async_readahead(struct address_space *mapping,\n--\ninclude/linux/pagemap.h-1476-{\ninclude/linux/pagemap.h:1477:\tDEFINE_READAHEAD(ractl, file, ra, mapping, folio-\u003eindex);\ninclude/linux/pagemap.h-1478-\tpage_cache_async_ra(\u0026ractl, folio, req_count);\n--\nmm/filemap.c=2672=static int filemap_readahead(struct kiocb *iocb, struct file *file,\n--\nmm/filemap.c-2675-{\nmm/filemap.c:2676:\tDEFINE_READAHEAD(ractl, file, \u0026file-\u003ef_ra, mapping, folio-\u003eindex);\nmm/filemap.c-2677-\n--\nmm/filemap.c=2686=static int filemap_get_pages(struct kiocb *iocb, size_t count,\n--\nmm/filemap.c-2705-\tif (!folio_batch_count(fbatch)) {\nmm/filemap.c:2706:\t\tDEFINE_READAHEAD(ractl, filp, \u0026filp-\u003ef_ra, mapping, index);\nmm/filemap.c-2707-\n--\nmm/filemap.c=3329=static struct file *do_sync_mmap_readahead(struct vm_fault *vmf)\n--\nmm/filemap.c-3333-\tstruct address_space *mapping = file-\u003ef_mapping;\nmm/filemap.c:3334:\tDEFINE_READAHEAD(ractl, file, ra, mapping, vmf-\u003epgoff);\nmm/filemap.c-3335-\tstruct file *fpin = NULL;\n--\nmm/filemap.c=3452=static struct file *do_async_mmap_readahead(struct vm_fault *vmf,\n--\nmm/filemap.c-3456-\tstruct file_ra_state *ra = \u0026file-\u003ef_ra;\nmm/filemap.c:3457:\tDEFINE_READAHEAD(ractl, file, ra, file-\u003ef_mapping, vmf-\u003epgoff);\nmm/filemap.c-3458-\tstruct file *fpin = NULL;\n--\nmm/internal.h=602=static inline void force_page_cache_readahead(struct address_space *mapping,\n--\nmm/internal.h-604-{\nmm/internal.h:605:\tDEFINE_READAHEAD(ractl, file, \u0026file-\u003ef_ra, mapping, index);\nmm/internal.h-606-\tforce_page_cache_ra(\u0026ractl, nr_to_read);\n"
} |
| 87/3 | 2026/09/22 23:14 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 38811 output: 36 thoughts: 1172 Thoughts: **Analyzing Page Private Fields and Readahead Control Initialization** Okay, so I'm diving into this code and my initial thought is, how is `readahead_control` initialized? It's always with `DEFINE_READAHEAD(...)`, so zero-initialization should set `_forward`, `_batch_count`, and the rest to zero, right? But wait, what if `readahead_folio` or `readahead_folio_last` gets called for the *first* time? Let's trace it and check `__readahead_advance`. Looking at `__readahead_advance`, I see that if `_forward` is true, then `_index` is incremented by `_batch_count`. After that the number of pages is decremented. And then `_batch_count` is set to 0. But, on the *first* call, `_batch_count` *is* zero due to initialization. So, `_index` is incremented by zero. The number of pages is also decremented by 0. Then `_batch_count` will be set to 0 and finally, `_forward` will be set to `true` (or `false` for `readahead_folio_last`). So it looks like everything should be initialized correctly. Now, let's switch gears and check out `gnttab_pages_set_private` and `gnttab_pages_clear_private` in `drivers/xen/grant-table.c`. I see a preprocessor check for `BITS_PER_LONG < 64`. On 32-bit, the code allocates a `xen_page_foreign` struct and assigns its address to `page->private`. On 64-bit, the set code is empty. The comment says that the data is stored in `page->private` elsewhere on 64-bit. So the set code does nothing on 64-bit. Now the clear code simply sets `page_private` to 0. Now, let's examine `arch/x86/events/intel/bts.c` and `kernel/events/ring_buffer.c`. I am now looking at `buf_nr_pages` which calls `page_private`. In the code, `page_private` now returns `1 << page_private(page)`. So previously it looked at `PagePrivate` and returned `1` if the private field was not set. Now that is gone. In `kernel/events/ring_buffer.c` I see `rb_alloc_aux_page` and `rb_free_aux_page`. I see that when `page` is allocated with order 0, what is `page_private(page)`? I check `rb_alloc_aux_page`, and now the logic sets the `order` to page private instead of setting the private bit. The free code now also clears the `page_private` field. |
| 88/3 | 2026/09/22 23:15 | tool | grepper |
0mArgs:{
"Expression": "rb_alloc_aux_page",
"PathPrefix": "kernel/events/ring_buffer.c"
}Results: {
"Output": "kernel/events/ring_buffer.c=583=long perf_output_copy_aux(struct perf_output_handle *aux_handle,\n--\nkernel/events/ring_buffer.c-617-\nkernel/events/ring_buffer.c:618:static struct page *rb_alloc_aux_page(int node, int order)\nkernel/events/ring_buffer.c-619-{\n--\nkernel/events/ring_buffer.c=678=int rb_alloc_aux(struct perf_buffer *rb, struct perf_event *event,\n--\nkernel/events/ring_buffer.c-742-\t\torder = min(max_order, ilog2(nr_pages - rb-\u003eaux_nr_pages));\nkernel/events/ring_buffer.c:743:\t\tpage = rb_alloc_aux_page(node, order);\nkernel/events/ring_buffer.c-744-\t\tif (!page)\n"
} |
| 89/3 | 2026/09/22 23:15 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 40903 output: 37 thoughts: 25 Thoughts: Okay, here's my interpretation of what's going through my mind as I approach this code: **Diving into `rb_alloc_aux_page`** Alright, time to get my hands dirty. I'm focusing on `rb_alloc_aux_page` now, and I know it's nestled within `kernel/events/ring_buffer.c`. My immediate thought is, "Okay, this function is obviously responsible for allocating auxiliary pages within the ring buffer infrastructure." Given my familiarity with how these systems work, I can already anticipate this is likely a critical piece in managing the memory used for event data. I expect to see memory allocation calls, perhaps dealing with `kmalloc` or `vmalloc`, and I’m going to be paying close attention to any error handling—specifically, how failures are managed. I'll be looking to see if there's any cleverness in how these auxiliary pages are managed, and how the system attempts to avoid fragmentation, and how the system attempts to handle allocation failures. I'll also be watching for any optimizations in the context of allocation and deallocation to maintain the performance of the system. Let's see what's actually going on. |
| 90/3 | 2026/09/22 23:15 | tool | read-file |
0mArgs:{
"File": "kernel/events/ring_buffer.c",
"FirstLine": 618,
"LineCount": 35
}Results: {
"Contents": " 618:\tstatic struct page *rb_alloc_aux_page(int node, int order)\n 619:\t{\n 620:\t\tstruct page *page;\n 621:\t\n 622:\t\tif (order \u003e MAX_PAGE_ORDER)\n 623:\t\t\torder = MAX_PAGE_ORDER;\n 624:\t\n 625:\t\tdo {\n 626:\t\t\tpage = alloc_pages_node(node, PERF_AUX_GFP, order);\n 627:\t\t} while (!page \u0026\u0026 order--);\n 628:\t\n 629:\t\tif (page \u0026\u0026 order) {\n 630:\t\t\t/*\n 631:\t\t\t * Communicate the allocation size to the driver:\n 632:\t\t\t * if we managed to secure a high-order allocation,\n 633:\t\t\t * set its first page's private to this order, otherwise page's\n 634:\t\t\t * private remains zero.\n 635:\t\t\t */\n 636:\t\t\tsplit_page(page, order);\n 637:\t\t\tset_page_private(page, order);\n 638:\t\t}\n 639:\t\n 640:\t\treturn page;\n 641:\t}\n 642:\t\n 643:\tstatic void rb_free_aux_page(struct perf_buffer *rb, int idx)\n 644:\t{\n 645:\t\tstruct page *page = virt_to_page(rb-\u003eaux_pages[idx]);\n 646:\t\n 647:\t\tset_page_private(page, 0);\n 648:\t\t__free_page(page);\n 649:\t}\n 650:\t\n 651:\tstatic void __rb_free_aux(struct perf_buffer *rb)\n 652:\t{\n"
} |
| 91/3 | 2026/09/22 23:15 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 41696 output: 36 thoughts: 945 Thoughts: **Analyzing EROFS Folio Management** Okay, so I'm looking at how `alloc_pages_node` works, and I see a crucial point about `page->private`. If the allocation order is zero, then `page_private(page)` is initially zero, and `1 << page_private(page)` evaluates to 1. When the order is greater than zero, then `set_page_private(page, order)` is called, so `page_private(page)` becomes equal to the order, and that means we get `1 << order`. Critically, when a page is freed, the private value is reset to zero. This is the background context. Now, let's dive into the `erofs` filesystem code, specifically `fs/erofs/data.c`. I need to understand how they are using the `folio->private` field. The diff shows some bit definitions: `EROFS_ONLINEFOLIO_EIO` (bit 30) for I/O errors, and `EROFS_ONLINEFOLIO_DIRTY` (bit 29) for dirty data. The critical part is that bits 0-28 are used to represent the remaining parts to complete a folio, but there is an important bias involved. In the original version, there was no bias. Now, the count is biased by `1` using `EROFS_ONLINEFOLIO_BIAS`. The mask is now `EROFS_ONLINEFOLIO_COUNT_MASK` to reflect the new bias. This makes sure that `->private` stays non-NULL while the folio is attached. The `erofs_onlinefolio_init` function is setting up the initial value. Originally, `folio->private` was set to 1. But now, it initializes the `folio->private` with `1 + EROFS_ONLINEFOLIO_BIAS` which is 2. The code now uses `folio_attach_private` instead of direct assignment. The key question I want to answer now is: Does `erofs_onlinefolio_split` touch `folio->private`? I'll need to scrutinize the `erofs_onlinefolio_split` function, specifically lines 250-275 of `fs/erofs/data.c` to figure this out. I have to see how it manipulates this field. |
| 92/3 | 2026/09/22 23:15 | tool | read-file |
0mArgs:{
"File": "fs/erofs/data.c",
"FirstLine": 250,
"LineCount": 35
}Results: {
"Contents": " 250:\tvoid erofs_onlinefolio_init(struct folio *folio)\n 251:\t{\n 252:\t\tunion {\n 253:\t\t\tatomic_t o;\n 254:\t\t\tvoid *v;\n 255:\t\t} u = { .o = ATOMIC_INIT(1 + EROFS_ONLINEFOLIO_BIAS) };\n 256:\t\n 257:\t\t/* valid only if file-backed folio is locked */\n 258:\t\tfolio_attach_private(folio, u.v);\n 259:\t}\n 260:\t\n 261:\tvoid erofs_onlinefolio_split(struct folio *folio)\n 262:\t{\n 263:\t\tatomic_inc((atomic_t *)\u0026folio-\u003eprivate);\n 264:\t}\n 265:\t\n 266:\tvoid erofs_onlinefolio_end(struct folio *folio, int err, bool dirty)\n 267:\t{\n 268:\t\tint orig, v;\n 269:\t\n 270:\t\tdo {\n 271:\t\t\torig = atomic_read((atomic_t *)\u0026folio-\u003eprivate);\n 272:\t\t\tDBG_BUGON((orig \u0026 EROFS_ONLINEFOLIO_COUNT_MASK) \u003c= EROFS_ONLINEFOLIO_BIAS);\n 273:\t\t\tv = dirty \u003c\u003c EROFS_ONLINEFOLIO_DIRTY;\n 274:\t\t\tv |= (orig - 1) | (!!err \u003c\u003c EROFS_ONLINEFOLIO_EIO);\n 275:\t\t} while (atomic_cmpxchg((atomic_t *)\u0026folio-\u003eprivate, orig, v) != orig);\n 276:\t\n 277:\t\tif ((v \u0026 EROFS_ONLINEFOLIO_COUNT_MASK) != EROFS_ONLINEFOLIO_BIAS)\n 278:\t\t\treturn;\n 279:\t\tfolio_detach_private(folio);\n 280:\t\tif (v \u0026 BIT(EROFS_ONLINEFOLIO_DIRTY))\n 281:\t\t\tflush_dcache_folio(folio);\n 282:\t\tfolio_end_read(folio, !(v \u0026 BIT(EROFS_ONLINEFOLIO_EIO)));\n 283:\t}\n 284:\t\n"
} |
| 93/3 | 2026/09/22 23:15 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 43771 output: 27 thoughts: 1311 Thoughts: **Analyzing Potential Issues with Folio/Page Conversion** Okay, let's dive into this. My initial focus is on the transition from `page` to `folio` structures and how this might impact the handling of private data and reference counting. I'll start by systematically checking the relevant areas to ensure there aren't any subtle regressions. First, I'm checking the `fs/f2fs` code. It looks like `fio.folio` replaced a union that included `struct page *page; struct folio *folio;` in `f2fs/f2fs.h`. Good, let's see how this change affected the other f2fs code. I check `f2fs_write_compressed_pages` and see that `.folio = NULL` was initialized. I also need to verify that `folio_test_f2fs_gcing`, `folio_set_f2fs_gcing`, and `folio_clear_f2fs_gcing` are correct, so I'll check `fs/f2fs/compress.c`. I have to confirm that those functions work as expected. Now, let's explore how the `F2FS_FOLIO_PRIVATE_*` macros are implemented. The code reveals how they interact with `folio_attach_private` and `folio_detach_private`. Crucially, these functions *should* maintain the reference count properly. I need to make sure this is consistent throughout all uses. Next, I'll move on to `mm/zsmalloc.c`. The removal of `PagePrivate` in `zpdesc_set_first`, `is_first_zpdesc`, `reset_zpdesc`, and `create_page_chain` is interesting. The code now checks `zspage->first_zpdesc == zpdesc` instead. I'm looking for anything that might have introduced uninitialized memory access or missed refcounting problems here. It seems that nothing's uninitialized now. Good. Now, here's where things get interesting. I'm focusing on the change in `drivers/md/md-bitmap.c`. The `free_buffers` function's modification from using `PagePrivate` to `folio_detach_private` catches my attention immediately. This is the critical piece here. Before, the code checked `!PagePrivate(page)` and returned if it was false. Now it calls `folio_detach_private(folio)`. But! If `folio_detach_private(folio)` returns NULL, that is, when the `folio->private` was NULL, then it should *not* call `folio_put(folio)`. However, the current code always calls `folio_put(folio)`. The important thing to consider is how this affects `free_buffers`. If `folio_detach_private(folio)` returns NULL, `bh` will be NULL. The `while (bh)` loop is skipped, which is probably okay. But... and this is critical... `folio_put(folio)` *is still called unconditionally! This is probably a bug. I need to check where `free_buffers` is called from in `md-bitmap.c` and make sure my understanding is correct and that this has not been addressed anywhere. |
| 94/3 | 2026/09/22 23:15 | tool | grepper |
0mArgs:{
"Expression": "free_buffers",
"PathPrefix": "drivers/md/"
}Results: {
"Output": "drivers/md/md-bitmap.c=517=static void write_file_page(struct bitmap *bitmap, struct page *page, int wait)\n--\ndrivers/md/md-bitmap.c-534-\ndrivers/md/md-bitmap.c:535:static void free_buffers(struct page *page)\ndrivers/md/md-bitmap.c-536-{\n--\ndrivers/md/md-bitmap.c=621=static int read_file_page(struct file *file, unsigned long index,\n--\ndrivers/md/md-bitmap.c-625-}\ndrivers/md/md-bitmap.c:626:static void free_buffers(struct page *page)\ndrivers/md/md-bitmap.c-627-{\n--\ndrivers/md/md-bitmap.c=1067=static void md_bitmap_file_unmap(struct bitmap_storage *store)\n--\ndrivers/md/md-bitmap.c-1075-\t\tif (map[pages] != sb_page) /* 0 is sb_page, release it below */\ndrivers/md/md-bitmap.c:1076:\t\t\tfree_buffers(map[pages]);\ndrivers/md/md-bitmap.c-1077-\tkfree(map);\n--\ndrivers/md/md-bitmap.c-1080-\tif (sb_page)\ndrivers/md/md-bitmap.c:1081:\t\tfree_buffers(sb_page);\ndrivers/md/md-bitmap.c-1082-\n"
} |
| 95/3 | 2026/09/22 23:15 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 46192 output: 461 thoughts: 2983 Thoughts: **KMSAN Assessment: No Uninitialized Memory Issues Detected** Alright, let's break this down. The core of this patch seems to be the removal and replacement of the `PG_private` page flag with direct checks on `folio->private` and the related functions like `folio_has_attached_private()`. My primary concern is always: did this introduce a scenario where uninitialized memory could be read, or where data that *should* be zeroed isn't? First, I went through the code piece by piece, starting with `free_buffers` and the changes to `detach_page_private` (or `folio_detach_private`). Initially, it looked like there might have been a refcount imbalance and a potential double `put_page()` situation. However, upon deeper examination, that kind of refcount or UAF problem, if it existed, would be flagged by KASAN, not KMSAN. Next, I methodically evaluated each of the four KMSAN criteria: 1. **Kernel Data to Userspace:** The initial thought was `fs/proc/page.c` and specifically `stable_page_flags`. The code now writes to `u64 info` in `kpage_read`, which gets copied to user space. However, `u` is properly initialized to 0, which means even removing a bit (like the `KPF_PRIVATE` flag) just keeps that bit at 0, preventing any uninitialized data leakage to user space. It also made me double-check `include/linux/kernel-page-flags.h`, `tools/mm/page-types.c`, `Documentation/admin-guide/kdump/vmcoreinfo.rst`, `kernel/vmcore_info.c`. The changes there did not present a problem of uninitialized memory. 2. **Conditional Logic with Uninitialized Data:** I looked for any cases where the patch introduced branching or conditional logic based on potentially uninitialized variables or struct fields. I reviewed `readahead_folio_last`, `folio_test_private`, and `rb_alloc_aux_page` / `rb_free_aux_page` and verified that data is initialized correctly. In the case of `folio->private`, page and folio allocation will initialize it, ensuring it's not uninitialized. 3. **Complex Data Structures with Uninitialized Fields:** I reviewed data structures for any situations where uninitialized fields are read, paying particular attention to structures like `struct f2fs_io_info`. However, every instance where `fio` fields are used, they are initialized. 4. **Bounds Checks/Logic Leading to Uninitialized Bytes:** I considered how logic or bounds check changes could allow access to uninitialized data. The changes to `intel/pt.c` and `intel/bts.c` involving `page_private(page)` were checked, it was determined to behave identically due to the initialization of `page_private(page)`. I then went back to ensure there weren't any KASAN / LOCKDEP issues. I made sure to assess refcounting around folios (e.g. `folio_attach_private`, `folio_detach_private`, `free_buffers`). Any use-after-free or memory corruption or leak would be caught by KASAN / SLUB debug. Similarly, concurrency aspects with `data_race(folio->private)` would be picked up by those tools, not KMSAN. In conclusion, the patch primarily reorganizes how page private information is tracked. It removes the `PG_private` flag and switches to directly checking and managing the `folio->private` pointer. There are no changes that introduce or modify kernel structures sent to userspace, introduce conditional logic based on uninitialized fields, or introduce any other situation that could result in reading uninitialized memory. Refcounting issues, concurrency problems, or UAF bugs are still possible, but they are issues that KASAN and other memory debuggers should catch. Thus, `NeedsKMSAN` should be false. |
| 96/3 | 2026/09/22 23:15 | tool | set-results |
0mArgs:{
"KMSANReasoning": "The patch series removes the `PG_private` page flag, transitioning the kernel to check `folio-\u003eprivate != NULL` (or `folio_has_attached_private()`, `page_private()`) instead. It updates core memory management, pagecache, tracing, procfs kpageflags, perf x86 AUX buffers, Xen grant tables, and filesystems (Ceph, EROFS, F2FS, NFS, UBIFS).\n\nKMSAN vs KASAN applicability:\n- No uninitialized memory usage or info-leaks:\n - In `fs/proc/page.c`, removing `kpf_copy_bit(..., KPF_PRIVATE, PG_private)` leaves the corresponding bit zeroed because the return accumulator `u` is initialized to 0. No uninitialized bytes or padding are exposed to userspace.\n - In `include/linux/pagemap.h`, the new `_forward` boolean added to `struct readahead_control` is properly zero-initialized by `DEFINE_READAHEAD` (which uses designated initializers, zeroing unspecified members).\n - In perf x86 events (`bts.c`, `pt.c`, `ring_buffer.c`), `page_private(p)` defaults to 0 on page allocation and is explicitly cleared to 0 on free; reading `1 \u003c\u003c page_private(p)` for order-0 pages evaluates deterministically to 1 without accessing uninitialized state.\n - In `fs/erofs`, `fs/f2fs`, and `drivers/md/md-bitmap.c`, all state attached to folios is explicitly initialized before use.\n- The primary risks of these changes involve page/folio lifecycle management, reference counting (e.g. `folio_attach_private` / `folio_detach_private` pairings), and use-after-free or buffer head leaks, which are directly monitored by KASAN and SLUB debugging rather than KMSAN.\n\nTherefore, a dedicated KMSAN fuzzing session is not justified.",
"NeedsKMSAN": false
}Results: {
"KMSANReasoning": "The patch series removes the `PG_private` page flag, transitioning the kernel to check `folio-\u003eprivate != NULL` (or `folio_has_attached_private()`, `page_private()`) instead. It updates core memory management, pagecache, tracing, procfs kpageflags, perf x86 AUX buffers, Xen grant tables, and filesystems (Ceph, EROFS, F2FS, NFS, UBIFS).\n\nKMSAN vs KASAN applicability:\n- No uninitialized memory usage or info-leaks:\n - In `fs/proc/page.c`, removing `kpf_copy_bit(..., KPF_PRIVATE, PG_private)` leaves the corresponding bit zeroed because the return accumulator `u` is initialized to 0. No uninitialized bytes or padding are exposed to userspace.\n - In `include/linux/pagemap.h`, the new `_forward` boolean added to `struct readahead_control` is properly zero-initialized by `DEFINE_READAHEAD` (which uses designated initializers, zeroing unspecified members).\n - In perf x86 events (`bts.c`, `pt.c`, `ring_buffer.c`), `page_private(p)` defaults to 0 on page allocation and is explicitly cleared to 0 on free; reading `1 \u003c\u003c page_private(p)` for order-0 pages evaluates deterministically to 1 without accessing uninitialized state.\n - In `fs/erofs`, `fs/f2fs`, and `drivers/md/md-bitmap.c`, all state attached to folios is explicitly initialized before use.\n- The primary risks of these changes involve page/folio lifecycle management, reference counting (e.g. `folio_attach_private` / `folio_detach_private` pairings), and use-after-free or buffer head leaks, which are directly monitored by KASAN and SLUB debugging rather than KMSAN.\n\nTherefore, a dedicated KMSAN fuzzing session is not justified.",
"NeedsKMSAN": false
} |
| Total Calls | Total Tokens | Avg Tokens | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|
| Total Calls | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|