Re: [PATCH wq/for-next 2/2] workqueue: let device core create the WQ_UNBOUND attributes

From: Greg Kroah-Hartman
Date: Mon Jun 07 2021 - 06:41:16 EST


On Mon, Jun 07, 2021 at 01:34:49PM +0300, Julian Wiedmann wrote:
> On 07.06.21 13:27, Greg Kroah-Hartman wrote:
> > On Mon, Jun 07, 2021 at 11:44:20AM +0200, Julian Wiedmann wrote:
> >> Wrap the attributes for a WQ_UNBOUND workqueue in ATTRIBUTE_GROUPS(),
> >> and wire them up in dev->groups so that the device core can manage them
> >> for us.
> >>
> >> As device_add() will add such attributes _prior_ to raising the KOBJ_ADD
> >> uevent, this also makes the initial uevent suppression unnecessary.
> >>
> >> Signed-off-by: Julian Wiedmann <jwi@xxxxxxxxxxxxx>
> >> ---
> >> kernel/workqueue.c | 51 ++++++++++++++++++++--------------------------
> >> 1 file changed, 22 insertions(+), 29 deletions(-)
> >>
> >> diff --git a/kernel/workqueue.c b/kernel/workqueue.c
> >> index 817dc2d7438a..629859ac5262 100644
> >> --- a/kernel/workqueue.c
> >> +++ b/kernel/workqueue.c
> >> @@ -5449,6 +5449,9 @@ static ssize_t wq_pool_ids_show(struct device *dev,
> >> return written;
> >> }
> >>
> >> +static struct device_attribute wq_sysfs_unbound_attr_pool_ids =
> >> + __ATTR(pool_ids, 0444, wq_pool_ids_show, NULL);
> >
> > __ATTR_RO() please.
> >
>
> I did consider using DEVICE_ATTR_*(), yes. But renaming all the _show and _store
> functions added too much unrelated churn for my taste. So let's maybe do this
> as a follow-on?

Wait, oops, yes, do NOT use __ATTR() for a device attribute, use
DEVICE_ATTR_RO() please.

And yes, if you want to do it as a pater patch in this series that is
fine, just say you are moving the attribute definitions closer to the
callbacks in this patch.

thanks,

greg k-h