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 17:07:57 +03:00
// SPDX-License-Identifier: GPL-2.0
2011-02-22 13:10:08 +03:00
/*
* NUMA emulation
*/
# include <linux/kernel.h>
# include <linux/errno.h>
# include <linux/topology.h>
# include <linux/memblock.h>
# include <asm/dma.h>
# include "numa_internal.h"
x86: delete __cpuinit usage from all x86 files
The __cpuinit type of throwaway sections might have made sense
some time ago when RAM was more constrained, but now the savings
do not offset the cost and complications. For example, the fix in
commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time")
is a good example of the nasty type of bugs that can be created
with improper use of the various __init prefixes.
After a discussion on LKML[1] it was decided that cpuinit should go
the way of devinit and be phased out. Once all the users are gone,
we can then finally remove the macros themselves from linux/init.h.
Note that some harmless section mismatch warnings may result, since
notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c)
are flagged as __cpuinit -- so if we remove the __cpuinit from
arch specific callers, we will also get section mismatch warnings.
As an intermediate step, we intend to turn the linux/init.h cpuinit
content into no-ops as early as possible, since that will get rid
of these warnings. In any case, they are temporary and harmless.
This removes all the arch/x86 uses of the __cpuinit macros from
all C files. x86 only had the one __CPUINIT used in assembly files,
and it wasn't paired off with a .previous or a __FINIT, so we can
delete it directly w/o any corresponding additional change there.
[1] https://lkml.org/lkml/2013/5/20/589
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
Acked-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: H. Peter Anvin <hpa@linux.intel.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2013-06-19 02:23:59 +04:00
static int emu_nid_to_phys [ MAX_NUMNODES ] ;
2011-02-22 13:10:08 +03:00
static char * emu_cmdline __initdata ;
void __init numa_emu_cmdline ( char * str )
{
emu_cmdline = str ;
}
static int __init emu_find_memblk_by_nid ( int nid , const struct numa_meminfo * mi )
{
int i ;
for ( i = 0 ; i < mi - > nr_blks ; i + + )
if ( mi - > blk [ i ] . nid = = nid )
return i ;
return - ENOENT ;
}
2012-02-28 19:16:33 +04:00
static u64 __init mem_hole_size ( u64 start , u64 end )
2011-07-12 13:16:04 +04:00
{
unsigned long start_pfn = PFN_UP ( start ) ;
unsigned long end_pfn = PFN_DOWN ( end ) ;
if ( start_pfn < end_pfn )
return PFN_PHYS ( absent_pages_in_range ( start_pfn , end_pfn ) ) ;
return 0 ;
}
2011-02-22 13:10:08 +03:00
/*
* Sets up nid to range from @ start to @ end . The return value is - errno if
* something went wrong , 0 otherwise .
*/
static int __init emu_setup_memblk ( struct numa_meminfo * ei ,
struct numa_meminfo * pi ,
int nid , int phys_blk , u64 size )
{
struct numa_memblk * eb = & ei - > blk [ ei - > nr_blks ] ;
struct numa_memblk * pb = & pi - > blk [ phys_blk ] ;
if ( ei - > nr_blks > = NR_NODE_MEMBLKS ) {
pr_err ( " NUMA: Too many emulated memblks, failing emulation \n " ) ;
return - EINVAL ;
}
ei - > nr_blks + + ;
eb - > start = pb - > start ;
eb - > end = pb - > start + size ;
eb - > nid = nid ;
if ( emu_nid_to_phys [ nid ] = = NUMA_NO_NODE )
2018-07-06 19:08:01 +03:00
emu_nid_to_phys [ nid ] = pb - > nid ;
2011-02-22 13:10:08 +03:00
pb - > start + = size ;
if ( pb - > start > = pb - > end ) {
WARN_ON_ONCE ( pb - > start > pb - > end ) ;
numa_remove_memblk_from ( phys_blk , pi ) ;
}
2012-05-30 02:06:29 +04:00
printk ( KERN_INFO " Faking node %d at [mem %#018Lx-%#018Lx] (%LuMB) \n " ,
nid , eb - > start , eb - > end - 1 , ( eb - > end - eb - > start ) > > 20 ) ;
2011-02-22 13:10:08 +03:00
return 0 ;
}
/*
* Sets up nr_nodes fake nodes interleaved over physical nodes ranging from addr
2017-07-08 04:30:58 +03:00
* to max_addr .
*
* Returns zero on success or negative on error .
2011-02-22 13:10:08 +03:00
*/
static int __init split_nodes_interleave ( struct numa_meminfo * ei ,
struct numa_meminfo * pi ,
u64 addr , u64 max_addr , int nr_nodes )
{
2017-07-08 04:30:58 +03:00
nodemask_t physnode_mask = numa_nodes_parsed ;
2011-02-22 13:10:08 +03:00
u64 size ;
int big ;
int nid = 0 ;
int i , ret ;
if ( nr_nodes < = 0 )
return - 1 ;
if ( nr_nodes > MAX_NUMNODES ) {
pr_info ( " numa=fake=%d too large, reducing to %d \n " ,
nr_nodes , MAX_NUMNODES ) ;
nr_nodes = MAX_NUMNODES ;
}
2011-05-02 19:24:48 +04:00
/*
* Calculate target node size . x86_32 freaks on __udivdi3 ( ) so do
* the division in ulong number of pages and convert back .
*/
2011-07-12 13:16:04 +04:00
size = max_addr - addr - mem_hole_size ( addr , max_addr ) ;
2011-05-02 19:24:48 +04:00
size = PFN_PHYS ( ( unsigned long ) ( size > > PAGE_SHIFT ) / nr_nodes ) ;
2011-02-22 13:10:08 +03:00
/*
* Calculate the number of big nodes that can be allocated as a result
* of consolidating the remainder .
*/
big = ( ( size & ~ FAKE_NODE_MIN_HASH_MASK ) * nr_nodes ) /
FAKE_NODE_MIN_SIZE ;
size & = FAKE_NODE_MIN_HASH_MASK ;
if ( ! size ) {
pr_err ( " Not enough memory for each node. "
" NUMA emulation disabled. \n " ) ;
return - 1 ;
}
/*
* Continue to fill physical nodes with fake nodes until there is no
* memory left on any of them .
*/
while ( nodes_weight ( physnode_mask ) ) {
for_each_node_mask ( i , physnode_mask ) {
u64 dma32_end = PFN_PHYS ( MAX_DMA32_PFN ) ;
u64 start , limit , end ;
int phys_blk ;
phys_blk = emu_find_memblk_by_nid ( i , pi ) ;
if ( phys_blk < 0 ) {
node_clear ( i , physnode_mask ) ;
continue ;
}
start = pi - > blk [ phys_blk ] . start ;
limit = pi - > blk [ phys_blk ] . end ;
end = start + size ;
if ( nid < big )
end + = FAKE_NODE_MIN_SIZE ;
/*
* Continue to add memory to this fake node if its
* non - reserved memory is less than the per - node size .
*/
2011-07-12 13:16:04 +04:00
while ( end - start - mem_hole_size ( start , end ) < size ) {
2011-02-22 13:10:08 +03:00
end + = FAKE_NODE_MIN_SIZE ;
if ( end > limit ) {
end = limit ;
break ;
}
}
/*
* If there won ' t be at least FAKE_NODE_MIN_SIZE of
* non - reserved memory in ZONE_DMA32 for the next node ,
* this one must extend to the boundary .
*/
if ( end < dma32_end & & dma32_end - end -
2011-07-12 13:16:04 +04:00
mem_hole_size ( end , dma32_end ) < FAKE_NODE_MIN_SIZE )
2011-02-22 13:10:08 +03:00
end = dma32_end ;
/*
* If there won ' t be enough non - reserved memory for the
* next node , this one must extend to the end of the
* physical node .
*/
2011-07-12 13:16:04 +04:00
if ( limit - end - mem_hole_size ( end , limit ) < size )
2011-02-22 13:10:08 +03:00
end = limit ;
ret = emu_setup_memblk ( ei , pi , nid + + % nr_nodes ,
phys_blk ,
min ( end , limit ) - start ) ;
if ( ret < 0 )
return ret ;
}
}
return 0 ;
}
/*
* Returns the end address of a node so that there is at least ` size ' amount of
* non - reserved memory or ` max_addr ' is reached .
*/
static u64 __init find_end_of_node ( u64 start , u64 max_addr , u64 size )
{
u64 end = start + size ;
2011-07-12 13:16:04 +04:00
while ( end - start - mem_hole_size ( start , end ) < size ) {
2011-02-22 13:10:08 +03:00
end + = FAKE_NODE_MIN_SIZE ;
if ( end > max_addr ) {
end = max_addr ;
break ;
}
}
return end ;
}
2018-07-06 19:08:06 +03:00
static u64 uniform_size ( u64 max_addr , u64 base , u64 hole , int nr_nodes )
{
unsigned long max_pfn = PHYS_PFN ( max_addr ) ;
unsigned long base_pfn = PHYS_PFN ( base ) ;
unsigned long hole_pfns = PHYS_PFN ( hole ) ;
return PFN_PHYS ( ( max_pfn - base_pfn - hole_pfns ) / nr_nodes ) ;
}
2011-02-22 13:10:08 +03:00
/*
* Sets up fake nodes of ` size ' interleaved over physical nodes ranging from
2017-07-08 04:30:58 +03:00
* ` addr ' to ` max_addr ' .
*
* Returns zero on success or negative on error .
2011-02-22 13:10:08 +03:00
*/
2018-07-06 19:08:06 +03:00
static int __init split_nodes_size_interleave_uniform ( struct numa_meminfo * ei ,
2011-02-22 13:10:08 +03:00
struct numa_meminfo * pi ,
2018-07-06 19:08:06 +03:00
u64 addr , u64 max_addr , u64 size ,
int nr_nodes , struct numa_memblk * pblk ,
int nid )
2011-02-22 13:10:08 +03:00
{
2017-07-08 04:30:58 +03:00
nodemask_t physnode_mask = numa_nodes_parsed ;
2018-07-06 19:08:06 +03:00
int i , ret , uniform = 0 ;
2011-02-22 13:10:08 +03:00
u64 min_size ;
2018-07-06 19:08:06 +03:00
if ( ( ! size & & ! nr_nodes ) | | ( nr_nodes & & ! pblk ) )
2011-02-22 13:10:08 +03:00
return - 1 ;
2018-07-06 19:08:06 +03:00
2011-02-22 13:10:08 +03:00
/*
2018-07-06 19:08:06 +03:00
* In the ' uniform ' case split the passed in physical node by
* nr_nodes , in the non - uniform case , ignore the passed in
* physical block and try to create nodes of at least size
* @ size .
*
* In the uniform case , split the nodes strictly by physical
* capacity , i . e . ignore holes . In the non - uniform case account
* for holes and treat @ size as a minimum floor .
2011-02-22 13:10:08 +03:00
*/
2018-07-06 19:08:06 +03:00
if ( ! nr_nodes )
nr_nodes = MAX_NUMNODES ;
else {
nodes_clear ( physnode_mask ) ;
node_set ( pblk - > nid , physnode_mask ) ;
uniform = 1 ;
}
if ( uniform ) {
min_size = uniform_size ( max_addr , addr , 0 , nr_nodes ) ;
size = min_size ;
} else {
/*
* The limit on emulated nodes is MAX_NUMNODES , so the
* size per node is increased accordingly if the
* requested size is too small . This creates a uniform
* distribution of node sizes across the entire machine
* ( but not necessarily over physical nodes ) .
*/
min_size = uniform_size ( max_addr , addr ,
mem_hole_size ( addr , max_addr ) , nr_nodes ) ;
}
min_size = ALIGN ( max ( min_size , FAKE_NODE_MIN_SIZE ) , FAKE_NODE_MIN_SIZE ) ;
2011-02-22 13:10:08 +03:00
if ( size < min_size ) {
pr_err ( " Fake node size %LuMB too small, increasing to %LuMB \n " ,
size > > 20 , min_size > > 20 ) ;
size = min_size ;
}
2018-07-06 19:08:06 +03:00
size = ALIGN_DOWN ( size , FAKE_NODE_MIN_SIZE ) ;
2011-02-22 13:10:08 +03:00
/*
* Fill physical nodes with fake nodes of size until there is no memory
* left on any of them .
*/
while ( nodes_weight ( physnode_mask ) ) {
for_each_node_mask ( i , physnode_mask ) {
2011-05-02 19:24:48 +04:00
u64 dma32_end = PFN_PHYS ( MAX_DMA32_PFN ) ;
2011-02-22 13:10:08 +03:00
u64 start , limit , end ;
int phys_blk ;
phys_blk = emu_find_memblk_by_nid ( i , pi ) ;
if ( phys_blk < 0 ) {
node_clear ( i , physnode_mask ) ;
continue ;
}
2018-07-06 19:08:06 +03:00
2011-02-22 13:10:08 +03:00
start = pi - > blk [ phys_blk ] . start ;
limit = pi - > blk [ phys_blk ] . end ;
2018-07-06 19:08:06 +03:00
if ( uniform )
end = start + size ;
else
end = find_end_of_node ( start , limit , size ) ;
2011-02-22 13:10:08 +03:00
/*
* If there won ' t be at least FAKE_NODE_MIN_SIZE of
* non - reserved memory in ZONE_DMA32 for the next node ,
* this one must extend to the boundary .
*/
if ( end < dma32_end & & dma32_end - end -
2011-07-12 13:16:04 +04:00
mem_hole_size ( end , dma32_end ) < FAKE_NODE_MIN_SIZE )
2011-02-22 13:10:08 +03:00
end = dma32_end ;
/*
* If there won ' t be enough non - reserved memory for the
* next node , this one must extend to the end of the
* physical node .
*/
2018-07-06 19:08:06 +03:00
if ( ( limit - end - mem_hole_size ( end , limit ) < size )
& & ! uniform )
2011-02-22 13:10:08 +03:00
end = limit ;
ret = emu_setup_memblk ( ei , pi , nid + + % MAX_NUMNODES ,
phys_blk ,
min ( end , limit ) - start ) ;
if ( ret < 0 )
return ret ;
}
}
2018-07-06 19:08:06 +03:00
return nid ;
}
static int __init split_nodes_size_interleave ( struct numa_meminfo * ei ,
struct numa_meminfo * pi ,
u64 addr , u64 max_addr , u64 size )
{
return split_nodes_size_interleave_uniform ( ei , pi , addr , max_addr , size ,
0 , NULL , NUMA_NO_NODE ) ;
2011-02-22 13:10:08 +03:00
}
2017-07-08 04:30:57 +03:00
int __init setup_emu2phys_nid ( int * dfl_phys_nid )
{
int i , max_emu_nid = 0 ;
* dfl_phys_nid = NUMA_NO_NODE ;
for ( i = 0 ; i < ARRAY_SIZE ( emu_nid_to_phys ) ; i + + ) {
if ( emu_nid_to_phys [ i ] ! = NUMA_NO_NODE ) {
max_emu_nid = i ;
if ( * dfl_phys_nid = = NUMA_NO_NODE )
* dfl_phys_nid = emu_nid_to_phys [ i ] ;
}
}
return max_emu_nid ;
}
2011-02-22 13:10:08 +03:00
/**
* numa_emulation - Emulate NUMA nodes
* @ numa_meminfo : NUMA configuration to massage
* @ numa_dist_cnt : The size of the physical NUMA distance table
*
* Emulate NUMA nodes according to the numa = fake kernel parameter .
* @ numa_meminfo contains the physical memory configuration and is modified
* to reflect the emulated configuration on success . @ numa_dist_cnt is
* used to determine the size of the physical distance table .
*
* On success , the following modifications are made .
*
* - @ numa_meminfo is updated to reflect the emulated nodes .
*
* - __apicid_to_node [ ] is updated such that APIC IDs are mapped to the
* emulated nodes .
*
* - NUMA distance table is rebuilt to represent distances between emulated
* nodes . The distances are determined considering how emulated nodes
* are mapped to physical nodes and match the actual distances .
*
* - emu_nid_to_phys [ ] reflects how emulated nodes are mapped to physical
* nodes . This is used by numa_add_cpu ( ) and numa_remove_cpu ( ) .
*
* If emulation is not enabled or fails , emu_nid_to_phys [ ] is filled with
* identity mapping and no other modification is made .
2011-02-22 13:10:08 +03:00
*/
void __init numa_emulation ( struct numa_meminfo * numa_meminfo , int numa_dist_cnt )
{
static struct numa_meminfo ei __initdata ;
static struct numa_meminfo pi __initdata ;
2011-05-02 19:24:48 +04:00
const u64 max_addr = PFN_PHYS ( max_pfn ) ;
2011-02-22 13:10:08 +03:00
u8 * phys_dist = NULL ;
2011-03-02 13:22:14 +03:00
size_t phys_size = numa_dist_cnt * numa_dist_cnt * sizeof ( phys_dist [ 0 ] ) ;
2011-03-11 12:33:31 +03:00
int max_emu_nid , dfl_phys_nid ;
2011-02-22 13:10:08 +03:00
int i , j , ret ;
if ( ! emu_cmdline )
goto no_emu ;
memset ( & ei , 0 , sizeof ( ei ) ) ;
pi = * numa_meminfo ;
for ( i = 0 ; i < MAX_NUMNODES ; i + + )
emu_nid_to_phys [ i ] = NUMA_NO_NODE ;
/*
* If the numa = fake command - line contains a ' M ' or ' G ' , it represents
* the fixed node size . Otherwise , if it is just a single number N ,
* split the system RAM into N fake nodes .
*/
2018-07-06 19:08:06 +03:00
if ( strchr ( emu_cmdline , ' U ' ) ) {
nodemask_t physnode_mask = numa_nodes_parsed ;
unsigned long n ;
int nid = 0 ;
n = simple_strtoul ( emu_cmdline , & emu_cmdline , 0 ) ;
ret = - 1 ;
for_each_node_mask ( i , physnode_mask ) {
2018-10-25 23:26:45 +03:00
/*
* The reason we pass in blk [ 0 ] is due to
* numa_remove_memblk_from ( ) called by
* emu_setup_memblk ( ) will delete entry 0
* and then move everything else up in the pi . blk
* array . Therefore we should always be looking
* at blk [ 0 ] .
*/
2018-07-06 19:08:06 +03:00
ret = split_nodes_size_interleave_uniform ( & ei , & pi ,
2018-10-25 23:26:45 +03:00
pi . blk [ 0 ] . start , pi . blk [ 0 ] . end , 0 ,
n , & pi . blk [ 0 ] , nid ) ;
2018-07-06 19:08:06 +03:00
if ( ret < 0 )
break ;
if ( ret < n ) {
pr_info ( " %s: phys: %d only got %d of %ld nodes, failing \n " ,
__func__ , i , ret , n ) ;
ret = - 1 ;
break ;
}
nid = ret ;
}
} else if ( strchr ( emu_cmdline , ' M ' ) | | strchr ( emu_cmdline , ' G ' ) ) {
2011-02-22 13:10:08 +03:00
u64 size ;
size = memparse ( emu_cmdline , & emu_cmdline ) ;
ret = split_nodes_size_interleave ( & ei , & pi , 0 , max_addr , size ) ;
} else {
unsigned long n ;
x86/numa: Allow specifying node_distance() for numa=fake
Allows emulating more interesting NUMA configurations like a quad
socket AMD Magny-Cour:
"numa=fake=8:10,16,16,22,16,22,16,22,
16,10,22,16,22,16,22,16,
16,22,10,16,16,22,16,22,
22,16,16,10,22,16,22,16,
16,22,16,22,10,16,16,22,
22,16,22,16,16,10,22,16,
16,22,16,22,16,22,10,16,
22,16,22,16,22,16,16,10"
Which has a non-fully-connected topology.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Tejun Heo <tj@kernel.org>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: x86@kernel.org
Link: http://lkml.kernel.org/n/tip-e1136ef7kdffj7yf9tjhydln@git.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2012-04-18 21:04:17 +04:00
n = simple_strtoul ( emu_cmdline , & emu_cmdline , 0 ) ;
2011-02-22 13:10:08 +03:00
ret = split_nodes_interleave ( & ei , & pi , 0 , max_addr , n ) ;
}
x86/numa: Allow specifying node_distance() for numa=fake
Allows emulating more interesting NUMA configurations like a quad
socket AMD Magny-Cour:
"numa=fake=8:10,16,16,22,16,22,16,22,
16,10,22,16,22,16,22,16,
16,22,10,16,16,22,16,22,
22,16,16,10,22,16,22,16,
16,22,16,22,10,16,16,22,
22,16,22,16,16,10,22,16,
16,22,16,22,16,22,10,16,
22,16,22,16,22,16,16,10"
Which has a non-fully-connected topology.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Tejun Heo <tj@kernel.org>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: x86@kernel.org
Link: http://lkml.kernel.org/n/tip-e1136ef7kdffj7yf9tjhydln@git.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2012-04-18 21:04:17 +04:00
if ( * emu_cmdline = = ' : ' )
emu_cmdline + + ;
2011-02-22 13:10:08 +03:00
if ( ret < 0 )
goto no_emu ;
if ( numa_cleanup_meminfo ( & ei ) < 0 ) {
pr_warning ( " NUMA: Warning: constructed meminfo invalid, disabling emulation \n " ) ;
goto no_emu ;
}
2011-03-02 13:22:14 +03:00
/* copy the physical distance table */
2011-02-22 13:10:08 +03:00
if ( numa_dist_cnt ) {
u64 phys ;
2011-05-02 19:24:48 +04:00
phys = memblock_find_in_range ( 0 , PFN_PHYS ( max_pfn_mapped ) ,
2011-03-02 13:22:14 +03:00
phys_size , PAGE_SIZE ) ;
2011-07-12 11:58:09 +04:00
if ( ! phys ) {
2011-02-22 13:10:08 +03:00
pr_warning ( " NUMA: Warning: can't allocate copy of distance table, disabling emulation \n " ) ;
goto no_emu ;
}
2011-07-12 13:16:06 +04:00
memblock_reserve ( phys , phys_size ) ;
2011-02-22 13:10:08 +03:00
phys_dist = __va ( phys ) ;
for ( i = 0 ; i < numa_dist_cnt ; i + + )
for ( j = 0 ; j < numa_dist_cnt ; j + + )
phys_dist [ i * numa_dist_cnt + j ] =
node_distance ( i , j ) ;
}
2011-03-11 12:33:31 +03:00
/*
* Determine the max emulated nid and the default phys nid to use
* for unmapped nodes .
*/
2017-07-08 04:30:57 +03:00
max_emu_nid = setup_emu2phys_nid ( & dfl_phys_nid ) ;
2011-03-04 18:32:02 +03:00
2011-02-22 13:10:08 +03:00
/* commit */
* numa_meminfo = ei ;
2017-07-08 04:30:59 +03:00
/* Make sure numa_nodes_parsed only contains emulated nodes */
nodes_clear ( numa_nodes_parsed ) ;
for ( i = 0 ; i < ARRAY_SIZE ( ei . blk ) ; i + + )
if ( ei . blk [ i ] . start ! = ei . blk [ i ] . end & &
ei . blk [ i ] . nid ! = NUMA_NO_NODE )
node_set ( ei . blk [ i ] . nid , numa_nodes_parsed ) ;
2011-02-22 13:10:08 +03:00
/*
* Transform __apicid_to_node table to use emulated nids by
* reverse - mapping phys_nid . The maps should always exist but fall
* back to zero just in case .
*/
for ( i = 0 ; i < ARRAY_SIZE ( __apicid_to_node ) ; i + + ) {
if ( __apicid_to_node [ i ] = = NUMA_NO_NODE )
continue ;
for ( j = 0 ; j < ARRAY_SIZE ( emu_nid_to_phys ) ; j + + )
if ( __apicid_to_node [ i ] = = emu_nid_to_phys [ j ] )
break ;
__apicid_to_node [ i ] = j < ARRAY_SIZE ( emu_nid_to_phys ) ? j : 0 ;
}
/* make sure all emulated nodes are mapped to a physical node */
for ( i = 0 ; i < ARRAY_SIZE ( emu_nid_to_phys ) ; i + + )
if ( emu_nid_to_phys [ i ] = = NUMA_NO_NODE )
2011-03-04 18:32:02 +03:00
emu_nid_to_phys [ i ] = dfl_phys_nid ;
2011-02-22 13:10:08 +03:00
2011-03-11 12:33:31 +03:00
/* transform distance table */
2011-02-22 13:10:08 +03:00
numa_reset_distance ( ) ;
2011-03-11 12:33:31 +03:00
for ( i = 0 ; i < max_emu_nid + 1 ; i + + ) {
for ( j = 0 ; j < max_emu_nid + 1 ; j + + ) {
2011-02-22 13:10:08 +03:00
int physi = emu_nid_to_phys [ i ] ;
int physj = emu_nid_to_phys [ j ] ;
int dist ;
x86/numa: Allow specifying node_distance() for numa=fake
Allows emulating more interesting NUMA configurations like a quad
socket AMD Magny-Cour:
"numa=fake=8:10,16,16,22,16,22,16,22,
16,10,22,16,22,16,22,16,
16,22,10,16,16,22,16,22,
22,16,16,10,22,16,22,16,
16,22,16,22,10,16,16,22,
22,16,22,16,16,10,22,16,
16,22,16,22,16,22,10,16,
22,16,22,16,22,16,16,10"
Which has a non-fully-connected topology.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Tejun Heo <tj@kernel.org>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: x86@kernel.org
Link: http://lkml.kernel.org/n/tip-e1136ef7kdffj7yf9tjhydln@git.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2012-04-18 21:04:17 +04:00
if ( get_option ( & emu_cmdline , & dist ) = = 2 )
;
else if ( physi > = numa_dist_cnt | | physj > = numa_dist_cnt )
2011-02-22 13:10:08 +03:00
dist = physi = = physj ?
LOCAL_DISTANCE : REMOTE_DISTANCE ;
else
dist = phys_dist [ physi * numa_dist_cnt + physj ] ;
numa_set_distance ( i , j , dist ) ;
}
}
2011-03-02 13:22:14 +03:00
/* free the copied physical distance table */
if ( phys_dist )
2011-07-12 13:16:06 +04:00
memblock_free ( __pa ( phys_dist ) , phys_size ) ;
2011-02-22 13:10:08 +03:00
return ;
no_emu :
/* No emulation. Build identity emu_nid_to_phys[] for numa_add_cpu() */
for ( i = 0 ; i < ARRAY_SIZE ( emu_nid_to_phys ) ; i + + )
emu_nid_to_phys [ i ] = i ;
}
# ifndef CONFIG_DEBUG_PER_CPU_MAPS
x86: delete __cpuinit usage from all x86 files
The __cpuinit type of throwaway sections might have made sense
some time ago when RAM was more constrained, but now the savings
do not offset the cost and complications. For example, the fix in
commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time")
is a good example of the nasty type of bugs that can be created
with improper use of the various __init prefixes.
After a discussion on LKML[1] it was decided that cpuinit should go
the way of devinit and be phased out. Once all the users are gone,
we can then finally remove the macros themselves from linux/init.h.
Note that some harmless section mismatch warnings may result, since
notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c)
are flagged as __cpuinit -- so if we remove the __cpuinit from
arch specific callers, we will also get section mismatch warnings.
As an intermediate step, we intend to turn the linux/init.h cpuinit
content into no-ops as early as possible, since that will get rid
of these warnings. In any case, they are temporary and harmless.
This removes all the arch/x86 uses of the __cpuinit macros from
all C files. x86 only had the one __CPUINIT used in assembly files,
and it wasn't paired off with a .previous or a __FINIT, so we can
delete it directly w/o any corresponding additional change there.
[1] https://lkml.org/lkml/2013/5/20/589
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
Acked-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: H. Peter Anvin <hpa@linux.intel.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2013-06-19 02:23:59 +04:00
void numa_add_cpu ( int cpu )
2011-02-22 13:10:08 +03:00
{
int physnid , nid ;
2011-03-04 16:49:28 +03:00
nid = early_cpu_to_node ( cpu ) ;
2011-02-22 13:10:08 +03:00
BUG_ON ( nid = = NUMA_NO_NODE | | ! node_online ( nid ) ) ;
physnid = emu_nid_to_phys [ nid ] ;
/*
* Map the cpu to each emulated node that is allocated on the physical
* node of the cpu ' s apic id .
*/
for_each_online_node ( nid )
if ( emu_nid_to_phys [ nid ] = = physnid )
cpumask_set_cpu ( cpu , node_to_cpumask_map [ nid ] ) ;
}
x86: delete __cpuinit usage from all x86 files
The __cpuinit type of throwaway sections might have made sense
some time ago when RAM was more constrained, but now the savings
do not offset the cost and complications. For example, the fix in
commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time")
is a good example of the nasty type of bugs that can be created
with improper use of the various __init prefixes.
After a discussion on LKML[1] it was decided that cpuinit should go
the way of devinit and be phased out. Once all the users are gone,
we can then finally remove the macros themselves from linux/init.h.
Note that some harmless section mismatch warnings may result, since
notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c)
are flagged as __cpuinit -- so if we remove the __cpuinit from
arch specific callers, we will also get section mismatch warnings.
As an intermediate step, we intend to turn the linux/init.h cpuinit
content into no-ops as early as possible, since that will get rid
of these warnings. In any case, they are temporary and harmless.
This removes all the arch/x86 uses of the __cpuinit macros from
all C files. x86 only had the one __CPUINIT used in assembly files,
and it wasn't paired off with a .previous or a __FINIT, so we can
delete it directly w/o any corresponding additional change there.
[1] https://lkml.org/lkml/2013/5/20/589
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
Acked-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: H. Peter Anvin <hpa@linux.intel.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2013-06-19 02:23:59 +04:00
void numa_remove_cpu ( int cpu )
2011-02-22 13:10:08 +03:00
{
int i ;
for_each_online_node ( i )
cpumask_clear_cpu ( cpu , node_to_cpumask_map [ i ] ) ;
}
# else /* !CONFIG_DEBUG_PER_CPU_MAPS */
x86: delete __cpuinit usage from all x86 files
The __cpuinit type of throwaway sections might have made sense
some time ago when RAM was more constrained, but now the savings
do not offset the cost and complications. For example, the fix in
commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time")
is a good example of the nasty type of bugs that can be created
with improper use of the various __init prefixes.
After a discussion on LKML[1] it was decided that cpuinit should go
the way of devinit and be phased out. Once all the users are gone,
we can then finally remove the macros themselves from linux/init.h.
Note that some harmless section mismatch warnings may result, since
notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c)
are flagged as __cpuinit -- so if we remove the __cpuinit from
arch specific callers, we will also get section mismatch warnings.
As an intermediate step, we intend to turn the linux/init.h cpuinit
content into no-ops as early as possible, since that will get rid
of these warnings. In any case, they are temporary and harmless.
This removes all the arch/x86 uses of the __cpuinit macros from
all C files. x86 only had the one __CPUINIT used in assembly files,
and it wasn't paired off with a .previous or a __FINIT, so we can
delete it directly w/o any corresponding additional change there.
[1] https://lkml.org/lkml/2013/5/20/589
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
Acked-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: H. Peter Anvin <hpa@linux.intel.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2013-06-19 02:23:59 +04:00
static void numa_set_cpumask ( int cpu , bool enable )
2011-02-22 13:10:08 +03:00
{
2011-04-21 06:19:13 +04:00
int nid , physnid ;
2011-02-22 13:10:08 +03:00
nid = early_cpu_to_node ( cpu ) ;
if ( nid = = NUMA_NO_NODE ) {
/* early_cpu_to_node() already emits a warning and trace */
return ;
}
physnid = emu_nid_to_phys [ nid ] ;
2011-04-21 06:19:13 +04:00
for_each_online_node ( nid ) {
2011-02-22 13:10:08 +03:00
if ( emu_nid_to_phys [ nid ] ! = physnid )
continue ;
2011-04-21 06:19:13 +04:00
debug_cpumask_set_cpu ( cpu , nid , enable ) ;
2011-02-22 13:10:08 +03:00
}
}
x86: delete __cpuinit usage from all x86 files
The __cpuinit type of throwaway sections might have made sense
some time ago when RAM was more constrained, but now the savings
do not offset the cost and complications. For example, the fix in
commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time")
is a good example of the nasty type of bugs that can be created
with improper use of the various __init prefixes.
After a discussion on LKML[1] it was decided that cpuinit should go
the way of devinit and be phased out. Once all the users are gone,
we can then finally remove the macros themselves from linux/init.h.
Note that some harmless section mismatch warnings may result, since
notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c)
are flagged as __cpuinit -- so if we remove the __cpuinit from
arch specific callers, we will also get section mismatch warnings.
As an intermediate step, we intend to turn the linux/init.h cpuinit
content into no-ops as early as possible, since that will get rid
of these warnings. In any case, they are temporary and harmless.
This removes all the arch/x86 uses of the __cpuinit macros from
all C files. x86 only had the one __CPUINIT used in assembly files,
and it wasn't paired off with a .previous or a __FINIT, so we can
delete it directly w/o any corresponding additional change there.
[1] https://lkml.org/lkml/2013/5/20/589
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
Acked-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: H. Peter Anvin <hpa@linux.intel.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2013-06-19 02:23:59 +04:00
void numa_add_cpu ( int cpu )
2011-02-22 13:10:08 +03:00
{
2011-04-21 06:19:13 +04:00
numa_set_cpumask ( cpu , true ) ;
2011-02-22 13:10:08 +03:00
}
x86: delete __cpuinit usage from all x86 files
The __cpuinit type of throwaway sections might have made sense
some time ago when RAM was more constrained, but now the savings
do not offset the cost and complications. For example, the fix in
commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time")
is a good example of the nasty type of bugs that can be created
with improper use of the various __init prefixes.
After a discussion on LKML[1] it was decided that cpuinit should go
the way of devinit and be phased out. Once all the users are gone,
we can then finally remove the macros themselves from linux/init.h.
Note that some harmless section mismatch warnings may result, since
notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c)
are flagged as __cpuinit -- so if we remove the __cpuinit from
arch specific callers, we will also get section mismatch warnings.
As an intermediate step, we intend to turn the linux/init.h cpuinit
content into no-ops as early as possible, since that will get rid
of these warnings. In any case, they are temporary and harmless.
This removes all the arch/x86 uses of the __cpuinit macros from
all C files. x86 only had the one __CPUINIT used in assembly files,
and it wasn't paired off with a .previous or a __FINIT, so we can
delete it directly w/o any corresponding additional change there.
[1] https://lkml.org/lkml/2013/5/20/589
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
Acked-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: H. Peter Anvin <hpa@linux.intel.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2013-06-19 02:23:59 +04:00
void numa_remove_cpu ( int cpu )
2011-02-22 13:10:08 +03:00
{
2011-04-21 06:19:13 +04:00
numa_set_cpumask ( cpu , false ) ;
2011-02-22 13:10:08 +03:00
}
# endif /* !CONFIG_DEBUG_PER_CPU_MAPS */