Re: [PATCH v2] PCI: Batch BAR sizing operations

From: Oleg Nesterov
Date: Mon Feb 10 2025 - 17:47:33 EST


On 02/10, David Laight wrote:
>
> On Mon, 10 Feb 2025 13:48:48 -0700
> Alex Williamson <alex.williamson@xxxxxxxxxx> wrote:
>
> > On Mon, 10 Feb 2025 21:08:19 +0100
> > Oleg Nesterov <oleg@xxxxxxxxxx> wrote:
> >
> > > On 02/10, Oleg Nesterov wrote:
> > > >
> > > > On 02/10, Alex Williamson wrote:
> > > > >
> > > > > --- a/drivers/pci/probe.c
> > > > > +++ b/drivers/pci/probe.c
> > > > > @@ -345,7 +345,8 @@ static void pci_read_bases(struct pci_dev *dev, unsigned int howmany, int rom)
>
> You probably need __always_inline to have any chance of a compile-time
> test of howmany.

Can't really comment...

But note that nobody else reported this problem, so I guess the newer
compilers are smart enough? Not that I am sure we can rely on it...

> > > >
> > > > BUILD_BUG_ON(__builtin_constant_p(howmany) && howmany > PCI_STD_NUM_BARS);
>
> statically_true(howmany > PCI_STD_NUM_BARS)

Indeed.

Oleg.