Re: [PATCH v4 2/2] locking/pvqspinlock, hv: Enable PV qspinlock for Hyper-V

From: Ingo Molnar
Date: Wed Oct 10 2018 - 01:50:37 EST



* Yi Sun <yi.y.sun@xxxxxxxxxxxxxxx> wrote:

> On 18-10-09 12:54:27, Ingo Molnar wrote:
> >
> > * Yi Sun <yi.y.sun@xxxxxxxxxxxxxxx> wrote:
> >
> > > Follow PV spinlock mechanism to implement the callback functions
> > > to allow the CPU idling and kicking operations on Hyper-V.
> >
> > > +#if defined(CONFIG_SMP)
> > > + smp_ops.smp_prepare_boot_cpu = hv_smp_prepare_boot_cpu;
> > > +#endif
> >
> > What's wrong with using the common pattern of:
> >
> > #ifdef CONFIG_SMP
> >
> > ?
>
> There is no difference between "#ifdef" and "#if defined". I just copied
> it from "hv_smp_prepare_boot_cpu()". Do you need me submit a fix patch
> after this set is merged?

It's equivalent code, my point was that '#ifdef CONFIG_XYZ' is the shorter, more canonical
pattern we use in the kernel most of the time, it's shorter, easier to read. We only use
defined() for longer preprocessor directive conditions, and it's a pattern for "there's
something more complex here than a simple CONFIG_XYZ dependency".

Anyway, Thomas fixed it up in the latest iteration.

Thanks,

Ingo