linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] block: insert a general SMP memory barrier before wake_up_bit()
       [not found] <20200813024438.13170-1-jian.w.wen@oracle.com>
@ 2020-08-13  7:31 ` Christoph Hellwig
  2020-08-13  7:46   ` Jacob Wen
  2020-08-13 11:40   ` peterz
  0 siblings, 2 replies; 4+ messages in thread
From: Christoph Hellwig @ 2020-08-13  7:31 UTC (permalink / raw)
  To: Jacob Wen; +Cc: linux-fsdevel, linux-kernel, Peter Zijlstra

On Thu, Aug 13, 2020 at 10:44:38AM +0800, Jacob Wen wrote:
> wake_up_bit() uses waitqueue_active() that needs the explicit smp_mb().

Sounds like the barrier should go into wake_up_bit then..

> 
> Signed-off-by: Jacob Wen <jian.w.wen@oracle.com>
> ---
>  fs/block_dev.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/fs/block_dev.c b/fs/block_dev.c
> index 0ae656e022fd..e74980848a2a 100644
> --- a/fs/block_dev.c
> +++ b/fs/block_dev.c
> @@ -1175,6 +1175,7 @@ static void bd_clear_claiming(struct block_device *whole, void *holder)
>  	/* tell others that we're done */
>  	BUG_ON(whole->bd_claiming != holder);
>  	whole->bd_claiming = NULL;
> +	smp_mb();
>  	wake_up_bit(&whole->bd_claiming, 0);
>  }
>  
> -- 
> 2.17.1
> 
---end quoted text---

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] block: insert a general SMP memory barrier before wake_up_bit()
  2020-08-13  7:31 ` [PATCH] block: insert a general SMP memory barrier before wake_up_bit() Christoph Hellwig
@ 2020-08-13  7:46   ` Jacob Wen
  2020-08-13 11:40   ` peterz
  1 sibling, 0 replies; 4+ messages in thread
From: Jacob Wen @ 2020-08-13  7:46 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-fsdevel, linux-kernel, Peter Zijlstra


On 8/13/20 3:31 PM, Christoph Hellwig wrote:
> On Thu, Aug 13, 2020 at 10:44:38AM +0800, Jacob Wen wrote:
>> wake_up_bit() uses waitqueue_active() that needs the explicit smp_mb().
> Sounds like the barrier should go into wake_up_bit then..

wake_up_bit() doesn't know which one to chose: smp_mb__after_atomic() or 
smp_mb().

>
>> Signed-off-by: Jacob Wen <jian.w.wen@oracle.com>
>> ---
>>   fs/block_dev.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/fs/block_dev.c b/fs/block_dev.c
>> index 0ae656e022fd..e74980848a2a 100644
>> --- a/fs/block_dev.c
>> +++ b/fs/block_dev.c
>> @@ -1175,6 +1175,7 @@ static void bd_clear_claiming(struct block_device *whole, void *holder)
>>   	/* tell others that we're done */
>>   	BUG_ON(whole->bd_claiming != holder);
>>   	whole->bd_claiming = NULL;
>> +	smp_mb();
>>   	wake_up_bit(&whole->bd_claiming, 0);
>>   }
>>   
>> -- 
>> 2.17.1
>>
> ---end quoted text---

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] block: insert a general SMP memory barrier before wake_up_bit()
  2020-08-13  7:31 ` [PATCH] block: insert a general SMP memory barrier before wake_up_bit() Christoph Hellwig
  2020-08-13  7:46   ` Jacob Wen
@ 2020-08-13 11:40   ` peterz
  2020-08-13 12:00     ` Matthew Wilcox
  1 sibling, 1 reply; 4+ messages in thread
From: peterz @ 2020-08-13 11:40 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Jacob Wen, linux-fsdevel, linux-kernel

On Thu, Aug 13, 2020 at 08:31:15AM +0100, Christoph Hellwig wrote:
> On Thu, Aug 13, 2020 at 10:44:38AM +0800, Jacob Wen wrote:
> > wake_up_bit() uses waitqueue_active() that needs the explicit smp_mb().
> 
> Sounds like the barrier should go into wake_up_bit then..

Oh, thanks for reminding me..

https://lkml.kernel.org/r/20190624165012.GH3436@hirez.programming.kicks-ass.net

I'll try and get back to that.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] block: insert a general SMP memory barrier before wake_up_bit()
  2020-08-13 11:40   ` peterz
@ 2020-08-13 12:00     ` Matthew Wilcox
  0 siblings, 0 replies; 4+ messages in thread
From: Matthew Wilcox @ 2020-08-13 12:00 UTC (permalink / raw)
  To: peterz; +Cc: Christoph Hellwig, Jacob Wen, linux-fsdevel, linux-kernel

On Thu, Aug 13, 2020 at 01:40:50PM +0200, peterz@infradead.org wrote:
> On Thu, Aug 13, 2020 at 08:31:15AM +0100, Christoph Hellwig wrote:
> > On Thu, Aug 13, 2020 at 10:44:38AM +0800, Jacob Wen wrote:
> > > wake_up_bit() uses waitqueue_active() that needs the explicit smp_mb().
> > 
> > Sounds like the barrier should go into wake_up_bit then..
> 
> Oh, thanks for reminding me..
> 
> https://lkml.kernel.org/r/20190624165012.GH3436@hirez.programming.kicks-ass.net
> 
> I'll try and get back to that.

+++ b/drivers/bluetooth/btmtkuart.c
@@ -340,11 +340,8 @@ static int btmtkuart_recv_event(struct hci_dev *hdev, struct sk_buff *skb)
 
 	if (hdr->evt == HCI_EV_VENDOR) {
 		if (test_and_clear_bit(BTMTKUART_TX_WAIT_VND_EVT,
-				       &bdev->tx_state)) {
-			/* Barrier to sync with other CPUs */
-			smp_mb__after_atomic();
+				       &bdev->tx_state))
 			wake_up_bit(&bdev->tx_state, BTMTKUART_TX_WAIT_VND_EVT);
-		}
 	}
 
 	return 0;

It'd be nice to be able to write:

	if (hdr->evt == HCI_EV_VENDOR)
		test_clear_and_wake_up_bit(&bdev->tx_state,
						BTMTKUART_TX_WAIT_VND_EVT);

... maybe with a better name.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-08-13 12:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20200813024438.13170-1-jian.w.wen@oracle.com>
2020-08-13  7:31 ` [PATCH] block: insert a general SMP memory barrier before wake_up_bit() Christoph Hellwig
2020-08-13  7:46   ` Jacob Wen
2020-08-13 11:40   ` peterz
2020-08-13 12:00     ` Matthew Wilcox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).