diff mbox series

[3/3] mm: skip page_cpupid_reset_last atomic update if the value is already reset

Message ID 20201220050340.849754-3-npiggin@gmail.com (mailing list archive)
State New, archived
Headers show
Series [1/3] mm: prefix page_cpupid_reset_last as non-atomic | expand

Commit Message

Nicholas Piggin Dec. 20, 2020, 5:03 a.m. UTC
Improves performance of a PROT_READ -> PROT_READ|PROT_WRITE -> store
microbenchmark (which goes via the wp_page_reuse fault path) by about
10% on a POWER9.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 include/linux/mm.h | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/include/linux/mm.h b/include/linux/mm.h
index 6ece500464e0..c0a9e8de0738 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1382,6 +1382,9 @@  static inline void __page_cpupid_reset_last(struct page *page)
 
 static inline void page_cpupid_reset_last(struct page *page)
 {
+	if (page_cpupid_last(page) == (-1 & LAST_CPUPID_MASK))
+		return;
+
 	page_cpupid_xchg_last(page, (1 << LAST_CPUPID_SHIFT) - 1);
 }