[tip/core/rcu,01/12] rcu: Remove rcu_swap_protected()
diff mbox series

Message ID 20191210040741.2943-1-paulmck@kernel.org
State New
Headers show
Series
  • Miscellaneous fixes for v5.6
Related show

Commit Message

Paul E. McKenney Dec. 10, 2019, 4:07 a.m. UTC
From: "Paul E. McKenney" <paulmck@kernel.org>

Now that the calls to rcu_swap_protected() have been replaced by
rcu_replace_pointer(), this commit removes rcu_swap_protected().

Link: https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/
Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Cc: Bart Van Assche <bart.vanassche@wdc.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Cc: Shane M Seymour <shane.seymour@hpe.com>
Cc: Martin K. Petersen <martin.petersen@oracle.com>
---
 include/linux/rcupdate.h | 16 ----------------
 1 file changed, 16 deletions(-)

Comments

Martin K. Petersen Dec. 11, 2019, 3:35 a.m. UTC | #1
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.

Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Paul E. McKenney Dec. 11, 2019, 3:51 a.m. UTC | #2
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@oracle.com>

Thank you!

							Thanx, Paul
Paul E. McKenney Dec. 11, 2019, 6:37 p.m. UTC | #3
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@oracle.com>
> 
> Thank you!

And here is the patch for the new one.

							Thanx, Paul

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

commit 10699d92c906707d679e28b099cd798a519b4f51
Author: Paul E. McKenney <paulmck@kernel.org>
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@mail.gmail.com/
    Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
    Reported-by: "Martin K. Petersen" <martin.petersen@oracle.com>
    Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
    Cc: Felix Fietkau <nbd@nbd.name>
    Cc: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
    Cc: Ryder Lee <ryder.lee@mediatek.com>
    Cc: Roy Luo <royluo@google.com>
    Cc: Kalle Valo <kvalo@codeaurora.org>
    Cc: "David S. Miller" <davem@davemloft.net>
    Cc: Matthias Brugger <matthias.bgg@gmail.com>
    Cc: <linux-wireless@vger.kernel.org>
    Cc: <netdev@vger.kernel.org>
    Cc: <linux-arm-kernel@lists.infradead.org>
    Cc: <linux-mediatek@lists.infradead.org>

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));
 	if (tid) {
 		mt76_rx_aggr_shutdown(dev, tid);
 		kfree_rcu(tid, rcu_head);
Matthias Brugger Dec. 11, 2019, 7:09 p.m. UTC | #4
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@oracle.com>
>>
>> Thank you!
> 
> And here is the patch for the new one.
> 
> 							Thanx, Paul
> 
> ------------------------------------------------------------------------
> 
> commit 10699d92c906707d679e28b099cd798a519b4f51
> Author: Paul E. McKenney <paulmck@kernel.org>
> 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@mail.gmail.com/
>     Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
>     Reported-by: "Martin K. Petersen" <martin.petersen@oracle.com>
>     Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
>     Cc: Felix Fietkau <nbd@nbd.name>
>     Cc: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
>     Cc: Ryder Lee <ryder.lee@mediatek.com>
>     Cc: Roy Luo <royluo@google.com>
>     Cc: Kalle Valo <kvalo@codeaurora.org>
>     Cc: "David S. Miller" <davem@davemloft.net>
>     Cc: Matthias Brugger <matthias.bgg@gmail.com>
>     Cc: <linux-wireless@vger.kernel.org>
>     Cc: <netdev@vger.kernel.org>
>     Cc: <linux-arm-kernel@lists.infradead.org>
>     Cc: <linux-mediatek@lists.infradead.org>
> 
> 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.

Regards,
Matthias

>  	if (tid) {
>  		mt76_rx_aggr_shutdown(dev, tid);
>  		kfree_rcu(tid, rcu_head);
>
Paul E. McKenney Dec. 11, 2019, 11:12 p.m. UTC | #5
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@oracle.com>
> >>
> >> Thank you!
> > 
> > And here is the patch for the new one.
> > 
> > 							Thanx, Paul
> > 
> > ------------------------------------------------------------------------
> > 
> > commit 10699d92c906707d679e28b099cd798a519b4f51
> > Author: Paul E. McKenney <paulmck@kernel.org>
> > 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@mail.gmail.com/
> >     Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
> >     Reported-by: "Martin K. Petersen" <martin.petersen@oracle.com>
> >     Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
> >     Cc: Felix Fietkau <nbd@nbd.name>
> >     Cc: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
> >     Cc: Ryder Lee <ryder.lee@mediatek.com>
> >     Cc: Roy Luo <royluo@google.com>
> >     Cc: Kalle Valo <kvalo@codeaurora.org>
> >     Cc: "David S. Miller" <davem@davemloft.net>
> >     Cc: Matthias Brugger <matthias.bgg@gmail.com>
> >     Cc: <linux-wireless@vger.kernel.org>
> >     Cc: <netdev@vger.kernel.org>
> >     Cc: <linux-arm-kernel@lists.infradead.org>
> >     Cc: <linux-mediatek@lists.infradead.org>
> > 
> > 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@kernel.org>
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@mail.gmail.com/
    Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
    Reported-by: "Martin K. Petersen" <martin.petersen@oracle.com>
    [ paulmck: Apply Matthias Brugger feedback. ]
    Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
    Reviewed-by: "Martin K. Petersen" <martin.petersen@oracle.com>
    Cc: Felix Fietkau <nbd@nbd.name>
    Cc: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
    Cc: Ryder Lee <ryder.lee@mediatek.com>
    Cc: Roy Luo <royluo@google.com>
    Cc: Kalle Valo <kvalo@codeaurora.org>
    Cc: "David S. Miller" <davem@davemloft.net>
    Cc: Matthias Brugger <matthias.bgg@gmail.com>
    Cc: <linux-wireless@vger.kernel.org>
    Cc: <netdev@vger.kernel.org>
    Cc: <linux-arm-kernel@lists.infradead.org>
    Cc: <linux-mediatek@lists.infradead.org>

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);
Kalle Valo Dec. 12, 2019, 9:31 a.m. UTC | #6
+ linux-wireless

"Paul E. McKenney" <paulmck@kernel.org> writes:

> On Wed, Dec 11, 2019 at 08:09:11PM +0100, Matthias Brugger wrote:
>> On 11/12/2019 19:37, Paul E. McKenney wrote:
>>
>> > --- 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@kernel.org>
> 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@mail.gmail.com/
>     Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
>     Reported-by: "Martin K. Petersen" <martin.petersen@oracle.com>
>     [ paulmck: Apply Matthias Brugger feedback. ]
>     Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
>     Reviewed-by: "Martin K. Petersen" <martin.petersen@oracle.com>
>     Cc: Felix Fietkau <nbd@nbd.name>
>     Cc: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
>     Cc: Ryder Lee <ryder.lee@mediatek.com>
>     Cc: Roy Luo <royluo@google.com>
>     Cc: Kalle Valo <kvalo@codeaurora.org>
>     Cc: "David S. Miller" <davem@davemloft.net>
>     Cc: Matthias Brugger <matthias.bgg@gmail.com>
>     Cc: <linux-wireless@vger.kernel.org>
>     Cc: <netdev@vger.kernel.org>
>     Cc: <linux-arm-kernel@lists.infradead.org>
>     Cc: <linux-mediatek@lists.infradead.org>

Via which tree is this supposed to go? If I should take this please
resend to linux-wireless so that patchwork sees it, but if someone else
is planning to take this:

Acked-by: Kalle Valo <kvalo@codeaurora.org>
Paul E. McKenney Dec. 12, 2019, 6:21 p.m. UTC | #7
On Thu, Dec 12, 2019 at 11:31:37AM +0200, Kalle Valo wrote:
> + linux-wireless
> 
> "Paul E. McKenney" <paulmck@kernel.org> writes:
> 
> > On Wed, Dec 11, 2019 at 08:09:11PM +0100, Matthias Brugger wrote:
> >> On 11/12/2019 19:37, Paul E. McKenney wrote:
> >>
> >> > --- 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@kernel.org>
> > 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@mail.gmail.com/
> >     Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
> >     Reported-by: "Martin K. Petersen" <martin.petersen@oracle.com>
> >     [ paulmck: Apply Matthias Brugger feedback. ]
> >     Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
> >     Reviewed-by: "Martin K. Petersen" <martin.petersen@oracle.com>
> >     Cc: Felix Fietkau <nbd@nbd.name>
> >     Cc: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
> >     Cc: Ryder Lee <ryder.lee@mediatek.com>
> >     Cc: Roy Luo <royluo@google.com>
> >     Cc: Kalle Valo <kvalo@codeaurora.org>
> >     Cc: "David S. Miller" <davem@davemloft.net>
> >     Cc: Matthias Brugger <matthias.bgg@gmail.com>
> >     Cc: <linux-wireless@vger.kernel.org>
> >     Cc: <netdev@vger.kernel.org>
> >     Cc: <linux-arm-kernel@lists.infradead.org>
> >     Cc: <linux-mediatek@lists.infradead.org>
> 
> Via which tree is this supposed to go? If I should take this please
> resend to linux-wireless so that patchwork sees it, but if someone else
> is planning to take this:
> 
> Acked-by: Kalle Valo <kvalo@codeaurora.org>

I have queued it just preceding the commit that remove rcu_swap_protected()
with your ack, thank you!

							Thanx, Paul

Patch
diff mbox series

diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index 0b75063..fe47024 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -401,22 +401,6 @@  do {									      \
 })
 
 /**
- * rcu_swap_protected() - swap an RCU and a regular pointer
- * @rcu_ptr: RCU pointer
- * @ptr: regular pointer
- * @c: the conditions under which the dereference will take place
- *
- * Perform swap(@rcu_ptr, @ptr) where @rcu_ptr is an RCU-annotated pointer and
- * @c is the argument that is passed to the rcu_dereference_protected() call
- * used to read that pointer.
- */
-#define rcu_swap_protected(rcu_ptr, ptr, c) do {			\
-	typeof(ptr) __tmp = rcu_dereference_protected((rcu_ptr), (c));	\
-	rcu_assign_pointer((rcu_ptr), (ptr));				\
-	(ptr) = __tmp;							\
-} while (0)
-
-/**
  * rcu_access_pointer() - fetch RCU pointer with no dereferencing
  * @p: The pointer to read
  *