Re: [PATCH tip/core/rcu 01/12] rcu: Remove rcu_swap_protected()

From: Paul E. McKenney
Date: Wed Dec 11 2019 - 18:12:43 EST


On Wed, Dec 11, 2019 at 08:09:11PM +0100, Matthias Brugger wrote:
>
>
> On 11/12/2019 19:37, Paul E. McKenney wrote:
> > On Tue, Dec 10, 2019 at 07:51:22PM -0800, Paul E. McKenney wrote:
> >> On Tue, Dec 10, 2019 at 10:35:49PM -0500, Martin K. Petersen wrote:
> >>>
> >>> Paul,
> >>>
> >>>> Now that the calls to rcu_swap_protected() have been replaced by
> >>>> rcu_replace_pointer(), this commit removes rcu_swap_protected().
> >>>
> >>> It appears there are two callers remaining in Linus' master. Otherwise
> >>> looks good to me.
> >>
> >> I did queue a fix for one of them, and thank you for calling my
> >> attention to the new one. This commit should hit -next soon, so
> >> hopefully this will discourage further additions. ;-)
> >>
> >>> Reviewed-by: Martin K. Petersen <martin.petersen@xxxxxxxxxx>
> >>
> >> Thank you!
> >
> > And here is the patch for the new one.
> >
> > Thanx, Paul
> >
> > ------------------------------------------------------------------------
> >
> > commit 10699d92c906707d679e28b099cd798a519b4f51
> > Author: Paul E. McKenney <paulmck@xxxxxxxxxx>
> > Date: Wed Dec 11 10:30:21 2019 -0800
> >
> > wireless/mediatek: Replace rcu_swap_protected() with rcu_replace_pointer()
> >
> > This commit replaces the use of rcu_swap_protected() with the more
> > intuitively appealing rcu_replace_pointer() as a step towards removing
> > rcu_swap_protected().
> >
> > Link: https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@xxxxxxxxxxxxxx/
> > Reported-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
> > Reported-by: "Martin K. Petersen" <martin.petersen@xxxxxxxxxx>
> > Signed-off-by: Paul E. McKenney <paulmck@xxxxxxxxxx>
> > Cc: Felix Fietkau <nbd@xxxxxxxx>
> > Cc: Lorenzo Bianconi <lorenzo.bianconi83@xxxxxxxxx>
> > Cc: Ryder Lee <ryder.lee@xxxxxxxxxxxx>
> > Cc: Roy Luo <royluo@xxxxxxxxxx>
> > Cc: Kalle Valo <kvalo@xxxxxxxxxxxxxx>
> > Cc: "David S. Miller" <davem@xxxxxxxxxxxxx>
> > Cc: Matthias Brugger <matthias.bgg@xxxxxxxxx>
> > Cc: <linux-wireless@xxxxxxxxxxxxxxx>
> > Cc: <netdev@xxxxxxxxxxxxxxx>
> > Cc: <linux-arm-kernel@xxxxxxxxxxxxxxxxxxx>
> > Cc: <linux-mediatek@xxxxxxxxxxxxxxxxxxx>
> >
> > diff --git a/drivers/net/wireless/mediatek/mt76/agg-rx.c b/drivers/net/wireless/mediatek/mt76/agg-rx.c
> > index 53b5a4b..80986ce 100644
> > --- a/drivers/net/wireless/mediatek/mt76/agg-rx.c
> > +++ b/drivers/net/wireless/mediatek/mt76/agg-rx.c
> > @@ -281,8 +281,8 @@ void mt76_rx_aggr_stop(struct mt76_dev *dev, struct mt76_wcid *wcid, u8 tidno)
> > {
> > struct mt76_rx_tid *tid = NULL;
> >
> > - rcu_swap_protected(wcid->aggr[tidno], tid,
> > - lockdep_is_held(&dev->mutex));
> > + tid = rcu_swap_protected(wcid->aggr[tidno], tid,
> > + lockdep_is_held(&dev->mutex));
>
> I suppose you meant: rcu_replace_pointer() here.

Indeed I did, and thank you for catching this! Bad patch day here. :-/

Update below...

Thanx, Paul

------------------------------------------------------------------------

commit ad5572b091429a45e863acaa6a36cf396d44f58d
Author: Paul E. McKenney <paulmck@xxxxxxxxxx>
Date: Wed Dec 11 10:30:21 2019 -0800

wireless/mediatek: Replace rcu_swap_protected() with rcu_replace_pointer()

This commit replaces the use of rcu_swap_protected() with the more
intuitively appealing rcu_replace_pointer() as a step towards removing
rcu_swap_protected().

Link: https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@xxxxxxxxxxxxxx/
Reported-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
Reported-by: "Martin K. Petersen" <martin.petersen@xxxxxxxxxx>
[ paulmck: Apply Matthias Brugger feedback. ]
Signed-off-by: Paul E. McKenney <paulmck@xxxxxxxxxx>
Reviewed-by: "Martin K. Petersen" <martin.petersen@xxxxxxxxxx>
Cc: Felix Fietkau <nbd@xxxxxxxx>
Cc: Lorenzo Bianconi <lorenzo.bianconi83@xxxxxxxxx>
Cc: Ryder Lee <ryder.lee@xxxxxxxxxxxx>
Cc: Roy Luo <royluo@xxxxxxxxxx>
Cc: Kalle Valo <kvalo@xxxxxxxxxxxxxx>
Cc: "David S. Miller" <davem@xxxxxxxxxxxxx>
Cc: Matthias Brugger <matthias.bgg@xxxxxxxxx>
Cc: <linux-wireless@xxxxxxxxxxxxxxx>
Cc: <netdev@xxxxxxxxxxxxxxx>
Cc: <linux-arm-kernel@xxxxxxxxxxxxxxxxxxx>
Cc: <linux-mediatek@xxxxxxxxxxxxxxxxxxx>

diff --git a/drivers/net/wireless/mediatek/mt76/agg-rx.c b/drivers/net/wireless/mediatek/mt76/agg-rx.c
index 53b5a4b..59c1878 100644
--- a/drivers/net/wireless/mediatek/mt76/agg-rx.c
+++ b/drivers/net/wireless/mediatek/mt76/agg-rx.c
@@ -281,8 +281,8 @@ void mt76_rx_aggr_stop(struct mt76_dev *dev, struct mt76_wcid *wcid, u8 tidno)
{
struct mt76_rx_tid *tid = NULL;

- rcu_swap_protected(wcid->aggr[tidno], tid,
- lockdep_is_held(&dev->mutex));
+ tid = rcu_replace_pointer(wcid->aggr[tidno], tid,
+ lockdep_is_held(&dev->mutex));
if (tid) {
mt76_rx_aggr_shutdown(dev, tid);
kfree_rcu(tid, rcu_head);