* [PATCH] bcache: optimize barrier usage for Rmw atomic bitops
@ 2020-01-29 18:08 Davidlohr Bueso
2020-03-20 15:24 ` Coly Li
0 siblings, 1 reply; 2+ messages in thread
From: Davidlohr Bueso @ 2020-01-29 18:08 UTC (permalink / raw)
To: colyli, kent.overstreet; +Cc: linux-bcache, linux-kernel, dave, Davidlohr Bueso
We can avoid the unnecessary barrier on non LL/SC architectures,
such as x86. Instead, use the smp_mb__after_atomic().
Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
---
drivers/md/bcache/writeback.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/md/bcache/writeback.c b/drivers/md/bcache/writeback.c
index 4a40f9eadeaf..284ff10f480f 100644
--- a/drivers/md/bcache/writeback.c
+++ b/drivers/md/bcache/writeback.c
@@ -183,7 +183,7 @@ static void update_writeback_rate(struct work_struct *work)
*/
set_bit(BCACHE_DEV_RATE_DW_RUNNING, &dc->disk.flags);
/* paired with where BCACHE_DEV_RATE_DW_RUNNING is tested */
- smp_mb();
+ smp_mb__after_atomic();
/*
* CACHE_SET_IO_DISABLE might be set via sysfs interface,
@@ -193,7 +193,7 @@ static void update_writeback_rate(struct work_struct *work)
test_bit(CACHE_SET_IO_DISABLE, &c->flags)) {
clear_bit(BCACHE_DEV_RATE_DW_RUNNING, &dc->disk.flags);
/* paired with where BCACHE_DEV_RATE_DW_RUNNING is tested */
- smp_mb();
+ smp_mb__after_atomic();
return;
}
@@ -229,7 +229,7 @@ static void update_writeback_rate(struct work_struct *work)
*/
clear_bit(BCACHE_DEV_RATE_DW_RUNNING, &dc->disk.flags);
/* paired with where BCACHE_DEV_RATE_DW_RUNNING is tested */
- smp_mb();
+ smp_mb__after_atomic();
}
static unsigned int writeback_delay(struct cached_dev *dc,
--
2.16.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] bcache: optimize barrier usage for Rmw atomic bitops
2020-01-29 18:08 [PATCH] bcache: optimize barrier usage for Rmw atomic bitops Davidlohr Bueso
@ 2020-03-20 15:24 ` Coly Li
0 siblings, 0 replies; 2+ messages in thread
From: Coly Li @ 2020-03-20 15:24 UTC (permalink / raw)
To: Davidlohr Bueso, kent.overstreet
Cc: linux-bcache, linux-kernel, Davidlohr Bueso
On 2020/1/30 2:08 上午, Davidlohr Bueso wrote:
> We can avoid the unnecessary barrier on non LL/SC architectures,
> such as x86. Instead, use the smp_mb__after_atomic().
>
Hi Davidlohr,
> Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
Sorry for replying late. Indeed we don't need to worry about the extra
smp_mb() because the code patch gets called every 5 seconds by default,
which is very infrequent. But I like this more accurate patch, it is in
my testing already.
And by your inspiration, I also fix some other locations to use
smp_mb__before/after_atomic().
Thank you.
Coly Li
> ---
> drivers/md/bcache/writeback.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/md/bcache/writeback.c b/drivers/md/bcache/writeback.c
> index 4a40f9eadeaf..284ff10f480f 100644
> --- a/drivers/md/bcache/writeback.c
> +++ b/drivers/md/bcache/writeback.c
> @@ -183,7 +183,7 @@ static void update_writeback_rate(struct work_struct *work)
> */
> set_bit(BCACHE_DEV_RATE_DW_RUNNING, &dc->disk.flags);
> /* paired with where BCACHE_DEV_RATE_DW_RUNNING is tested */
> - smp_mb();
> + smp_mb__after_atomic();
>
> /*
> * CACHE_SET_IO_DISABLE might be set via sysfs interface,
> @@ -193,7 +193,7 @@ static void update_writeback_rate(struct work_struct *work)
> test_bit(CACHE_SET_IO_DISABLE, &c->flags)) {
> clear_bit(BCACHE_DEV_RATE_DW_RUNNING, &dc->disk.flags);
> /* paired with where BCACHE_DEV_RATE_DW_RUNNING is tested */
> - smp_mb();
> + smp_mb__after_atomic();
> return;
> }
>
> @@ -229,7 +229,7 @@ static void update_writeback_rate(struct work_struct *work)
> */
> clear_bit(BCACHE_DEV_RATE_DW_RUNNING, &dc->disk.flags);
> /* paired with where BCACHE_DEV_RATE_DW_RUNNING is tested */
> - smp_mb();
> + smp_mb__after_atomic();
> }
>
> static unsigned int writeback_delay(struct cached_dev *dc,
>
--
Coly Li
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-03-20 15:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-29 18:08 [PATCH] bcache: optimize barrier usage for Rmw atomic bitops Davidlohr Bueso
2020-03-20 15:24 ` Coly Li
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.