linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][next][V2] mm/mincore: improve performance by adding an unlikely hint
@ 2025-02-19  8:36 Colin Ian King
  0 siblings, 0 replies; only message in thread
From: Colin Ian King @ 2025-02-19  8:36 UTC (permalink / raw)
  To: Andrew Morton, linux-mm; +Cc: kernel-janitors, Matthew Wilcox, linux-kernel

Adding an unlikely() hint on the masked start comparison error
return path improves run-time performance of the mincore system call.

Benchmarking on an i9-12900 shows an improvement of 7ns on mincore calls
on a 256KB mmap'd region where 50% of the pages we resident. Improvement
was from ~970 ns down to 963 ns, so a small ~0.7% improvement.

Results based on running 20 tests with turbo disabled (to reduce
clock freq turbo changes), with 10 second run per test and comparing
the number of mincores calls per second. The % standard deviation of
the 20 tests was ~0.10%, so results are reliable.

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>

---

V2: Add information about % improvement and timings in nanoseconds

---
 mm/mincore.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/mincore.c b/mm/mincore.c
index d6bd19e520fc..832f29f46767 100644
--- a/mm/mincore.c
+++ b/mm/mincore.c
@@ -239,7 +239,7 @@ SYSCALL_DEFINE3(mincore, unsigned long, start, size_t, len,
 	start = untagged_addr(start);
 
 	/* Check the start address: needs to be page-aligned.. */
-	if (start & ~PAGE_MASK)
+	if (unlikely(start & ~PAGE_MASK))
 		return -EINVAL;
 
 	/* ..and we need to be passed a valid user-space range */
-- 
2.47.2



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-02-19  8:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-19  8:36 [PATCH][next][V2] mm/mincore: improve performance by adding an unlikely hint Colin Ian King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox