lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250317083155.9g9ksofZ@linutronix.de>
Date: Mon, 17 Mar 2025 09:31:55 +0100
From: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
To: Ingo Molnar <mingo@...nel.org>
Cc: linux-kernel@...r.kernel.org, linux-rt-devel@...ts.linux.dev,
	Ben Segall <bsegall@...gle.com>,
	Catalin Marinas <catalin.marinas@....com>,
	Dietmar Eggemann <dietmar.eggemann@....com>,
	Ingo Molnar <mingo@...hat.com>, Juri Lelli <juri.lelli@...hat.com>,
	Mel Gorman <mgorman@...e.de>, Peter Zijlstra <peterz@...radead.org>,
	Shrikanth Hegde <sshegde@...ux.ibm.com>,
	Steven Rostedt <rostedt@...dmis.org>,
	Thomas Gleixner <tglx@...utronix.de>,
	Valentin Schneider <vschneid@...hat.com>,
	Vincent Guittot <vincent.guittot@...aro.org>,
	Will Deacon <will@...nel.org>
Subject: Re: [PATCH v4 1/9] sched: Add a generic function to return the
 preemption string.

On 2025-03-16 12:15:47 [+0100], Ingo Molnar wrote:
> 
> * Sebastian Andrzej Siewior <bigeasy@...utronix.de> wrote:
> 
> > +const char *preempt_modes[] = {
> > +	"none", "voluntary", "full", "lazy", NULL,
> > +};
> 
> > +	/* Count entries in NULL terminated preempt_modes */
> > +	for (j = 0; preempt_modes[j]; j++)
> > +		;
> 
> I'm pretty sure the build-time ARRAY_SIZE() primitive is superior here. ;-)

It would be but it is not an option.
That array is defined in core.c where it is "always" required while
debug.c needs it optionally. core.c is its one compile unit while
debug.c is included by build_utility.c. So I don't see how this can work
unless we shift things:

|   CC      kernel/sched/build_utility.o
| In file included from include/linux/kernel.h:16,
|                  from include/linux/cpumask.h:11,
|                  from include/linux/smp.h:13,
|                  from include/linux/sched/clock.h:5,
|                  from kernel/sched/build_utility.c:12:
| kernel/sched/debug.c: In function ‘sched_dynamic_show’:
| include/linux/array_size.h:11:32: error: invalid application of ‘sizeof’ to incomplete type ‘const char *[]’
|    11 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
|       |                                ^
| kernel/sched/debug.c:250:13: note: in expansion of macro ‘ARRAY_SIZE’
|   250 |         j = ARRAY_SIZE(preempt_modes);
|       |             ^~~~~~~~~~

> Thanks,
> 
> 	Ingo

Sebastian

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ