[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aG5-PV7U2KaZDNGX@google.com>
Date: Wed, 9 Jul 2025 07:35:41 -0700
From: Sean Christopherson <seanjc@...gle.com>
To: Neeraj Upadhyay <Neeraj.Upadhyay@....com>
Cc: linux-kernel@...r.kernel.org, bp@...en8.de, tglx@...utronix.de,
mingo@...hat.com, dave.hansen@...ux.intel.com, Thomas.Lendacky@....com,
nikunj@....com, Santosh.Shukla@....com, Vasant.Hegde@....com,
Suravee.Suthikulpanit@....com, David.Kaplan@....com, x86@...nel.org,
hpa@...or.com, peterz@...radead.org, pbonzini@...hat.com, kvm@...r.kernel.org,
kirill.shutemov@...ux.intel.com, huibo.wang@....com, naveen.rao@....com,
kai.huang@...el.com
Subject: Re: [RFC PATCH v8 16/35] x86/apic: Simplify bitwise operations on
APIC bitmap
On Wed, Jul 09, 2025, Neeraj Upadhyay wrote:
> Use 'regs' as a contiguous linear bitmap for bitwise operations in
> apic_{set|clear|test}_vector(). This makes the code simpler by eliminating
That's very debatable. I don't find this code to be any simpler. Quite the
opposite; it adds yet another open coded math exercise, which is so "simple"
that it warrants its own comment to explain what it's doing.
I'm not dead set against this, but I'd strongly prefer to drop this patch.
> diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
> index b7cbe9ba363e..f91d23757375 100644
> --- a/arch/x86/include/asm/apic.h
> +++ b/arch/x86/include/asm/apic.h
> @@ -564,19 +564,28 @@ static __always_inline void apic_set_reg64(void *regs, int reg, u64 val)
> ap->regs64[reg / 8] = val;
> }
>
> +static inline unsigned int get_vec_bit(unsigned int vec)
> +{
> + /*
> + * The registers are 32-bit wide and 16-byte aligned.
> + * Compensate for the resulting bit number spacing.
> + */
> + return vec + 96 * (vec / 32);
> +}
> +
> static inline void apic_clear_vector(int vec, void *bitmap)
> {
> - clear_bit(APIC_VECTOR_TO_BIT_NUMBER(vec), bitmap + APIC_VECTOR_TO_REG_OFFSET(vec));
> + clear_bit(get_vec_bit(vec), bitmap);
> }
>
> static inline void apic_set_vector(int vec, void *bitmap)
> {
> - set_bit(APIC_VECTOR_TO_BIT_NUMBER(vec), bitmap + APIC_VECTOR_TO_REG_OFFSET(vec));
> + set_bit(get_vec_bit(vec), bitmap);
> }
>
> static inline int apic_test_vector(int vec, void *bitmap)
> {
> - return test_bit(APIC_VECTOR_TO_BIT_NUMBER(vec), bitmap + APIC_VECTOR_TO_REG_OFFSET(vec));
> + return test_bit(get_vec_bit(vec), bitmap);
> }
>
> /*
> --
> 2.34.1
>
Powered by blists - more mailing lists