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 */
|
2012-09-17 08:31:14 +00:00
|
|
|
#ifndef __PERF_STATS_H
|
|
|
|
#define __PERF_STATS_H
|
|
|
|
|
2014-04-25 19:31:02 +00:00
|
|
|
#include <linux/types.h>
|
2015-06-03 14:25:59 +00:00
|
|
|
#include <stdio.h>
|
2015-06-26 09:29:10 +00:00
|
|
|
#include "xyarray.h"
|
2017-12-05 14:03:01 +00:00
|
|
|
#include "rblist.h"
|
2012-09-17 08:31:14 +00:00
|
|
|
|
|
|
|
struct stats
|
|
|
|
{
|
|
|
|
double n, mean, M2;
|
2013-08-02 20:05:40 +00:00
|
|
|
u64 max, min;
|
2012-09-17 08:31:14 +00:00
|
|
|
};
|
|
|
|
|
2015-06-04 13:50:55 +00:00
|
|
|
enum perf_stat_evsel_id {
|
|
|
|
PERF_STAT_EVSEL_ID__NONE = 0,
|
2015-06-03 14:25:52 +00:00
|
|
|
PERF_STAT_EVSEL_ID__CYCLES_IN_TX,
|
|
|
|
PERF_STAT_EVSEL_ID__TRANSACTION_START,
|
|
|
|
PERF_STAT_EVSEL_ID__ELISION_START,
|
|
|
|
PERF_STAT_EVSEL_ID__CYCLES_IN_TX_CP,
|
2016-05-24 19:52:37 +00:00
|
|
|
PERF_STAT_EVSEL_ID__TOPDOWN_TOTAL_SLOTS,
|
|
|
|
PERF_STAT_EVSEL_ID__TOPDOWN_SLOTS_ISSUED,
|
|
|
|
PERF_STAT_EVSEL_ID__TOPDOWN_SLOTS_RETIRED,
|
|
|
|
PERF_STAT_EVSEL_ID__TOPDOWN_FETCH_BUBBLES,
|
|
|
|
PERF_STAT_EVSEL_ID__TOPDOWN_RECOVERY_BUBBLES,
|
2017-05-26 19:05:38 +00:00
|
|
|
PERF_STAT_EVSEL_ID__SMI_NUM,
|
|
|
|
PERF_STAT_EVSEL_ID__APERF,
|
2015-06-04 13:50:55 +00:00
|
|
|
PERF_STAT_EVSEL_ID__MAX,
|
|
|
|
};
|
|
|
|
|
2015-10-16 10:41:03 +00:00
|
|
|
struct perf_stat_evsel {
|
2017-07-26 12:02:05 +00:00
|
|
|
struct stats res_stats[3];
|
|
|
|
enum perf_stat_evsel_id id;
|
|
|
|
u64 *group_data;
|
2015-06-04 13:50:55 +00:00
|
|
|
};
|
|
|
|
|
2015-06-03 14:25:59 +00:00
|
|
|
enum aggr_mode {
|
|
|
|
AGGR_NONE,
|
|
|
|
AGGR_GLOBAL,
|
|
|
|
AGGR_SOCKET,
|
|
|
|
AGGR_CORE,
|
perf stat: Introduce --per-thread option
Currently all the -p option PID arguments tasks values get aggregated
and printed as single values.
Adding --per-tasks option to print values per task.
$ perf stat -e cycles,instructions --per-thread -p 30190,30242
^C
Performance counter stats for process id '30190,30242':
cat-30190 0 cycles
yes-30242 3,842,525,421 cycles
cat-30190 0 instructions
yes-30242 10,370,817,010 instructions
1.143155657 seconds time elapsed
Also works under interval mode:
$ perf stat -e cycles,instructions --per-thread -p 30190,30242 -I 1000
# time comm-pid counts unit events
1.000073435 cat-30190 89,058 cycles
1.000073435 yes-30242 3,360,786,902 cycles (100.00%)
1.000073435 cat-30190 14,066 instructions
1.000073435 yes-30242 9,069,937,462 instructions
2.000204830 cat-30190 0 cycles
2.000204830 yes-30242 3,351,667,626 cycles
2.000204830 cat-30190 0 instructions
2.000204830 yes-30242 9,045,796,885 instructions
^C 2.771286639 cat-30190 0 cycles
2.771286639 yes-30242 2,593,884,166 cycles
2.771286639 cat-30190 0 instructions
2.771286639 yes-30242 7,001,171,191 instructions
It works only with -t and -p options, otherwise following error is
printed:
$ perf stat -e cycles --per-thread -I 1000 ls
The --per-thread option is only available when monitoring via -p -t options.
-p, --pid <pid> stat events on existing process id
-t, --tid <tid> stat events on existing thread id
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1435310967-14570-23-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-26 09:29:27 +00:00
|
|
|
AGGR_THREAD,
|
2015-10-16 10:41:04 +00:00
|
|
|
AGGR_UNSET,
|
2015-06-03 14:25:59 +00:00
|
|
|
};
|
|
|
|
|
2017-12-05 14:03:01 +00:00
|
|
|
enum {
|
|
|
|
CTX_BIT_USER = 1 << 0,
|
|
|
|
CTX_BIT_KERNEL = 1 << 1,
|
|
|
|
CTX_BIT_HV = 1 << 2,
|
|
|
|
CTX_BIT_HOST = 1 << 3,
|
|
|
|
CTX_BIT_IDLE = 1 << 4,
|
|
|
|
CTX_BIT_MAX = 1 << 5,
|
|
|
|
};
|
|
|
|
|
|
|
|
#define NUM_CTX CTX_BIT_MAX
|
|
|
|
|
|
|
|
enum stat_type {
|
|
|
|
STAT_NONE = 0,
|
|
|
|
STAT_NSECS,
|
|
|
|
STAT_CYCLES,
|
|
|
|
STAT_STALLED_CYCLES_FRONT,
|
|
|
|
STAT_STALLED_CYCLES_BACK,
|
|
|
|
STAT_BRANCHES,
|
|
|
|
STAT_CACHEREFS,
|
|
|
|
STAT_L1_DCACHE,
|
|
|
|
STAT_L1_ICACHE,
|
|
|
|
STAT_LL_CACHE,
|
|
|
|
STAT_ITLB_CACHE,
|
|
|
|
STAT_DTLB_CACHE,
|
|
|
|
STAT_CYCLES_IN_TX,
|
|
|
|
STAT_TRANSACTION,
|
|
|
|
STAT_ELISION,
|
|
|
|
STAT_TOPDOWN_TOTAL_SLOTS,
|
|
|
|
STAT_TOPDOWN_SLOTS_ISSUED,
|
|
|
|
STAT_TOPDOWN_SLOTS_RETIRED,
|
|
|
|
STAT_TOPDOWN_FETCH_BUBBLES,
|
|
|
|
STAT_TOPDOWN_RECOVERY_BUBBLES,
|
|
|
|
STAT_SMI_NUM,
|
|
|
|
STAT_APERF,
|
|
|
|
STAT_MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
struct runtime_stat {
|
|
|
|
struct rblist value_list;
|
|
|
|
};
|
|
|
|
|
2015-07-21 12:31:22 +00:00
|
|
|
struct perf_stat_config {
|
|
|
|
enum aggr_mode aggr_mode;
|
2015-07-21 12:31:23 +00:00
|
|
|
bool scale;
|
2015-07-21 12:31:24 +00:00
|
|
|
FILE *output;
|
2015-07-21 12:31:25 +00:00
|
|
|
unsigned int interval;
|
2015-07-21 12:31:22 +00:00
|
|
|
};
|
|
|
|
|
2012-09-17 08:31:14 +00:00
|
|
|
void update_stats(struct stats *stats, u64 val);
|
|
|
|
double avg_stats(struct stats *stats);
|
|
|
|
double stddev_stats(struct stats *stats);
|
|
|
|
double rel_stddev_stats(double stddev, double avg);
|
|
|
|
|
2013-08-02 20:05:40 +00:00
|
|
|
static inline void init_stats(struct stats *stats)
|
|
|
|
{
|
|
|
|
stats->n = 0.0;
|
|
|
|
stats->mean = 0.0;
|
|
|
|
stats->M2 = 0.0;
|
|
|
|
stats->min = (u64) -1;
|
|
|
|
stats->max = 0;
|
|
|
|
}
|
2015-06-04 13:50:55 +00:00
|
|
|
|
|
|
|
struct perf_evsel;
|
2015-06-26 09:29:16 +00:00
|
|
|
struct perf_evlist;
|
|
|
|
|
2015-06-04 13:50:55 +00:00
|
|
|
bool __perf_evsel_stat__is(struct perf_evsel *evsel,
|
|
|
|
enum perf_stat_evsel_id id);
|
|
|
|
|
|
|
|
#define perf_stat_evsel__is(evsel, id) \
|
|
|
|
__perf_evsel_stat__is(evsel, PERF_STAT_EVSEL_ID__ ## id)
|
|
|
|
|
|
|
|
void perf_stat_evsel_id_init(struct perf_evsel *evsel);
|
|
|
|
|
2015-06-03 14:25:59 +00:00
|
|
|
extern struct stats walltime_nsecs_stats;
|
|
|
|
|
2016-01-30 17:06:49 +00:00
|
|
|
typedef void (*print_metric_t)(void *ctx, const char *color, const char *unit,
|
|
|
|
const char *fmt, double val);
|
|
|
|
typedef void (*new_line_t )(void *ctx);
|
|
|
|
|
2016-03-01 18:57:52 +00:00
|
|
|
void perf_stat__init_shadow_stats(void);
|
2015-06-03 14:25:59 +00:00
|
|
|
void perf_stat__reset_shadow_stats(void);
|
2017-01-23 21:42:56 +00:00
|
|
|
void perf_stat__update_shadow_stats(struct perf_evsel *counter, u64 count,
|
2015-06-03 14:25:59 +00:00
|
|
|
int cpu);
|
2016-01-30 17:06:49 +00:00
|
|
|
struct perf_stat_output_ctx {
|
|
|
|
void *ctx;
|
|
|
|
print_metric_t print_metric;
|
|
|
|
new_line_t new_line;
|
perf stat: Output JSON MetricExpr metric
Add generic infrastructure to perf stat to output ratios for
"MetricExpr" entries in the event lists. Many events are more useful as
ratios than in raw form, typically some count in relation to total
ticks.
Transfer the MetricExpr information from the alias to the evsel.
We mark the events that need to be collected for MetricExpr, and also
link the events using them with a pointer. The code is careful to always
prefer the right event in the same group to minimize multiplexing
errors. At the moment only a single relation is supported.
Then add a rblist to the stat shadow code that remembers stats based on
the cpu and context.
Then finally update and retrieve and print these values similarly to the
existing hardcoded perf metrics. We use the simple expression parser
added earlier to evaluate the expression.
Normally we just output the result without further commentary, but for
--metric-only this would lead to empty columns. So for this case use the
original event as description.
There is no attempt to automatically add the MetricExpr event, if it is
missing, however we suggest it to the user, because the user tool
doesn't have enough information to reliably construct a group that is
guaranteed to schedule. So we leave that to the user.
% perf stat -a -I 1000 -e '{unc_p_clockticks,unc_p_freq_max_os_cycles}'
1.000147889 800,085,181 unc_p_clockticks
1.000147889 93,126,241 unc_p_freq_max_os_cycles # 11.6
2.000448381 800,218,217 unc_p_clockticks
2.000448381 142,516,095 unc_p_freq_max_os_cycles # 17.8
3.000639852 800,243,057 unc_p_clockticks
3.000639852 162,292,689 unc_p_freq_max_os_cycles # 20.3
% perf stat -a -I 1000 -e '{unc_p_clockticks,unc_p_freq_max_os_cycles}' --metric-only
# time freq_max_os_cycles %
1.000127077 0.9
2.000301436 0.7
3.000456379 0.0
v2: Change from DivideBy to MetricExpr
v3: Use expr__ prefix. Support more than one other event.
v4: Update description
v5: Only print warning message once for multiple PMUs.
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Link: http://lkml.kernel.org/r/20170320201711.14142-11-andi@firstfloor.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2017-03-20 20:17:08 +00:00
|
|
|
bool force_header;
|
2016-01-30 17:06:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void perf_stat__print_shadow_stats(struct perf_evsel *evsel,
|
|
|
|
double avg, int cpu,
|
2017-08-31 19:40:31 +00:00
|
|
|
struct perf_stat_output_ctx *out,
|
|
|
|
struct rblist *metric_events);
|
perf stat: Output JSON MetricExpr metric
Add generic infrastructure to perf stat to output ratios for
"MetricExpr" entries in the event lists. Many events are more useful as
ratios than in raw form, typically some count in relation to total
ticks.
Transfer the MetricExpr information from the alias to the evsel.
We mark the events that need to be collected for MetricExpr, and also
link the events using them with a pointer. The code is careful to always
prefer the right event in the same group to minimize multiplexing
errors. At the moment only a single relation is supported.
Then add a rblist to the stat shadow code that remembers stats based on
the cpu and context.
Then finally update and retrieve and print these values similarly to the
existing hardcoded perf metrics. We use the simple expression parser
added earlier to evaluate the expression.
Normally we just output the result without further commentary, but for
--metric-only this would lead to empty columns. So for this case use the
original event as description.
There is no attempt to automatically add the MetricExpr event, if it is
missing, however we suggest it to the user, because the user tool
doesn't have enough information to reliably construct a group that is
guaranteed to schedule. So we leave that to the user.
% perf stat -a -I 1000 -e '{unc_p_clockticks,unc_p_freq_max_os_cycles}'
1.000147889 800,085,181 unc_p_clockticks
1.000147889 93,126,241 unc_p_freq_max_os_cycles # 11.6
2.000448381 800,218,217 unc_p_clockticks
2.000448381 142,516,095 unc_p_freq_max_os_cycles # 17.8
3.000639852 800,243,057 unc_p_clockticks
3.000639852 162,292,689 unc_p_freq_max_os_cycles # 20.3
% perf stat -a -I 1000 -e '{unc_p_clockticks,unc_p_freq_max_os_cycles}' --metric-only
# time freq_max_os_cycles %
1.000127077 0.9
2.000301436 0.7
3.000456379 0.0
v2: Change from DivideBy to MetricExpr
v3: Use expr__ prefix. Support more than one other event.
v4: Update description
v5: Only print warning message once for multiple PMUs.
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Link: http://lkml.kernel.org/r/20170320201711.14142-11-andi@firstfloor.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2017-03-20 20:17:08 +00:00
|
|
|
void perf_stat__collect_metric_expr(struct perf_evlist *);
|
2015-06-03 14:25:59 +00:00
|
|
|
|
2015-06-26 09:29:16 +00:00
|
|
|
int perf_evlist__alloc_stats(struct perf_evlist *evlist, bool alloc_raw);
|
|
|
|
void perf_evlist__free_stats(struct perf_evlist *evlist);
|
|
|
|
void perf_evlist__reset_stats(struct perf_evlist *evlist);
|
2015-07-21 12:31:27 +00:00
|
|
|
|
|
|
|
int perf_stat_process_counter(struct perf_stat_config *config,
|
|
|
|
struct perf_evsel *counter);
|
2015-10-25 14:51:32 +00:00
|
|
|
struct perf_tool;
|
|
|
|
union perf_event;
|
|
|
|
struct perf_session;
|
|
|
|
int perf_event__process_stat_event(struct perf_tool *tool,
|
|
|
|
union perf_event *event,
|
|
|
|
struct perf_session *session);
|
2015-10-25 14:51:35 +00:00
|
|
|
|
|
|
|
size_t perf_event__fprintf_stat(union perf_event *event, FILE *fp);
|
|
|
|
size_t perf_event__fprintf_stat_round(union perf_event *event, FILE *fp);
|
|
|
|
size_t perf_event__fprintf_stat_config(union perf_event *event, FILE *fp);
|
2012-09-17 08:31:14 +00:00
|
|
|
#endif
|