Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1622463 > unrolled thread

[PATCH v2 1/2] cpumask: Add helper cpumask_available()

Started byMatthias Kaehlcke <mka@chromium.org>
First post2017-04-12 20:30 +0200
Last post2017-04-14 20:00 +0200
Articles 6 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH v2 1/2] cpumask: Add helper cpumask_available() Matthias Kaehlcke <mka@chromium.org> - 2017-04-12 20:30 +0200
    [PATCH v2 2/2] kernel/irq: Use cpumask_available() for check of cpumask variable Matthias Kaehlcke <mka@chromium.org> - 2017-04-12 20:30 +0200
      Re: [PATCH v2 2/2] kernel/irq: Use cpumask_available() for check of  cpumask variable Thomas Gleixner <tglx@linutronix.de> - 2017-04-14 20:00 +0200
      [tip:irq/core] kernel/irq: Use cpumask_available() for check of  cpumask variable tip-bot for Matthias Kaehlcke <tipbot@zytor.com> - 2017-04-14 20:00 +0200
      [tip:irq/core] genirq: Use cpumask_available() for check of cpumask  variable tip-bot for Matthias Kaehlcke <tipbot@zytor.com> - 2017-04-14 21:00 +0200
    [tip:irq/core] cpumask: Add helper cpumask_available() tip-bot for Matthias Kaehlcke <tipbot@zytor.com> - 2017-04-14 20:00 +0200

#1622463 — [PATCH v2 1/2] cpumask: Add helper cpumask_available()

FromMatthias Kaehlcke <mka@chromium.org>
Date2017-04-12 20:30 +0200
Subject[PATCH v2 1/2] cpumask: Add helper cpumask_available()
Message-ID<tvvbI-7UV-21@gated-at.bofh.it>
With CONFIG_CPUMASK_OFFSTACK=y cpumask_var_t is a struct cpumask
pointer, otherwise a struct cpumask array with a single element.

Some code dealing with cpumasks needs to validate that a cpumask_var_t
is not a NULL pointer when CONFIG_CPUMASK_OFFSTACK=y. This is typically
done by performing the check always, regardless of the underlying type
of cpumask_var_t. This works in both cases, however clang raises a
warning like this when CONFIG_CPUMASK_OFFSTACK=n:

kernel/irq/manage.c:839:28: error: address of array
'desc->irq_common_data.affinity' will always evaluate to 'true'
[-Werror,-Wpointer-bool-conversion]

Add the inline helper cpumask_available() which only performs the
pointer check if CONFIG_CPUMASK_OFFSTACK=y.

Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
---
Changes in v2:
- Patch added

 include/linux/cpumask.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index 96f1e88b767c..1a675604b17d 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -667,6 +667,11 @@ void alloc_bootmem_cpumask_var(cpumask_var_t *mask);
 void free_cpumask_var(cpumask_var_t mask);
 void free_bootmem_cpumask_var(cpumask_var_t mask);
 
+static inline bool cpumask_available(cpumask_var_t mask)
+{
+	return mask != NULL;
+}
+
 #else
 typedef struct cpumask cpumask_var_t[1];
 
@@ -708,6 +713,11 @@ static inline void free_cpumask_var(cpumask_var_t mask)
 static inline void free_bootmem_cpumask_var(cpumask_var_t mask)
 {
 }
+
+static inline bool cpumask_available(cpumask_var_t mask)
+{
+	return true;
+}
 #endif /* CONFIG_CPUMASK_OFFSTACK */
 
 /* It's common to want to use cpu_all_mask in struct member initializers,
-- 
2.12.2.715.g7642488e1d-goog

[toc] | [next] | [standalone]


#1622467 — [PATCH v2 2/2] kernel/irq: Use cpumask_available() for check of cpumask variable

FromMatthias Kaehlcke <mka@chromium.org>
Date2017-04-12 20:30 +0200
Subject[PATCH v2 2/2] kernel/irq: Use cpumask_available() for check of cpumask variable
Message-ID<tvvbI-7UV-31@gated-at.bofh.it>
In reply to#1622463
This fixes the following clang warning when CONFIG_CPUMASK_OFFSTACK=y:

kernel/irq/manage.c:839:28: error: address of array
'desc->irq_common_data.affinity' will always evaluate to 'true'
[-Werror,-Wpointer-bool-conversion]

Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
---
Changes in v2:
- Use cpumask_available() instead if #ifdef construct

 kernel/irq/manage.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index a4afe5cc5af1..155e3c3357a1 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -852,7 +852,7 @@ irq_thread_check_affinity(struct irq_desc *desc, struct irqaction *action)
 	 * This code is triggered unconditionally. Check the affinity
 	 * mask pointer. For CPU_MASK_OFFSTACK=n this is optimized out.
 	 */
-	if (desc->irq_common_data.affinity)
+	if (cpumask_available(desc->irq_common_data.affinity))
 		cpumask_copy(mask, desc->irq_common_data.affinity);
 	else
 		valid = false;
-- 
2.12.2.715.g7642488e1d-goog

[toc] | [prev] | [next] | [standalone]


#1623815 — Re: [PATCH v2 2/2] kernel/irq: Use cpumask_available() for check of cpumask variable

FromThomas Gleixner <tglx@linutronix.de>
Date2017-04-14 20:00 +0200
SubjectRe: [PATCH v2 2/2] kernel/irq: Use cpumask_available() for check of cpumask variable
Message-ID<twdFL-43B-7@gated-at.bofh.it>
In reply to#1622467
On Wed, 12 Apr 2017, Matthias Kaehlcke wrote:

> This fixes the following clang warning when CONFIG_CPUMASK_OFFSTACK=y:

That should be '=n', right? I fixed it up.

Thanks,

	tglx

[toc] | [prev] | [next] | [standalone]


#1623816 — [tip:irq/core] kernel/irq: Use cpumask_available() for check of cpumask variable

Fromtip-bot for Matthias Kaehlcke <tipbot@zytor.com>
Date2017-04-14 20:00 +0200
Subject[tip:irq/core] kernel/irq: Use cpumask_available() for check of cpumask variable
Message-ID<twdFL-43B-5@gated-at.bofh.it>
In reply to#1622467
Commit-ID:  31299f44f42dd8dbc5ed200d3064f9c6ddbd3447
Gitweb:     http://git.kernel.org/tip/31299f44f42dd8dbc5ed200d3064f9c6ddbd3447
Author:     Matthias Kaehlcke <mka@chromium.org>
AuthorDate: Wed, 12 Apr 2017 11:20:30 -0700
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 14 Apr 2017 19:50:47 +0200

kernel/irq: Use cpumask_available() for check of cpumask variable

This fixes the following clang warning when CONFIG_CPUMASK_OFFSTACK=n:

kernel/irq/manage.c:839:28: error: address of array
'desc->irq_common_data.affinity' will always evaluate to 'true'
[-Werror,-Wpointer-bool-conversion]

Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
Cc: Grant Grundler <grundler@chromium.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Greg Hackmann <ghackmann@google.com>
Cc: Michael Davidson <md@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Link: http://lkml.kernel.org/r/20170412182030.83657-2-mka@chromium.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 kernel/irq/manage.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index a4afe5c..155e3c3 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -852,7 +852,7 @@ irq_thread_check_affinity(struct irq_desc *desc, struct irqaction *action)
 	 * This code is triggered unconditionally. Check the affinity
 	 * mask pointer. For CPU_MASK_OFFSTACK=n this is optimized out.
 	 */
-	if (desc->irq_common_data.affinity)
+	if (cpumask_available(desc->irq_common_data.affinity))
 		cpumask_copy(mask, desc->irq_common_data.affinity);
 	else
 		valid = false;

[toc] | [prev] | [next] | [standalone]


#1623859 — [tip:irq/core] genirq: Use cpumask_available() for check of cpumask variable

Fromtip-bot for Matthias Kaehlcke <tipbot@zytor.com>
Date2017-04-14 21:00 +0200
Subject[tip:irq/core] genirq: Use cpumask_available() for check of cpumask variable
Message-ID<tweBP-4E1-1@gated-at.bofh.it>
In reply to#1622467
Commit-ID:  d170fe7dd992b313d4851ae5ab77ee7a51ed8c72
Gitweb:     http://git.kernel.org/tip/d170fe7dd992b313d4851ae5ab77ee7a51ed8c72
Author:     Matthias Kaehlcke <mka@chromium.org>
AuthorDate: Wed, 12 Apr 2017 11:20:30 -0700
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 14 Apr 2017 20:49:27 +0200

genirq: Use cpumask_available() for check of cpumask variable

This fixes the following clang warning when CONFIG_CPUMASK_OFFSTACK=n:

kernel/irq/manage.c:839:28: error: address of array
'desc->irq_common_data.affinity' will always evaluate to 'true'
[-Werror,-Wpointer-bool-conversion]

Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
Cc: Grant Grundler <grundler@chromium.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Greg Hackmann <ghackmann@google.com>
Cc: Michael Davidson <md@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Link: http://lkml.kernel.org/r/20170412182030.83657-2-mka@chromium.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 kernel/irq/manage.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index a4afe5c..155e3c3 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -852,7 +852,7 @@ irq_thread_check_affinity(struct irq_desc *desc, struct irqaction *action)
 	 * This code is triggered unconditionally. Check the affinity
 	 * mask pointer. For CPU_MASK_OFFSTACK=n this is optimized out.
 	 */
-	if (desc->irq_common_data.affinity)
+	if (cpumask_available(desc->irq_common_data.affinity))
 		cpumask_copy(mask, desc->irq_common_data.affinity);
 	else
 		valid = false;

[toc] | [prev] | [next] | [standalone]


#1623818 — [tip:irq/core] cpumask: Add helper cpumask_available()

Fromtip-bot for Matthias Kaehlcke <tipbot@zytor.com>
Date2017-04-14 20:00 +0200
Subject[tip:irq/core] cpumask: Add helper cpumask_available()
Message-ID<twdFL-43B-11@gated-at.bofh.it>
In reply to#1622463
Commit-ID:  f7e30f01a9e221067bb4b579e3cfc25cd2617467
Gitweb:     http://git.kernel.org/tip/f7e30f01a9e221067bb4b579e3cfc25cd2617467
Author:     Matthias Kaehlcke <mka@chromium.org>
AuthorDate: Wed, 12 Apr 2017 11:20:29 -0700
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 14 Apr 2017 19:50:47 +0200

cpumask: Add helper cpumask_available()

With CONFIG_CPUMASK_OFFSTACK=y cpumask_var_t is a struct cpumask
pointer, otherwise a struct cpumask array with a single element.

Some code dealing with cpumasks needs to validate that a cpumask_var_t
is not a NULL pointer when CONFIG_CPUMASK_OFFSTACK=y. This is typically
done by performing the check always, regardless of the underlying type
of cpumask_var_t. This works in both cases, however clang raises a
warning like this when CONFIG_CPUMASK_OFFSTACK=n:

kernel/irq/manage.c:839:28: error: address of array
'desc->irq_common_data.affinity' will always evaluate to 'true'
[-Werror,-Wpointer-bool-conversion]

Add the inline helper cpumask_available() which only performs the
pointer check if CONFIG_CPUMASK_OFFSTACK=y.

Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
Cc: Grant Grundler <grundler@chromium.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Greg Hackmann <ghackmann@google.com>
Cc: Michael Davidson <md@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Link: http://lkml.kernel.org/r/20170412182030.83657-1-mka@chromium.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 include/linux/cpumask.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index 96f1e88..1a67560 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -667,6 +667,11 @@ void alloc_bootmem_cpumask_var(cpumask_var_t *mask);
 void free_cpumask_var(cpumask_var_t mask);
 void free_bootmem_cpumask_var(cpumask_var_t mask);
 
+static inline bool cpumask_available(cpumask_var_t mask)
+{
+	return mask != NULL;
+}
+
 #else
 typedef struct cpumask cpumask_var_t[1];
 
@@ -708,6 +713,11 @@ static inline void free_cpumask_var(cpumask_var_t mask)
 static inline void free_bootmem_cpumask_var(cpumask_var_t mask)
 {
 }
+
+static inline bool cpumask_available(cpumask_var_t mask)
+{
+	return true;
+}
 #endif /* CONFIG_CPUMASK_OFFSTACK */
 
 /* It's common to want to use cpu_all_mask in struct member initializers,

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web