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 14:07:57 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2005-04-16 22:20:36 +00:00
|
|
|
#ifndef __LINUX_CACHE_H
|
|
|
|
#define __LINUX_CACHE_H
|
|
|
|
|
2014-01-23 23:54:16 +00:00
|
|
|
#include <uapi/linux/kernel.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <asm/cache.h>
|
|
|
|
|
|
|
|
#ifndef L1_CACHE_ALIGN
|
2014-01-23 23:54:16 +00:00
|
|
|
#define L1_CACHE_ALIGN(x) __ALIGN_KERNEL(x, L1_CACHE_BYTES)
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef SMP_CACHE_BYTES
|
|
|
|
#define SMP_CACHE_BYTES L1_CACHE_BYTES
|
|
|
|
#endif
|
|
|
|
|
cache: add __cacheline_group_{begin, end}_aligned() (+ couple more)
JIRA: https://issues.redhat.com/browse/RHEL-68652
commit 2cb13dec8c5e5e104fd2f71c2dee761d6ed9a333
Author: Alexander Lobakin <aleksander.lobakin@intel.com>
Date: Thu Jun 20 15:53:34 2024 +0200
cache: add __cacheline_group_{begin, end}_aligned() (+ couple more)
__cacheline_group_begin(), unfortunately, doesn't align the group
anyhow. If it is wanted, then you need to do something like
__cacheline_group_begin(grp) __aligned(ALIGN)
which isn't really convenient nor compact.
Add the _aligned() counterparts to align the groups automatically to
either the specified alignment (optional) or ``SMP_CACHE_BYTES``.
Note that the actual struct layout will then be (on x64 with 64-byte CL):
struct x {
u32 y; // offset 0, size 4, padding 56
__cacheline_group_begin__grp; // offset 64, size 0
u32 z; // offset 64, size 4, padding 4
__cacheline_group_end__grp; // offset 72, size 0
__cacheline_group_pad__grp; // offset 72, size 0, padding 56
u32 w; // offset 128
};
The end marker is aligned to long, so that you can assert the struct
size more strictly, but the offset of the next field in the structure
will be aligned to the group alignment, so that the next field won't
fall into the group it's not intended to.
Add __LARGEST_ALIGN definition and LARGEST_ALIGN() macro.
__LARGEST_ALIGN is the value to which the compilers align fields when
__aligned_largest is specified. Sometimes, it might be needed to get
this value outside of variable definitions. LARGEST_ALIGN() is macro
which just aligns a value to __LARGEST_ALIGN.
Also add SMP_CACHE_ALIGN(), similar to L1_CACHE_ALIGN(), but using
``SMP_CACHE_BYTES`` instead of ``L1_CACHE_BYTES`` as the former
also accounts L2, needed in some cases.
Signed-off-by: Alexander Lobakin <aleksander.lobakin@intel.com>
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Signed-off-by: CKI Backport Bot <cki-ci-bot+cki-gitlab-backport-bot@redhat.com>
2024-11-22 14:44:32 +00:00
|
|
|
/**
|
|
|
|
* SMP_CACHE_ALIGN - align a value to the L2 cacheline size
|
|
|
|
* @x: value to align
|
|
|
|
*
|
|
|
|
* On some architectures, L2 ("SMP") CL size is bigger than L1, and sometimes,
|
|
|
|
* this needs to be accounted.
|
|
|
|
*
|
|
|
|
* Return: aligned value.
|
|
|
|
*/
|
|
|
|
#ifndef SMP_CACHE_ALIGN
|
|
|
|
#define SMP_CACHE_ALIGN(x) ALIGN(x, SMP_CACHE_BYTES)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ``__aligned_largest`` aligns a field to the value most optimal for the
|
|
|
|
* target architecture to perform memory operations. Get the actual value
|
|
|
|
* to be able to use it anywhere else.
|
|
|
|
*/
|
|
|
|
#ifndef __LARGEST_ALIGN
|
|
|
|
#define __LARGEST_ALIGN sizeof(struct { long x; } __aligned_largest)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef LARGEST_ALIGN
|
|
|
|
#define LARGEST_ALIGN(x) ALIGN(x, __LARGEST_ALIGN)
|
|
|
|
#endif
|
|
|
|
|
2016-02-17 22:41:15 +00:00
|
|
|
/*
|
|
|
|
* __read_mostly is used to keep rarely changing variables out of frequently
|
2020-06-09 04:35:07 +00:00
|
|
|
* updated cachelines. Its use should be reserved for data that is used
|
|
|
|
* frequently in hot paths. Performance traces can help decide when to use
|
|
|
|
* this. You want __read_mostly data to be tightly packed, so that in the
|
|
|
|
* best case multiple frequently read variables for a hot path will be next
|
|
|
|
* to each other in order to reduce the number of cachelines needed to
|
|
|
|
* execute a critical path. We should be mindful and selective of its use.
|
|
|
|
* ie: if you're going to use it please supply a *good* justification in your
|
|
|
|
* commit log
|
2016-02-17 22:41:15 +00:00
|
|
|
*/
|
2006-03-23 11:00:16 +00:00
|
|
|
#ifndef __read_mostly
|
2005-07-08 00:56:59 +00:00
|
|
|
#define __read_mostly
|
|
|
|
#endif
|
|
|
|
|
2016-02-17 22:41:15 +00:00
|
|
|
/*
|
|
|
|
* __ro_after_init is used to mark things that are read-only after init (i.e.
|
|
|
|
* after mark_rodata_ro() has been called). These are effectively read-only,
|
|
|
|
* but may get written to during init, so can't live in .rodata (via "const").
|
|
|
|
*/
|
|
|
|
#ifndef __ro_after_init
|
2020-10-22 02:36:07 +00:00
|
|
|
#define __ro_after_init __section(".data..ro_after_init")
|
2016-02-17 22:41:15 +00:00
|
|
|
#endif
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
#ifndef ____cacheline_aligned
|
|
|
|
#define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef ____cacheline_aligned_in_smp
|
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
#define ____cacheline_aligned_in_smp ____cacheline_aligned
|
|
|
|
#else
|
|
|
|
#define ____cacheline_aligned_in_smp
|
|
|
|
#endif /* CONFIG_SMP */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __cacheline_aligned
|
|
|
|
#define __cacheline_aligned \
|
|
|
|
__attribute__((__aligned__(SMP_CACHE_BYTES), \
|
2010-02-20 00:03:34 +00:00
|
|
|
__section__(".data..cacheline_aligned")))
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif /* __cacheline_aligned */
|
|
|
|
|
|
|
|
#ifndef __cacheline_aligned_in_smp
|
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
#define __cacheline_aligned_in_smp __cacheline_aligned
|
|
|
|
#else
|
|
|
|
#define __cacheline_aligned_in_smp
|
|
|
|
#endif /* CONFIG_SMP */
|
|
|
|
#endif
|
|
|
|
|
2006-01-08 09:01:27 +00:00
|
|
|
/*
|
|
|
|
* The maximum alignment needed for some critical structures
|
|
|
|
* These could be inter-node cacheline sizes/L3 cacheline
|
|
|
|
* size etc. Define this in asm/cache.h for your arch
|
|
|
|
*/
|
|
|
|
#ifndef INTERNODE_CACHE_SHIFT
|
|
|
|
#define INTERNODE_CACHE_SHIFT L1_CACHE_SHIFT
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !defined(____cacheline_internodealigned_in_smp)
|
2005-04-16 22:20:36 +00:00
|
|
|
#if defined(CONFIG_SMP)
|
2006-01-08 09:01:27 +00:00
|
|
|
#define ____cacheline_internodealigned_in_smp \
|
|
|
|
__attribute__((__aligned__(1 << (INTERNODE_CACHE_SHIFT))))
|
2005-04-16 22:20:36 +00:00
|
|
|
#else
|
2006-01-08 09:01:27 +00:00
|
|
|
#define ____cacheline_internodealigned_in_smp
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2008-04-28 09:12:22 +00:00
|
|
|
#ifndef CONFIG_ARCH_HAS_CACHE_LINE_SIZE
|
|
|
|
#define cache_line_size() L1_CACHE_BYTES
|
|
|
|
#endif
|
|
|
|
|
2024-04-26 11:56:42 +00:00
|
|
|
#ifndef __cacheline_group_begin
|
|
|
|
#define __cacheline_group_begin(GROUP) \
|
|
|
|
__u8 __cacheline_group_begin__##GROUP[0]
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __cacheline_group_end
|
|
|
|
#define __cacheline_group_end(GROUP) \
|
|
|
|
__u8 __cacheline_group_end__##GROUP[0]
|
|
|
|
#endif
|
|
|
|
|
cache: add __cacheline_group_{begin, end}_aligned() (+ couple more)
JIRA: https://issues.redhat.com/browse/RHEL-68652
commit 2cb13dec8c5e5e104fd2f71c2dee761d6ed9a333
Author: Alexander Lobakin <aleksander.lobakin@intel.com>
Date: Thu Jun 20 15:53:34 2024 +0200
cache: add __cacheline_group_{begin, end}_aligned() (+ couple more)
__cacheline_group_begin(), unfortunately, doesn't align the group
anyhow. If it is wanted, then you need to do something like
__cacheline_group_begin(grp) __aligned(ALIGN)
which isn't really convenient nor compact.
Add the _aligned() counterparts to align the groups automatically to
either the specified alignment (optional) or ``SMP_CACHE_BYTES``.
Note that the actual struct layout will then be (on x64 with 64-byte CL):
struct x {
u32 y; // offset 0, size 4, padding 56
__cacheline_group_begin__grp; // offset 64, size 0
u32 z; // offset 64, size 4, padding 4
__cacheline_group_end__grp; // offset 72, size 0
__cacheline_group_pad__grp; // offset 72, size 0, padding 56
u32 w; // offset 128
};
The end marker is aligned to long, so that you can assert the struct
size more strictly, but the offset of the next field in the structure
will be aligned to the group alignment, so that the next field won't
fall into the group it's not intended to.
Add __LARGEST_ALIGN definition and LARGEST_ALIGN() macro.
__LARGEST_ALIGN is the value to which the compilers align fields when
__aligned_largest is specified. Sometimes, it might be needed to get
this value outside of variable definitions. LARGEST_ALIGN() is macro
which just aligns a value to __LARGEST_ALIGN.
Also add SMP_CACHE_ALIGN(), similar to L1_CACHE_ALIGN(), but using
``SMP_CACHE_BYTES`` instead of ``L1_CACHE_BYTES`` as the former
also accounts L2, needed in some cases.
Signed-off-by: Alexander Lobakin <aleksander.lobakin@intel.com>
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Signed-off-by: CKI Backport Bot <cki-ci-bot+cki-gitlab-backport-bot@redhat.com>
2024-11-22 14:44:32 +00:00
|
|
|
/**
|
|
|
|
* __cacheline_group_begin_aligned - declare an aligned group start
|
|
|
|
* @GROUP: name of the group
|
|
|
|
* @...: optional group alignment
|
|
|
|
*
|
|
|
|
* The following block inside a struct:
|
|
|
|
*
|
|
|
|
* __cacheline_group_begin_aligned(grp);
|
|
|
|
* field a;
|
|
|
|
* field b;
|
|
|
|
* __cacheline_group_end_aligned(grp);
|
|
|
|
*
|
|
|
|
* will always be aligned to either the specified alignment or
|
|
|
|
* ``SMP_CACHE_BYTES``.
|
|
|
|
*/
|
|
|
|
#define __cacheline_group_begin_aligned(GROUP, ...) \
|
|
|
|
__cacheline_group_begin(GROUP) \
|
|
|
|
__aligned((__VA_ARGS__ + 0) ? : SMP_CACHE_BYTES)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* __cacheline_group_end_aligned - declare an aligned group end
|
|
|
|
* @GROUP: name of the group
|
|
|
|
* @...: optional alignment (same as was in __cacheline_group_begin_aligned())
|
|
|
|
*
|
|
|
|
* Note that the end marker is aligned to sizeof(long) to allow more precise
|
|
|
|
* size assertion. It also declares a padding at the end to avoid next field
|
|
|
|
* falling into this cacheline.
|
|
|
|
*/
|
|
|
|
#define __cacheline_group_end_aligned(GROUP, ...) \
|
|
|
|
__cacheline_group_end(GROUP) __aligned(sizeof(long)); \
|
|
|
|
struct { } __cacheline_group_pad__##GROUP \
|
|
|
|
__aligned((__VA_ARGS__ + 0) ? : SMP_CACHE_BYTES)
|
|
|
|
|
2024-04-26 11:56:42 +00:00
|
|
|
#ifndef CACHELINE_ASSERT_GROUP_MEMBER
|
|
|
|
#define CACHELINE_ASSERT_GROUP_MEMBER(TYPE, GROUP, MEMBER) \
|
|
|
|
BUILD_BUG_ON(!(offsetof(TYPE, MEMBER) >= \
|
|
|
|
offsetofend(TYPE, __cacheline_group_begin__##GROUP) && \
|
|
|
|
offsetofend(TYPE, MEMBER) <= \
|
|
|
|
offsetof(TYPE, __cacheline_group_end__##GROUP)))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef CACHELINE_ASSERT_GROUP_SIZE
|
|
|
|
#define CACHELINE_ASSERT_GROUP_SIZE(TYPE, GROUP, SIZE) \
|
|
|
|
BUILD_BUG_ON(offsetof(TYPE, __cacheline_group_end__##GROUP) - \
|
|
|
|
offsetofend(TYPE, __cacheline_group_begin__##GROUP) > \
|
|
|
|
SIZE)
|
|
|
|
#endif
|
|
|
|
|
2022-10-31 23:33:27 +00:00
|
|
|
/*
|
|
|
|
* Helper to add padding within a struct to ensure data fall into separate
|
|
|
|
* cachelines.
|
|
|
|
*/
|
|
|
|
#if defined(CONFIG_SMP)
|
|
|
|
struct cacheline_padding {
|
|
|
|
char x[0];
|
|
|
|
} ____cacheline_internodealigned_in_smp;
|
|
|
|
#define CACHELINE_PADDING(name) struct cacheline_padding name
|
|
|
|
#else
|
|
|
|
#define CACHELINE_PADDING(name)
|
|
|
|
#endif
|
|
|
|
|
2023-06-12 15:31:45 +00:00
|
|
|
#ifdef ARCH_DMA_MINALIGN
|
|
|
|
#define ARCH_HAS_DMA_MINALIGN
|
|
|
|
#else
|
|
|
|
#define ARCH_DMA_MINALIGN __alignof__(unsigned long long)
|
|
|
|
#endif
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif /* __LINUX_CACHE_H */
|