[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZEfpB7m3bWr1bPlv@nvidia.com>
Date: Tue, 25 Apr 2023 11:51:51 -0300
From: Jason Gunthorpe <jgg@...dia.com>
To: Reinette Chatre <reinette.chatre@...el.com>
Cc: Alex Williamson <alex.williamson@...hat.com>, yishaih@...dia.com,
shameerali.kolothum.thodi@...wei.com, kevin.tian@...el.com,
tglx@...utronix.de, darwi@...utronix.de, kvm@...r.kernel.org,
dave.jiang@...el.com, jing2.liu@...el.com, ashok.raj@...el.com,
fenghua.yu@...el.com, tom.zanussi@...ux.intel.com,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH V3 08/10] vfio/pci: Probe and store ability to support
dynamic MSI-X
On Mon, Apr 24, 2023 at 04:52:08PM -0700, Reinette Chatre wrote:
> Hi Jason,
>
> On 4/24/2023 10:43 AM, Jason Gunthorpe wrote:
> > On Wed, Apr 19, 2023 at 11:11:48AM -0700, Reinette Chatre wrote:
> >> On 4/18/2023 3:38 PM, Alex Williamson wrote:
> >>> On Tue, 18 Apr 2023 10:29:19 -0700
> >>> Reinette Chatre <reinette.chatre@...el.com> wrote:
>
> ...
>
> >> diff --git a/include/linux/vfio_pci_core.h b/include/linux/vfio_pci_core.h
> >> index 4f070f2d6fde..d730d78754a2 100644
> >> --- a/include/linux/vfio_pci_core.h
> >> +++ b/include/linux/vfio_pci_core.h
> >> @@ -67,8 +67,8 @@ struct vfio_pci_core_device {
> >> u8 msix_bar;
> >> u16 msix_size;
> >> u32 msix_offset;
> >> - bool has_dyn_msix;
> >> u32 rbar[7];
> >> + bool has_dyn_msix;
> >> bool pci_2_3;
> >> bool virq_disabled;
> >> bool reset_works;
> >
> > Also, Linus on record as strongly disliking these lists of bools
>
> This looks like an example:
> https://lkml.org/lkml/2017/11/21/384
>
> >
> > If they don't need read_once/etc stuff then use a list of bitfields
>
> I do not see any direct usage of read_once in the driver, but it is not
> clear to me what falls under the "etc" umbrella.
Anything that might assume atomicity, smp_store_release, set_bit, and others
> Do you consider all the bools in struct vfio_pci_core_device to be
> candidates for transition?
Yes, group them ito into a bitfield.
> I think a base type of unsigned int since it appears to be the custom
> and (if I understand correctly) was preferred at the time Linus wrote
> the message I found.
It doesn't matter a lot, using "bool" means the compiler adds extra
code to ensure "foo = 4" stores true, and the underyling size is not
well defined (but we don't care here)
> Looking ahead there seems be be a bigger task here. A quick search
> revealed a few other instances of vfio using "bool" in a struct. It
> does not all qualify for your "lists of bools" comment, but they
> may need a closer look because of the "please don't use "bool" in
> structures at all" comment made by Linus in the email I found.
IMHO bool is helpful for clarity, it says it is a flag. In these cases
we won't gain anything by using u8 instead
Lists of bools however start to get a little silly when we use maybe 4
bytes per bool (though x86-64 is using 1 byte in structs)
Jason
Powered by blists - more mailing lists