Fix Power CI build
v2 cover Fix Power CI build
Hello all,
This series contains a few minor fixes to the CI config and one additional patch to common/ that resolve ppc64-specific CI failures that Jan discovered.
Thanks,
Shawn Anastasio (2):
automation: Change build script to use arch defconfig xen/common: Add NUMA node id bounds check to
page_alloc.c/node_to_scrub
automation/scripts/build | 7 ++++++- xen/common/page_alloc.c | 8 ++++++++ 2 files changed, 14 insertions(+), 1 deletion(-)
--
2.30.2
PATCH v2 2/2 xen/common: Add NUMA node id bounds check to page_alloc.c/node_to_scrub
When building for Power with CONFIG_DEBUG unset, a compiler error gets raised inside page_alloc.c's node_to_scrub function:
common/page_alloc.c: In function 'node_to_scrub.part.0':common/page_alloc.c:1217:29: error: array subscript 1 is above array
bounds of 'long unsigned int[1]' [-Werror=array-bounds]
1217 | if ( node_need_scrub[node] )
It appears that this is a false positive, given that in practice cycle_node should never return a node ID >= MAX_NUMNODES as long as the architecture's node_online_map is properly defined and initialized, so this additional bounds check is only to satisfy GCC.
---
v2: Add comment to explain the bounds check.
xen/common/page_alloc.c | 8 ++++++++ 1 file changed, 8 insertions(+)
xen/common/page_alloc.c +8 -0
@@ -1211,6 +1211,14 @@ static unsigned int node_to_scrub(bool get_node) }while ( !cpumask_empty (&node_to_cpumask (node)) && (node != local_node) ); +/* +* In practice `node` will always be within MAX_NUMNODES, but GCC can't +* always see that, so an explicit check is necessary to avoid tripping +* its out-of-bounds array access warning (-Warray-bounds). +*/ +if ( node >=MAX_NUMNODES ) +break ; +if ( node == local_node )break ;
--
2.30.2
PATCH v2 1/2 automation: Change build script to use arch defconfig
In reply to Shawn AnastasioChange automation build script to call the make defconfig target before setting CONFIG_DEBUG and extra options. This fixes issues on Power where the build fails without using the ppc64_defconfig.
---
v2: No changes.
automation/scripts/build | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
automation/scripts/build +6 -1
@@ -22,7 +22,12 @@ if [[ "${RANDCONFIG}" == "y" ]]; then # RANDCONFIG implies HYPERVISOR_ONLY HYPERVISOR_ONLY="y" else - echo "CONFIG_DEBUG=${debug}" > xen/.config + # Start off with arch's defconfig + make -C xen defconfig + + # Drop existing CONFIG_DEBUG and replace with value of ${debug} + sed -i 's/^CONFIG_DEBUG=[yn]//g' xen/.config + echo "CONFIG_DEBUG=${debug}" >> xen/.config if [[ -n "${EXTRA_XEN_CONFIG}" ]]; then echo "${EXTRA_XEN_CONFIG}" >> xen/.config
--
2.30.2
Re: [PATCH v2 1/2] automation: Change build script to use arch defconfig
Quoted 5 lines · Shawn Anastasio
automation/scripts/build +0
-0
automation/scripts/build if [[ "${RANDCONFIG}" == "y" ]]; then · line 30
Quoted 10 lines
automation/scripts/build +6
-1@@ -22,7 +22,12 @@ if [[ "${RANDCONFIG}" == "y" ]]; then # RANDCONFIG implies HYPERVISOR_ONLY HYPERVISOR_ONLY="y" else - echo "CONFIG_DEBUG=${debug}" > xen/.config + # Start off with arch's defconfig + make -C xen defconfig + + # Drop existing CONFIG_DEBUG and replace with value of ${debug} + sed -i 's/^CONFIG_DEBUG=[yn]//g' xen/.config + echo "CONFIG_DEBUG=${debug}" >> xen/.config
Kconfig is latest-takes precedence, which is why we always append for this and the other related options. There's no need for sed to drop the old value.
~Andrew
Re: [PATCH v2 2/2] xen/common: Add NUMA node id bounds check to page_alloc.c/node_to_scrub
In reply to Shawn AnastasioQuoted 8 lines · Shawn Anastasio
When building for Power with
CONFIG_DEBUGunset, a compiler error gets raised inside page_alloc.c'snode_to_scrubfunction:
common/page_alloc.c: In function 'node_to_scrub.part.0':common/page_alloc.c:1217:29: error: array subscript 1 is above array
bounds of 'long unsigned int[1]' [-Werror=array-bounds]
1217 | if ( node_need_scrub[node] )
Quoted 4 lines
It appears that this is a false positive, given that in practice
cycle_nodeshould never return a node ID >=MAX_NUMNODESas long as the architecture'snode_online_mapis properly defined and initialized, so this additional bounds check is only to satisfy GCC.
If GCC thinks it's got an index of 1 here, then it thinks it's proved that a 1 gets passed. But the fact that cycle_node() really can return 1 if one variable gets tweaked in memory means that logic derived on this property is broken.
But we've got even more basic problems to fix first.
xen$ git grep -B1 '__read_mostly node_online_map' arch/arm/smpboot.c-45-/* Fake one node for now. See also asm/numa.h */ arch/arm/smpboot.c:46:nodemask_t __read_mostly node_online_map = { { [0] = 1UL } };arch/ppc/stubs.c-25-
arch/ppc/stubs.c:26:nodemask_t __read_mostly node_online_map = { { [0] = 1UL } };
common/numa.c-44-
common/numa.c:45:nodemask_t __read_mostly node_online_map = { { [0] = 1UL } };
There are 3 identical definitions of node_online_map, one for the architecture which really supports NUMA, and two for the stubs which don't.
And the bug here is that code outside of CONFIG_NUMA assumes NUMA is valid, including several places in page_alloc.c, domain_set_node_affinity(), credit1 and sysctl. XEN_SYSCTL_numainfo even has a bigger sin of using a static MAX_NUMNODES array when it doesn't need an array in the first place.
It's rude for xen/nodemask.h to short circuit some of the operations on node_online_map based on MAX_NUMNODES but not others.
If nothing else, the fallback for "not really NUMA" needs providing by the common code and not by the arch stubs. When that is sorted, we might have more consistent behaviour to investigate.
~Andrew
Re: [PATCH v2 2/2] xen/common: Add NUMA node id bounds check to page_alloc.c/node_to_scrub
In reply to Shawn AnastasioQuoted 8 lines · Shawn Anastasio
When building for Power with
CONFIG_DEBUGunset, a compiler error gets raised inside page_alloc.c'snode_to_scrubfunction:
common/page_alloc.c: In function 'node_to_scrub.part.0':common/page_alloc.c:1217:29: error: array subscript 1 is above array
bounds of 'long unsigned int[1]' [-Werror=array-bounds]
1217 | if ( node_need_scrub[node] )
Quoted 6 lines
It appears that this is a false positive, given that in practice
cycle_nodeshould never return a node ID >=MAX_NUMNODESas long as the architecture'snode_online_mapis properly defined and initialized, so this additional bounds check is only to satisfy GCC.Signed-off-by Shawn Anastasio <[email protected]>
Quoted 28 lines
---
v2: Add comment to explain the bounds check.xen/common/page_alloc.c | 8 ++++++++ 1 file changed, 8 insertions(+)xen/common/page_alloc.c +8
-1@@ -1211,6 +1211,14 @@ static unsigned int node_to_scrub(bool get_node) }while ( !cpumask_empty (&node_to_cpumask (node)) && (node != local_node) ); +/* +* In practice `node` will always be within MAX_NUMNODES, but GCC can't +* always see that, so an explicit check is necessary to avoid tripping +* its out-of-bounds array access warning (-Warray-bounds). +*/ +if ( node >=MAX_NUMNODES ) +break ; +if ( node == local_node )break ; --2.30.2
Re: [PATCH v2 1/2] automation: Change build script to use arch defconfig
In reply to Andrew CooperQuoted 12 lines · Andrew Cooper
Quoted 11 lines · Shawn Anastasio
automation/scripts/build +2
-1@@ -22,7 +22,12 @@ if [[ "${RANDCONFIG}" == "y" ]]; then # RANDCONFIG implies HYPERVISOR_ONLY HYPERVISOR_ONLY="y" else - echo "CONFIG_DEBUG=${debug}" > xen/.config + # Start off with arch's defconfig + make -C xen defconfig
Quoted 8 lines
automation/scripts/build if [[ "${RANDCONFIG}" == "y" ]]; then · line 30
Quoted 4 lines
automation/scripts/build +4
-0+ + # Drop existing CONFIG_DEBUG and replace with value of ${debug} + sed -i 's/^CONFIG_DEBUG=[yn]//g' xen/.config + echo "CONFIG_DEBUG=${debug}" >> xen/.config
Kconfigis latest-takes precedence, which is why we always append for this and the other related options. There's no need for sed to drop the old value.
+1
Re: [PATCH v2 1/2] automation: Change build script to use arch defconfig
In reply to Andrew CooperQuoted 12 lines · Andrew Cooper
Quoted 11 lines · Shawn Anastasio
automation/scripts/build +2
-1@@ -22,7 +22,12 @@ if [[ "${RANDCONFIG}" == "y" ]]; then # RANDCONFIG implies HYPERVISOR_ONLY HYPERVISOR_ONLY="y" else - echo "CONFIG_DEBUG=${debug}" > xen/.config + # Start off with arch's defconfig + make -C xen defconfig
Quoted 9 lines
automation/scripts/build if [[ "${RANDCONFIG}" == "y" ]]; then · line 30
Quoted 4 lines
automation/scripts/build +4
-0+ + # Drop existing CONFIG_DEBUG and replace with value of ${debug} + sed -i 's/^CONFIG_DEBUG=[yn]//g' xen/.config + echo "CONFIG_DEBUG=${debug}" >> xen/.config
Kconfigis latest-takes precedence, which is why we always append for this and the other related options. There's no need for sed to drop the old value.
Thank you for the confirmation. I'll go ahead and drop the sed.
Quoted 1 line
~Andrew
Thanks,
Shawn
Re: [PATCH v2 2/2] xen/common: Add NUMA node id bounds check to page_alloc.c/node_to_scrub
In reply to Andrew CooperQuoted 32 lines · Andrew Cooper
Quoted 8 lines · Shawn Anastasio
When building for Power with
CONFIG_DEBUGunset, a compiler error gets raised inside page_alloc.c'snode_to_scrubfunction:
common/page_alloc.c: In function 'node_to_scrub.part.0':common/page_alloc.c:1217:29: error: array subscript 1 is above array
bounds of 'long unsigned int[1]' [-Werror=array-bounds]
1217 | if ( node_need_scrub[node] )Quoted 4 lines
It appears that this is a false positive, given that in practice
cycle_nodeshould never return a node ID >=MAX_NUMNODESas long as the architecture'snode_online_mapis properly defined and initialized, so this additional bounds check is only to satisfy GCC.If GCC thinks it's got an index of 1 here, then it thinks it's proved that a 1 gets passed. But the fact that
cycle_node()really can return 1 if one variable gets tweaked in memory means that logic derived on this property is broken.But we've got even more basic problems to fix first.
xen$ git grep -B1 '
__read_mostlynode_online_map'arch/arm/smpboot.c-45-/*Fake one node for now. See alsoasm/numa.h*/ arch/arm/smpboot.c:46:nodemask_t__read_mostlynode_online_map= { { [0] = 1UL } };arch/ppc/stubs.c-25-
arch/ppc/stubs.c:26:nodemask_t__read_mostlynode_online_map= { { [0] = 1UL } };
common/numa.c-44-
common/numa.c:45:nodemask_t__read_mostlynode_online_map= { { [0] = 1UL } };
Quoted 9 lines
There are 3 identical definitions of
node_online_map, one for the architecture which really supports NUMA, and two for the stubs which don't.And the bug here is that code outside of
CONFIG_NUMAassumes NUMA is valid, including several places inpage_alloc.c,domain_set_node_affinity(), credit1 and sysctl.XEN_SYSCTL_numainfoeven has a bigger sin of using a staticMAX_NUMNODESarray when it doesn't need an array in the first place.
Agreed. It seems like the current state of affairs resulted from hacks in Arm to work around NUMA assumptions in common instead of properly making common support !CONFIG_NUMA. And now ppc is inheriting some of that baggage.
Quoted 7 lines
It's rude for
xen/nodemask.hto short circuit some of the operations onnode_online_mapbased onMAX_NUMNODESbut not others.If nothing else, the fallback for "not really NUMA" needs providing by the common code and not by the arch stubs. When that is sorted, we might have more consistent behaviour to investigate.
I'll leave these more sweeping changes up to someone with a bit more familiarity with this code for now. In the meantime, this patch at should introduce no functional change to the status quo and allows ppc to build in the interim.
Quoted 1 line
~Andrew
Thanks,
Shawn