* [PATCH] md: optimize barrier usage for Rmw atomic bitops
@ 2020-01-29 18:14 Davidlohr Bueso
2020-01-31 16:43 ` Guoqing Jiang
0 siblings, 1 reply; 3+ messages in thread
From: Davidlohr Bueso @ 2020-01-29 18:14 UTC (permalink / raw)
To: song; +Cc: linux-raid, linux-kernel, dave, Davidlohr Bueso
For both set and clear_bit, we can avoid the unnecessary barrier
on non LL/SC architectures, such as x86. Instead, use the
smp_mb__{before,after}_atomic() calls.
Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
---
drivers/md/md.c | 2 +-
drivers/md/raid10.c | 7 ++++---
drivers/md/raid5.c | 9 +++++----
3 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 4824d50526fa..4ed2eb6933f7 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -2561,7 +2561,7 @@ static bool set_in_sync(struct mddev *mddev)
* Ensure ->in_sync is visible before we clear
* ->sync_checkers.
*/
- smp_mb();
+ smp_mb__before_atomic();
set_bit(MD_SB_CHANGE_CLEAN, &mddev->sb_flags);
sysfs_notify_dirent_safe(mddev->sysfs_state);
}
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index ec136e44aef7..1993a1958c75 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -1865,9 +1865,10 @@ static int raid10_remove_disk(struct mddev *mddev, struct md_rdev *rdev)
/* We must have just cleared 'rdev' */
p->rdev = p->replacement;
clear_bit(Replacement, &p->replacement->flags);
- smp_mb(); /* Make sure other CPUs may see both as identical
- * but will never see neither -- if they are careful.
- */
+ /* Make sure other CPUs may see both as identical
+ * but will never see neither -- if they are careful.
+ */
+ smp_mb__after_atomic();
p->replacement = NULL;
}
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index ba00e9877f02..3ad6209287cf 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -364,7 +364,7 @@ static int release_stripe_list(struct r5conf *conf,
int hash;
/* sh could be readded after STRIPE_ON_RELEASE_LIST is cleard */
- smp_mb();
+ smp_mb__before_atomic();
clear_bit(STRIPE_ON_RELEASE_LIST, &sh->state);
/*
* Don't worry the bit is set here, because if the bit is set
@@ -7654,9 +7654,10 @@ static int raid5_remove_disk(struct mddev *mddev, struct md_rdev *rdev)
/* We must have just cleared 'rdev' */
p->rdev = p->replacement;
clear_bit(Replacement, &p->replacement->flags);
- smp_mb(); /* Make sure other CPUs may see both as identical
- * but will never see neither - if they are careful
- */
+ /* Make sure other CPUs may see both as identical
+ * but will never see neither - if they are careful
+ */
+ smp_mb__after_atomic();
p->replacement = NULL;
if (!err)
--
2.16.4
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] md: optimize barrier usage for Rmw atomic bitops
2020-01-29 18:14 [PATCH] md: optimize barrier usage for Rmw atomic bitops Davidlohr Bueso
@ 2020-01-31 16:43 ` Guoqing Jiang
2020-02-04 0:25 ` Song Liu
0 siblings, 1 reply; 3+ messages in thread
From: Guoqing Jiang @ 2020-01-31 16:43 UTC (permalink / raw)
To: Davidlohr Bueso, song; +Cc: linux-raid, linux-kernel, Davidlohr Bueso
On 1/29/20 7:14 PM, Davidlohr Bueso wrote:
> For both set and clear_bit, we can avoid the unnecessary barrier
> on non LL/SC architectures, such as x86. Instead, use the
> smp_mb__{before,after}_atomic() calls.
>
> Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
> ---
> drivers/md/md.c | 2 +-
> drivers/md/raid10.c | 7 ++++---
> drivers/md/raid5.c | 9 +++++----
> 3 files changed, 10 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index 4824d50526fa..4ed2eb6933f7 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -2561,7 +2561,7 @@ static bool set_in_sync(struct mddev *mddev)
> * Ensure ->in_sync is visible before we clear
> * ->sync_checkers.
> */
> - smp_mb();
> + smp_mb__before_atomic();
> set_bit(MD_SB_CHANGE_CLEAN, &mddev->sb_flags);
> sysfs_notify_dirent_safe(mddev->sysfs_state);
> }
> diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
> index ec136e44aef7..1993a1958c75 100644
> --- a/drivers/md/raid10.c
> +++ b/drivers/md/raid10.c
> @@ -1865,9 +1865,10 @@ static int raid10_remove_disk(struct mddev *mddev, struct md_rdev *rdev)
> /* We must have just cleared 'rdev' */
> p->rdev = p->replacement;
> clear_bit(Replacement, &p->replacement->flags);
> - smp_mb(); /* Make sure other CPUs may see both as identical
> - * but will never see neither -- if they are careful.
> - */
> + /* Make sure other CPUs may see both as identical
> + * but will never see neither -- if they are careful.
> + */
Since we are here, it is better to change the comment style to
/*
* ...
*/
> + smp_mb__after_atomic();
> p->replacement = NULL;
> }
>
> diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
> index ba00e9877f02..3ad6209287cf 100644
> --- a/drivers/md/raid5.c
> +++ b/drivers/md/raid5.c
> @@ -364,7 +364,7 @@ static int release_stripe_list(struct r5conf *conf,
> int hash;
>
> /* sh could be readded after STRIPE_ON_RELEASE_LIST is cleard */
> - smp_mb();
> + smp_mb__before_atomic();
> clear_bit(STRIPE_ON_RELEASE_LIST, &sh->state);
> /*
> * Don't worry the bit is set here, because if the bit is set
> @@ -7654,9 +7654,10 @@ static int raid5_remove_disk(struct mddev *mddev, struct md_rdev *rdev)
> /* We must have just cleared 'rdev' */
> p->rdev = p->replacement;
> clear_bit(Replacement, &p->replacement->flags);
> - smp_mb(); /* Make sure other CPUs may see both as identical
> - * but will never see neither - if they are careful
> - */
Ditto.
Acked-by: Guoqing Jiang <guoqing.jiang@cloud.ionos.com>
Thanks,
Guoqing
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] md: optimize barrier usage for Rmw atomic bitops
2020-01-31 16:43 ` Guoqing Jiang
@ 2020-02-04 0:25 ` Song Liu
0 siblings, 0 replies; 3+ messages in thread
From: Song Liu @ 2020-02-04 0:25 UTC (permalink / raw)
To: Guoqing Jiang; +Cc: Davidlohr Bueso, linux-raid, open list, Davidlohr Bueso
On Fri, Jan 31, 2020 at 8:43 AM Guoqing Jiang
<guoqing.jiang@cloud.ionos.com> wrote:
>
>
>
> On 1/29/20 7:14 PM, Davidlohr Bueso wrote:
> > For both set and clear_bit, we can avoid the unnecessary barrier
> > on non LL/SC architectures, such as x86. Instead, use the
> > smp_mb__{before,after}_atomic() calls.
> >
> > Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
./scripts/checkpatch.pl reports the following:
=============== 8< =================
WARNING: memory barrier without comment
#81: FILE: drivers/md/md.c:2564:
+ smp_mb__before_atomic();
WARNING: memory barrier without comment
#112: FILE: drivers/md/raid5.c:367:
+ smp_mb__before_atomic();
WARNING: Missing Signed-off-by: line by nominal patch author
'Davidlohr Bueso <dave@stgolabs.net>'
total: 0 errors, 3 warnings, 42 lines checked
=============== 8< =================
Since we are on it, let's add comments for the barriers. Also, please
double check the email
is correct.
Thanks,
Song
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-02-04 0:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-29 18:14 [PATCH] md: optimize barrier usage for Rmw atomic bitops Davidlohr Bueso
2020-01-31 16:43 ` Guoqing Jiang
2020-02-04 0:25 ` Song Liu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®