mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-26 05:35:13 +07:00
1a59d1b8e0
Based on 1 normalized pattern(s): this program is free software you can redistribute it and or modify it under the terms of the gnu general public license as published by the free software foundation either version 2 of the license or at your option any later version this program is distributed in the hope that it will be useful but without any warranty without even the implied warranty of merchantability or fitness for a particular purpose see the gnu general public license for more details you should have received a copy of the gnu general public license along with this program if not write to the free software foundation inc 59 temple place suite 330 boston ma 02111 1307 usa extracted by the scancode license scanner the SPDX license identifier GPL-2.0-or-later has been chosen to replace the boilerplate/reference in 1334 file(s). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Allison Randal <allison@lohutok.net> Reviewed-by: Richard Fontana <rfontana@redhat.com> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190527070033.113240726@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
74 lines
1.8 KiB
C
74 lines
1.8 KiB
C
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
/*
|
|
*
|
|
* ia64 kernel NUMA specific stuff
|
|
*
|
|
* Copyright (C) 2002 Erich Focht <efocht@ess.nec.de>
|
|
* Copyright (C) 2004 Silicon Graphics, Inc.
|
|
* Jesse Barnes <jbarnes@sgi.com>
|
|
*/
|
|
#include <linux/topology.h>
|
|
#include <linux/module.h>
|
|
#include <asm/processor.h>
|
|
#include <asm/smp.h>
|
|
|
|
u16 cpu_to_node_map[NR_CPUS] __cacheline_aligned;
|
|
EXPORT_SYMBOL(cpu_to_node_map);
|
|
|
|
cpumask_t node_to_cpu_mask[MAX_NUMNODES] __cacheline_aligned;
|
|
EXPORT_SYMBOL(node_to_cpu_mask);
|
|
|
|
void map_cpu_to_node(int cpu, int nid)
|
|
{
|
|
int oldnid;
|
|
if (nid < 0) { /* just initialize by zero */
|
|
cpu_to_node_map[cpu] = 0;
|
|
return;
|
|
}
|
|
/* sanity check first */
|
|
oldnid = cpu_to_node_map[cpu];
|
|
if (cpumask_test_cpu(cpu, &node_to_cpu_mask[oldnid])) {
|
|
return; /* nothing to do */
|
|
}
|
|
/* we don't have cpu-driven node hot add yet...
|
|
In usual case, node is created from SRAT at boot time. */
|
|
if (!node_online(nid))
|
|
nid = first_online_node;
|
|
cpu_to_node_map[cpu] = nid;
|
|
cpumask_set_cpu(cpu, &node_to_cpu_mask[nid]);
|
|
return;
|
|
}
|
|
|
|
void unmap_cpu_from_node(int cpu, int nid)
|
|
{
|
|
WARN_ON(!cpumask_test_cpu(cpu, &node_to_cpu_mask[nid]));
|
|
WARN_ON(cpu_to_node_map[cpu] != nid);
|
|
cpu_to_node_map[cpu] = 0;
|
|
cpumask_clear_cpu(cpu, &node_to_cpu_mask[nid]);
|
|
}
|
|
|
|
|
|
/**
|
|
* build_cpu_to_node_map - setup cpu to node and node to cpumask arrays
|
|
*
|
|
* Build cpu to node mapping and initialize the per node cpu masks using
|
|
* info from the node_cpuid array handed to us by ACPI.
|
|
*/
|
|
void __init build_cpu_to_node_map(void)
|
|
{
|
|
int cpu, i, node;
|
|
|
|
for(node=0; node < MAX_NUMNODES; node++)
|
|
cpumask_clear(&node_to_cpu_mask[node]);
|
|
|
|
for_each_possible_early_cpu(cpu) {
|
|
node = NUMA_NO_NODE;
|
|
for (i = 0; i < NR_CPUS; ++i)
|
|
if (cpu_physical_id(cpu) == node_cpuid[i].phys_id) {
|
|
node = node_cpuid[i].nid;
|
|
break;
|
|
}
|
|
map_cpu_to_node(cpu, node);
|
|
}
|
|
}
|