Re: [PATCH v2 03/10] kvm: arm64: Remove __hyp_this_cpu_read
From: David Brazdil
Date: Thu Sep 17 2020 - 04:34:46 EST
> > +#ifdef __KVM_NVHE_HYPERVISOR__
> > +#define __my_cpu_offset __hyp_my_cpu_offset()
> Is there a benefit to this being used for __KVM_VHE_HYPERVISOR__ too
> since that is "hyp" too and doesn't need the alternative since it will
> always pick EL2?
Minor time and space savings, but you're right, makes sense to treat them
equally. Updated in v3.
> > +/* Redefine macros for nVHE hyp under DEBUG_PREEMPT to avoid its dependencies. */
> > +#if defined(__KVM_NVHE_HYPERVISOR__) && defined(CONFIG_DEBUG_PREEMPT)
> > +#undef this_cpu_ptr
> > +#define this_cpu_ptr raw_cpu_ptr
> > +#undef __this_cpu_read
> > +#define __this_cpu_read raw_cpu_read
> > +#undef __this_cpu_write
> > +#define __this_cpu_write raw_cpu_write
> > +#endif
> This is an incomplete cherry-picked list of macros that are redefined to
> remove the call to __this_cpu_preempt_check that would result in a
> linker failure since that symbol is not defined for nVHE hyp.
> I remember there being some dislike of truely defining that symbol with
> an nVHE hyp implementation but I can't see why. Yes, nVHE hyp is always
> has preemption disabled so the implementation is just an empty function
> but why is is preferrable to redefine some of these macros instead?
That was my initial implementation and we could probably sway others in that
direction, too. That said, I just tried it on 5.9-rc5 and there are two more
dependencies. No idea what changed sinced the last time I tried, maybe I simply
messed up back then.
Basically, this_cpu_ptr translates to:
__this_cpu_preempt_check(); per_cpu_ptr(sym, debug_smp_processor_id())
__this_cpu_preempt_check: should be empty for hyp
per_cpu_ptr: needs mapping of the array of bases in hyp, otherwise easy
debug_smp_processor_id: needs a clone of 'cpu_number' percpu variable
Neither of these is particularly difficult to implement, and two will even be
useful going forward, but it still feels too fiddly for posting this late in
the 5.10 cycle. So I suggest we stick to the macro redefines for now and I'll
post those patches for 5.11. WDYT?
You can find the patches on branch 'topic/percpu-v3-debug-preempt' of