From nobody Mon Dec 1 21:30:56 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 EFA152417C2 for ; Mon, 1 Dec 2025 19:19:47 +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=1764616788; cv=none; b=kr+9pczzB9ybauFeDIVigg2C2/41WbwbjsE1MimDa43BfykMrdCJWve8xX5dnNleokZm0p6IZO3fBJ4wCvddRB7GsC2wZZ1FHVS8Y8CiXnCSDliRtF+eSiMTNmkztrkbO9cRNLv/l3755NbkABHiC3w7FMpToT0DM1ws8zpCcS8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764616788; c=relaxed/simple; bh=qPAgh3J2+RQx0JuEOkYRh0szxr3XonhjB1XnpF8XRmE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bU79ksqDPixZ8fWADT0NXoU+O8a/GXJcVR0kPVKkncbEWrrAUf0ZJV60mYQzUUfO+3BHaa5GDw7ues4T0Y/Y+2UHR/GhNzkd3F/HhPxDkzxBY7Z5WjxvuT7SsDYdkK8s8AVtO+xDx+W4ntjsGVydEz9ZsQuNI1tq8lS2ZPvPETw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FxJaniuq; 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="FxJaniuq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BCB5CC19422; Mon, 1 Dec 2025 19:19:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1764616787; bh=qPAgh3J2+RQx0JuEOkYRh0szxr3XonhjB1XnpF8XRmE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FxJaniuqA9QxNGSqyD2DrWMHT6htzxZK4J2vWD4y+hGzmr7vAu75sPgGC8O9481WJ jK7t09I0XMT5GwYWRM0+yqcJQvFWV+IzvLVtsOhRV8ZYHSYHPGvmw6UvW5/vlBNa5L 6Nwvlo31jCzHIhNDoHaWls+scv50p/bvE6qb0y1/iwyFQwEajSuYGYsLSQ9TVzf6du iOFft850BkTsn+XY/qm5fydvCZmpOnrXW98M33HjwC1zm45OBLKHQMqm1jlXPyyfP9 keLhAHbwqG7Iz5oAiZRCXFTHPpfjkUG+CeLuA91FopZlUcO9bDB6Cn4S1D892CBo6a x7TFfM6+sM/xA== From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Cc: Jaegeuk Kim Subject: [PATCH 2/4] mm/readahead: use page_cache_sync_ra for FADVISE_FAV_WILLNEED Date: Mon, 1 Dec 2025 19:16:14 +0000 Message-ID: <20251201191940.883657-3-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" Given we have a_ops->folio_order which passes the desired folio order, let'= s use page_cache_sync_ra in fadvise(FADVISE_FAV_WILLNEED) to get large folios. Before: f2fs_fadvise: dev =3D (252,16), ino =3D 14, i_size =3D 4294967296 offset:0= , len:4294967296, advise:3 page_cache_ra_unbounded: dev=3D252:16 ino=3De index=3D0 nr_to_read=3D2048 = lookahead_size=3D0 page_cache_ra_unbounded: dev=3D252:16 ino=3De index=3D2048 nr_to_read=3D20= 48 lookahead_size=3D0 page_cache_ra_unbounded: dev=3D252:16 ino=3De index=3D4096 nr_to_read=3D20= 48 lookahead_size=3D0 page_cache_ra_unbounded: dev=3D252:16 ino=3De index=3D6144 nr_to_read=3D20= 48 lookahead_size=3D0 page_cache_ra_unbounded: dev=3D252:16 ino=3De index=3D8192 nr_to_read=3D20= 48 lookahead_size=3D0 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=3D12288 nr_to_read=3D2= 048 lookahead_size=3D0 page_cache_ra_unbounded: dev=3D252:16 ino=3De index=3D14336 nr_to_read=3D2= 048 lookahead_size=3D0 page_cache_ra_unbounded: dev=3D252:16 ino=3De index=3D16384 nr_to_read=3D2= 048 lookahead_size=3D0 page_cache_ra_unbounded: dev=3D252:16 ino=3De index=3D18432 nr_to_read=3D2= 048 lookahead_size=3D0 page_cache_ra_unbounded: dev=3D252:16 ino=3De index=3D20480 nr_to_read=3D2= 048 lookahead_size=3D0 page_cache_ra_unbounded: dev=3D252:16 ino=3De index=3D22528 nr_to_read=3D2= 048 lookahead_size=3D0 page_cache_ra_unbounded: dev=3D252:16 ino=3De index=3D24576 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 This is all zero-order page allocation. After (order=3D0 by default): 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 Signed-off-by: Jaegeuk Kim --- mm/readahead.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/mm/readahead.c b/mm/readahead.c index c0db049a5b7b..5beaf7803554 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -340,6 +340,7 @@ void force_page_cache_ra(struct readahead_control *ract= l, unsigned long nr_to_read) { struct address_space *mapping =3D ractl->mapping; + struct inode *inode =3D mapping->host; struct backing_dev_info *bdi =3D inode_to_bdi(mapping->host); unsigned long this_chunk; =20 @@ -352,11 +353,19 @@ void force_page_cache_ra(struct readahead_control *ra= ctl, this_chunk =3D max_t(unsigned long, bdi->io_pages, ractl->ra->ra_pages); =20 while (nr_to_read) { - this_chunk =3D min_t(unsigned long, this_chunk, nr_to_read); + unsigned long index =3D readahead_index(ractl); + pgoff_t end_index =3D (i_size_read(inode) - 1) >> PAGE_SHIFT; =20 - if (do_page_cache_ra(ractl, this_chunk, 0)) + if (index > end_index) break; =20 + if (nr_to_read > end_index - index) + nr_to_read =3D end_index - index + 1; + + this_chunk =3D min_t(unsigned long, this_chunk, nr_to_read); + + page_cache_sync_ra(ractl, this_chunk); + nr_to_read -=3D this_chunk; } } @@ -573,7 +582,7 @@ void page_cache_sync_ra(struct readahead_control *ractl, =20 /* be dumb */ if (do_forced_ra) { - force_page_cache_ra(ractl, req_count); + do_page_cache_ra(ractl, req_count, 0); return; } =20 --=20 2.52.0.107.ga0afd4fd5b-goog