Skip to contentSkip to conversation

x86: mmiotrace: Use cpumask_available for cpumask_var_t variables

PATCH Applied Nathan Chancellor 6 participants 10 messages Apr 8, 2020 – May 19, 2020

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

PATCH 1/1 x86: mmiotrace: Use cpumask_available for cpumask_var_t variables

When building with Clang + -Wtautological-compare and CONFIG_CPUMASK_OFFSTACK unset:

arch/x86/mm/mmio-mod.c:375:6: warning: comparison of array 'downed_cpus' equal to a null pointer is always false [-Wtautological-pointer-compare]

        if (downed_cpus == NULL &&
            ^~~~~~~~~~~    ~~~~
arch/x86/mm/mmio-mod.c:405:6: warning: comparison of array 'downed_cpus'
equal to a null pointer is always false [-Wtautological-pointer-compare]
        if (downed_cpus == NULL || cpumask_weight(downed_cpus) == 0)
            ^~~~~~~~~~~    ~~~~

2 warnings generated.

Commit f7e30f01a9e2 ("cpumask: Add helper cpumask_available()") added cpumask_available to fix warnings of this nature. Use that here so that clang does not warn regardless of CONFIG_CPUMASK_OFFSTACK's value.

---
 arch/x86/mm/mmio-mod.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/mm/mmio-mod.c +2 -2
index 109325d77b3e..43fd19b3f118 100644
@@ -372,7 +372,7 @@ static void enter_uniprocessor(void)
 	int cpu;
 	int err;
 
-	if (downed_cpus == NULL &&
+	if (!cpumask_available(downed_cpus) &&
 	    !alloc_cpumask_var(&downed_cpus, GFP_KERNEL)) {
 		pr_notice("Failed to allocate mask\n");
 		goto out;
@@ -402,7 +402,7 @@ static void leave_uniprocessor(void)
 	int cpu;
 	int err;
 
-	if (downed_cpus == NULL || cpumask_weight(downed_cpus) == 0)
+	if (!cpumask_available(downed_cpus) || cpumask_weight(downed_cpus) == 0)
 		return;
 	pr_notice("Re-enabling CPUs...\n");
 	for_each_cpu(cpu, downed_cpus) {

base-commit: ae46d2aa6a7fbe8ca0946f24b061b6ccdc6c3f25

Signature · 1 line
2.26.0
#1 lore raw
Quoted 4 lines · Nathan Chancellor

When building with Clang + -Wtautological-compare and CONFIG_CPUMASK_OFFSTACK unset:

Hi Nathan,

thanks for the quick patch.

I can confirm I have no CONFIG_CPUMASK_OFFSTACK set.

Regards,
- Sedat -

Quoted 48 lines

arch/x86/mm/mmio-mod.c:375:6: warning: comparison of array 'downed_cpus' equal to a null pointer is always false [-Wtautological-pointer-compare]

        if (downed_cpus == NULL &&
            ^~~~~~~~~~~    ~~~~
arch/x86/mm/mmio-mod.c:405:6: warning: comparison of array 'downed_cpus'
equal to a null pointer is always false [-Wtautological-pointer-compare]
        if (downed_cpus == NULL || cpumask_weight(downed_cpus) == 0)
            ^~~~~~~~~~~    ~~~~

2 warnings generated.

Commit f7e30f01a9e2 ("cpumask: Add helper cpumask_available()") added cpumask_available to fix warnings of this nature. Use that here so that clang does not warn regardless of CONFIG_CPUMASK_OFFSTACK's value.

---
 arch/x86/mm/mmio-mod.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/mm/mmio-mod.c +2 -2
index 109325d77b3e..43fd19b3f118 100644
@@ -372,7 +372,7 @@ static void enter_uniprocessor(void)
        int cpu;
        int err;
 
-       if (downed_cpus == NULL &&
+       if (!cpumask_available(downed_cpus) &&
            !alloc_cpumask_var(&downed_cpus, GFP_KERNEL)) {
                pr_notice("Failed to allocate mask\n");
                goto out;
@@ -402,7 +402,7 @@ static void leave_uniprocessor(void)
        int cpu;
        int err;
 
-       if (downed_cpus == NULL || cpumask_weight(downed_cpus) == 0)
+       if (!cpumask_available(downed_cpus) || cpumask_weight(downed_cpus) == 0)
                return;
        pr_notice("Re-enabling CPUs...\n");
        for_each_cpu(cpu, downed_cpus) {

base-commit: ae46d2aa6a7fbe8ca0946f24b061b6ccdc6c3f25 --
2.26.0

Tested-by
#2 lore raw
Quoted 8 lines · Sedat Dilek
Quoted 4 lines · Nathan Chancellor

When building with Clang + -Wtautological-compare and CONFIG_CPUMASK_OFFSTACK unset:

Quoted 6 lines

Hi Nathan,

thanks for the quick patch.

I can confirm I have no CONFIG_CPUMASK_OFFSTACK set.

Feel free to add appropriate credits:

Regards,
- Sedat -

Quoted 49 lines
Quoted 49 lines

arch/x86/mm/mmio-mod.c:375:6: warning: comparison of array 'downed_cpus' equal to a null pointer is always false [-Wtautological-pointer-compare]

        if (downed_cpus == NULL &&
            ^~~~~~~~~~~    ~~~~
arch/x86/mm/mmio-mod.c:405:6: warning: comparison of array 'downed_cpus'
equal to a null pointer is always false [-Wtautological-pointer-compare]
        if (downed_cpus == NULL || cpumask_weight(downed_cpus) == 0)
            ^~~~~~~~~~~    ~~~~

2 warnings generated.

Commit f7e30f01a9e2 ("cpumask: Add helper cpumask_available()") added cpumask_available to fix warnings of this nature. Use that here so that clang does not warn regardless of CONFIG_CPUMASK_OFFSTACK's value.

---
 arch/x86/mm/mmio-mod.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/mm/mmio-mod.c +2 -2
index 109325d77b3e..43fd19b3f118 100644
@@ -372,7 +372,7 @@ static void enter_uniprocessor(void)
        int cpu;
        int err;
 
-       if (downed_cpus == NULL &&
+       if (!cpumask_available(downed_cpus) &&
            !alloc_cpumask_var(&downed_cpus, GFP_KERNEL)) {
                pr_notice("Failed to allocate mask\n");
                goto out;
@@ -402,7 +402,7 @@ static void leave_uniprocessor(void)
        int cpu;
        int err;
 
-       if (downed_cpus == NULL || cpumask_weight(downed_cpus) == 0)
+       if (!cpumask_available(downed_cpus) || cpumask_weight(downed_cpus) == 0)
                return;
        pr_notice("Re-enabling CPUs...\n");
        for_each_cpu(cpu, downed_cpus) {

base-commit: ae46d2aa6a7fbe8ca0946f24b061b6ccdc6c3f25 --
2.26.0

#3 lore raw

On Wed, Apr 8, 2020 at 11:36 PM Sedat Dilek <[email protected]> wrote:

[ ... ]

Quoted 4 lines

Feel free to add appropriate credits:

Re-tested with Linux v5.7-rc1 which shows this warning - with GCC v9.3 and LLVM/Clang v10.0.0 (and snapshot/pre-release of v10.0.1) on Debian/testing AMD64.

- Sedat -

maintainer Acked-by on v1 1/1
#4 lore raw
In reply to Nathan Chancellor
Quoted 13 lines · On Wed, 8 Apr 2020 13:53:23 -0700 Nathan Chancellor…

When building with Clang + -Wtautological-compare and CONFIG_CPUMASK_OFFSTACK unset:

arch/x86/mm/mmio-mod.c:375:6: warning: comparison of array 'downed_cpus' equal to a null pointer is always false [-Wtautological-pointer-compare]

        if (downed_cpus == NULL &&
            ^~~~~~~~~~~    ~~~~
arch/x86/mm/mmio-mod.c:405:6: warning: comparison of array 'downed_cpus'
equal to a null pointer is always false [-Wtautological-pointer-compare]
        if (downed_cpus == NULL || cpumask_weight(downed_cpus) == 0)
            ^~~~~~~~~~~    ~~~~

2 warnings generated.

Quoted 9 lines

Commit f7e30f01a9e2 ("cpumask: Add helper cpumask_available()") added cpumask_available to fix warnings of this nature. Use that here so that clang does not warn regardless of CONFIG_CPUMASK_OFFSTACK's value.

---

-- Steve

#5 lore raw
In reply to Nathan Chancellor
Quoted 47 lines · Nathan Chancellor

When building with Clang + -Wtautological-compare and CONFIG_CPUMASK_OFFSTACK unset:

arch/x86/mm/mmio-mod.c:375:6: warning: comparison of array 'downed_cpus' equal to a null pointer is always false [-Wtautological-pointer-compare]

        if (downed_cpus == NULL &&
            ^~~~~~~~~~~    ~~~~
arch/x86/mm/mmio-mod.c:405:6: warning: comparison of array 'downed_cpus'
equal to a null pointer is always false [-Wtautological-pointer-compare]
        if (downed_cpus == NULL || cpumask_weight(downed_cpus) == 0)
            ^~~~~~~~~~~    ~~~~

2 warnings generated.

Commit f7e30f01a9e2 ("cpumask: Add helper cpumask_available()") added cpumask_available to fix warnings of this nature. Use that here so that clang does not warn regardless of CONFIG_CPUMASK_OFFSTACK's value.

---
 arch/x86/mm/mmio-mod.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/mm/mmio-mod.c +2 -2
index 109325d77b3e..43fd19b3f118 100644
@@ -372,7 +372,7 @@ static void enter_uniprocessor(void)
 	int cpu;
 	int err;
 
-	if (downed_cpus == NULL &&
+	if (!cpumask_available(downed_cpus) &&
 	    !alloc_cpumask_var(&downed_cpus, GFP_KERNEL)) {
 		pr_notice("Failed to allocate mask\n");
 		goto out;
@@ -402,7 +402,7 @@ static void leave_uniprocessor(void)
 	int cpu;
 	int err;
 
-	if (downed_cpus == NULL || cpumask_weight(downed_cpus) == 0)
+	if (!cpumask_available(downed_cpus) || cpumask_weight(downed_cpus) == 0)
 		return;
 	pr_notice("Re-enabling CPUs...\n");
 	for_each_cpu(cpu, downed_cpus) {
Quoted 4 lines

base-commit: ae46d2aa6a7fbe8ca0946f24b061b6ccdc6c3f25

Signature · 1 line
2.26.0

Gentle ping for acceptance, I am not sure who should take this.

Cheers,
Nathan

Reviewed-by
#6 lore raw
Quoted 15 lines · Nathan Chancellor
Quoted 13 lines · Nathan Chancellor

When building with Clang + -Wtautological-compare and CONFIG_CPUMASK_OFFSTACK unset:

arch/x86/mm/mmio-mod.c:375:6: warning: comparison of array 'downed_cpus' equal to a null pointer is always false [-Wtautological-pointer-compare]

        if (downed_cpus == NULL &&
            ^~~~~~~~~~~    ~~~~
arch/x86/mm/mmio-mod.c:405:6: warning: comparison of array 'downed_cpus'
equal to a null pointer is always false [-Wtautological-pointer-compare]
        if (downed_cpus == NULL || cpumask_weight(downed_cpus) == 0)
            ^~~~~~~~~~~    ~~~~

2 warnings generated.

Quoted 7 lines
Quoted 7 lines

Commit f7e30f01a9e2 ("cpumask: Add helper cpumask_available()") added cpumask_available to fix warnings of this nature. Use that here so that clang does not warn regardless of CONFIG_CPUMASK_OFFSTACK's value.

Thanks for the patch, sorry I'm falling behind on code review!

Quoted 27 lines
Quoted 27 lines
---
 arch/x86/mm/mmio-mod.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/mm/mmio-mod.c +2 -2
index 109325d77b3e..43fd19b3f118 100644
@@ -372,7 +372,7 @@ static void enter_uniprocessor(void)
      int cpu;
      int err;
 
-     if (downed_cpus == NULL &&
+     if (!cpumask_available(downed_cpus) &&
          !alloc_cpumask_var(&downed_cpus, GFP_KERNEL)) {
              pr_notice("Failed to allocate mask\n");
              goto out;
@@ -402,7 +402,7 @@ static void leave_uniprocessor(void)
      int cpu;
      int err;
 
-     if (downed_cpus == NULL || cpumask_weight(downed_cpus) == 0)
+     if (!cpumask_available(downed_cpus) || cpumask_weight(downed_cpus) == 0)
              return;
      pr_notice("Re-enabling CPUs...\n");
      for_each_cpu(cpu, downed_cpus) {
Quoted 6 lines
Quoted 4 lines

base-commit: ae46d2aa6a7fbe8ca0946f24b061b6ccdc6c3f25 --
2.26.0

Gentle ping for acceptance, I am not sure who should take this.

Looks like Steven or Ingo are the listed maintainers for MMIOTRACE?

Signature · 2 lines
Thanks,
~Nick Desaulniers
maintainer
#7 lore raw
Quoted 21 lines · On Mon, 18 May 2020 11:52:47 -0700 Nick Desaulniers…
Quoted 19 lines · Nathan Chancellor
Quoted 17 lines · Nathan Chancellor

When building with Clang + -Wtautological-compare and CONFIG_CPUMASK_OFFSTACK unset:

arch/x86/mm/mmio-mod.c:375:6: warning: comparison of array 'downed_cpus' equal to a null pointer is always false [-Wtautological-pointer-compare]

        if (downed_cpus == NULL &&
            ^~~~~~~~~~~    ~~~~
arch/x86/mm/mmio-mod.c:405:6: warning: comparison of array 'downed_cpus'
equal to a null pointer is always false [-Wtautological-pointer-compare]
        if (downed_cpus == NULL || cpumask_weight(downed_cpus) == 0)
            ^~~~~~~~~~~    ~~~~

2 warnings generated.

Commit f7e30f01a9e2 ("cpumask: Add helper cpumask_available()") added cpumask_available to fix warnings of this nature. Use that here so that clang does not warn regardless of CONFIG_CPUMASK_OFFSTACK's value.

Quoted 6 lines
Quoted 3 lines
Quoted 3 lines

Thanks for the patch, sorry I'm falling behind on code review!

Linus sent me a issue about this failure privately as well, and had two solutions for it (one being identical to this one, and I shared that with him, and another one he thought would be better, but had some issues).

Linus,

Are you OK with this patch?

-- Steve

Quoted 37 lines
Quoted 28 lines
Quoted 28 lines
---
 arch/x86/mm/mmio-mod.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/mm/mmio-mod.c +2 -2
index 109325d77b3e..43fd19b3f118 100644
@@ -372,7 +372,7 @@ static void enter_uniprocessor(void)
      int cpu;
      int err;
 
-     if (downed_cpus == NULL &&
+     if (!cpumask_available(downed_cpus) &&
          !alloc_cpumask_var(&downed_cpus, GFP_KERNEL)) {
              pr_notice("Failed to allocate mask\n");
              goto out;
@@ -402,7 +402,7 @@ static void leave_uniprocessor(void)
      int cpu;
      int err;
 
-     if (downed_cpus == NULL || cpumask_weight(downed_cpus) == 0)
+     if (!cpumask_available(downed_cpus) || cpumask_weight(downed_cpus) == 0)
              return;
      pr_notice("Re-enabling CPUs...\n");
      for_each_cpu(cpu, downed_cpus) {
Quoted 6 lines
Quoted 4 lines

base-commit: ae46d2aa6a7fbe8ca0946f24b061b6ccdc6c3f25 --
2.26.0

Gentle ping for acceptance, I am not sure who should take this.

Looks like Steven or Ingo are the listed maintainers for MMIOTRACE?

#8 lore raw
Quoted 4 lines · Steven Rostedt

Linus,

Are you OK with this patch?

Yup, I don't care deeply either way, as long as we can get rid of the warning.

Linus

#9 lore raw

[tip: x86/urgent] x86/mmiotrace: Use cpumask_available() for cpumask_var_t variables

In reply to Nathan Chancellor
The following commit has been merged into the x86/urgent branch of tip:

The following commit has been merged into the x86/urgent branch of tip:

Commit-ID:     d7110a26e5905ec2fe3fc88bc6a538901accb72b
Gitweb:        https://git.kernel.org/tip/d7110a26e5905ec2fe3fc88bc6a538901accb72b
Author:        Nathan Chancellor <[email protected]>
AuthorDate:    Wed, 08 Apr 2020 13:53:23 -07:00
Committer:     Borislav Petkov <[email protected]>
CommitterDate: Tue, 19 May 2020 19:30:28 +02:00

x86/mmiotrace: Use cpumask_available() for cpumask_var_t variables

When building with Clang + -Wtautological-compare and CONFIG_CPUMASK_OFFSTACK unset:

arch/x86/mm/mmio-mod.c:375:6: warning: comparison of array 'downed_cpus' equal to a null pointer is always false [-Wtautological-pointer-compare]

          if (downed_cpus == NULL &&
              ^~~~~~~~~~~    ~~~~
  arch/x86/mm/mmio-mod.c:405:6: warning: comparison of array 'downed_cpus'
  equal to a null pointer is always false [-Wtautological-pointer-compare]
          if (downed_cpus == NULL || cpumask_weight(downed_cpus) == 0)
              ^~~~~~~~~~~    ~~~~

2 warnings generated.

Commit

f7e30f01a9e2 ("cpumask: Add helper cpumask_available()")

added cpumask_available() to fix warnings of this nature. Use that here so that clang does not warn regardless of CONFIG_CPUMASK_OFFSTACK's value.

---
 arch/x86/mm/mmio-mod.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/mm/mmio-mod.c +2 -2
index 109325d..43fd19b 100644
@@ -372,7 +372,7 @@ static void enter_uniprocessor(void)
 	int cpu;
 	int err;
 
-	if (downed_cpus == NULL &&
+	if (!cpumask_available(downed_cpus) &&
 	    !alloc_cpumask_var(&downed_cpus, GFP_KERNEL)) {
 		pr_notice("Failed to allocate mask\n");
 		goto out;
@@ -402,7 +402,7 @@ static void leave_uniprocessor(void)
 	int cpu;
 	int err;
 
-	if (downed_cpus == NULL || cpumask_weight(downed_cpus) == 0)
+	if (!cpumask_available(downed_cpus) || cpumask_weight(downed_cpus) == 0)
 		return;
 	pr_notice("Re-enabling CPUs...\n");
 	for_each_cpu(cpu, downed_cpus) {