Subject: Re: [PATCH net-next 7/9] devlink: allow registering parameters after the instance

From: Leon Romanovsky <[email-masked]>
Date: Fri, 13 Jan 2023 08:45:46 +0200

On Thu, Jan 12, 2023 at 02:44:43PM -0800, Jacob Keller wrote:
> 
> 
> On 1/12/2023 12:09 PM, Leon Romanovsky wrote:
> > On Thu, Jan 12, 2023 at 11:20:21AM -0800, Jakub Kicinski wrote:
> >> On Thu, 12 Jan 2023 09:07:43 +0200 Leon Romanovsky wrote:
> >>> As a user, I don't want to see any late dynamic object addition which is
> >>> not triggered by me explicitly. As it doesn't make any sense to add
> >>> various delays per-vendor/kernel in configuration scripts just because
> >>> not everything is ready. Users need predictability, lazy addition of
> >>> objects adds chaos instead.
> >>>
> >>> Agree with Jakub, it is anti-pattern.
> >>
> >> To be clear my preference would be to always construct the three from
> >> the root. Register the main instance, then sub-objects. I mean - you
> >> tried forcing the opposite order and it only succeeded in 90-something
> >> percent of cases. There's always special cases.

Back then, we had only one special case - netdevsim. I still think that
all recent complexity that was brought to the devlink could be avoided
if we would change netdevsim to behave as HW driver (remove sysfs).

> Right. I think its easier to simply require devlink to be registered first.

devlink_register() is no more than a fancy way to say to the world: "I'm
ready to accept commands". Right now, when the need_lock flag is removed
from all devlink commands, we can place devlink_register() at any place.

> 
> >> I don't understand your concern about user experience here. We have
> >> notifications for each sub-object. Plus I think drivers should hold 
> >> the instance lock throughout the probe routine. I don't see a scenario
> >> in which registering the main instance first would lead to retry/sleep
> >> hacks in user space, do you? I'm talking about devlink and the subobjs
> >> we have specifically.
> > 
> > The term "dynamic object addition" means for me what driver authors will
> > be able to add objects anytime in lifetime of the driver. I'm pretty sure
> > that once you allow that, we will see zoo here. Over time, you will get
> > everything from .probe() to workqueues. The latter caused me to write
> > about retry/sleep hacks.
> > 
> > If you success to force everyone to add objects in .probe() only, it
> > will be very close to what I tried to achieve.
> > 
> > Thanks
> 
> Yea. I was initially thinking of something like that, but I've convinced
> myself that its a bad idea. The only "dynamic" objects (added after the
> initialization phase of devlink) should be those which are triggered via
> user space request (i.e. "devlink port add").

Exactly.

> Thanks,
> Jake