[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230412190650.70baee3e@kernel.org>
Date: Wed, 12 Apr 2023 19:06:50 -0700
From: Jakub Kicinski <kuba@...nel.org>
To: Edward Cree <ecree.xilinx@...il.com>
Cc: Andrew Lunn <andrew@...n.ch>, edward.cree@....com,
linux-net-drivers@....com, davem@...emloft.net, pabeni@...hat.com,
edumazet@...gle.com, netdev@...r.kernel.org,
habetsm.xilinx@...il.com, sudheer.mogilappagari@...el.com
Subject: Re: [RFC PATCH v2 net-next 6/7] net: ethtool: add a mutex
protecting RSS contexts
On Wed, 12 Apr 2023 18:42:16 +0100 Edward Cree wrote:
> On 12/04/2023 18:15, Andrew Lunn wrote:
> > I have to wonder if your locking model is wrong. When i look at the
> > next patch, i see the driver is also using this lock. And i generally
> > find that is wrong.
> ...
> > Drivers writers should not need to worry about locking. The API
> > into the driver will take the locks needed before entering the driver,
> > and release them on exit.
> I don't think that's possible without increasing driver complexity in
> other ways. Essentially, for the driver to take advantage of the core
> tracking these contexts, and thus not need its own data structures to
> track them as well (like the efx->rss_context.list we remove in patch
> #7), it has to be able to access them on driver-initiated (not just
> core-initiated) events. (The central example of this being "oh, the
> NIC MCPU just rebooted, we have to reinstall all our filters".) And
> it needs to be able to exclude writes while it does that, not only for
> consistency but also because e.g. context deletion will free that
> memory (though I guess we could finesse that part with RCU?).
> What I *could* do is add suitable wrapper functions for access to
> dev->ethtool->rss_ctx (e.g. a core equivalent of
> efx_find_rss_context_entry() that wraps the idr_find()) and have them
> assert that the lock is held (like efx_find_rss_context_entry() does);
> that would at least validate the driver locking somewhat.
> But having those helper functions perform the locking themselves would
> mean going to a get/put model for managing the lifetime of the
> driver's reference (with a separate get_write for exclusive access),
> at which point it's probably harder for driver writers to understand
> than "any time you're touching rss_ctx you need to hold the rss_lock".
IMO the "MCPU has rebooted" case is a control path, taking rtnl seems
like the right thing to do. Does that happen often enough or takes so
long to recover that we need to be concerned about locking down rtnl?
aRFS can't sleep IIUC so the mutex is does not seem like a great match.
IOW I had the same reaction as Andrew first time I saw this mutex :(
Powered by blists - more mailing lists