Re: [RFC PATCH v7 03/37] x86/apic: KVM: Deduplicate APIC vector => register+bit math

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jun 25, 2025, Neeraj Upadhyay wrote:
> 
> 
> On 6/23/2025 5:19 PM, Borislav Petkov wrote:
> > On Tue, Jun 10, 2025 at 11:23:50PM +0530, Neeraj Upadhyay wrote:
> >> diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
> >> index 23d86c9750b9..c84d4e86fe4e 100644
> >> --- a/arch/x86/include/asm/apic.h
> >> +++ b/arch/x86/include/asm/apic.h
> >> @@ -488,11 +488,14 @@ static inline void apic_setup_apic_calls(void) { }
> >>  
> >>  extern void apic_ack_irq(struct irq_data *data);
> >>  
> >> +#define APIC_VECTOR_TO_BIT_NUMBER(v) ((unsigned int)(v) % 32)
> >> +#define APIC_VECTOR_TO_REG_OFFSET(v) ((unsigned int)(v) / 32 * 0x10)
> > 
> > Dunno - I'd probably shorten those macro names:
> > 
> > APIC_VEC_TO_BITNUM()
> > APIC_VEC_TO_REGOFF()
> > 
> > because this way of shortening those words is very common and is still very
> > readable, even if not fully written out...
> > 
> 
> Sounds good to me. Will change this in next version (will also wait for Sean's
> comment on this).

My vote is for the long names.  I find REG_OFFSET in particular to be much more
self-documenting.  My brain gets there eventually with REGOFF, but I just don't
see the point in shortening the names.  The only uses where line lengths get a
bit too long are apic_set_isr() and apic_clear_isr(), and the lines are still
quite long with the shorter names.




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux