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
|
2016-03-18 05:21:45 +08:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <assert.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/bitops.h>
|
|
|
|
|
|
|
|
#include "test.h"
|
|
|
|
|
|
|
|
struct item *
|
|
|
|
item_tag_set(struct radix_tree_root *root, unsigned long index, int tag)
|
|
|
|
{
|
|
|
|
return radix_tree_tag_set(root, index, tag);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct item *
|
|
|
|
item_tag_clear(struct radix_tree_root *root, unsigned long index, int tag)
|
|
|
|
{
|
|
|
|
return radix_tree_tag_clear(root, index, tag);
|
|
|
|
}
|
|
|
|
|
|
|
|
int item_tag_get(struct radix_tree_root *root, unsigned long index, int tag)
|
|
|
|
{
|
|
|
|
return radix_tree_tag_get(root, index, tag);
|
|
|
|
}
|
|
|
|
|
2016-12-15 07:08:23 +08:00
|
|
|
int __item_insert(struct radix_tree_root *root, struct item *item)
|
2016-03-18 05:21:45 +08:00
|
|
|
{
|
2016-12-15 07:08:23 +08:00
|
|
|
return __radix_tree_insert(root, item->index, item->order, item);
|
2016-03-18 05:21:45 +08:00
|
|
|
}
|
|
|
|
|
2017-01-29 14:48:34 +08:00
|
|
|
struct item *item_create(unsigned long index, unsigned int order)
|
2016-03-18 05:21:45 +08:00
|
|
|
{
|
2017-01-29 14:48:34 +08:00
|
|
|
struct item *ret = malloc(sizeof(*ret));
|
|
|
|
|
|
|
|
ret->index = index;
|
|
|
|
ret->order = order;
|
|
|
|
return ret;
|
2016-05-21 08:02:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int item_insert_order(struct radix_tree_root *root, unsigned long index,
|
|
|
|
unsigned order)
|
|
|
|
{
|
2017-01-29 14:48:34 +08:00
|
|
|
struct item *item = item_create(index, order);
|
|
|
|
int err = __item_insert(root, item);
|
|
|
|
if (err)
|
|
|
|
free(item);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
int item_insert(struct radix_tree_root *root, unsigned long index)
|
|
|
|
{
|
|
|
|
return item_insert_order(root, index, 0);
|
2016-12-15 07:08:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void item_sanity(struct item *item, unsigned long index)
|
|
|
|
{
|
|
|
|
unsigned long mask;
|
|
|
|
assert(!radix_tree_is_internal_node(item));
|
|
|
|
assert(item->order < BITS_PER_LONG);
|
|
|
|
mask = (1UL << item->order) - 1;
|
|
|
|
assert((item->index | mask) == (index | mask));
|
2016-03-18 05:21:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int item_delete(struct radix_tree_root *root, unsigned long index)
|
|
|
|
{
|
|
|
|
struct item *item = radix_tree_delete(root, index);
|
|
|
|
|
|
|
|
if (item) {
|
2016-12-15 07:08:23 +08:00
|
|
|
item_sanity(item, index);
|
2016-03-18 05:21:45 +08:00
|
|
|
free(item);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-05-19 07:08:58 +08:00
|
|
|
static void item_free_rcu(struct rcu_head *head)
|
|
|
|
{
|
|
|
|
struct item *item = container_of(head, struct item, rcu_head);
|
|
|
|
|
|
|
|
free(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
int item_delete_rcu(struct radix_tree_root *root, unsigned long index)
|
|
|
|
{
|
|
|
|
struct item *item = radix_tree_delete(root, index);
|
|
|
|
|
|
|
|
if (item) {
|
|
|
|
item_sanity(item, index);
|
|
|
|
call_rcu(&item->rcu_head, item_free_rcu);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-03-18 05:21:45 +08:00
|
|
|
void item_check_present(struct radix_tree_root *root, unsigned long index)
|
|
|
|
{
|
|
|
|
struct item *item;
|
|
|
|
|
|
|
|
item = radix_tree_lookup(root, index);
|
2016-12-15 07:08:23 +08:00
|
|
|
assert(item != NULL);
|
|
|
|
item_sanity(item, index);
|
2016-03-18 05:21:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
struct item *item_lookup(struct radix_tree_root *root, unsigned long index)
|
|
|
|
{
|
|
|
|
return radix_tree_lookup(root, index);
|
|
|
|
}
|
|
|
|
|
|
|
|
void item_check_absent(struct radix_tree_root *root, unsigned long index)
|
|
|
|
{
|
|
|
|
struct item *item;
|
|
|
|
|
|
|
|
item = radix_tree_lookup(root, index);
|
2016-12-15 07:08:23 +08:00
|
|
|
assert(item == NULL);
|
2016-03-18 05:21:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Scan only the passed (start, start+nr] for present items
|
|
|
|
*/
|
|
|
|
void item_gang_check_present(struct radix_tree_root *root,
|
|
|
|
unsigned long start, unsigned long nr,
|
|
|
|
int chunk, int hop)
|
|
|
|
{
|
|
|
|
struct item *items[chunk];
|
|
|
|
unsigned long into;
|
|
|
|
|
|
|
|
for (into = 0; into < nr; ) {
|
|
|
|
int nfound;
|
|
|
|
int nr_to_find = chunk;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (nr_to_find > (nr - into))
|
|
|
|
nr_to_find = nr - into;
|
|
|
|
|
|
|
|
nfound = radix_tree_gang_lookup(root, (void **)items,
|
|
|
|
start + into, nr_to_find);
|
|
|
|
assert(nfound == nr_to_find);
|
|
|
|
for (i = 0; i < nfound; i++)
|
|
|
|
assert(items[i]->index == start + into + i);
|
|
|
|
into += hop;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Scan the entire tree, only expecting present items (start, start+nr]
|
|
|
|
*/
|
|
|
|
void item_full_scan(struct radix_tree_root *root, unsigned long start,
|
|
|
|
unsigned long nr, int chunk)
|
|
|
|
{
|
|
|
|
struct item *items[chunk];
|
|
|
|
unsigned long into = 0;
|
|
|
|
unsigned long this_index = start;
|
|
|
|
int nfound;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
// printf("%s(0x%08lx, 0x%08lx, %d)\n", __FUNCTION__, start, nr, chunk);
|
|
|
|
|
|
|
|
while ((nfound = radix_tree_gang_lookup(root, (void **)items, into,
|
|
|
|
chunk))) {
|
|
|
|
// printf("At 0x%08lx, nfound=%d\n", into, nfound);
|
|
|
|
for (i = 0; i < nfound; i++) {
|
|
|
|
assert(items[i]->index == this_index);
|
|
|
|
this_index++;
|
|
|
|
}
|
|
|
|
// printf("Found 0x%08lx->0x%08lx\n",
|
|
|
|
// items[0]->index, items[nfound-1]->index);
|
|
|
|
into = this_index;
|
|
|
|
}
|
|
|
|
if (chunk)
|
|
|
|
assert(this_index == start + nr);
|
|
|
|
nfound = radix_tree_gang_lookup(root, (void **)items,
|
|
|
|
this_index, chunk);
|
|
|
|
assert(nfound == 0);
|
|
|
|
}
|
|
|
|
|
2016-12-15 07:08:55 +08:00
|
|
|
/* Use the same pattern as tag_pages_for_writeback() in mm/page-writeback.c */
|
|
|
|
int tag_tagged_items(struct radix_tree_root *root, pthread_mutex_t *lock,
|
|
|
|
unsigned long start, unsigned long end, unsigned batch,
|
|
|
|
unsigned iftag, unsigned thentag)
|
|
|
|
{
|
|
|
|
unsigned long tagged = 0;
|
|
|
|
struct radix_tree_iter iter;
|
|
|
|
void **slot;
|
|
|
|
|
|
|
|
if (batch == 0)
|
|
|
|
batch = 1;
|
|
|
|
|
|
|
|
if (lock)
|
|
|
|
pthread_mutex_lock(lock);
|
|
|
|
radix_tree_for_each_tagged(slot, root, &iter, start, iftag) {
|
|
|
|
if (iter.index > end)
|
|
|
|
break;
|
|
|
|
radix_tree_iter_tag_set(root, &iter, thentag);
|
|
|
|
tagged++;
|
|
|
|
if ((tagged % batch) != 0)
|
|
|
|
continue;
|
|
|
|
slot = radix_tree_iter_resume(slot, &iter);
|
|
|
|
if (lock) {
|
|
|
|
pthread_mutex_unlock(lock);
|
|
|
|
rcu_barrier();
|
|
|
|
pthread_mutex_lock(lock);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (lock)
|
|
|
|
pthread_mutex_unlock(lock);
|
|
|
|
|
|
|
|
return tagged;
|
|
|
|
}
|
|
|
|
|
2016-12-15 07:08:52 +08:00
|
|
|
/* Use the same pattern as find_swap_entry() in mm/shmem.c */
|
|
|
|
unsigned long find_item(struct radix_tree_root *root, void *item)
|
|
|
|
{
|
|
|
|
struct radix_tree_iter iter;
|
|
|
|
void **slot;
|
|
|
|
unsigned long found = -1;
|
|
|
|
unsigned long checked = 0;
|
|
|
|
|
|
|
|
radix_tree_for_each_slot(slot, root, &iter, 0) {
|
|
|
|
if (*slot == item) {
|
|
|
|
found = iter.index;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
checked++;
|
|
|
|
if ((checked % 4) != 0)
|
|
|
|
continue;
|
|
|
|
slot = radix_tree_iter_resume(slot, &iter);
|
|
|
|
}
|
|
|
|
|
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
2016-03-18 05:21:45 +08:00
|
|
|
static int verify_node(struct radix_tree_node *slot, unsigned int tag,
|
2016-05-21 08:03:16 +08:00
|
|
|
int tagged)
|
2016-03-18 05:21:45 +08:00
|
|
|
{
|
|
|
|
int anyset = 0;
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
|
2016-05-21 08:03:27 +08:00
|
|
|
slot = entry_to_node(slot);
|
2016-03-18 05:21:48 +08:00
|
|
|
|
2016-03-18 05:21:45 +08:00
|
|
|
/* Verify consistency at this level */
|
|
|
|
for (i = 0; i < RADIX_TREE_TAG_LONGS; i++) {
|
|
|
|
if (slot->tags[tag][i]) {
|
|
|
|
anyset = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (tagged != anyset) {
|
2016-05-21 08:03:16 +08:00
|
|
|
printf("tag: %u, shift %u, tagged: %d, anyset: %d\n",
|
|
|
|
tag, slot->shift, tagged, anyset);
|
2016-03-18 05:21:45 +08:00
|
|
|
for (j = 0; j < RADIX_TREE_MAX_TAGS; j++) {
|
|
|
|
printf("tag %d: ", j);
|
|
|
|
for (i = 0; i < RADIX_TREE_TAG_LONGS; i++)
|
|
|
|
printf("%016lx ", slot->tags[j][i]);
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
assert(tagged == anyset);
|
|
|
|
|
|
|
|
/* Go for next level */
|
2016-05-21 08:03:16 +08:00
|
|
|
if (slot->shift > 0) {
|
2016-03-18 05:21:45 +08:00
|
|
|
for (i = 0; i < RADIX_TREE_MAP_SIZE; i++)
|
|
|
|
if (slot->slots[i])
|
2016-05-21 08:03:16 +08:00
|
|
|
if (verify_node(slot->slots[i], tag,
|
2016-03-18 05:21:45 +08:00
|
|
|
!!test_bit(i, slot->tags[tag]))) {
|
|
|
|
printf("Failure at off %d\n", i);
|
|
|
|
for (j = 0; j < RADIX_TREE_MAX_TAGS; j++) {
|
|
|
|
printf("tag %d: ", j);
|
|
|
|
for (i = 0; i < RADIX_TREE_TAG_LONGS; i++)
|
|
|
|
printf("%016lx ", slot->tags[j][i]);
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void verify_tag_consistency(struct radix_tree_root *root, unsigned int tag)
|
|
|
|
{
|
2016-05-21 08:03:16 +08:00
|
|
|
struct radix_tree_node *node = root->rnode;
|
2016-05-21 08:03:30 +08:00
|
|
|
if (!radix_tree_is_internal_node(node))
|
2016-03-18 05:21:45 +08:00
|
|
|
return;
|
2016-05-21 08:03:16 +08:00
|
|
|
verify_node(node, tag, !!root_tag_get(root, tag));
|
2016-03-18 05:21:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void item_kill_tree(struct radix_tree_root *root)
|
|
|
|
{
|
2016-12-15 07:08:20 +08:00
|
|
|
struct radix_tree_iter iter;
|
|
|
|
void **slot;
|
2016-03-18 05:21:45 +08:00
|
|
|
struct item *items[32];
|
|
|
|
int nfound;
|
|
|
|
|
2016-12-15 07:08:20 +08:00
|
|
|
radix_tree_for_each_slot(slot, root, &iter, 0) {
|
|
|
|
if (radix_tree_exceptional_entry(*slot))
|
|
|
|
radix_tree_delete(root, iter.index);
|
|
|
|
}
|
|
|
|
|
2016-03-18 05:21:45 +08:00
|
|
|
while ((nfound = radix_tree_gang_lookup(root, (void **)items, 0, 32))) {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < nfound; i++) {
|
|
|
|
void *ret;
|
|
|
|
|
|
|
|
ret = radix_tree_delete(root, items[i]->index);
|
|
|
|
assert(ret == items[i]);
|
|
|
|
free(items[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
assert(radix_tree_gang_lookup(root, (void **)items, 0, 32) == 0);
|
|
|
|
assert(root->rnode == NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void tree_verify_min_height(struct radix_tree_root *root, int maxindex)
|
|
|
|
{
|
2016-05-21 08:03:16 +08:00
|
|
|
unsigned shift;
|
|
|
|
struct radix_tree_node *node = root->rnode;
|
2016-05-21 08:03:30 +08:00
|
|
|
if (!radix_tree_is_internal_node(node)) {
|
2016-05-21 08:03:16 +08:00
|
|
|
assert(maxindex == 0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-05-21 08:03:27 +08:00
|
|
|
node = entry_to_node(node);
|
2016-05-21 08:03:16 +08:00
|
|
|
assert(maxindex <= node_maxindex(node));
|
|
|
|
|
|
|
|
shift = node->shift;
|
|
|
|
if (shift > 0)
|
|
|
|
assert(maxindex > shift_maxindex(shift - RADIX_TREE_MAP_SHIFT));
|
|
|
|
else
|
|
|
|
assert(maxindex > 0);
|
2016-03-18 05:21:45 +08:00
|
|
|
}
|