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-10-30 09:16:54 +08:00
|
|
|
/*
|
|
|
|
* include/linux/memory.h - generic memory definition
|
|
|
|
*
|
|
|
|
* This is mainly for topological representation. We define the
|
|
|
|
* basic "struct memory_block" here, which can be embedded in per-arch
|
|
|
|
* definitions or NUMA information.
|
|
|
|
*
|
|
|
|
* Basic handling of the devices is done in drivers/base/memory.c
|
|
|
|
* and system devices are handled in drivers/base/sys.c.
|
|
|
|
*
|
|
|
|
* Memory block are exported via sysfs in the class/memory/devices/
|
|
|
|
* directory.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#ifndef _LINUX_MEMORY_H_
|
|
|
|
#define _LINUX_MEMORY_H_
|
|
|
|
|
|
|
|
#include <linux/node.h>
|
|
|
|
#include <linux/compiler.h>
|
2008-02-05 15:35:47 +08:00
|
|
|
#include <linux/mutex.h>
|
2013-04-30 06:08:04 +08:00
|
|
|
#include <linux/notifier.h>
|
2005-10-30 09:16:54 +08:00
|
|
|
|
2012-09-18 05:08:56 +08:00
|
|
|
#define MIN_MEMORY_BLOCK_SIZE (1UL << SECTION_SIZE_BITS)
|
2011-06-14 08:57:50 +08:00
|
|
|
|
2005-10-30 09:16:54 +08:00
|
|
|
struct memory_block {
|
2011-01-21 00:44:29 +08:00
|
|
|
unsigned long start_section_nr;
|
2013-08-21 05:05:05 +08:00
|
|
|
unsigned long state; /* serialized by the dev->lock */
|
|
|
|
int section_count; /* serialized by mem_sysfs_mutex */
|
|
|
|
int online_type; /* for passing data to online routine */
|
2005-10-30 09:16:54 +08:00
|
|
|
int phys_device; /* to which fru does this belong? */
|
2011-12-22 06:48:43 +08:00
|
|
|
struct device dev;
|
2018-04-06 07:23:00 +08:00
|
|
|
int nid; /* NID for this memory block */
|
2005-10-30 09:16:54 +08:00
|
|
|
};
|
|
|
|
|
2010-03-15 12:35:03 +08:00
|
|
|
int arch_get_memory_phys_device(unsigned long start_pfn);
|
2014-10-14 09:00:47 +08:00
|
|
|
unsigned long memory_block_size_bytes(void);
|
2018-05-25 04:17:12 +08:00
|
|
|
int set_memory_block_size_order(unsigned int order);
|
2010-03-15 12:35:03 +08:00
|
|
|
|
2005-10-30 09:16:54 +08:00
|
|
|
/* These states are exposed to userspace as text strings in sysfs */
|
|
|
|
#define MEM_ONLINE (1<<0) /* exposed to userspace */
|
|
|
|
#define MEM_GOING_OFFLINE (1<<1) /* exposed to userspace */
|
|
|
|
#define MEM_OFFLINE (1<<2) /* exposed to userspace */
|
2007-10-22 07:41:36 +08:00
|
|
|
#define MEM_GOING_ONLINE (1<<3)
|
|
|
|
#define MEM_CANCEL_ONLINE (1<<4)
|
|
|
|
#define MEM_CANCEL_OFFLINE (1<<5)
|
2005-10-30 09:16:54 +08:00
|
|
|
|
2007-10-22 07:41:36 +08:00
|
|
|
struct memory_notify {
|
|
|
|
unsigned long start_pfn;
|
|
|
|
unsigned long nr_pages;
|
2012-12-12 08:01:03 +08:00
|
|
|
int status_change_nid_normal;
|
2012-12-13 05:51:49 +08:00
|
|
|
int status_change_nid_high;
|
2007-10-22 07:41:36 +08:00
|
|
|
int status_change_nid;
|
|
|
|
};
|
2005-10-30 09:16:54 +08:00
|
|
|
|
2005-11-07 16:59:43 +08:00
|
|
|
struct notifier_block;
|
|
|
|
struct mem_section;
|
|
|
|
|
2008-04-29 16:00:41 +08:00
|
|
|
/*
|
|
|
|
* Priorities for the hotplug memory callback routines (stored in decreasing
|
|
|
|
* order in the callback chain)
|
|
|
|
*/
|
|
|
|
#define SLAB_CALLBACK_PRI 1
|
2008-04-29 16:00:42 +08:00
|
|
|
#define IPC_CALLBACK_PRI 10
|
2008-04-29 16:00:41 +08:00
|
|
|
|
2006-10-01 14:27:08 +08:00
|
|
|
#ifndef CONFIG_MEMORY_HOTPLUG_SPARSE
|
2019-09-24 06:35:46 +08:00
|
|
|
static inline void memory_dev_init(void)
|
2005-10-30 09:16:54 +08:00
|
|
|
{
|
2019-09-24 06:35:46 +08:00
|
|
|
return;
|
2005-10-30 09:16:54 +08:00
|
|
|
}
|
|
|
|
static inline int register_memory_notifier(struct notifier_block *nb)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
static inline void unregister_memory_notifier(struct notifier_block *nb)
|
|
|
|
{
|
|
|
|
}
|
2007-10-22 07:41:36 +08:00
|
|
|
static inline int memory_notify(unsigned long val, void *v)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2005-10-30 09:16:54 +08:00
|
|
|
#else
|
2007-10-22 07:41:36 +08:00
|
|
|
extern int register_memory_notifier(struct notifier_block *nb);
|
|
|
|
extern void unregister_memory_notifier(struct notifier_block *nb);
|
2019-07-19 06:56:56 +08:00
|
|
|
int create_memory_block_devices(unsigned long start, unsigned long size);
|
2019-07-19 06:57:06 +08:00
|
|
|
void remove_memory_block_devices(unsigned long start, unsigned long size);
|
2019-09-24 06:35:46 +08:00
|
|
|
extern void memory_dev_init(void);
|
2007-10-22 07:41:36 +08:00
|
|
|
extern int memory_notify(unsigned long val, void *v);
|
2009-01-07 06:39:14 +08:00
|
|
|
extern struct memory_block *find_memory_block(struct mem_section *);
|
2019-07-19 06:57:50 +08:00
|
|
|
typedef int (*walk_memory_blocks_func_t)(struct memory_block *, void *);
|
|
|
|
extern int walk_memory_blocks(unsigned long start, unsigned long size,
|
|
|
|
void *arg, walk_memory_blocks_func_t func);
|
mm/memory_hotplug: fix try_offline_node()
try_offline_node() is pretty much broken right now:
- The node span is updated when onlining memory, not when adding it. We
ignore memory that was mever onlined. Bad.
- We touch possible garbage memmaps. The pfn_to_nid(pfn) can easily
trigger a kernel panic. Bad for memory that is offline but also bad
for subsection hotadd with ZONE_DEVICE, whereby the memmap of the
first PFN of a section might contain garbage.
- Sections belonging to mixed nodes are not properly considered.
As memory blocks might belong to multiple nodes, we would have to walk
all pageblocks (or at least subsections) within present sections.
However, we don't have a way to identify whether a memmap that is not
online was initialized (relevant for ZONE_DEVICE). This makes things
more complicated.
Luckily, we can piggy pack on the node span and the nid stored in memory
blocks. Currently, the node span is grown when calling
move_pfn_range_to_zone() - e.g., when onlining memory, and shrunk when
removing memory, before calling try_offline_node(). Sysfs links are
created via link_mem_sections(), e.g., during boot or when adding
memory.
If the node still spans memory or if any memory block belongs to the
nid, we don't set the node offline. As memory blocks that span multiple
nodes cannot get offlined, the nid stored in memory blocks is reliable
enough (for such online memory blocks, the node still spans the memory).
Introduce for_each_memory_block() to efficiently walk all memory blocks.
Note: We will soon stop shrinking the ZONE_DEVICE zone and the node span
when removing ZONE_DEVICE memory to fix similar issues (access of
garbage memmaps) - until we have a reliable way to identify whether
these memmaps were properly initialized. This implies later, that once
a node had ZONE_DEVICE memory, we won't be able to set a node offline -
which should be acceptable.
Since commit f1dd2cd13c4b ("mm, memory_hotplug: do not associate
hotadded memory to zones until online") memory that is added is not
assoziated with a zone/node (memmap not initialized). The introducing
commit 60a5a19e7419 ("memory-hotplug: remove sysfs file of node")
already missed that we could have multiple nodes for a section and that
the zone/node span is updated when onlining pages, not when adding them.
I tested this by hotplugging two DIMMs to a memory-less and cpu-less
NUMA node. The node is properly onlined when adding the DIMMs. When
removing the DIMMs, the node is properly offlined.
Masayoshi Mizuma reported:
: Without this patch, memory hotplug fails as panic:
:
: BUG: kernel NULL pointer dereference, address: 0000000000000000
: ...
: Call Trace:
: remove_memory_block_devices+0x81/0xc0
: try_remove_memory+0xb4/0x130
: __remove_memory+0xa/0x20
: acpi_memory_device_remove+0x84/0x100
: acpi_bus_trim+0x57/0x90
: acpi_bus_trim+0x2e/0x90
: acpi_device_hotplug+0x2b2/0x4d0
: acpi_hotplug_work_fn+0x1a/0x30
: process_one_work+0x171/0x380
: worker_thread+0x49/0x3f0
: kthread+0xf8/0x130
: ret_from_fork+0x35/0x40
[david@redhat.com: v3]
Link: http://lkml.kernel.org/r/20191102120221.7553-1-david@redhat.com
Link: http://lkml.kernel.org/r/20191028105458.28320-1-david@redhat.com
Fixes: 60a5a19e7419 ("memory-hotplug: remove sysfs file of node")
Fixes: f1dd2cd13c4b ("mm, memory_hotplug: do not associate hotadded memory to zones until online") # visiable after d0dc12e86b319
Signed-off-by: David Hildenbrand <david@redhat.com>
Tested-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
Cc: Tang Chen <tangchen@cn.fujitsu.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Keith Busch <keith.busch@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org>
Cc: Jani Nikula <jani.nikula@intel.com>
Cc: Nayna Jain <nayna@linux.ibm.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-11-16 09:34:57 +08:00
|
|
|
extern int for_each_memory_block(void *arg, walk_memory_blocks_func_t func);
|
2005-10-30 09:16:54 +08:00
|
|
|
#define CONFIG_MEM_BLOCK_SIZE (PAGES_PER_SECTION<<PAGE_SHIFT)
|
2006-10-01 14:27:08 +08:00
|
|
|
#endif /* CONFIG_MEMORY_HOTPLUG_SPARSE */
|
2005-10-30 09:16:54 +08:00
|
|
|
|
2007-10-22 07:41:37 +08:00
|
|
|
#ifdef CONFIG_MEMORY_HOTPLUG
|
2013-04-30 06:08:04 +08:00
|
|
|
#define hotplug_memory_notifier(fn, pri) ({ \
|
2008-11-23 01:38:34 +08:00
|
|
|
static __meminitdata struct notifier_block fn##_mem_nb =\
|
2013-04-30 06:08:04 +08:00
|
|
|
{ .notifier_call = fn, .priority = pri };\
|
2005-10-30 09:16:54 +08:00
|
|
|
register_memory_notifier(&fn##_mem_nb); \
|
2013-04-30 06:08:04 +08:00
|
|
|
})
|
|
|
|
#define register_hotmemory_notifier(nb) register_memory_notifier(nb)
|
|
|
|
#define unregister_hotmemory_notifier(nb) unregister_memory_notifier(nb)
|
2007-10-22 07:41:37 +08:00
|
|
|
#else
|
2013-05-01 06:26:45 +08:00
|
|
|
#define hotplug_memory_notifier(fn, pri) ({ 0; })
|
2013-04-30 06:08:04 +08:00
|
|
|
/* These aren't inline functions due to a GCC bug. */
|
|
|
|
#define register_hotmemory_notifier(nb) ({ (void)(nb); 0; })
|
|
|
|
#define unregister_hotmemory_notifier(nb) ({ (void)(nb); })
|
2007-10-22 07:41:37 +08:00
|
|
|
#endif
|
2005-10-30 09:16:54 +08:00
|
|
|
|
2009-03-06 23:35:52 +08:00
|
|
|
/*
|
|
|
|
* Kernel text modification mutex, used for code patching. Users of this lock
|
|
|
|
* can sleep.
|
|
|
|
*/
|
|
|
|
extern struct mutex text_mutex;
|
|
|
|
|
2005-10-30 09:16:54 +08:00
|
|
|
#endif /* _LINUX_MEMORY_H_ */
|