Skip to contentSkip to conversation

readahead-use-ilog2-instead-of-a-while-loop-in-page_cache_ra_order.patch removed from -mm tree

merged mm-stable Andrew Morton 1 participant 1 message Feb 22, 2024

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: readahead: use ilog2 instead of a while loop in page_cache_ra_order()
has been removed from the -mm tree. Its filename was
readahead-use-ilog2-instead-of-a-while-loop-in-page_cache_ra_order.patch

This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Pankaj Raghav <[email protected]>
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.

---

 mm/readahead.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
mm/readahead.c renamed from mm/readahead.c~readahead-use-ilog2-instead-of-a-while-loop-in-page_cache_ra_order +2 -4
@@ -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 [email protected] are