linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kernel/irq: Limit validation of cpumask_var_t to CONFIG_CPUMASK_OFFSTACK=y
@ 2017-04-11 23:52 Matthias Kaehlcke
  2017-04-12  7:23 ` Thomas Gleixner
  0 siblings, 1 reply; 3+ messages in thread
From: Matthias Kaehlcke @ 2017-04-11 23:52 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: linux-kernel, Grant Grundler, Greg Hackmann, Michael Davidson,
	Matthias Kaehlcke

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

irq_thread_check_affinity() validates the cpumask_var_t field in the
interrupt descriptor by checking if it is not NULL. This works for
both CONFIG_CPUMASK_OFFSTACK=y/n, however clang raises the following
warning with 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]

To get rid of the warning only validate the cpumask_var_t field when
CONFIG_CPUMASK_OFFSTACK=y.

Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
---
 kernel/irq/manage.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index a4afe5cc5af1..5d38fe85122b 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -848,14 +848,14 @@ irq_thread_check_affinity(struct irq_desc *desc, struct irqaction *action)
 	}
 
 	raw_spin_lock_irq(&desc->lock);
-	/*
-	 * 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)
-		cpumask_copy(mask, desc->irq_common_data.affinity);
-	else
+
+#ifdef CONFIG_CPUMASK_OFFSTACK
+	if (!desc->irq_common_data.affinity)
 		valid = false;
+	else
+#endif
+	cpumask_copy(mask, desc->irq_common_data.affinity);
+
 	raw_spin_unlock_irq(&desc->lock);
 
 	if (valid)
-- 
2.12.2.715.g7642488e1d-goog

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] kernel/irq: Limit validation of cpumask_var_t to CONFIG_CPUMASK_OFFSTACK=y
  2017-04-11 23:52 [PATCH] kernel/irq: Limit validation of cpumask_var_t to CONFIG_CPUMASK_OFFSTACK=y Matthias Kaehlcke
@ 2017-04-12  7:23 ` Thomas Gleixner
  2017-04-12 16:43   ` Matthias Kaehlcke
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Gleixner @ 2017-04-12  7:23 UTC (permalink / raw)
  To: Matthias Kaehlcke
  Cc: linux-kernel, Grant Grundler, Greg Hackmann, Michael Davidson

On Tue, 11 Apr 2017, Matthias Kaehlcke wrote:
> With CONFIG_CPUMASK_OFFSTACK=y cpumask_var_t is a struct cpumask
> pointer, otherwise a struct cpumask array with a single element.
> 
> irq_thread_check_affinity() validates the cpumask_var_t field in the
> interrupt descriptor by checking if it is not NULL. This works for
> both CONFIG_CPUMASK_OFFSTACK=y/n, however clang raises the following
> warning with 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]
> 
> To get rid of the warning only validate the cpumask_var_t field when
> CONFIG_CPUMASK_OFFSTACK=y.

This ifdeffery is horrible. Can you please create a helper inline
cpumask_available() or something like that which hides this in a header
file. The irq code is probably not the only place which does this.

Thanks,

	tglx

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] kernel/irq: Limit validation of cpumask_var_t to CONFIG_CPUMASK_OFFSTACK=y
  2017-04-12  7:23 ` Thomas Gleixner
@ 2017-04-12 16:43   ` Matthias Kaehlcke
  0 siblings, 0 replies; 3+ messages in thread
From: Matthias Kaehlcke @ 2017-04-12 16:43 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: linux-kernel, Grant Grundler, Greg Hackmann, Michael Davidson

Hi Thomas,

El Wed, Apr 12, 2017 at 09:23:58AM +0200 Thomas Gleixner ha dit:

> On Tue, 11 Apr 2017, Matthias Kaehlcke wrote:
> > With CONFIG_CPUMASK_OFFSTACK=y cpumask_var_t is a struct cpumask
> > pointer, otherwise a struct cpumask array with a single element.
> > 
> > irq_thread_check_affinity() validates the cpumask_var_t field in the
> > interrupt descriptor by checking if it is not NULL. This works for
> > both CONFIG_CPUMASK_OFFSTACK=y/n, however clang raises the following
> > warning with 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]
> > 
> > To get rid of the warning only validate the cpumask_var_t field when
> > CONFIG_CPUMASK_OFFSTACK=y.
> 
> This ifdeffery is horrible. Can you please create a helper inline
> cpumask_available() or something like that which hides this in a header
> file. The irq code is probably not the only place which does this.

Thanks for your comments, I'll rework the patch to use a helper
instead.

Cheers

Matthias

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-04-12 16:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-11 23:52 [PATCH] kernel/irq: Limit validation of cpumask_var_t to CONFIG_CPUMASK_OFFSTACK=y Matthias Kaehlcke
2017-04-12  7:23 ` Thomas Gleixner
2017-04-12 16:43   ` Matthias Kaehlcke

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).