All of lore.kernel.org
 help / color / mirror / Atom feed
* [tj-wq:for-7.1 14/18] kernel/workqueue.c:8289:34: warning: array subscript 1 is above array bounds of 'int[1]'
@ 2026-04-03  8:42 kernel test robot
  2026-04-09 15:27 ` Breno Leitao
  0 siblings, 1 reply; 2+ messages in thread
From: kernel test robot @ 2026-04-03  8:42 UTC (permalink / raw)
  To: Breno Leitao; +Cc: oe-kbuild-all, Tejun Heo

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/tj/wq.git for-7.1
head:   41e3ccca00b374b7f39cf68e818b59a921cd7069
commit: 5920d046f7ae3bf9cf51b9d915c1fff13d299d84 [14/18] workqueue: add WQ_AFFN_CACHE_SHARD affinity scope
config: nios2-randconfig-001-20260402 (https://download.01.org/0day-ci/archive/20260402/202604022343.GQtkF2vO-lkp@intel.com/config)
compiler: nios2-linux-gcc (GCC) 8.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260402/202604022343.GQtkF2vO-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202604022343.GQtkF2vO-lkp@intel.com/

All warnings (new ones prefixed by >>):

   kernel/workqueue.c: In function 'workqueue_init_topology':
>> kernel/workqueue.c:8289:34: warning: array subscript 1 is above array bounds of 'int[1]' [-Warray-bounds]
       cpu_shard_id[c] = cpu_shard_id[cpumask_first(sibling_cpus)];
                         ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~


vim +8289 kernel/workqueue.c

  8251	
  8252	/**
  8253	 * llc_populate_cpu_shard_id - populate cpu_shard_id[] for each CPU in an LLC pod
  8254	 * @pod_cpus:  the cpumask of CPUs in the LLC pod
  8255	 * @smt_pods:  the SMT pod type, used to identify sibling groups
  8256	 * @nr_cores:  number of distinct cores in @pod_cpus (from llc_count_cores())
  8257	 *
  8258	 * Walks @pod_cpus in order. At each SMT group leader, advances to the next
  8259	 * shard once the current shard is full. Results are written to cpu_shard_id[].
  8260	 */
  8261	static void __init llc_populate_cpu_shard_id(const struct cpumask *pod_cpus,
  8262						     struct wq_pod_type *smt_pods,
  8263						     int nr_cores)
  8264	{
  8265		struct llc_shard_layout layout = llc_calc_shard_layout(nr_cores);
  8266		const struct cpumask *sibling_cpus;
  8267		/* Count the number of cores in the current shard_id */
  8268		int cores_in_shard = 0;
  8269		/* This is a cursor for the shards. Go from zero to nr_shards - 1*/
  8270		int shard_id = 0;
  8271		int c;
  8272	
  8273		/* Iterate at every CPU for a given LLC pod, and assign it a shard */
  8274		for_each_cpu(c, pod_cpus) {
  8275			sibling_cpus = smt_pods->pod_cpus[smt_pods->cpu_pod[c]];
  8276			if (cpumask_first(sibling_cpus) == c) {
  8277				/* This is the CPU leader for the siblings */
  8278				if (llc_shard_is_full(cores_in_shard, shard_id, &layout)) {
  8279					shard_id++;
  8280					cores_in_shard = 0;
  8281				}
  8282				cores_in_shard++;
  8283				cpu_shard_id[c] = shard_id;
  8284			} else {
  8285				/*
  8286				 * The siblings' shard MUST be the same as the leader.
  8287				 * never split threads in the same core.
  8288				 */
> 8289				cpu_shard_id[c] = cpu_shard_id[cpumask_first(sibling_cpus)];
  8290			}
  8291		}
  8292	
  8293		WARN_ON_ONCE(shard_id != (layout.nr_shards - 1));
  8294	}
  8295	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

* Re: [tj-wq:for-7.1 14/18] kernel/workqueue.c:8289:34: warning: array subscript 1 is above array bounds of 'int[1]'
  2026-04-03  8:42 [tj-wq:for-7.1 14/18] kernel/workqueue.c:8289:34: warning: array subscript 1 is above array bounds of 'int[1]' kernel test robot
@ 2026-04-09 15:27 ` Breno Leitao
  0 siblings, 0 replies; 2+ messages in thread
From: Breno Leitao @ 2026-04-09 15:27 UTC (permalink / raw)
  To: kernel test robot; +Cc: oe-kbuild-all, Tejun Heo

On Fri, Apr 03, 2026 at 04:42:14PM +0800, kernel test robot wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/tj/wq.git for-7.1
> head:   41e3ccca00b374b7f39cf68e818b59a921cd7069
> commit: 5920d046f7ae3bf9cf51b9d915c1fff13d299d84 [14/18] workqueue: add WQ_AFFN_CACHE_SHARD affinity scope
> config: nios2-randconfig-001-20260402 (https://download.01.org/0day-ci/archive/20260402/202604022343.GQtkF2vO-lkp@intel.com/config)
> compiler: nios2-linux-gcc (GCC) 8.5.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260402/202604022343.GQtkF2vO-lkp@intel.com/reproduce)
> 
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202604022343.GQtkF2vO-lkp@intel.com/
> 
> All warnings (new ones prefixed by >>):
> 
>    kernel/workqueue.c: In function 'workqueue_init_topology':
> >> kernel/workqueue.c:8289:34: warning: array subscript 1 is above array bounds of 'int[1]' [-Warray-bounds]
>        cpu_shard_id[c] = cpu_shard_id[cpumask_first(sibling_cpus)];
>                          ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I can finally reproduce it. This is related to nios2 having NR_CPU=1.

	In function ‘llc_populate_cpu_shard_id’,
	inlined from ‘precompute_cache_shard_ids’ at /home/leit/Devel/linux-next/kernel/workqueue.c:8321:3,
	inlined from ‘workqueue_init_topology’ at /home/leit/Devel/linux-next/kernel/workqueue.c:8354:2:
	/home/leit/Devel/linux-next/kernel/workqueue.c:8289:55: warning: array subscript 1 is above array bounds of ‘int[1]’ [-Warray-bounds]
	8289 |                         cpu_shard_id[c] = cpu_shard_id[cpumask_first(sibling_cpus)];
	|                                           ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	/home/leit/Devel/linux-next/kernel/workqueue.c: In function ‘workqueue_init_topology’:
	/home/leit/Devel/linux-next/kernel/workqueue.c:8171:12: note: while referencing ‘cpu_shard_id’
	8171 | static int cpu_shard_id[NR_CPUS] __initdata;
	|            ^~~~~~~~~~~~
	make[1]: Leaving directory '/tmp/wq-nios2'


Working on a fix,

Thanks for the report, dear robot :-)
--breno

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

end of thread, other threads:[~2026-04-09 15:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-03  8:42 [tj-wq:for-7.1 14/18] kernel/workqueue.c:8289:34: warning: array subscript 1 is above array bounds of 'int[1]' kernel test robot
2026-04-09 15:27 ` Breno Leitao

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.