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 21:07:57 +07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2005-04-17 05:20:36 +07:00
|
|
|
#ifndef __LINUX_COMPLETION_H
|
|
|
|
#define __LINUX_COMPLETION_H
|
|
|
|
|
|
|
|
/*
|
|
|
|
* (C) Copyright 2001 Linus Torvalds
|
|
|
|
*
|
|
|
|
* Atomic wait-for-completion handler data structures.
|
2013-10-05 03:06:53 +07:00
|
|
|
* See kernel/sched/completion.c for details.
|
2005-04-17 05:20:36 +07:00
|
|
|
*/
|
|
|
|
|
2020-03-21 18:26:00 +07:00
|
|
|
#include <linux/swait.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2010-10-27 04:17:25 +07:00
|
|
|
/*
|
2008-08-26 15:26:54 +07:00
|
|
|
* struct completion - structure used to maintain state for a "completion"
|
|
|
|
*
|
|
|
|
* This is the opaque structure used to maintain the state for a "completion".
|
|
|
|
* Completions currently use a FIFO to queue threads that have to wait for
|
|
|
|
* the "completion" event.
|
|
|
|
*
|
|
|
|
* See also: complete(), wait_for_completion() (and friends _timeout,
|
|
|
|
* _interruptible, _interruptible_timeout, and _killable), init_completion(),
|
2013-11-15 05:32:01 +07:00
|
|
|
* reinit_completion(), and macros DECLARE_COMPLETION(),
|
|
|
|
* DECLARE_COMPLETION_ONSTACK().
|
2008-08-26 15:26:54 +07:00
|
|
|
*/
|
2005-04-17 05:20:36 +07:00
|
|
|
struct completion {
|
|
|
|
unsigned int done;
|
2020-03-21 18:26:00 +07:00
|
|
|
struct swait_queue_head wait;
|
2005-04-17 05:20:36 +07:00
|
|
|
};
|
|
|
|
|
2017-10-25 15:56:03 +07:00
|
|
|
#define init_completion_map(x, m) __init_completion(x)
|
2017-08-07 14:12:56 +07:00
|
|
|
#define init_completion(x) __init_completion(x)
|
|
|
|
static inline void complete_acquire(struct completion *x) {}
|
|
|
|
static inline void complete_release(struct completion *x) {}
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
#define COMPLETION_INITIALIZER(work) \
|
2020-03-21 18:26:00 +07:00
|
|
|
{ 0, __SWAIT_QUEUE_HEAD_INITIALIZER((work).wait) }
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2017-10-25 15:56:03 +07:00
|
|
|
#define COMPLETION_INITIALIZER_ONSTACK_MAP(work, map) \
|
|
|
|
(*({ init_completion_map(&(work), &(map)); &(work); }))
|
|
|
|
|
2006-07-10 18:44:05 +07:00
|
|
|
#define COMPLETION_INITIALIZER_ONSTACK(work) \
|
sched/completion: Avoid unnecessary stack allocation for COMPLETION_INITIALIZER_ONSTACK()
In theory, COMPLETION_INITIALIZER_ONSTACK() should never affect the
stack allocation of the caller. However, on some compilers, a temporary
structure was allocated for the return value of
COMPLETION_INITIALIZER_ONSTACK().
For example in write_journal() with LOCKDEP_COMPLETIONS=y (GCC is 7.1.1):
io_comp.comp = COMPLETION_INITIALIZER_ONSTACK(io_comp.comp);
2462: e8 00 00 00 00 callq 2467 <write_journal+0x47>
2467: 48 8d 85 80 fd ff ff lea -0x280(%rbp),%rax
246e: 48 c7 c6 00 00 00 00 mov $0x0,%rsi
2475: 48 c7 c2 00 00 00 00 mov $0x0,%rdx
x->done = 0;
247c: c7 85 90 fd ff ff 00 movl $0x0,-0x270(%rbp)
2483: 00 00 00
init_waitqueue_head(&x->wait);
2486: 48 8d 78 18 lea 0x18(%rax),%rdi
248a: e8 00 00 00 00 callq 248f <write_journal+0x6f>
if (commit_start + commit_sections <= ic->journal_sections) {
248f: 41 8b 87 a8 00 00 00 mov 0xa8(%r15),%eax
io_comp.comp = COMPLETION_INITIALIZER_ONSTACK(io_comp.comp);
2496: 48 8d bd e8 f9 ff ff lea -0x618(%rbp),%rdi
249d: 48 8d b5 90 fd ff ff lea -0x270(%rbp),%rsi
24a4: b9 17 00 00 00 mov $0x17,%ecx
24a9: f3 48 a5 rep movsq %ds:(%rsi),%es:(%rdi)
if (commit_start + commit_sections <= ic->journal_sections) {
24ac: 41 39 c6 cmp %eax,%r14d
io_comp.comp = COMPLETION_INITIALIZER_ONSTACK(io_comp.comp);
24af: 48 8d bd 90 fd ff ff lea -0x270(%rbp),%rdi
24b6: 48 8d b5 e8 f9 ff ff lea -0x618(%rbp),%rsi
24bd: b9 17 00 00 00 mov $0x17,%ecx
24c2: f3 48 a5 rep movsq %ds:(%rsi),%es:(%rdi)
We can obviously see the temporary structure allocated, and the compiler
also does two meaningless memcpy with "rep movsq".
And according to:
https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html#Statement-Exprs
The return value of a statement expression is returned by value, so the
temporary variable is created in COMPLETION_INITIALIZER_ONSTACK(), and
that's why the temporary structures are allocted.
To fix this, make the brace block in COMPLETION_INITIALIZER_ONSTACK()
return a pointer and dereference it outside the block rather than return
the whole structure, in this way, we are able to teach the compiler not
to do the unnecessary stack allocation.
This could also reduce the stack size even if !LOCKDEP, for example in
write_journal(), compiled with gcc 7.1.1, the result of command:
objdump -d drivers/md/dm-integrity.o | ./scripts/checkstack.pl x86
before:
0x0000246a write_journal [dm-integrity.o]: 696
after:
0x00002b7a write_journal [dm-integrity.o]: 296
Reported-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Byungchul Park <byungchul.park@lge.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: walken@google.com
Cc: willy@infradead.org
Link: http://lkml.kernel.org/r/20170823152542.5150-3-boqun.feng@gmail.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2017-08-23 22:25:38 +07:00
|
|
|
(*({ init_completion(&work); &work; }))
|
2006-07-10 18:44:05 +07:00
|
|
|
|
2008-08-26 15:26:54 +07:00
|
|
|
/**
|
2010-10-27 04:17:25 +07:00
|
|
|
* DECLARE_COMPLETION - declare and initialize a completion structure
|
2008-08-26 15:26:54 +07:00
|
|
|
* @work: identifier for the completion structure
|
|
|
|
*
|
|
|
|
* This macro declares and initializes a completion structure. Generally used
|
|
|
|
* for static declarations. You should use the _ONSTACK variant for automatic
|
|
|
|
* variables.
|
|
|
|
*/
|
2005-04-17 05:20:36 +07:00
|
|
|
#define DECLARE_COMPLETION(work) \
|
|
|
|
struct completion work = COMPLETION_INITIALIZER(work)
|
|
|
|
|
2006-07-03 14:24:28 +07:00
|
|
|
/*
|
|
|
|
* Lockdep needs to run a non-constant initializer for on-stack
|
|
|
|
* completions - so we use the _ONSTACK() variant for those that
|
|
|
|
* are on the kernel stack:
|
|
|
|
*/
|
2008-08-26 15:26:54 +07:00
|
|
|
/**
|
2010-10-27 04:17:25 +07:00
|
|
|
* DECLARE_COMPLETION_ONSTACK - declare and initialize a completion structure
|
2008-08-26 15:26:54 +07:00
|
|
|
* @work: identifier for the completion structure
|
|
|
|
*
|
|
|
|
* This macro declares and initializes a completion structure on the kernel
|
|
|
|
* stack.
|
|
|
|
*/
|
2006-07-03 14:24:28 +07:00
|
|
|
#ifdef CONFIG_LOCKDEP
|
|
|
|
# define DECLARE_COMPLETION_ONSTACK(work) \
|
2006-07-10 18:44:05 +07:00
|
|
|
struct completion work = COMPLETION_INITIALIZER_ONSTACK(work)
|
2017-10-25 15:56:03 +07:00
|
|
|
# define DECLARE_COMPLETION_ONSTACK_MAP(work, map) \
|
|
|
|
struct completion work = COMPLETION_INITIALIZER_ONSTACK_MAP(work, map)
|
2006-07-03 14:24:28 +07:00
|
|
|
#else
|
|
|
|
# define DECLARE_COMPLETION_ONSTACK(work) DECLARE_COMPLETION(work)
|
2017-10-25 15:56:03 +07:00
|
|
|
# define DECLARE_COMPLETION_ONSTACK_MAP(work, map) DECLARE_COMPLETION(work)
|
2006-07-03 14:24:28 +07:00
|
|
|
#endif
|
|
|
|
|
2008-08-26 15:26:54 +07:00
|
|
|
/**
|
2010-10-27 04:17:25 +07:00
|
|
|
* init_completion - Initialize a dynamically allocated completion
|
2013-11-15 05:32:01 +07:00
|
|
|
* @x: pointer to completion structure that is to be initialized
|
2008-08-26 15:26:54 +07:00
|
|
|
*
|
|
|
|
* This inline function will initialize a dynamically created completion
|
|
|
|
* structure.
|
|
|
|
*/
|
2017-08-07 14:12:56 +07:00
|
|
|
static inline void __init_completion(struct completion *x)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
x->done = 0;
|
2020-03-21 18:26:00 +07:00
|
|
|
init_swait_queue_head(&x->wait);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2013-11-15 05:32:01 +07:00
|
|
|
/**
|
|
|
|
* reinit_completion - reinitialize a completion structure
|
|
|
|
* @x: pointer to completion structure that is to be reinitialized
|
|
|
|
*
|
|
|
|
* This inline function should be used to reinitialize a completion structure so it can
|
|
|
|
* be reused. This is especially important after complete_all() is used.
|
|
|
|
*/
|
|
|
|
static inline void reinit_completion(struct completion *x)
|
|
|
|
{
|
|
|
|
x->done = 0;
|
|
|
|
}
|
|
|
|
|
2007-10-24 23:23:48 +07:00
|
|
|
extern void wait_for_completion(struct completion *);
|
2013-02-14 21:19:58 +07:00
|
|
|
extern void wait_for_completion_io(struct completion *);
|
2007-10-24 23:23:48 +07:00
|
|
|
extern int wait_for_completion_interruptible(struct completion *x);
|
2007-12-07 00:29:54 +07:00
|
|
|
extern int wait_for_completion_killable(struct completion *x);
|
2007-10-24 23:23:48 +07:00
|
|
|
extern unsigned long wait_for_completion_timeout(struct completion *x,
|
|
|
|
unsigned long timeout);
|
2013-02-14 21:19:58 +07:00
|
|
|
extern unsigned long wait_for_completion_io_timeout(struct completion *x,
|
|
|
|
unsigned long timeout);
|
2011-01-05 08:50:16 +07:00
|
|
|
extern long wait_for_completion_interruptible_timeout(
|
|
|
|
struct completion *x, unsigned long timeout);
|
|
|
|
extern long wait_for_completion_killable_timeout(
|
|
|
|
struct completion *x, unsigned long timeout);
|
2008-08-15 14:40:44 +07:00
|
|
|
extern bool try_wait_for_completion(struct completion *x);
|
|
|
|
extern bool completion_done(struct completion *x);
|
2007-10-24 23:23:48 +07:00
|
|
|
|
|
|
|
extern void complete(struct completion *);
|
|
|
|
extern void complete_all(struct completion *);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
#endif
|