[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAK-6q+h07LM1-Cu_mkxAZWN2kG9LLxoKvXxUiQ5DPSYwRkbXZw@mail.gmail.com>
Date: Thu, 12 May 2022 10:44:35 -0400
From: Alexander Aring <aahringo@...hat.com>
To: Miquel Raynal <miquel.raynal@...tlin.com>
Cc: Alexander Aring <alex.aring@...il.com>,
Stefan Schmidt <stefan@...enfreihafen.org>,
linux-wpan@...r.kernel.org,
"David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Network Development <netdev@...r.kernel.org>,
David Girault <david.girault@...vo.com>,
Romuald Despres <romuald.despres@...vo.com>,
Frederic Blain <frederic.blain@...vo.com>,
Nicolas Schodet <nico@...fr.eu.org>,
Thomas Petazzoni <thomas.petazzoni@...tlin.com>
Subject: Re: [PATCH wpan-next 06/11] net: mac802154: Hold the transmit queue
when relevant
Hi,
On Thu, May 12, 2022 at 10:33 AM Miquel Raynal
<miquel.raynal@...tlin.com> wrote:
>
> Hi Alexander,
>
> aahringo@...hat.com wrote on Wed, 11 May 2022 09:09:40 -0400:
>
> > Hi,
> >
> > On Tue, May 10, 2022 at 10:52 AM Miquel Raynal
> > <miquel.raynal@...tlin.com> wrote:
> > >
> > > Hi Alex,
> > >
> > > > > --- a/net/mac802154/tx.c
> > > > > +++ b/net/mac802154/tx.c
> > > > > @@ -106,6 +106,21 @@ ieee802154_tx(struct ieee802154_local *local, struct sk_buff *skb)
> > > > > return NETDEV_TX_OK;
> > > > > }
> > > > >
> > > > > +void ieee802154_hold_queue(struct ieee802154_local *local)
> > > > > +{
> > > > > + atomic_inc(&local->phy->hold_txs);
> > > > > +}
> > > > > +
> > > > > +void ieee802154_release_queue(struct ieee802154_local *local)
> > > > > +{
> > > > > + atomic_dec(&local->phy->hold_txs);
> > > > > +}
> > > > > +
> > > > > +bool ieee802154_queue_is_held(struct ieee802154_local *local)
> > > > > +{
> > > > > + return atomic_read(&local->phy->hold_txs);
> > > > > +}
> > > >
> > > > I am not getting this, should the release_queue() function not do
> > > > something like:
> > > >
> > > > if (atomic_dec_and_test(hold_txs))
> > > > ieee802154_wake_queue(local);
> > > >
> > > > I think we don't need the test of "ieee802154_queue_is_held()" here,
> > > > then we need to replace all stop_queue/wake_queue with hold and
> > > > release?
> > >
> > > That's actually a good idea. I've implemented it and it looks nice too.
> > > I'll clean this up and share a new version with:
> > > - The wake call checked everytime hold_txs gets decremented
> > > - The removal of the _queue_is_held() helper
> > > - _wake/stop_queue() turned static
> > > - _hold/release_queue() used everywhere
> > >
> >
> > I think there is also a lock necessary for atomic inc/dec hitting zero
> > and the stop/wake call afterwards...
>
> Mmmh that is true, it can race. I've introduced a mutex (I think it's
> safe but it can be turned into a spinlock if proven necessary) to
> secure these increment/decrement+wakeup operations.
>
be aware that you might call these functions from different contexts,
test your patches with PROVE_LOCKING enabled.
> > ,there are also a lot of
> > optimization techniques to only hold the lock for hitting zero cases
> > in such areas. However we will see...
>
> I am not aware of technical solutions to avoid the locking in these
> cases, what do you have in mind? Otherwise I propose just to come up
> with a working and hopefully solid solution and then we'll see how to
> optimize.
Yes, it's not so important...
- Alex
Powered by blists - more mailing lists