[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <878qo234rj.fsf@oracle.com>
Date: Mon, 14 Apr 2025 12:46:40 -0700
From: Ankur Arora <ankur.a.arora@...cle.com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Ingo Molnar <mingo@...nel.org>, Ankur Arora <ankur.a.arora@...cle.com>,
linux-kernel@...r.kernel.org, linux-mm@...ck.org, x86@...nel.org,
torvalds@...ux-foundation.org, akpm@...ux-foundation.org, bp@...en8.de,
dave.hansen@...ux.intel.com, hpa@...or.com, mingo@...hat.com,
luto@...nel.org, paulmck@...nel.org, rostedt@...dmis.org,
tglx@...utronix.de, willy@...radead.org, jon.grimm@....com,
bharata@....com, raghavendra.kt@....com, boris.ostrovsky@...cle.com,
konrad.wilk@...cle.com
Subject: Re: [PATCH v3 1/4] x86/clear_page: extend clear_page*() for
multi-page clearing
Peter Zijlstra <peterz@...radead.org> writes:
> On Mon, Apr 14, 2025 at 08:32:29AM +0200, Ingo Molnar wrote:
[ ... ]
>> > -SYM_TYPED_FUNC_START(clear_page_orig)
>> > +/*
>> > + * Original page zeroing loop.
>> > + * Input:
>> > + * %rdi - destination
>> > + * %esi - length
>> > + *
>> > + * Clobbers: %rax, %rcx, %rflags
>> > + */
>> > +SYM_TYPED_FUNC_START(clear_pages_orig)
>> > + movl %esi, %ecx
>> > xorl %eax,%eax
>> > - movl $4096/64,%ecx
>> > + shrl $6,%ecx
>>
>> So if the natural input parameter is RCX, why is this function using
>> RSI as the input 'length' parameter? Causes unnecessary register
>> shuffling.
>
> This symbol is written as a C function with C calling convention, even
> though it is only meant to be called from that clear_page() alternative.
>
> If we want to go change all this, then we should go do the same we do
> for __clear_user() and write it thusly:
>
> asm volatile(ALTERNATIVE("rep stosb",
> "call rep_stos_alternative", ALT_NOT(X86_FEATURE_FSRS)
> : "+c" (size), "+D" (addr), ASM_CALL_CONSTRAINT
> : "a" (0))
>
> And forget about all those clear_page_*() thingies.
Yeah, this makes sense. We don't call any of the clear_pages_*() variants
from anywhere else.
clear_pages_rep() and clear_pages_erms() are trivial enough to be
inlined in the ALTERNATIVE as well.
Thanks!
--
ankur
Powered by blists - more mailing lists