* + readahead-use-ilog2-instead-of-a-while-loop-in-page_cache_ra_order.patch added to mm-unstable branch
@ 2024-01-16 20:09 Andrew Morton
0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2024-01-16 20:09 UTC (permalink / raw)
To: mm-commits, willy, p.raghav, akpm
The patch titled
Subject: readahead: use ilog2 instead of a while loop in page_cache_ra_order()
has been added to the -mm mm-unstable branch. Its filename is
readahead-use-ilog2-instead-of-a-while-loop-in-page_cache_ra_order.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/readahead-use-ilog2-instead-of-a-while-loop-in-page_cache_ra_order.patch
This patch will later appear in the mm-unstable branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via the mm-everything
branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there every 2-3 working days
------------------------------------------------------
From: Pankaj Raghav <p.raghav@samsung.com>
Subject: readahead: use ilog2 instead of a while loop in page_cache_ra_order()
Date: Mon, 15 Jan 2024 11:25:22 +0100
A while loop is used to adjust the new_order to be lower than the
ra->size. ilog2 could be used to do the same instead of using a loop.
ilog2 typically resolves to a bit scan reverse instruction. This is
particularly useful when ra->size is smaller than the 2^new_order as it
resolves in one instruction instead of looping to find the new_order.
No functional changes.
Link: https://lkml.kernel.org/r/20240115102523.2336742-1-kernel@pankajraghav.com
Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
mm/readahead.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
--- a/mm/readahead.c~readahead-use-ilog2-instead-of-a-while-loop-in-page_cache_ra_order
+++ a/mm/readahead.c
@@ -500,10 +500,8 @@ void page_cache_ra_order(struct readahea
if (new_order < MAX_PAGECACHE_ORDER) {
new_order += 2;
- if (new_order > MAX_PAGECACHE_ORDER)
- new_order = MAX_PAGECACHE_ORDER;
- while ((1 << new_order) > ra->size)
- new_order--;
+ new_order = min_t(unsigned int, MAX_PAGECACHE_ORDER, new_order);
+ new_order = min_t(unsigned int, new_order, ilog2(ra->size));
}
filemap_invalidate_lock_shared(mapping);
_
Patches currently in -mm which might be from p.raghav@samsung.com are
readahead-use-ilog2-instead-of-a-while-loop-in-page_cache_ra_order.patch
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-01-16 20:09 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-16 20:09 + readahead-use-ilog2-instead-of-a-while-loop-in-page_cache_ra_order.patch added to mm-unstable branch Andrew Morton
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.