Re: [PATCH v3] PCI/DOE: Expose the DOE protocols via sysfs

From: Greg KH
Date: Thu Aug 10 2023 - 03:48:58 EST


On Thu, Aug 10, 2023 at 09:44:44AM +0200, Lukas Wunner wrote:
> On Thu, Aug 10, 2023 at 07:05:12AM +0200, Greg KH wrote:
> > On Wed, Aug 09, 2023 at 07:28:51PM -0400, Alistair Francis wrote:
> > > v3:
> > > - Expose each DOE feature as a separate file
> >
> > But you don't actually have anything in the sysfs files, why not?
>
> He wants to expose a list of supported protocols.
>
> He first exposed the list in a single attribute, separated by newlines.
> Which made sense because it allows users to grep for a specific protocol.
>
> You told him not to expose multiple values in a single attribute.
> So he's exposing the available protocols each in an empty file.
> The file name contains the protocol.
>
> You got what you asked for. ;)

But that's not what was documented, it should say "empty file",
otherwise this is going to be very odd when people try to read a file
that is marked as readable, but yet returns an error :(

> > > --- a/drivers/pci/doe.c
> > > +++ b/drivers/pci/doe.c
> > > @@ -56,6 +56,10 @@ struct pci_doe_mb {
> > > wait_queue_head_t wq;
> > > struct workqueue_struct *work_queue;
> > > unsigned long flags;
> > > +
> > > +#ifdef CONFIG_SYSFS
> > > + struct device_attribute *sysfs_attrs;
> > > +#endif
> >
> > Please don't put #ifdefs in .c files if you can prevent it. I think
> > this will work just fine if you don't have the #ifdef. And who would be
> > using pci without sysfs?
>
> People with space-constrained devices such as routers.

So the extra pointer here is a real problem for them? And how much
memory are you saving?

> It is perfectly legal to compile a kernel with CONFIG_PCI=y and
> CONFIG_SYSFS=n.

Sure, just not common.

> And it is reasonable not to include code in the kernel which has
> specifically been deselected in the kernel config.

Sure, but not at the expense of a zillion #ifdef lines :)

thanks,

greg k-h