License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 22:07:57 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2000, 2003 Silicon Graphics, Inc. All rights reserved.
|
|
|
|
* Copyright (c) 2001 Intel Corp.
|
|
|
|
* Copyright (c) 2001 Tony Luck <tony.luck@intel.com>
|
|
|
|
* Copyright (c) 2002 NEC Corp.
|
|
|
|
* Copyright (c) 2002 Kimio Suganuma <k-suganuma@da.jp.nec.com>
|
|
|
|
* Copyright (c) 2004 Silicon Graphics, Inc
|
|
|
|
* Russ Anderson <rja@sgi.com>
|
|
|
|
* Jesse Barnes <jbarnes@sgi.com>
|
|
|
|
* Jack Steiner <steiner@sgi.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Platform initialization for Discontig Memory
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/mm.h>
|
2007-08-23 02:34:38 +08:00
|
|
|
#include <linux/nmi.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/swap.h>
|
2018-07-23 13:56:58 +08:00
|
|
|
#include <linux/memblock.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/acpi.h>
|
|
|
|
#include <linux/efi.h>
|
|
|
|
#include <linux/nodemask.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <asm/pgalloc.h>
|
|
|
|
#include <asm/tlb.h>
|
|
|
|
#include <asm/meminit.h>
|
|
|
|
#include <asm/numa.h>
|
|
|
|
#include <asm/sections.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Track per-node information needed to setup the boot memory allocator, the
|
|
|
|
* per-node areas, and the real VM.
|
|
|
|
*/
|
|
|
|
struct early_node_data {
|
|
|
|
struct ia64_node_data *node_data;
|
|
|
|
unsigned long pernode_addr;
|
|
|
|
unsigned long pernode_size;
|
|
|
|
unsigned long min_pfn;
|
|
|
|
unsigned long max_pfn;
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct early_node_data mem_data[MAX_NUMNODES] __initdata;
|
2005-07-01 00:52:00 +08:00
|
|
|
static nodemask_t memory_less_mask __initdata;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-17 14:27:27 +08:00
|
|
|
pg_data_t *pgdat_list[MAX_NUMNODES];
|
2006-06-27 17:53:38 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* To prevent cache aliasing effects, align per-node structures so that they
|
|
|
|
* start at addresses that are strided by node number.
|
|
|
|
*/
|
2005-12-06 03:56:50 +08:00
|
|
|
#define MAX_NODE_ALIGN_OFFSET (32 * 1024 * 1024)
|
2005-04-17 06:20:36 +08:00
|
|
|
#define NODEDATA_ALIGN(addr, node) \
|
2005-12-06 03:56:50 +08:00
|
|
|
((((addr) + 1024*1024-1) & ~(1024*1024-1)) + \
|
|
|
|
(((node)*PERCPU_PAGE_SIZE) & (MAX_NODE_ALIGN_OFFSET - 1)))
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/**
|
2018-07-23 13:56:57 +08:00
|
|
|
* build_node_maps - callback to setup mem_data structs for each node
|
2005-04-17 06:20:36 +08:00
|
|
|
* @start: physical start of range
|
|
|
|
* @len: length of range
|
|
|
|
* @node: node where this range resides
|
|
|
|
*
|
2018-07-23 13:56:57 +08:00
|
|
|
* Detect extents of each piece of memory that we wish to
|
2005-04-17 06:20:36 +08:00
|
|
|
* treat as a virtually contiguous block (i.e. each node). Each such block
|
|
|
|
* must start on an %IA64_GRANULE_SIZE boundary, so we round the address down
|
|
|
|
* if necessary. Any non-existent pages will simply be part of the virtual
|
2018-07-23 13:56:57 +08:00
|
|
|
* memmap.
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
|
|
|
static int __init build_node_maps(unsigned long start, unsigned long len,
|
|
|
|
int node)
|
|
|
|
{
|
2008-07-24 12:28:09 +08:00
|
|
|
unsigned long spfn, epfn, end = start + len;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
epfn = GRANULEROUNDUP(end) >> PAGE_SHIFT;
|
2008-07-24 12:28:09 +08:00
|
|
|
spfn = GRANULEROUNDDOWN(start) >> PAGE_SHIFT;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2018-07-23 13:56:57 +08:00
|
|
|
if (!mem_data[node].min_pfn) {
|
|
|
|
mem_data[node].min_pfn = spfn;
|
|
|
|
mem_data[node].max_pfn = epfn;
|
2005-04-17 06:20:36 +08:00
|
|
|
} else {
|
2018-07-23 13:56:57 +08:00
|
|
|
mem_data[node].min_pfn = min(spfn, mem_data[node].min_pfn);
|
|
|
|
mem_data[node].max_pfn = max(epfn, mem_data[node].max_pfn);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2005-07-01 00:52:00 +08:00
|
|
|
* early_nr_cpus_node - return number of cpus on a given node
|
2005-04-17 06:20:36 +08:00
|
|
|
* @node: node to check
|
|
|
|
*
|
2005-07-01 00:52:00 +08:00
|
|
|
* Count the number of cpus on @node. We can't use nr_cpus_node() yet because
|
2005-04-17 06:20:36 +08:00
|
|
|
* acpi_boot_init() (which builds the node_to_cpu_mask array) hasn't been
|
2005-07-01 00:52:00 +08:00
|
|
|
* called yet. Note that node 0 will also count all non-existent cpus.
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
2006-06-27 17:53:40 +08:00
|
|
|
static int __meminit early_nr_cpus_node(int node)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
int cpu, n = 0;
|
|
|
|
|
2008-04-04 04:17:13 +08:00
|
|
|
for_each_possible_early_cpu(cpu)
|
2005-04-17 06:20:36 +08:00
|
|
|
if (node == node_cpuid[cpu].nid)
|
2005-07-01 00:52:00 +08:00
|
|
|
n++;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
2005-07-01 00:52:00 +08:00
|
|
|
/**
|
|
|
|
* compute_pernodesize - compute size of pernode data
|
|
|
|
* @node: the node id.
|
|
|
|
*/
|
2006-06-27 17:53:40 +08:00
|
|
|
static unsigned long __meminit compute_pernodesize(int node)
|
2005-07-01 00:52:00 +08:00
|
|
|
{
|
|
|
|
unsigned long pernodesize = 0, cpus;
|
|
|
|
|
|
|
|
cpus = early_nr_cpus_node(node);
|
|
|
|
pernodesize += PERCPU_PAGE_SIZE * cpus;
|
|
|
|
pernodesize += node * L1_CACHE_BYTES;
|
|
|
|
pernodesize += L1_CACHE_ALIGN(sizeof(pg_data_t));
|
|
|
|
pernodesize += L1_CACHE_ALIGN(sizeof(struct ia64_node_data));
|
2008-04-04 04:17:12 +08:00
|
|
|
pernodesize += L1_CACHE_ALIGN(sizeof(pg_data_t));
|
2005-07-01 00:52:00 +08:00
|
|
|
pernodesize = PAGE_ALIGN(pernodesize);
|
|
|
|
return pernodesize;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-07-07 09:18:10 +08:00
|
|
|
/**
|
|
|
|
* per_cpu_node_setup - setup per-cpu areas on each node
|
|
|
|
* @cpu_data: per-cpu area on this node
|
|
|
|
* @node: node to setup
|
|
|
|
*
|
|
|
|
* Copy the static per-cpu data into the region we just set aside and then
|
|
|
|
* setup __per_cpu_offset for each CPU on this node. Return a pointer to
|
|
|
|
* the end of the area.
|
|
|
|
*/
|
|
|
|
static void *per_cpu_node_setup(void *cpu_data, int node)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
int cpu;
|
|
|
|
|
2008-04-04 04:17:13 +08:00
|
|
|
for_each_possible_early_cpu(cpu) {
|
2009-10-02 12:28:56 +08:00
|
|
|
void *src = cpu == 0 ? __cpu0_per_cpu : __phys_per_cpu_start;
|
|
|
|
|
|
|
|
if (node != node_cpuid[cpu].nid)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
memcpy(__va(cpu_data), src, __per_cpu_end - __per_cpu_start);
|
|
|
|
__per_cpu_offset[cpu] = (char *)__va(cpu_data) -
|
|
|
|
__per_cpu_start;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* percpu area for cpu0 is moved from the __init area
|
|
|
|
* which is setup by head.S and used till this point.
|
|
|
|
* Update ar.k3. This move is ensures that percpu
|
|
|
|
* area for cpu0 is on the correct node and its
|
|
|
|
* virtual address isn't insanely far from other
|
|
|
|
* percpu areas which is important for congruent
|
|
|
|
* percpu allocator.
|
|
|
|
*/
|
|
|
|
if (cpu == 0)
|
|
|
|
ia64_set_kr(IA64_KR_PER_CPU_DATA,
|
|
|
|
(unsigned long)cpu_data -
|
|
|
|
(unsigned long)__per_cpu_start);
|
|
|
|
|
|
|
|
cpu_data += PERCPU_PAGE_SIZE;
|
2005-07-07 09:18:10 +08:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return cpu_data;
|
|
|
|
}
|
|
|
|
|
2009-10-02 12:28:56 +08:00
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
/**
|
|
|
|
* setup_per_cpu_areas - setup percpu areas
|
|
|
|
*
|
|
|
|
* Arch code has already allocated and initialized percpu areas. All
|
|
|
|
* this function has to do is to teach the determined layout to the
|
|
|
|
* dynamic percpu allocator, which happens to be more complex than
|
|
|
|
* creating whole new ones using helpers.
|
|
|
|
*/
|
|
|
|
void __init setup_per_cpu_areas(void)
|
|
|
|
{
|
|
|
|
struct pcpu_alloc_info *ai;
|
|
|
|
struct pcpu_group_info *uninitialized_var(gi);
|
|
|
|
unsigned int *cpu_map;
|
|
|
|
void *base;
|
|
|
|
unsigned long base_offset;
|
|
|
|
unsigned int cpu;
|
|
|
|
ssize_t static_size, reserved_size, dyn_size;
|
|
|
|
int node, prev_node, unit, nr_units, rc;
|
|
|
|
|
|
|
|
ai = pcpu_alloc_alloc_info(MAX_NUMNODES, nr_cpu_ids);
|
|
|
|
if (!ai)
|
|
|
|
panic("failed to allocate pcpu_alloc_info");
|
|
|
|
cpu_map = ai->groups[0].cpu_map;
|
|
|
|
|
|
|
|
/* determine base */
|
|
|
|
base = (void *)ULONG_MAX;
|
|
|
|
for_each_possible_cpu(cpu)
|
|
|
|
base = min(base,
|
|
|
|
(void *)(__per_cpu_offset[cpu] + __per_cpu_start));
|
|
|
|
base_offset = (void *)__per_cpu_start - base;
|
|
|
|
|
|
|
|
/* build cpu_map, units are grouped by node */
|
|
|
|
unit = 0;
|
|
|
|
for_each_node(node)
|
|
|
|
for_each_possible_cpu(cpu)
|
|
|
|
if (node == node_cpuid[cpu].nid)
|
|
|
|
cpu_map[unit++] = cpu;
|
|
|
|
nr_units = unit;
|
|
|
|
|
|
|
|
/* set basic parameters */
|
|
|
|
static_size = __per_cpu_end - __per_cpu_start;
|
|
|
|
reserved_size = PERCPU_MODULE_RESERVE;
|
|
|
|
dyn_size = PERCPU_PAGE_SIZE - static_size - reserved_size;
|
|
|
|
if (dyn_size < 0)
|
|
|
|
panic("percpu area overflow static=%zd reserved=%zd\n",
|
|
|
|
static_size, reserved_size);
|
|
|
|
|
|
|
|
ai->static_size = static_size;
|
|
|
|
ai->reserved_size = reserved_size;
|
|
|
|
ai->dyn_size = dyn_size;
|
|
|
|
ai->unit_size = PERCPU_PAGE_SIZE;
|
|
|
|
ai->atom_size = PAGE_SIZE;
|
|
|
|
ai->alloc_size = PERCPU_PAGE_SIZE;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* CPUs are put into groups according to node. Walk cpu_map
|
|
|
|
* and create new groups at node boundaries.
|
|
|
|
*/
|
2019-03-06 07:42:58 +08:00
|
|
|
prev_node = NUMA_NO_NODE;
|
2009-10-02 12:28:56 +08:00
|
|
|
ai->nr_groups = 0;
|
|
|
|
for (unit = 0; unit < nr_units; unit++) {
|
|
|
|
cpu = cpu_map[unit];
|
|
|
|
node = node_cpuid[cpu].nid;
|
|
|
|
|
|
|
|
if (node == prev_node) {
|
|
|
|
gi->nr_units++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
prev_node = node;
|
|
|
|
|
|
|
|
gi = &ai->groups[ai->nr_groups++];
|
|
|
|
gi->nr_units = 1;
|
|
|
|
gi->base_offset = __per_cpu_offset[cpu] + base_offset;
|
|
|
|
gi->cpu_map = &cpu_map[unit];
|
|
|
|
}
|
|
|
|
|
2019-07-03 16:25:52 +08:00
|
|
|
pcpu_setup_first_chunk(ai, base);
|
2009-10-02 12:28:56 +08:00
|
|
|
pcpu_free_alloc_info(ai);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/**
|
2005-07-01 00:52:00 +08:00
|
|
|
* fill_pernode - initialize pernode data.
|
|
|
|
* @node: the node id.
|
|
|
|
* @pernode: physical address of pernode data
|
|
|
|
* @pernodesize: size of the pernode data
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
2005-07-01 00:52:00 +08:00
|
|
|
static void __init fill_pernode(int node, unsigned long pernode,
|
|
|
|
unsigned long pernodesize)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-07-01 00:52:00 +08:00
|
|
|
void *cpu_data;
|
2005-07-07 09:18:10 +08:00
|
|
|
int cpus = early_nr_cpus_node(node);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-07-01 00:52:00 +08:00
|
|
|
mem_data[node].pernode_addr = pernode;
|
|
|
|
mem_data[node].pernode_size = pernodesize;
|
|
|
|
memset(__va(pernode), 0, pernodesize);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-07-01 00:52:00 +08:00
|
|
|
cpu_data = (void *)pernode;
|
|
|
|
pernode += PERCPU_PAGE_SIZE * cpus;
|
|
|
|
pernode += node * L1_CACHE_BYTES;
|
|
|
|
|
2006-06-27 17:53:38 +08:00
|
|
|
pgdat_list[node] = __va(pernode);
|
2005-07-01 00:52:00 +08:00
|
|
|
pernode += L1_CACHE_ALIGN(sizeof(pg_data_t));
|
|
|
|
|
|
|
|
mem_data[node].node_data = __va(pernode);
|
|
|
|
pernode += L1_CACHE_ALIGN(sizeof(struct ia64_node_data));
|
|
|
|
pernode += L1_CACHE_ALIGN(sizeof(pg_data_t));
|
|
|
|
|
2005-07-07 09:18:10 +08:00
|
|
|
cpu_data = per_cpu_node_setup(cpu_data, node);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-07-01 00:52:00 +08:00
|
|
|
return;
|
|
|
|
}
|
2005-07-07 09:18:10 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/**
|
|
|
|
* find_pernode_space - allocate memory for memory map and per-node structures
|
|
|
|
* @start: physical start of range
|
|
|
|
* @len: length of range
|
|
|
|
* @node: node where this range resides
|
|
|
|
*
|
|
|
|
* This routine reserves space for the per-cpu data struct, the list of
|
|
|
|
* pg_data_ts and the per-node data struct. Each node will have something like
|
|
|
|
* the following in the first chunk of addr. space large enough to hold it.
|
|
|
|
*
|
|
|
|
* ________________________
|
|
|
|
* | |
|
|
|
|
* |~~~~~~~~~~~~~~~~~~~~~~~~| <-- NODEDATA_ALIGN(start, node) for the first
|
|
|
|
* | PERCPU_PAGE_SIZE * | start and length big enough
|
|
|
|
* | cpus_on_this_node | Node 0 will also have entries for all non-existent cpus.
|
|
|
|
* |------------------------|
|
|
|
|
* | local pg_data_t * |
|
|
|
|
* |------------------------|
|
|
|
|
* | local ia64_node_data |
|
|
|
|
* |------------------------|
|
|
|
|
* | ??? |
|
|
|
|
* |________________________|
|
|
|
|
*
|
|
|
|
* Once this space has been set aside, the bootmem maps are initialized. We
|
|
|
|
* could probably move the allocation of the per-cpu and ia64_node_data space
|
|
|
|
* outside of this function and use alloc_bootmem_node(), but doing it here
|
|
|
|
* is straightforward and we get the alignments we want so...
|
|
|
|
*/
|
|
|
|
static int __init find_pernode_space(unsigned long start, unsigned long len,
|
|
|
|
int node)
|
|
|
|
{
|
2008-07-24 12:28:09 +08:00
|
|
|
unsigned long spfn, epfn;
|
2018-07-23 13:56:58 +08:00
|
|
|
unsigned long pernodesize = 0, pernode;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-07-24 12:28:09 +08:00
|
|
|
spfn = start >> PAGE_SHIFT;
|
2005-04-17 06:20:36 +08:00
|
|
|
epfn = (start + len) >> PAGE_SHIFT;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Make sure this memory falls within this node's usable memory
|
|
|
|
* since we may have thrown some away in build_maps().
|
|
|
|
*/
|
2018-07-23 13:56:57 +08:00
|
|
|
if (spfn < mem_data[node].min_pfn || epfn > mem_data[node].max_pfn)
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* Don't setup this node's local space twice... */
|
|
|
|
if (mem_data[node].pernode_addr)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Calculate total size needed, incl. what's necessary
|
|
|
|
* for good alignment and alias prevention.
|
|
|
|
*/
|
2005-07-01 00:52:00 +08:00
|
|
|
pernodesize = compute_pernodesize(node);
|
2005-04-17 06:20:36 +08:00
|
|
|
pernode = NODEDATA_ALIGN(start, node);
|
|
|
|
|
|
|
|
/* Is this range big enough for what we want to store here? */
|
2018-07-23 13:56:58 +08:00
|
|
|
if (start + len > (pernode + pernodesize))
|
2005-07-01 00:52:00 +08:00
|
|
|
fill_pernode(node, pernode, pernodesize);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* reserve_pernode_space - reserve memory for per-node space
|
|
|
|
*
|
|
|
|
* Reserve the space used by the bootmem maps & per-node space in the boot
|
|
|
|
* allocator so that when we actually create the real mem maps we don't
|
|
|
|
* use their memory.
|
|
|
|
*/
|
|
|
|
static void __init reserve_pernode_space(void)
|
|
|
|
{
|
2018-07-23 13:56:58 +08:00
|
|
|
unsigned long base, size;
|
2005-04-17 06:20:36 +08:00
|
|
|
int node;
|
|
|
|
|
|
|
|
for_each_online_node(node) {
|
2005-07-01 00:52:00 +08:00
|
|
|
if (node_isset(node, memory_less_mask))
|
|
|
|
continue;
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Now the per-node space */
|
|
|
|
size = mem_data[node].pernode_size;
|
|
|
|
base = __pa(mem_data[node].pernode_addr);
|
2018-07-23 13:56:58 +08:00
|
|
|
memblock_reserve(base, size);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
[PATCH] pgdat allocation and update for ia64 of memory hotplug: update pgdat address array
This is to refresh node_data[] array for ia64. As I mentioned previous
patches, ia64 has copies of information of pgdat address array on each node as
per node data.
At v2 of node_add, this function used stop_machine_run() to update them. (I
wished that they were copied safety as much as possible.) But, in this patch,
this arrays are just copied simply, and set node_online_map bit after
completion of pgdat initialization.
So, kernel must touch NODE_DATA() macro after checking node_online_map().
(Current code has already done it.) This is more simple way for just
hot-add.....
Note : It will be problem when hot-remove will occur,
because, even if online_map bit is set, kernel may
touch NODE_DATA() due to race condition. :-(
Signed-off-by: Yasunori Goto <y-goto@jp.fujitsu.com>
Cc: "Luck, Tony" <tony.luck@intel.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-06-27 17:53:39 +08:00
|
|
|
static void __meminit scatter_node_data(void)
|
|
|
|
{
|
|
|
|
pg_data_t **dst;
|
|
|
|
int node;
|
|
|
|
|
2006-07-04 17:57:51 +08:00
|
|
|
/*
|
|
|
|
* for_each_online_node() can't be used at here.
|
|
|
|
* node_online_map is not set for hot-added nodes at this time,
|
|
|
|
* because we are halfway through initialization of the new node's
|
|
|
|
* structures. If for_each_online_node() is used, a new node's
|
2007-05-12 05:55:43 +08:00
|
|
|
* pg_data_ptrs will be not initialized. Instead of using it,
|
2006-07-04 17:57:51 +08:00
|
|
|
* pgdat_list[] is checked.
|
|
|
|
*/
|
|
|
|
for_each_node(node) {
|
|
|
|
if (pgdat_list[node]) {
|
|
|
|
dst = LOCAL_DATA_ADDR(pgdat_list[node])->pg_data_ptrs;
|
|
|
|
memcpy(dst, pgdat_list, sizeof(pgdat_list));
|
|
|
|
}
|
[PATCH] pgdat allocation and update for ia64 of memory hotplug: update pgdat address array
This is to refresh node_data[] array for ia64. As I mentioned previous
patches, ia64 has copies of information of pgdat address array on each node as
per node data.
At v2 of node_add, this function used stop_machine_run() to update them. (I
wished that they were copied safety as much as possible.) But, in this patch,
this arrays are just copied simply, and set node_online_map bit after
completion of pgdat initialization.
So, kernel must touch NODE_DATA() macro after checking node_online_map().
(Current code has already done it.) This is more simple way for just
hot-add.....
Note : It will be problem when hot-remove will occur,
because, even if online_map bit is set, kernel may
touch NODE_DATA() due to race condition. :-(
Signed-off-by: Yasunori Goto <y-goto@jp.fujitsu.com>
Cc: "Luck, Tony" <tony.luck@intel.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-06-27 17:53:39 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/**
|
|
|
|
* initialize_pernode_data - fixup per-cpu & per-node pointers
|
|
|
|
*
|
|
|
|
* Each node's per-node area has a copy of the global pg_data_t list, so
|
|
|
|
* we copy that to each node here, as well as setting the per-cpu pointer
|
2019-08-13 15:25:02 +08:00
|
|
|
* to the local node data structure.
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
|
|
|
static void __init initialize_pernode_data(void)
|
|
|
|
{
|
2005-07-07 09:18:10 +08:00
|
|
|
int cpu, node;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
[PATCH] pgdat allocation and update for ia64 of memory hotplug: update pgdat address array
This is to refresh node_data[] array for ia64. As I mentioned previous
patches, ia64 has copies of information of pgdat address array on each node as
per node data.
At v2 of node_add, this function used stop_machine_run() to update them. (I
wished that they were copied safety as much as possible.) But, in this patch,
this arrays are just copied simply, and set node_online_map bit after
completion of pgdat initialization.
So, kernel must touch NODE_DATA() macro after checking node_online_map().
(Current code has already done it.) This is more simple way for just
hot-add.....
Note : It will be problem when hot-remove will occur,
because, even if online_map bit is set, kernel may
touch NODE_DATA() due to race condition. :-(
Signed-off-by: Yasunori Goto <y-goto@jp.fujitsu.com>
Cc: "Luck, Tony" <tony.luck@intel.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-06-27 17:53:39 +08:00
|
|
|
scatter_node_data();
|
|
|
|
|
2005-07-07 09:18:10 +08:00
|
|
|
#ifdef CONFIG_SMP
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Set the node_data pointer for each per-cpu struct */
|
2008-04-04 04:17:13 +08:00
|
|
|
for_each_possible_early_cpu(cpu) {
|
2005-04-17 06:20:36 +08:00
|
|
|
node = node_cpuid[cpu].nid;
|
2009-10-29 21:34:14 +08:00
|
|
|
per_cpu(ia64_cpu_info, cpu).node_data =
|
|
|
|
mem_data[node].node_data;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2005-07-07 09:18:10 +08:00
|
|
|
#else
|
|
|
|
{
|
|
|
|
struct cpuinfo_ia64 *cpu0_cpu_info;
|
|
|
|
cpu = 0;
|
|
|
|
node = node_cpuid[cpu].nid;
|
|
|
|
cpu0_cpu_info = (struct cpuinfo_ia64 *)(__phys_per_cpu_start +
|
2009-10-29 21:34:15 +08:00
|
|
|
((char *)&ia64_cpu_info - __per_cpu_start));
|
2005-07-07 09:18:10 +08:00
|
|
|
cpu0_cpu_info->node_data = mem_data[node].node_data;
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_SMP */
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2005-07-01 00:52:00 +08:00
|
|
|
/**
|
|
|
|
* memory_less_node_alloc - * attempt to allocate memory on the best NUMA slit
|
|
|
|
* node but fall back to any other node when __alloc_bootmem_node fails
|
|
|
|
* for best.
|
|
|
|
* @nid: node id
|
|
|
|
* @pernodesize: size of this node's pernode data
|
|
|
|
*/
|
2005-10-30 05:23:05 +08:00
|
|
|
static void __init *memory_less_node_alloc(int nid, unsigned long pernodesize)
|
2005-07-01 00:52:00 +08:00
|
|
|
{
|
|
|
|
void *ptr = NULL;
|
|
|
|
u8 best = 0xff;
|
2019-03-06 07:42:58 +08:00
|
|
|
int bestnode = NUMA_NO_NODE, node, anynode = 0;
|
2005-07-01 00:52:00 +08:00
|
|
|
|
|
|
|
for_each_online_node(node) {
|
|
|
|
if (node_isset(node, memory_less_mask))
|
|
|
|
continue;
|
|
|
|
else if (node_distance(nid, node) < best) {
|
|
|
|
best = node_distance(nid, node);
|
|
|
|
bestnode = node;
|
|
|
|
}
|
2005-10-30 05:23:05 +08:00
|
|
|
anynode = node;
|
2005-07-01 00:52:00 +08:00
|
|
|
}
|
|
|
|
|
2019-03-06 07:42:58 +08:00
|
|
|
if (bestnode == NUMA_NO_NODE)
|
2005-10-30 05:23:05 +08:00
|
|
|
bestnode = anynode;
|
|
|
|
|
2018-10-31 06:08:45 +08:00
|
|
|
ptr = memblock_alloc_try_nid(pernodesize, PERCPU_PAGE_SIZE,
|
|
|
|
__pa(MAX_DMA_ADDRESS),
|
2018-10-31 06:09:44 +08:00
|
|
|
MEMBLOCK_ALLOC_ACCESSIBLE,
|
2018-10-31 06:08:45 +08:00
|
|
|
bestnode);
|
2019-03-12 14:30:00 +08:00
|
|
|
if (!ptr)
|
|
|
|
panic("%s: Failed to allocate %lu bytes align=0x%lx nid=%d from=%lx\n",
|
|
|
|
__func__, pernodesize, PERCPU_PAGE_SIZE, bestnode,
|
|
|
|
__pa(MAX_DMA_ADDRESS));
|
2005-07-01 00:52:00 +08:00
|
|
|
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* memory_less_nodes - allocate and initialize CPU only nodes pernode
|
|
|
|
* information.
|
|
|
|
*/
|
|
|
|
static void __init memory_less_nodes(void)
|
|
|
|
{
|
|
|
|
unsigned long pernodesize;
|
|
|
|
void *pernode;
|
|
|
|
int node;
|
|
|
|
|
|
|
|
for_each_node_mask(node, memory_less_mask) {
|
|
|
|
pernodesize = compute_pernodesize(node);
|
2005-10-30 05:23:05 +08:00
|
|
|
pernode = memory_less_node_alloc(node, pernodesize);
|
2005-07-01 00:52:00 +08:00
|
|
|
fill_pernode(node, __pa(pernode), pernodesize);
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/**
|
|
|
|
* find_memory - walk the EFI memory map and setup the bootmem allocator
|
|
|
|
*
|
|
|
|
* Called early in boot to setup the bootmem allocator, and to
|
|
|
|
* allocate the per-cpu and per-node structures.
|
|
|
|
*/
|
|
|
|
void __init find_memory(void)
|
|
|
|
{
|
|
|
|
int node;
|
|
|
|
|
|
|
|
reserve_memory();
|
2018-07-23 13:56:58 +08:00
|
|
|
efi_memmap_walk(filter_memory, register_active_ranges);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (num_online_nodes() == 0) {
|
|
|
|
printk(KERN_ERR "node info missing!\n");
|
|
|
|
node_set_online(0);
|
|
|
|
}
|
|
|
|
|
2005-07-01 00:52:00 +08:00
|
|
|
nodes_or(memory_less_mask, memory_less_mask, node_online_map);
|
2005-04-17 06:20:36 +08:00
|
|
|
min_low_pfn = -1;
|
|
|
|
max_low_pfn = 0;
|
|
|
|
|
|
|
|
/* These actually end up getting called by call_pernode_memory() */
|
|
|
|
efi_memmap_walk(filter_rsvd_memory, build_node_maps);
|
|
|
|
efi_memmap_walk(filter_rsvd_memory, find_pernode_space);
|
[IA64] min_low_pfn and max_low_pfn calculation fix
We have seen bad_pte_print when testing crashdump on an SN machine in
recent 2.6.20 kernel. There are tons of bad pte print (pfn < max_low_pfn)
reports when the crash kernel boots up, all those reported bad pages
are inside initmem range; That is because if the crash kernel code and
data happens to be at the beginning of the 1st node. build_node_maps in
discontig.c will bypass reserved regions with filter_rsvd_memory. Since
min_low_pfn is calculated in build_node_map, so in this case, min_low_pfn
will be greater than kernel code and data.
Because pages inside initmem are freed and reused later, we saw
pfn_valid check fail on those pages.
I think this theoretically happen on a normal kernel. When I check
min_low_pfn and max_low_pfn calculation in contig.c and discontig.c.
I found more issues than this.
1. min_low_pfn and max_low_pfn calculation is inconsistent between
contig.c and discontig.c,
min_low_pfn is calculated as the first page number of boot memmap in
contig.c (Why? Though this may work at the most of the time, I don't
think it is the right logic). It is calculated as the lowest physical
memory page number bypass reserved regions in discontig.c.
max_low_pfn is calculated include reserved regions in contig.c. It is
calculated exclude reserved regions in discontig.c.
2. If kernel code and data region is happen to be at the begin or the
end of physical memory, when min_low_pfn and max_low_pfn calculation is
bypassed kernel code and data, pages in initmem will report bad.
3. initrd is also in reserved regions, if it is at the begin or at the
end of physical memory, kernel will refuse to reuse the memory. Because
the virt_addr_valid check in free_initrd_mem.
So it is better to fix and clean up those issues.
Calculate min_low_pfn and max_low_pfn in a consistent way.
Signed-off-by: Zou Nan hai <nanhai.zou@intel.com>
Acked-by: Jay Lan <jlan@sgi.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>
2007-03-21 04:41:57 +08:00
|
|
|
efi_memmap_walk(find_max_min_low_pfn, NULL);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-07-01 00:52:00 +08:00
|
|
|
for_each_online_node(node)
|
2018-07-23 13:56:57 +08:00
|
|
|
if (mem_data[node].min_pfn)
|
2005-07-01 00:52:00 +08:00
|
|
|
node_clear(node, memory_less_mask);
|
2007-01-30 18:11:09 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
reserve_pernode_space();
|
2005-07-01 00:52:00 +08:00
|
|
|
memory_less_nodes();
|
2005-04-17 06:20:36 +08:00
|
|
|
initialize_pernode_data();
|
|
|
|
|
|
|
|
max_pfn = max_low_pfn;
|
|
|
|
|
|
|
|
find_initrd();
|
|
|
|
}
|
|
|
|
|
2005-07-07 09:18:10 +08:00
|
|
|
#ifdef CONFIG_SMP
|
2005-04-17 06:20:36 +08:00
|
|
|
/**
|
|
|
|
* per_cpu_init - setup per-cpu variables
|
|
|
|
*
|
|
|
|
* find_pernode_space() does most of this already, we just need to set
|
|
|
|
* local_per_cpu_offset
|
|
|
|
*/
|
2013-06-18 03:51:20 +08:00
|
|
|
void *per_cpu_init(void)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
int cpu;
|
2005-11-12 06:32:40 +08:00
|
|
|
static int first_time = 1;
|
|
|
|
|
|
|
|
if (first_time) {
|
|
|
|
first_time = 0;
|
2008-04-04 04:17:13 +08:00
|
|
|
for_each_possible_early_cpu(cpu)
|
2005-11-12 06:32:40 +08:00
|
|
|
per_cpu(local_per_cpu_offset, cpu) = __per_cpu_offset[cpu];
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
return __per_cpu_start + __per_cpu_offset[smp_processor_id()];
|
|
|
|
}
|
2005-07-07 09:18:10 +08:00
|
|
|
#endif /* CONFIG_SMP */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* call_pernode_memory - use SRAT to call callback functions with node info
|
|
|
|
* @start: physical start of range
|
|
|
|
* @len: length of range
|
|
|
|
* @arg: function to call for each range
|
|
|
|
*
|
|
|
|
* efi_memmap_walk() knows nothing about layout of memory across nodes. Find
|
|
|
|
* out to which node a block of memory belongs. Ignore memory that we cannot
|
|
|
|
* identify, and split blocks that run across multiple nodes.
|
|
|
|
*
|
|
|
|
* Take this opportunity to round the start address up and the end address
|
|
|
|
* down to page boundaries.
|
|
|
|
*/
|
|
|
|
void call_pernode_memory(unsigned long start, unsigned long len, void *arg)
|
|
|
|
{
|
|
|
|
unsigned long rs, re, end = start + len;
|
|
|
|
void (*func)(unsigned long, unsigned long, int);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
start = PAGE_ALIGN(start);
|
|
|
|
end &= PAGE_MASK;
|
|
|
|
if (start >= end)
|
|
|
|
return;
|
|
|
|
|
|
|
|
func = arg;
|
|
|
|
|
|
|
|
if (!num_node_memblks) {
|
|
|
|
/* No SRAT table, so assume one node (node 0) */
|
|
|
|
if (start < end)
|
|
|
|
(*func)(start, end - start, 0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < num_node_memblks; i++) {
|
|
|
|
rs = max(start, node_memblk[i].start_paddr);
|
|
|
|
re = min(end, node_memblk[i].start_paddr +
|
|
|
|
node_memblk[i].size);
|
|
|
|
|
|
|
|
if (rs < re)
|
|
|
|
(*func)(rs, re - rs, node_memblk[i].nid);
|
|
|
|
|
|
|
|
if (re == end)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* paging_init - setup page tables
|
|
|
|
*
|
|
|
|
* paging_init() sets up the page tables for each node of the system and frees
|
|
|
|
* the bootmem allocator memory for general use.
|
|
|
|
*/
|
|
|
|
void __init paging_init(void)
|
|
|
|
{
|
|
|
|
unsigned long max_dma;
|
|
|
|
unsigned long pfn_offset = 0;
|
2006-09-27 16:49:54 +08:00
|
|
|
unsigned long max_pfn = 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
int node;
|
2006-09-27 16:49:54 +08:00
|
|
|
unsigned long max_zone_pfns[MAX_NR_ZONES];
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
max_dma = virt_to_phys((void *) MAX_DMA_ADDRESS) >> PAGE_SHIFT;
|
|
|
|
|
2007-02-06 08:20:08 +08:00
|
|
|
sparse_memory_present_with_active_regions(MAX_NUMNODES);
|
|
|
|
sparse_init();
|
|
|
|
|
2005-10-05 03:13:57 +08:00
|
|
|
#ifdef CONFIG_VIRTUAL_MEM_MAP
|
2009-10-02 12:28:55 +08:00
|
|
|
VMALLOC_END -= PAGE_ALIGN(ALIGN(max_low_pfn, MAX_ORDER_NR_PAGES) *
|
2006-06-29 00:54:55 +08:00
|
|
|
sizeof(struct page));
|
2009-10-02 12:28:55 +08:00
|
|
|
vmem_map = (struct page *) VMALLOC_END;
|
2005-07-01 00:52:00 +08:00
|
|
|
efi_memmap_walk(create_mem_map_page_table, NULL);
|
|
|
|
printk("Virtual mem_map starts at 0x%p\n", vmem_map);
|
2005-10-05 03:13:57 +08:00
|
|
|
#endif
|
2005-07-01 00:52:00 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
for_each_online_node(node) {
|
|
|
|
pfn_offset = mem_data[node].min_pfn;
|
|
|
|
|
2005-10-05 03:13:57 +08:00
|
|
|
#ifdef CONFIG_VIRTUAL_MEM_MAP
|
2005-04-17 06:20:36 +08:00
|
|
|
NODE_DATA(node)->node_mem_map = vmem_map + pfn_offset;
|
2005-10-05 03:13:57 +08:00
|
|
|
#endif
|
2006-09-27 16:49:54 +08:00
|
|
|
if (mem_data[node].max_pfn > max_pfn)
|
|
|
|
max_pfn = mem_data[node].max_pfn;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2006-10-11 16:20:39 +08:00
|
|
|
memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
|
2017-12-24 20:20:52 +08:00
|
|
|
#ifdef CONFIG_ZONE_DMA32
|
|
|
|
max_zone_pfns[ZONE_DMA32] = max_dma;
|
2007-02-10 17:43:11 +08:00
|
|
|
#endif
|
2006-09-27 16:49:54 +08:00
|
|
|
max_zone_pfns[ZONE_NORMAL] = max_pfn;
|
|
|
|
free_area_init_nodes(max_zone_pfns);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
zero_page_memmap_ptr = virt_to_page(ia64_imva(empty_zero_page));
|
|
|
|
}
|
[PATCH] pgdat allocation and update for ia64 of memory hotplug: update pgdat address array
This is to refresh node_data[] array for ia64. As I mentioned previous
patches, ia64 has copies of information of pgdat address array on each node as
per node data.
At v2 of node_add, this function used stop_machine_run() to update them. (I
wished that they were copied safety as much as possible.) But, in this patch,
this arrays are just copied simply, and set node_online_map bit after
completion of pgdat initialization.
So, kernel must touch NODE_DATA() macro after checking node_online_map().
(Current code has already done it.) This is more simple way for just
hot-add.....
Note : It will be problem when hot-remove will occur,
because, even if online_map bit is set, kernel may
touch NODE_DATA() due to race condition. :-(
Signed-off-by: Yasunori Goto <y-goto@jp.fujitsu.com>
Cc: "Luck, Tony" <tony.luck@intel.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-06-27 17:53:39 +08:00
|
|
|
|
2007-05-08 15:23:07 +08:00
|
|
|
#ifdef CONFIG_MEMORY_HOTPLUG
|
2006-06-27 17:53:40 +08:00
|
|
|
pg_data_t *arch_alloc_nodedata(int nid)
|
|
|
|
{
|
|
|
|
unsigned long size = compute_pernodesize(nid);
|
|
|
|
|
|
|
|
return kzalloc(size, GFP_KERNEL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void arch_free_nodedata(pg_data_t *pgdat)
|
|
|
|
{
|
|
|
|
kfree(pgdat);
|
|
|
|
}
|
|
|
|
|
[PATCH] pgdat allocation and update for ia64 of memory hotplug: update pgdat address array
This is to refresh node_data[] array for ia64. As I mentioned previous
patches, ia64 has copies of information of pgdat address array on each node as
per node data.
At v2 of node_add, this function used stop_machine_run() to update them. (I
wished that they were copied safety as much as possible.) But, in this patch,
this arrays are just copied simply, and set node_online_map bit after
completion of pgdat initialization.
So, kernel must touch NODE_DATA() macro after checking node_online_map().
(Current code has already done it.) This is more simple way for just
hot-add.....
Note : It will be problem when hot-remove will occur,
because, even if online_map bit is set, kernel may
touch NODE_DATA() due to race condition. :-(
Signed-off-by: Yasunori Goto <y-goto@jp.fujitsu.com>
Cc: "Luck, Tony" <tony.luck@intel.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-06-27 17:53:39 +08:00
|
|
|
void arch_refresh_nodedata(int update_node, pg_data_t *update_pgdat)
|
|
|
|
{
|
|
|
|
pgdat_list[update_node] = update_pgdat;
|
|
|
|
scatter_node_data();
|
|
|
|
}
|
2007-05-08 15:23:07 +08:00
|
|
|
#endif
|
2007-10-16 16:24:15 +08:00
|
|
|
|
|
|
|
#ifdef CONFIG_SPARSEMEM_VMEMMAP
|
2017-12-29 15:53:54 +08:00
|
|
|
int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node,
|
|
|
|
struct vmem_altmap *altmap)
|
2007-10-16 16:24:15 +08:00
|
|
|
{
|
2013-04-30 06:07:50 +08:00
|
|
|
return vmemmap_populate_basepages(start, end, node);
|
2007-10-16 16:24:15 +08:00
|
|
|
}
|
2013-02-23 08:33:00 +08:00
|
|
|
|
2017-12-29 15:53:56 +08:00
|
|
|
void vmemmap_free(unsigned long start, unsigned long end,
|
|
|
|
struct vmem_altmap *altmap)
|
2013-02-23 08:33:08 +08:00
|
|
|
{
|
|
|
|
}
|
2007-10-16 16:24:15 +08:00
|
|
|
#endif
|