[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CACT4oud9B-yCD5jVWRt9c4JXq2_Ap-qMkr9y3xJ5cgTTggYT1w@mail.gmail.com>
Date: Wed, 19 Oct 2022 08:18:29 +0200
From: Íñigo Huguet <ihuguet@...hat.com>
To: Jakub Kicinski <kuba@...nel.org>
Cc: Andrew Lunn <andrew@...n.ch>, irusskikh@...vell.com,
dbogdanov@...vell.com, davem@...emloft.net, edumazet@...gle.com,
pabeni@...hat.com, netdev@...r.kernel.org,
Li Liang <liali@...hat.com>
Subject: Re: [PATCH net] atlantic: fix deadlock at aq_nic_stop
On Tue, Oct 18, 2022 at 5:59 PM Jakub Kicinski <kuba@...nel.org> wrote:
>
> On Tue, 18 Oct 2022 08:15:38 +0200 Íñigo Huguet wrote:
> > Interesting solution, I didn't even think of something like this.
> > However, despite not being 100% sure, I think that it's not valid in
> > this case because the work's task communicates with fw and uses
> > resources that are deinitialized at ndo_stop. That's why I think that
> > just holding a reference to the device is not enough.
>
> You hold a reference to the netdev just to be able to take rtnl_lock()
> and check if it's still running. If it is UP you're protected from it
> going down due to rtnl_lock you took. If it's DOWN, as you say, it's not
> safe to access all the bits so just unlock and return.
>
> But because you're holding the reference it's safe to cancel_work()
> without _sync on down, because the work itself will check if it should
> have been canceled.
>
> Dunno if that's a good explanation :S
Yes, now I get it.
However, I think I won't use this strategy this time: rtnl_lock is
only needed in the work task if IS_ENABLED(CONFIG_MACSEC). Acquiring
rtnl_lock every time if macsec is not enabled wouldn't be protecting
anything, so it would be a waste. I think that the strategy suggested
by Andrew of adding a dedicated mutex to protect atlantic's macsec
operations makes more sense in this case. Do you agree?
--
Íñigo Huguet
Powered by blists - more mailing lists