David Hildenbrand <david@xxxxxxxxxx> writes:
On 11.07.25 19:26, Ankur Arora wrote:
David Hildenbrand <david@xxxxxxxxxx> writes:
On 10.07.25 02:59, Ankur Arora wrote:Thanks. Yes, this makes way more sense.
clear_page_rep() and clear_page_erms() are wrappers around "REP; STOS"
variations. Inlining gets rid of an unnecessary CALL/RET (which isn't
free when using RETHUNK speculative execution mitigations.)
Fixup and rename clear_page_orig() to adapt to the changed calling
convention.
And, add a comment from Dave Hansen detailing various clearing mechanisms
used in clear_page().
Signed-off-by: Ankur Arora <ankur.a.arora@xxxxxxxxxx>
---
arch/x86/include/asm/page_32.h | 6 +++++
arch/x86/include/asm/page_64.h | 42 ++++++++++++++++++++++++++--------
arch/x86/lib/clear_page_64.S | 39 +++++++------------------------
3 files changed, 46 insertions(+), 41 deletions(-)
diff --git a/arch/x86/include/asm/page_32.h b/arch/x86/include/asm/page_32.h
index 0c623706cb7e..a8ff43bb9652 100644
--- a/arch/x86/include/asm/page_32.h
+++ b/arch/x86/include/asm/page_32.h
@@ -17,6 +17,12 @@ extern unsigned long __phys_addr(unsigned long);
#include <linux/string.h>
+/*
/** if this was supposed to be kernel doc (which it looks like it is)
+ * clear_page() - clear kernel page.
"clear a kernel page"
Although I am not sure what a "kernel page" is.
Did you mean "clear a page using a kernel virtual address" ?
FWIW, most clear_user_page() will just call clear_page(). The ones that don't,
have to deal with the dcache flushing, as the page might have cache alias from
another (mm) address space.
So clear_page() is just about clearing page content using a kernel virtual
address, and clear_user_page() is additionally taking care of any dcache
aliases.
Yeah that's a good point.
Right now I'm assuming that clear_user_page() and clear_page() are
effectively identical. Which as you say, isn't true for all the
architectures that can't disambiguate dcache aliases.
So maybe I should be adjusting the naming of the helpers a bit?
Specifically, by calling clear_user_pages() from clear_pages_resched().
Which on x86 etc can just call clear_pages().