Re: [PATCH v2 -tip] x86/percpu: Use C for arch_raw_cpu_ptr()
From: Linus Torvalds
Date: Mon Oct 16 2023 - 17:00:09 EST
On Mon, 16 Oct 2023 at 13:35, Nadav Amit <namit@xxxxxxxxxx> wrote:
>
> I don’t think it means that it the aliasing does not work; I think it all means that
> it actually works *too well*.
Hmm. The *only* case I can think of is __switch_to() itself when doing that
raw_cpu_write(pcpu_hot.current_task, next_p);
and arguably that part should never have been done in C at all, but here we are.
I do think that from a sanity standpoint, it would be good to split
"__switch_to()" into two: a "before stack switch" and "after stack
switch", and change 'current' from within the asm section (ie do that
part in __switch_to_asm").
Or maybe we should just keep the single "__switch_to()" function, but
make it clear that it happens *after* current has been changed (and
maybe rename it to 'funish_switch_to()" or something like that to make
it clearer).
Because the situation with __switch_to() right now is outright
confusing, where it has 'prevp' and 'nextp', but then implicitly uses
'current' in two different ways.
Ugh.
Linus