Skip to contentSkip to conversation

dax: use assign_bit() where applicable

PATCH NAK Peng Fan (OSS) 5 participants 7 messages Sep 19 – Oct 8

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dax: use assign_bit() where applicable

From: Peng Fan <[email protected]>

Convert open-coded if/else with set_bit/clear_bit to the assign_bit API.

---
 drivers/dax/super.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/dax/super.c +1 -4
index 45f84b0eb909..60c4aec52ae1 100644
@@ -385,10 +385,7 @@ EXPORT_SYMBOL_GPL(dax_flush);
 
 void dax_write_cache(struct dax_device *dax_dev, bool wc)
 {
-	if (wc)
-		set_bit(DAXDEV_WRITE_CACHE, &dax_dev->flags);
-	else
-		clear_bit(DAXDEV_WRITE_CACHE, &dax_dev->flags);
+	assign_bit(DAXDEV_WRITE_CACHE, &dax_dev->flags, wc);
 }
 EXPORT_SYMBOL_GPL(dax_write_cache);
 
Signature · 1 line
2.51.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines

[You don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]

From: Peng Fan <[email protected]>

Convert open-coded if/else with set_bit/clear_bit to the assign_bit API.

Quoted 24 lines
---
  drivers/dax/super.c | 5 +----
  1 file changed, 1 insertion(+), 4 deletions(-)
drivers/dax/super.c +1 -5
index 45f84b0eb909..60c4aec52ae1 100644
@@ -385,10 +385,7 @@ EXPORT_SYMBOL_GPL(dax_flush);
 
  void dax_write_cache(struct dax_device *dax_dev, bool wc)
  {
-       if (wc)
-               set_bit(DAXDEV_WRITE_CACHE, &dax_dev->flags);
-       else
-               clear_bit(DAXDEV_WRITE_CACHE, &dax_dev->flags);
+       assign_bit(DAXDEV_WRITE_CACHE, &dax_dev->flags, wc);
  }
  EXPORT_SYMBOL_GPL(dax_write_cache);
 
--

2.51.0

Reviewed-by
#2 lore raw
Quoted 9 lines · Pankaj
Quoted 7 lines

[You don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]

From: Peng Fan <[email protected]>

Convert open-coded if/else with set_bit/clear_bit to the assign_bit API.

A bit marginal wrt to churn but a good change in general. Up to DAX maintainers on whether they want this type of small focused improvement.

Quoted 26 lines
Quoted 25 lines
---
  drivers/dax/super.c | 5 +----
  1 file changed, 1 insertion(+), 4 deletions(-)
drivers/dax/super.c +1 -5
index 45f84b0eb909..60c4aec52ae1 100644
@@ -385,10 +385,7 @@ EXPORT_SYMBOL_GPL(dax_flush);
 
  void dax_write_cache(struct dax_device *dax_dev, bool wc)
  {
-       if (wc)
-               set_bit(DAXDEV_WRITE_CACHE, &dax_dev->flags);
-       else
-               clear_bit(DAXDEV_WRITE_CACHE, &dax_dev->flags);
+       assign_bit(DAXDEV_WRITE_CACHE, &dax_dev->flags, wc);
  }
  EXPORT_SYMBOL_GPL(dax_write_cache);
 
--

2.51.0

maintainer
#3 lore raw
Quoted 9 lines · Jonathan Cameron
Quoted 6 lines · Pankaj
Quoted 6 lines

[You don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]

From: Peng Fan <[email protected]>

Convert open-coded if/else with set_bit/clear_bit to the assign_bit API.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

A bit marginal wrt to churn but a good change in general. Up to DAX maintainers on whether they want this type of small focused improvement.

I didn't see the improvement. When I peruse the file I see set_bit and clear_bit, and now I see a couple of those obfuscated by a new assign_bit, needlessly.

If Peng wants to come back around with a 'why' then I'd take another look. I shared my NAK story here:

https://lore.kernel.org/lkml/[email protected]/

Quoted 30 lines
Quoted 26 lines
Quoted 25 lines
---
  drivers/dax/super.c | 5 +----
  1 file changed, 1 insertion(+), 4 deletions(-)
drivers/dax/super.c +1 -5
index 45f84b0eb909..60c4aec52ae1 100644
@@ -385,10 +385,7 @@ EXPORT_SYMBOL_GPL(dax_flush);
 
  void dax_write_cache(struct dax_device *dax_dev, bool wc)
  {
-       if (wc)
-               set_bit(DAXDEV_WRITE_CACHE, &dax_dev->flags);
-       else
-               clear_bit(DAXDEV_WRITE_CACHE, &dax_dev->flags);
+       assign_bit(DAXDEV_WRITE_CACHE, &dax_dev->flags, wc);
  }
  EXPORT_SYMBOL_GPL(dax_write_cache);
 
--

2.51.0

author
#4 lore raw

Hi Alison,

Quoted 18 lines · Alison Schofield
Quoted 9 lines · Jonathan Cameron
Quoted 6 lines · Pankaj
Quoted 6 lines

[You don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]

From: Peng Fan <[email protected]>

Convert open-coded if/else with set_bit/clear_bit to the assign_bit API.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

A bit marginal wrt to churn but a good change in general. Up to DAX maintainers on whether they want this type of small focused improvement.

Quoted 8 lines

I didn't see the improvement. When I peruse the file I see set_bit and clear_bit, and now I see a couple of those obfuscated by a new assign_bit, needlessly.

If Peng wants to come back around with a 'why' then I'd take another look. I shared my NAK story here:

https://lore.kernel.org/lkml/[email protected]/

Thanks for taking the time to explain, and for the link to your earlier reply - that was useful context.

This patch was done by a cocci rule.
sorry for not providing a justification for this particular conversion or making the intent clearer. Converting only some of the call sites leaves the file with a mix of styles.

Free to drop the patch.

Thanks
Peng

Quoted 33 lines
Quoted 32 lines
Quoted 26 lines
Quoted 25 lines
---
  drivers/dax/super.c | 5 +----
  1 file changed, 1 insertion(+), 4 deletions(-)
drivers/dax/super.c +1 -5
index 45f84b0eb909..60c4aec52ae1 100644
@@ -385,10 +385,7 @@ EXPORT_SYMBOL_GPL(dax_flush);
 
  void dax_write_cache(struct dax_device *dax_dev, bool wc)
  {
-       if (wc)
-               set_bit(DAXDEV_WRITE_CACHE, &dax_dev->flags);
-       else
-               clear_bit(DAXDEV_WRITE_CACHE, &dax_dev->flags);
+       assign_bit(DAXDEV_WRITE_CACHE, &dax_dev->flags, wc);
  }
  EXPORT_SYMBOL_GPL(dax_write_cache);
 
--

2.51.0

maintainer Reviewed-by on v1 1/1
#5 lore raw
In reply to Peng Fan (OSS)
Quoted 5 lines · Peng Fan (OSS)

From: Peng Fan <[email protected]>

Convert open-coded if/else with set_bit/clear_bit to the assign_bit API.

Quoted 20 lines
---
 drivers/dax/super.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/dax/super.c +1 -4
index 45f84b0eb909..60c4aec52ae1 100644
@@ -385,10 +385,7 @@ EXPORT_SYMBOL_GPL(dax_flush);
 
 void dax_write_cache(struct dax_device *dax_dev, bool wc)
 {
-	if (wc)
-		set_bit(DAXDEV_WRITE_CACHE, &dax_dev->flags);
-	else
-		clear_bit(DAXDEV_WRITE_CACHE, &dax_dev->flags);
+	assign_bit(DAXDEV_WRITE_CACHE, &dax_dev->flags, wc);
 }
 EXPORT_SYMBOL_GPL(dax_write_cache);
 
maintainer NAK
#6 lore raw
In reply to Peng Fan (OSS)
Quoted 3 lines · Peng Fan (OSS)

From: Peng Fan <[email protected]>

Convert open-coded if/else with set_bit/clear_bit to the assign_bit API.

NAK

See also:
https://lore.kernel.org/lkml/[email protected]/

Quoted 26 lines
---
 drivers/dax/super.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/dax/super.c +1 -4
index 45f84b0eb909..60c4aec52ae1 100644
@@ -385,10 +385,7 @@ EXPORT_SYMBOL_GPL(dax_flush);
 
 void dax_write_cache(struct dax_device *dax_dev, bool wc)
 {
-	if (wc)
-		set_bit(DAXDEV_WRITE_CACHE, &dax_dev->flags);
-	else
-		clear_bit(DAXDEV_WRITE_CACHE, &dax_dev->flags);
+	assign_bit(DAXDEV_WRITE_CACHE, &dax_dev->flags, wc);
 }
 EXPORT_SYMBOL_GPL(dax_write_cache);
 
Signature · 1 line
2.51.0