From nobody Mon Dec 1 21:30:54 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 10F1F262FC7 for ; Mon, 1 Dec 2025 19:19:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764616791; cv=none; b=cRwUOqp0HsU7JLjVpbePhxV+g9bSm/C1o9irX20VFk0wfK2y47p7SOHcHQFCfuf9l4ua6v9S8Ok2Xd3dy6SkuSmwQFdq6C6GM7Ifm27XUHlrisbCFRJfa0rndgvt3TkCet06ZH7Fr622Il0ZBRdbpVHVVFaRGH0M5yUpmNT9b0M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764616791; c=relaxed/simple; bh=yQWcD18TLiYKqUnnCMGR7D3L1yi9ktuyT2awpIXDdM8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=u2as2wdcGMIMCy+mGIHSzaN2yfodYSizUIiStNxryrpPfOs27PVpr0lOn42JLHqY3N3yR5ri2SFM6gWXyer1/ji4V61eFgMJ1B7aNWJemhwE2QUAp2+M62CSeRll88KvzIc2Nf6ttT55xFv+n9IZ2s947R0ugFG4oZAoX3hqbm0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DHOj6SBm; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="DHOj6SBm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8053CC4CEF1; Mon, 1 Dec 2025 19:19:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1764616789; bh=yQWcD18TLiYKqUnnCMGR7D3L1yi9ktuyT2awpIXDdM8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DHOj6SBmUT+6RFQqgxHoqAR2XBLJ78YEgsX+umpqHGeLbTSnnfLCrbP8NGLcc9Hq8 ckbvmfhj7hofWfx1DIBQT3P4tvrgnrD174NoySJBJMEnJdHMMyE2SMwjAWU4VLZ9qM 1DHAhjNJKo+lRfNfiV71ODwLp4vHlPaz4P1oRMzdu8NWtI3belLja0p4SDN9fqJQrS 2FkzFob4ZBLHU9mt9PhFBKgq9IVOM1EjDXRsC4+++RuLDjTo/ijHGpl0GWnb164LLX sArEI795Ss/HFVbD5TopoN6nNQpNppHV5SdpBEMr6le1j2d5wfzFba5z6HojunUzTS Uclic7q9yH6/w== From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Cc: Jaegeuk Kim Subject: [PATCH 4/4] f2fs: attach a_ops->ra_folio_order to allocate large folios for readahead Date: Mon, 1 Dec 2025 19:16:16 +0000 Message-ID: <20251201191940.883657-5-jaegeuk@kernel.org> X-Mailer: git-send-email 2.52.0.107.ga0afd4fd5b-goog In-Reply-To: <20251201191940.883657-1-jaegeuk@kernel.org> References: <20251201191940.883657-1-jaegeuk@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This patch adds a sysfs entry to change the folio order. Given ra_folio_ord= er=3D9, we can see page_cache_ra_order getting order=3D9 when we submit readahead()= as below. =3D=3D=3D=3D folio_order=3D0 =3D=3D=3D=3D f2fs_fadvise: dev =3D (252,16), ino =3D 14, i_size =3D 4294967296 offset:0= , len:4294967296, advise:3 page_cache_sync_ra: dev=3D252:16 ino=3De index=3D0 req_count=3D2048 order= =3D0 size=3D0 async_size=3D0 ra_pages=3D2048 mmap_miss=3D0 prev_pos=3D-1 page_cache_ra_order: dev=3D252:16 ino=3De index=3D0 order=3D0 size=3D2048 = async_size=3D1024 ra_pages=3D2048 page_cache_sync_ra: dev=3D252:16 ino=3De index=3D2048 req_count=3D2048 ord= er=3D0 size=3D2048 async_size=3D1024 ra_pages=3D2048 mmap_miss=3D0 prev_pos= =3D-1 page_cache_ra_unbounded: dev=3D252:16 ino=3De index=3D2048 nr_to_read=3D20= 48 lookahead_size=3D0 page_cache_sync_ra: dev=3D252:16 ino=3De index=3D4096 req_count=3D2048 ord= er=3D0 size=3D2048 async_size=3D1024 ra_pages=3D2048 mmap_miss=3D0 prev_pos= =3D-1 page_cache_ra_unbounded: dev=3D252:16 ino=3De index=3D4096 nr_to_read=3D20= 48 lookahead_size=3D0 page_cache_sync_ra: dev=3D252:16 ino=3De index=3D6144 req_count=3D2048 ord= er=3D0 size=3D2048 async_size=3D1024 ra_pages=3D2048 mmap_miss=3D0 prev_pos= =3D-1 page_cache_ra_unbounded: dev=3D252:16 ino=3De index=3D6144 nr_to_read=3D20= 48 lookahead_size=3D0 page_cache_sync_ra: dev=3D252:16 ino=3De index=3D8192 req_count=3D2048 ord= er=3D0 size=3D2048 async_size=3D1024 ra_pages=3D2048 mmap_miss=3D0 prev_pos= =3D-1 page_cache_ra_unbounded: dev=3D252:16 ino=3De index=3D8192 nr_to_read=3D20= 48 lookahead_size=3D0 page_cache_sync_ra: dev=3D252:16 ino=3De index=3D10240 req_count=3D2048 or= der=3D0 size=3D2048 async_size=3D1024 ra_pages=3D2048 mmap_miss=3D0 prev_po= s=3D-1 page_cache_ra_unbounded: dev=3D252:16 ino=3De index=3D10240 nr_to_read=3D2= 048 lookahead_size=3D0 ... page_cache_ra_unbounded: dev=3D252:16 ino=3De index=3D1042432 nr_to_read= =3D2048 lookahead_size=3D0 page_cache_sync_ra: dev=3D252:16 ino=3De index=3D1044480 req_count=3D2048 = order=3D0 size=3D2048 async_size=3D1024 ra_pages=3D2048 mmap_miss=3D0 prev_= pos=3D-1 page_cache_ra_unbounded: dev=3D252:16 ino=3De index=3D1044480 nr_to_read= =3D2048 lookahead_size=3D0 page_cache_sync_ra: dev=3D252:16 ino=3De index=3D1046528 req_count=3D2048 = order=3D0 size=3D2048 async_size=3D1024 ra_pages=3D2048 mmap_miss=3D0 prev_= pos=3D-1 page_cache_ra_unbounded: dev=3D252:16 ino=3De index=3D1046528 nr_to_read= =3D2048 lookahead_size=3D0 =3D=3D=3D=3D folio_order=3D9 =3D=3D=3D=3D f2fs_fadvise: dev =3D (252,16), ino =3D 14, i_size =3D 4294967296 offset:0= , len:4294967296, advise:3 page_cache_sync_ra: dev=3D252:16 ino=3De index=3D0 req_count=3D2048 order= =3D0 size=3D0 async_size=3D0 ra_pages=3D2048 mmap_miss=3D0 prev_pos=3D-1 page_cache_ra_order: dev=3D252:16 ino=3De index=3D0 order=3D9 size=3D2048 = async_size=3D1024 ra_pages=3D2048 page_cache_sync_ra: dev=3D252:16 ino=3De index=3D2048 req_count=3D2048 ord= er=3D9 size=3D2048 async_size=3D1024 ra_pages=3D2048 mmap_miss=3D0 prev_pos= =3D-1 page_cache_ra_order: dev=3D252:16 ino=3De index=3D2048 order=3D9 size=3D20= 48 async_size=3D1024 ra_pages=3D2048 page_cache_sync_ra: dev=3D252:16 ino=3De index=3D4096 req_count=3D2048 ord= er=3D9 size=3D2048 async_size=3D1024 ra_pages=3D2048 mmap_miss=3D0 prev_pos= =3D-1 page_cache_ra_order: dev=3D252:16 ino=3De index=3D4096 order=3D9 size=3D20= 48 async_size=3D1024 ra_pages=3D2048 page_cache_sync_ra: dev=3D252:16 ino=3De index=3D6144 req_count=3D2048 ord= er=3D9 size=3D2048 async_size=3D1024 ra_pages=3D2048 mmap_miss=3D0 prev_pos= =3D-1 page_cache_ra_order: dev=3D252:16 ino=3De index=3D6144 order=3D9 size=3D20= 48 async_size=3D1024 ra_pages=3D2048 page_cache_sync_ra: dev=3D252:16 ino=3De index=3D8192 req_count=3D2048 ord= er=3D9 size=3D2048 async_size=3D1024 ra_pages=3D2048 mmap_miss=3D0 prev_pos= =3D-1 page_cache_ra_order: dev=3D252:16 ino=3De index=3D8192 order=3D9 size=3D20= 48 async_size=3D1024 ra_pages=3D2048 page_cache_sync_ra: dev=3D252:16 ino=3De index=3D10240 req_count=3D2048 or= der=3D9 size=3D2048 async_size=3D1024 ra_pages=3D2048 mmap_miss=3D0 prev_po= s=3D-1 page_cache_ra_order: dev=3D252:16 ino=3De index=3D10240 order=3D9 size=3D2= 048 async_size=3D1024 ra_pages=3D2048 page_cache_sync_ra: dev=3D252:16 ino=3De index=3D12288 req_count=3D2048 or= der=3D9 size=3D2048 async_size=3D1024 ra_pages=3D2048 mmap_miss=3D0 prev_po= s=3D-1 ... page_cache_sync_ra: dev=3D252:16 ino=3De index=3D1040384 req_count=3D2048 = order=3D9 size=3D2048 async_size=3D1024 ra_pages=3D2048 mmap_miss=3D0 prev_= pos=3D-1 page_cache_ra_order: dev=3D252:16 ino=3De index=3D1040384 order=3D9 size= =3D2048 async_size=3D1024 ra_pages=3D2048 page_cache_sync_ra: dev=3D252:16 ino=3De index=3D1042432 req_count=3D2048 = order=3D9 size=3D2048 async_size=3D1024 ra_pages=3D2048 mmap_miss=3D0 prev_= pos=3D-1 page_cache_ra_order: dev=3D252:16 ino=3De index=3D1042432 order=3D9 size= =3D2048 async_size=3D1024 ra_pages=3D2048 page_cache_sync_ra: dev=3D252:16 ino=3De index=3D1044480 req_count=3D2048 = order=3D9 size=3D2048 async_size=3D1024 ra_pages=3D2048 mmap_miss=3D0 prev_= pos=3D-1 page_cache_ra_order: dev=3D252:16 ino=3De index=3D1044480 order=3D9 size= =3D2048 async_size=3D1024 ra_pages=3D2048 page_cache_sync_ra: dev=3D252:16 ino=3De index=3D1046528 req_count=3D2048 = order=3D9 size=3D2048 async_size=3D1024 ra_pages=3D2048 mmap_miss=3D0 prev_= pos=3D-1 page_cache_ra_order: dev=3D252:16 ino=3De index=3D1046528 order=3D9 size= =3D2048 async_size=3D1024 ra_pages=3D2048 Signed-off-by: Jaegeuk Kim --- fs/f2fs/data.c | 9 +++++++++ fs/f2fs/f2fs.h | 3 +++ fs/f2fs/super.c | 1 + fs/f2fs/sysfs.c | 9 +++++++++ 4 files changed, 22 insertions(+) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 1746519e403d..2813475070f8 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -4059,6 +4059,14 @@ static bool f2fs_dirty_data_folio(struct address_spa= ce *mapping, return false; } =20 +static unsigned int f2fs_ra_folio_order(struct address_space *mapping, + unsigned int order) +{ + if (!mapping_large_folio_support(mapping)) + return order; + + return max(order, F2FS_M_SB(mapping)->ra_folio_order); +} =20 static sector_t f2fs_bmap_compress(struct inode *inode, sector_t block) { @@ -4377,6 +4385,7 @@ const struct address_space_operations f2fs_dblock_aop= s =3D { .dirty_folio =3D f2fs_dirty_data_folio, .migrate_folio =3D filemap_migrate_folio, .invalidate_folio =3D f2fs_invalidate_folio, + .ra_folio_order =3D f2fs_ra_folio_order, .release_folio =3D f2fs_release_folio, .bmap =3D f2fs_bmap, .swap_activate =3D f2fs_swap_activate, diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 6eeb8772cee3..c5be600fb1a6 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -1926,6 +1926,9 @@ struct f2fs_sb_info { /* carve out reserved_blocks from total blocks */ bool carve_out; =20 + /* enable large folio for readahead. */ + unsigned int ra_folio_order; + #ifdef CONFIG_F2FS_FS_COMPRESSION struct kmem_cache *page_array_slab; /* page array entry */ unsigned int page_array_slab_size; /* default page array slab size */ diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index ccb477086444..bae02ca96c1f 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -4287,6 +4287,7 @@ static void init_sb_info(struct f2fs_sb_info *sbi) NAT_ENTRY_PER_BLOCK)); sbi->allocate_section_hint =3D le32_to_cpu(raw_super->section_count); sbi->allocate_section_policy =3D ALLOCATE_FORWARD_NOHINT; + sbi->ra_folio_order =3D 0; F2FS_ROOT_INO(sbi) =3D le32_to_cpu(raw_super->root_ino); F2FS_NODE_INO(sbi) =3D le32_to_cpu(raw_super->node_ino); F2FS_META_INO(sbi) =3D le32_to_cpu(raw_super->meta_ino); diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c index c42f4f979d13..2537a25986a6 100644 --- a/fs/f2fs/sysfs.c +++ b/fs/f2fs/sysfs.c @@ -906,6 +906,13 @@ static ssize_t __sbi_store(struct f2fs_attr *a, return count; } =20 + if (!strcmp(a->attr.name, "ra_folio_order")) { + if (t < 0 || t > MAX_PAGECACHE_ORDER) + return -EINVAL; + sbi->ra_folio_order =3D t; + return count; + } + *ui =3D (unsigned int)t; =20 return count; @@ -1180,6 +1187,7 @@ F2FS_SBI_GENERAL_RW_ATTR(migration_window_granularity= ); F2FS_SBI_GENERAL_RW_ATTR(dir_level); F2FS_SBI_GENERAL_RW_ATTR(allocate_section_hint); F2FS_SBI_GENERAL_RW_ATTR(allocate_section_policy); +F2FS_SBI_GENERAL_RW_ATTR(ra_folio_order); #ifdef CONFIG_F2FS_IOSTAT F2FS_SBI_GENERAL_RW_ATTR(iostat_enable); F2FS_SBI_GENERAL_RW_ATTR(iostat_period_ms); @@ -1422,6 +1430,7 @@ static struct attribute *f2fs_attrs[] =3D { ATTR_LIST(reserved_pin_section), ATTR_LIST(allocate_section_hint), ATTR_LIST(allocate_section_policy), + ATTR_LIST(ra_folio_order), NULL, }; ATTRIBUTE_GROUPS(f2fs); --=20 2.52.0.107.ga0afd4fd5b-goog