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 15:07:57 +01:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2014-08-06 16:05:25 -07:00
|
|
|
#ifndef __CMA_H__
|
|
|
|
|
#define __CMA_H__
|
|
|
|
|
|
2016-12-12 16:43:15 -08:00
|
|
|
#include <linux/init.h>
|
|
|
|
|
#include <linux/types.h>
|
2020-04-10 14:32:42 -07:00
|
|
|
#include <linux/numa.h>
|
2016-12-12 16:43:15 -08:00
|
|
|
|
2014-08-06 16:05:25 -07:00
|
|
|
#ifdef CONFIG_CMA_AREAS
|
2024-02-05 10:49:29 +05:30
|
|
|
#define MAX_CMA_AREAS CONFIG_CMA_AREAS
|
2014-08-06 16:05:25 -07:00
|
|
|
#endif
|
|
|
|
|
|
2020-08-24 11:03:09 +12:00
|
|
|
#define CMA_MAX_NAME 64
|
|
|
|
|
|
2022-03-22 14:43:17 -07:00
|
|
|
/*
|
2022-05-12 20:22:58 -07:00
|
|
|
* the buddy -- especially pageblock merging and alloc_contig_range()
|
2022-03-22 14:43:17 -07:00
|
|
|
* -- can deal with only some pageblocks of a higher-order page being
|
|
|
|
|
* MIGRATE_CMA, we can use pageblock_nr_pages.
|
|
|
|
|
*/
|
2022-05-12 20:22:58 -07:00
|
|
|
#define CMA_MIN_ALIGNMENT_PAGES pageblock_nr_pages
|
2022-03-22 14:43:17 -07:00
|
|
|
#define CMA_MIN_ALIGNMENT_BYTES (PAGE_SIZE * CMA_MIN_ALIGNMENT_PAGES)
|
|
|
|
|
|
2014-08-06 16:05:25 -07:00
|
|
|
struct cma;
|
|
|
|
|
|
mm: cma: split cma-reserved in dmesg log
When the system boots up, in the dmesg logs we can see the memory
statistics along with total reserved as below. Memory: 458840k/458840k
available, 65448k reserved, 0K highmem
When CMA is enabled, still the total reserved memory remains the same.
However, the CMA memory is not considered as reserved. But, when we see
/proc/meminfo, the CMA memory is part of free memory. This creates
confusion. This patch corrects the problem by properly subtracting the
CMA reserved memory from the total reserved memory in dmesg logs.
Below is the dmesg snapshot from an arm based device with 512MB RAM and
12MB single CMA region.
Before this change:
Memory: 458840k/458840k available, 65448k reserved, 0K highmem
After this change:
Memory: 458840k/458840k available, 53160k reserved, 12288k cma-reserved, 0K highmem
Signed-off-by: Pintu Kumar <pintu.k@samsung.com>
Signed-off-by: Vishnu Pratap Singh <vishnu.ps@samsung.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Cc: Rafael Aquini <aquini@redhat.com>
Cc: Jerome Marchand <jmarchan@redhat.com>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2014-12-18 16:17:15 -08:00
|
|
|
extern unsigned long totalcma_pages;
|
2015-04-14 15:47:04 -07:00
|
|
|
extern phys_addr_t cma_get_base(const struct cma *cma);
|
|
|
|
|
extern unsigned long cma_get_size(const struct cma *cma);
|
2017-04-18 11:27:03 -07:00
|
|
|
extern const char *cma_get_name(const struct cma *cma);
|
2014-08-06 16:05:25 -07:00
|
|
|
|
2020-04-10 14:32:42 -07:00
|
|
|
extern int __init cma_declare_contiguous_nid(phys_addr_t base,
|
2014-10-24 17:47:57 +08:00
|
|
|
phys_addr_t size, phys_addr_t limit,
|
2014-08-06 16:05:25 -07:00
|
|
|
phys_addr_t alignment, unsigned int order_per_bit,
|
2020-04-10 14:32:42 -07:00
|
|
|
bool fixed, const char *name, struct cma **res_cma,
|
|
|
|
|
int nid);
|
|
|
|
|
static inline int __init cma_declare_contiguous(phys_addr_t base,
|
|
|
|
|
phys_addr_t size, phys_addr_t limit,
|
|
|
|
|
phys_addr_t alignment, unsigned int order_per_bit,
|
|
|
|
|
bool fixed, const char *name, struct cma **res_cma)
|
|
|
|
|
{
|
|
|
|
|
return cma_declare_contiguous_nid(base, size, limit, alignment,
|
|
|
|
|
order_per_bit, fixed, name, res_cma, NUMA_NO_NODE);
|
|
|
|
|
}
|
mm, cma: support multiple contiguous ranges, if requested
Currently, CMA manages one range of physically contiguous memory.
Creation of larger CMA areas with hugetlb_cma may run in to gaps in
physical memory, so that they are not able to allocate that contiguous
physical range from memblock when creating the CMA area.
This can happen, for example, on an AMD system with > 1TB of memory, where
there will be a gap just below the 1TB (40bit DMA) line. If you have set
aside most of memory for potential hugetlb CMA allocation,
cma_declare_contiguous_nid will fail.
hugetlb_cma doesn't need the entire area to be one physically contiguous
range. It just cares about being able to get physically contiguous chunks
of a certain size (e.g. 1G), and it is fine to have the CMA area backed
by multiple physical ranges, as long as it gets 1G contiguous allocations.
Multi-range support is implemented by introducing an array of ranges,
instead of just one big one. Each range has its own bitmap. Effectively,
the allocate and release operations work as before, just per-range. So,
instead of going through one large bitmap, they now go through a number of
smaller ones.
The maximum number of supported ranges is 8, as defined in CMA_MAX_RANGES.
Since some current users of CMA expect a CMA area to just use one
physically contiguous range, only allow for multiple ranges if a new
interface, cma_declare_contiguous_nid_multi, is used. The other
interfaces will work like before, creating only CMA areas with 1 range.
cma_declare_contiguous_nid_multi works as follows, mimicking the
default "bottom-up, above 4G" reservation approach:
0) Try cma_declare_contiguous_nid, which will use only one
region. If this succeeds, return. This makes sure that for
all the cases that currently work, the behavior remains
unchanged even if the caller switches from
cma_declare_contiguous_nid to cma_declare_contiguous_nid_multi.
1) Select the largest free memblock ranges above 4G, with
a maximum number of CMA_MAX_RANGES.
2) If we did not find at most CMA_MAX_RANGES that add
up to the total size requested, return -ENOMEM.
3) Sort the selected ranges by base address.
4) Reserve them bottom-up until we get what we wanted.
Link: https://lkml.kernel.org/r/20250228182928.2645936-3-fvdl@google.com
Signed-off-by: Frank van der Linden <fvdl@google.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Dan Carpenter <dan.carpenter@linaro.org>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Joao Martins <joao.m.martins@oracle.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Roman Gushchin (Cruise) <roman.gushchin@linux.dev>
Cc: Usama Arif <usamaarif642@gmail.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Yu Zhao <yuzhao@google.com>
Cc: Zi Yan <ziy@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2025-02-28 18:29:03 +00:00
|
|
|
extern int __init cma_declare_contiguous_multi(phys_addr_t size,
|
|
|
|
|
phys_addr_t align, unsigned int order_per_bit,
|
|
|
|
|
const char *name, struct cma **res_cma, int nid);
|
2015-04-14 15:47:04 -07:00
|
|
|
extern int cma_init_reserved_mem(phys_addr_t base, phys_addr_t size,
|
|
|
|
|
unsigned int order_per_bit,
|
2017-04-18 11:27:03 -07:00
|
|
|
const char *name,
|
2014-10-13 15:51:09 -07:00
|
|
|
struct cma **res_cma);
|
2021-05-04 18:37:34 -07:00
|
|
|
extern struct page *cma_alloc(struct cma *cma, unsigned long count, unsigned int align,
|
2018-08-17 15:48:57 -07:00
|
|
|
bool no_warn);
|
2021-11-05 13:41:23 -07:00
|
|
|
extern bool cma_pages_valid(struct cma *cma, const struct page *pages, unsigned long count);
|
2021-05-04 18:37:34 -07:00
|
|
|
extern bool cma_release(struct cma *cma, const struct page *pages, unsigned long count);
|
2017-04-18 11:27:04 -07:00
|
|
|
|
|
|
|
|
extern int cma_for_each_area(int (*it)(struct cma *cma, void *data), void *data);
|
2025-02-28 18:29:04 +00:00
|
|
|
extern bool cma_intersects(struct cma *cma, unsigned long start, unsigned long end);
|
2022-03-22 14:46:14 -07:00
|
|
|
|
|
|
|
|
extern void cma_reserve_pages_on_error(struct cma *cma);
|
2024-08-13 21:54:50 -06:00
|
|
|
|
|
|
|
|
#ifdef CONFIG_CMA
|
|
|
|
|
struct folio *cma_alloc_folio(struct cma *cma, int order, gfp_t gfp);
|
|
|
|
|
bool cma_free_folio(struct cma *cma, const struct folio *folio);
|
2025-02-28 18:29:24 +00:00
|
|
|
bool cma_validate_zones(struct cma *cma);
|
2024-08-13 21:54:50 -06:00
|
|
|
#else
|
|
|
|
|
static inline struct folio *cma_alloc_folio(struct cma *cma, int order, gfp_t gfp)
|
|
|
|
|
{
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline bool cma_free_folio(struct cma *cma, const struct folio *folio)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2025-02-28 18:29:24 +00:00
|
|
|
static inline bool cma_validate_zones(struct cma *cma)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2024-08-13 21:54:50 -06:00
|
|
|
#endif
|
|
|
|
|
|
2014-08-06 16:05:25 -07:00
|
|
|
#endif
|