2021-09-16 08:44:23

by Geert Uytterhoeven

[permalink] [raw]
Subject: [PATCH 0/2] Fix NUMA without SMP

Hi all,

SuperH is the only architecture which still supports NUMA without SMP,
for good reasons (various memories scattered around the address space,
each with varying latencies). This series fixes two build errors due to
variables and functions used by the NUMA code being provided by SMP-only
source files or sections.

These are compile-tested only, as the remote Migo-R is MIA.

Thanks for your comments!

Geert Uytterhoeven (2):
mm: Move node_reclaim_distance to fix NUMA without SMP
mm: Move fold_vm_numa_events() to fix NUMA without SMP

kernel/sched/topology.c | 1 -
mm/page_alloc.c | 2 ++
mm/vmstat.c | 56 ++++++++++++++++++++---------------------
3 files changed, 30 insertions(+), 29 deletions(-)

--
2.25.1

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


2021-09-16 08:44:49

by Geert Uytterhoeven

[permalink] [raw]
Subject: [PATCH 1/2] mm: Move node_reclaim_distance to fix NUMA without SMP

If CONFIG_NUMA=y, but CONFIG_SMP=n (e.g. sh/migor_defconfig):

sh4-linux-gnu-ld: mm/page_alloc.o: in function `get_page_from_freelist':
page_alloc.c:(.text+0x2c24): undefined reference to `node_reclaim_distance'

Fix this by moving the declaration of node_reclaim_distance from an
SMP-only to a generic file.

Fixes: a55c7454a8c887b2 ("sched/topology: Improve load balancing on AMD EPYC systems")
Suggested-by: Matt Fleming <[email protected]>
Signed-off-by: Geert Uytterhoeven <[email protected]>
---
kernel/sched/topology.c | 1 -
mm/page_alloc.c | 2 ++
2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
index 4e8698e62f0754a3..738ee7fa79724c7d 100644
--- a/kernel/sched/topology.c
+++ b/kernel/sched/topology.c
@@ -1481,7 +1481,6 @@ static int sched_domains_curr_level;
int sched_max_numa_distance;
static int *sched_domains_numa_distance;
static struct cpumask ***sched_domains_numa_masks;
-int __read_mostly node_reclaim_distance = RECLAIM_DISTANCE;

static unsigned long __read_mostly *sched_numa_onlined_nodes;
#endif
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index b37435c274cf1cb1..8b2d7a9bae6c1754 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -3966,6 +3966,8 @@ bool zone_watermark_ok_safe(struct zone *z, unsigned int order,
}

#ifdef CONFIG_NUMA
+int __read_mostly node_reclaim_distance = RECLAIM_DISTANCE;
+
static bool zone_allows_reclaim(struct zone *local_zone, struct zone *zone)
{
return node_distance(zone_to_nid(local_zone), zone_to_nid(zone)) <=
--
2.25.1

2021-09-16 08:45:09

by Geert Uytterhoeven

[permalink] [raw]
Subject: [PATCH 2/2] mm: Move fold_vm_numa_events() to fix NUMA without SMP

If CONFIG_NUMA=y, but CONFIG_SMP=n (e.g. sh/migor_defconfig):

sh4-linux-gnu-ld: mm/vmstat.o: in function `vmstat_start':
vmstat.c:(.text+0x97c): undefined reference to `fold_vm_numa_events'
sh4-linux-gnu-ld: drivers/base/node.o: in function `node_read_vmstat':
node.c:(.text+0x140): undefined reference to `fold_vm_numa_events'
sh4-linux-gnu-ld: drivers/base/node.o: in function `node_read_numastat':
node.c:(.text+0x1d0): undefined reference to `fold_vm_numa_events'

Fix this by moving fold_vm_numa_events() outside the SMP-only section.

Fixes: f19298b9516c1a03 ("mm/vmstat: convert NUMA statistics to basic NUMA counters")
Signed-off-by: Geert Uytterhoeven <[email protected]>
---
mm/vmstat.c | 56 ++++++++++++++++++++++++++---------------------------
1 file changed, 28 insertions(+), 28 deletions(-)

diff --git a/mm/vmstat.c b/mm/vmstat.c
index 8ce2620344b2f8b4..5db54581feab9ac9 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -165,6 +165,34 @@ atomic_long_t vm_numa_event[NR_VM_NUMA_EVENT_ITEMS] __cacheline_aligned_in_smp;
EXPORT_SYMBOL(vm_zone_stat);
EXPORT_SYMBOL(vm_node_stat);

+#ifdef CONFIG_NUMA
+static void fold_vm_zone_numa_events(struct zone *zone)
+{
+ unsigned long zone_numa_events[NR_VM_NUMA_EVENT_ITEMS] = { 0, };
+ int cpu;
+ enum numa_stat_item item;
+
+ for_each_online_cpu(cpu) {
+ struct per_cpu_zonestat *pzstats;
+
+ pzstats = per_cpu_ptr(zone->per_cpu_zonestats, cpu);
+ for (item = 0; item < NR_VM_NUMA_EVENT_ITEMS; item++)
+ zone_numa_events[item] += xchg(&pzstats->vm_numa_event[item], 0);
+ }
+
+ for (item = 0; item < NR_VM_NUMA_EVENT_ITEMS; item++)
+ zone_numa_event_add(zone_numa_events[item], zone, item);
+}
+
+void fold_vm_numa_events(void)
+{
+ struct zone *zone;
+
+ for_each_populated_zone(zone)
+ fold_vm_zone_numa_events(zone);
+}
+#endif
+
#ifdef CONFIG_SMP

int calculate_pressure_threshold(struct zone *zone)
@@ -771,34 +799,6 @@ static int fold_diff(int *zone_diff, int *node_diff)
return changes;
}

-#ifdef CONFIG_NUMA
-static void fold_vm_zone_numa_events(struct zone *zone)
-{
- unsigned long zone_numa_events[NR_VM_NUMA_EVENT_ITEMS] = { 0, };
- int cpu;
- enum numa_stat_item item;
-
- for_each_online_cpu(cpu) {
- struct per_cpu_zonestat *pzstats;
-
- pzstats = per_cpu_ptr(zone->per_cpu_zonestats, cpu);
- for (item = 0; item < NR_VM_NUMA_EVENT_ITEMS; item++)
- zone_numa_events[item] += xchg(&pzstats->vm_numa_event[item], 0);
- }
-
- for (item = 0; item < NR_VM_NUMA_EVENT_ITEMS; item++)
- zone_numa_event_add(zone_numa_events[item], zone, item);
-}
-
-void fold_vm_numa_events(void)
-{
- struct zone *zone;
-
- for_each_populated_zone(zone)
- fold_vm_zone_numa_events(zone);
-}
-#endif
-
/*
* Update the zone counters for the current cpu.
*
--
2.25.1

2021-09-21 12:35:20

by Mel Gorman

[permalink] [raw]
Subject: Re: [PATCH 1/2] mm: Move node_reclaim_distance to fix NUMA without SMP

On Thu, Sep 16, 2021 at 10:42:42AM +0200, Geert Uytterhoeven wrote:
> If CONFIG_NUMA=y, but CONFIG_SMP=n (e.g. sh/migor_defconfig):
>
> sh4-linux-gnu-ld: mm/page_alloc.o: in function `get_page_from_freelist':
> page_alloc.c:(.text+0x2c24): undefined reference to `node_reclaim_distance'
>
> Fix this by moving the declaration of node_reclaim_distance from an
> SMP-only to a generic file.
>
> Fixes: a55c7454a8c887b2 ("sched/topology: Improve load balancing on AMD EPYC systems")
> Suggested-by: Matt Fleming <[email protected]>
> Signed-off-by: Geert Uytterhoeven <[email protected]>

Acked-by: Mel Gorman <[email protected]>

--
Mel Gorman
SUSE Labs

2021-09-21 12:35:44

by Mel Gorman

[permalink] [raw]
Subject: Re: [PATCH 2/2] mm: Move fold_vm_numa_events() to fix NUMA without SMP

On Thu, Sep 16, 2021 at 10:42:43AM +0200, Geert Uytterhoeven wrote:
> If CONFIG_NUMA=y, but CONFIG_SMP=n (e.g. sh/migor_defconfig):
>
> sh4-linux-gnu-ld: mm/vmstat.o: in function `vmstat_start':
> vmstat.c:(.text+0x97c): undefined reference to `fold_vm_numa_events'
> sh4-linux-gnu-ld: drivers/base/node.o: in function `node_read_vmstat':
> node.c:(.text+0x140): undefined reference to `fold_vm_numa_events'
> sh4-linux-gnu-ld: drivers/base/node.o: in function `node_read_numastat':
> node.c:(.text+0x1d0): undefined reference to `fold_vm_numa_events'
>
> Fix this by moving fold_vm_numa_events() outside the SMP-only section.
>
> Fixes: f19298b9516c1a03 ("mm/vmstat: convert NUMA statistics to basic NUMA counters")
> Signed-off-by: Geert Uytterhoeven <[email protected]>

Acked-by: Mel Gorman <[email protected]>

--
Mel Gorman
SUSE Labs