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-02-15 16:34:35 +08:00
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
2016-02-24 16:46:42 +08:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <api/fs/fs.h>
|
2017-04-17 22:39:06 +08:00
|
|
|
#include <linux/kernel.h>
|
2016-02-15 16:34:34 +08:00
|
|
|
#include "mem-events.h"
|
2016-02-15 16:34:35 +08:00
|
|
|
#include "debug.h"
|
2016-02-24 16:46:46 +08:00
|
|
|
#include "symbol.h"
|
2016-09-22 23:36:30 +08:00
|
|
|
#include "sort.h"
|
2016-02-15 16:34:34 +08:00
|
|
|
|
2016-06-15 02:19:11 +08:00
|
|
|
unsigned int perf_mem_events__loads_ldlat = 30;
|
|
|
|
|
2016-02-24 16:46:42 +08:00
|
|
|
#define E(t, n, s) { .tag = t, .name = n, .sysfs_name = s }
|
2016-02-15 16:34:34 +08:00
|
|
|
|
|
|
|
struct perf_mem_event perf_mem_events[PERF_MEM_EVENTS__MAX] = {
|
2016-06-15 02:19:11 +08:00
|
|
|
E("ldlat-loads", "cpu/mem-loads,ldlat=%u/P", "mem-loads"),
|
2016-02-24 16:46:42 +08:00
|
|
|
E("ldlat-stores", "cpu/mem-stores/P", "mem-stores"),
|
2016-02-15 16:34:34 +08:00
|
|
|
};
|
2016-02-24 16:46:42 +08:00
|
|
|
#undef E
|
2016-02-15 16:34:34 +08:00
|
|
|
|
|
|
|
#undef E
|
2016-02-15 16:34:35 +08:00
|
|
|
|
2016-06-15 02:19:11 +08:00
|
|
|
static char mem_loads_name[100];
|
|
|
|
static bool mem_loads_name__init;
|
|
|
|
|
2019-01-29 21:24:12 +08:00
|
|
|
char * __weak perf_mem_events__name(int i)
|
2016-02-24 16:46:43 +08:00
|
|
|
{
|
2016-06-15 02:19:11 +08:00
|
|
|
if (i == PERF_MEM_EVENTS__LOAD) {
|
|
|
|
if (!mem_loads_name__init) {
|
|
|
|
mem_loads_name__init = true;
|
|
|
|
scnprintf(mem_loads_name, sizeof(mem_loads_name),
|
|
|
|
perf_mem_events[i].name,
|
|
|
|
perf_mem_events__loads_ldlat);
|
|
|
|
}
|
|
|
|
return mem_loads_name;
|
|
|
|
}
|
|
|
|
|
2016-02-24 16:46:43 +08:00
|
|
|
return (char *)perf_mem_events[i].name;
|
|
|
|
}
|
|
|
|
|
2016-02-15 16:34:35 +08:00
|
|
|
int perf_mem_events__parse(const char *str)
|
|
|
|
{
|
|
|
|
char *tok, *saveptr = NULL;
|
|
|
|
bool found = false;
|
|
|
|
char *buf;
|
|
|
|
int j;
|
|
|
|
|
|
|
|
/* We need buffer that we know we can write to. */
|
|
|
|
buf = malloc(strlen(str) + 1);
|
|
|
|
if (!buf)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
strcpy(buf, str);
|
|
|
|
|
|
|
|
tok = strtok_r((char *)buf, ",", &saveptr);
|
|
|
|
|
|
|
|
while (tok) {
|
|
|
|
for (j = 0; j < PERF_MEM_EVENTS__MAX; j++) {
|
|
|
|
struct perf_mem_event *e = &perf_mem_events[j];
|
|
|
|
|
|
|
|
if (strstr(e->tag, tok))
|
|
|
|
e->record = found = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
tok = strtok_r(NULL, ",", &saveptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
free(buf);
|
|
|
|
|
|
|
|
if (found)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
pr_err("failed: event '%s' not found, use '-e list' to get list of available events\n", str);
|
|
|
|
return -1;
|
|
|
|
}
|
2016-02-24 16:46:42 +08:00
|
|
|
|
|
|
|
int perf_mem_events__init(void)
|
|
|
|
{
|
|
|
|
const char *mnt = sysfs__mount();
|
|
|
|
bool found = false;
|
|
|
|
int j;
|
|
|
|
|
|
|
|
if (!mnt)
|
|
|
|
return -ENOENT;
|
|
|
|
|
|
|
|
for (j = 0; j < PERF_MEM_EVENTS__MAX; j++) {
|
|
|
|
char path[PATH_MAX];
|
|
|
|
struct perf_mem_event *e = &perf_mem_events[j];
|
|
|
|
struct stat st;
|
|
|
|
|
|
|
|
scnprintf(path, PATH_MAX, "%s/devices/cpu/events/%s",
|
|
|
|
mnt, e->sysfs_name);
|
|
|
|
|
|
|
|
if (!stat(path, &st))
|
|
|
|
e->supported = found = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return found ? 0 : -ENOENT;
|
|
|
|
}
|
2016-02-24 16:46:46 +08:00
|
|
|
|
|
|
|
static const char * const tlb_access[] = {
|
|
|
|
"N/A",
|
|
|
|
"HIT",
|
|
|
|
"MISS",
|
|
|
|
"L1",
|
|
|
|
"L2",
|
|
|
|
"Walker",
|
|
|
|
"Fault",
|
|
|
|
};
|
|
|
|
|
2016-02-24 16:46:50 +08:00
|
|
|
int perf_mem__tlb_scnprintf(char *out, size_t sz, struct mem_info *mem_info)
|
2016-02-24 16:46:46 +08:00
|
|
|
{
|
|
|
|
size_t l = 0, i;
|
|
|
|
u64 m = PERF_MEM_TLB_NA;
|
|
|
|
u64 hit, miss;
|
|
|
|
|
|
|
|
sz -= 1; /* -1 for null termination */
|
|
|
|
out[0] = '\0';
|
|
|
|
|
|
|
|
if (mem_info)
|
|
|
|
m = mem_info->data_src.mem_dtlb;
|
|
|
|
|
|
|
|
hit = m & PERF_MEM_TLB_HIT;
|
|
|
|
miss = m & PERF_MEM_TLB_MISS;
|
|
|
|
|
|
|
|
/* already taken care of */
|
|
|
|
m &= ~(PERF_MEM_TLB_HIT|PERF_MEM_TLB_MISS);
|
|
|
|
|
|
|
|
for (i = 0; m && i < ARRAY_SIZE(tlb_access); i++, m >>= 1) {
|
|
|
|
if (!(m & 0x1))
|
|
|
|
continue;
|
|
|
|
if (l) {
|
|
|
|
strcat(out, " or ");
|
|
|
|
l += 4;
|
|
|
|
}
|
2016-02-24 16:46:50 +08:00
|
|
|
l += scnprintf(out + l, sz - l, tlb_access[i]);
|
2016-02-24 16:46:46 +08:00
|
|
|
}
|
|
|
|
if (*out == '\0')
|
2016-02-24 16:46:50 +08:00
|
|
|
l += scnprintf(out, sz - l, "N/A");
|
2016-02-24 16:46:46 +08:00
|
|
|
if (hit)
|
2016-02-24 16:46:50 +08:00
|
|
|
l += scnprintf(out + l, sz - l, " hit");
|
2016-02-24 16:46:46 +08:00
|
|
|
if (miss)
|
2016-02-24 16:46:50 +08:00
|
|
|
l += scnprintf(out + l, sz - l, " miss");
|
|
|
|
|
|
|
|
return l;
|
2016-02-24 16:46:46 +08:00
|
|
|
}
|
2016-02-24 16:46:47 +08:00
|
|
|
|
|
|
|
static const char * const mem_lvl[] = {
|
|
|
|
"N/A",
|
|
|
|
"HIT",
|
|
|
|
"MISS",
|
|
|
|
"L1",
|
|
|
|
"LFB",
|
|
|
|
"L2",
|
|
|
|
"L3",
|
|
|
|
"Local RAM",
|
|
|
|
"Remote RAM (1 hop)",
|
|
|
|
"Remote RAM (2 hops)",
|
|
|
|
"Remote Cache (1 hop)",
|
|
|
|
"Remote Cache (2 hops)",
|
|
|
|
"I/O",
|
|
|
|
"Uncached",
|
|
|
|
};
|
|
|
|
|
2017-08-17 06:21:55 +08:00
|
|
|
static const char * const mem_lvlnum[] = {
|
|
|
|
[PERF_MEM_LVLNUM_ANY_CACHE] = "Any cache",
|
|
|
|
[PERF_MEM_LVLNUM_LFB] = "LFB",
|
|
|
|
[PERF_MEM_LVLNUM_RAM] = "RAM",
|
|
|
|
[PERF_MEM_LVLNUM_PMEM] = "PMEM",
|
|
|
|
[PERF_MEM_LVLNUM_NA] = "N/A",
|
|
|
|
};
|
|
|
|
|
2016-02-24 16:46:51 +08:00
|
|
|
int perf_mem__lvl_scnprintf(char *out, size_t sz, struct mem_info *mem_info)
|
2016-02-24 16:46:47 +08:00
|
|
|
{
|
|
|
|
size_t i, l = 0;
|
|
|
|
u64 m = PERF_MEM_LVL_NA;
|
|
|
|
u64 hit, miss;
|
2017-08-17 06:21:55 +08:00
|
|
|
int printed;
|
2016-02-24 16:46:47 +08:00
|
|
|
|
|
|
|
if (mem_info)
|
|
|
|
m = mem_info->data_src.mem_lvl;
|
|
|
|
|
|
|
|
sz -= 1; /* -1 for null termination */
|
|
|
|
out[0] = '\0';
|
|
|
|
|
|
|
|
hit = m & PERF_MEM_LVL_HIT;
|
|
|
|
miss = m & PERF_MEM_LVL_MISS;
|
|
|
|
|
|
|
|
/* already taken care of */
|
|
|
|
m &= ~(PERF_MEM_LVL_HIT|PERF_MEM_LVL_MISS);
|
|
|
|
|
2017-08-17 06:21:55 +08:00
|
|
|
|
|
|
|
if (mem_info && mem_info->data_src.mem_remote) {
|
|
|
|
strcat(out, "Remote ");
|
|
|
|
l += 7;
|
|
|
|
}
|
|
|
|
|
|
|
|
printed = 0;
|
2016-02-24 16:46:47 +08:00
|
|
|
for (i = 0; m && i < ARRAY_SIZE(mem_lvl); i++, m >>= 1) {
|
|
|
|
if (!(m & 0x1))
|
|
|
|
continue;
|
2017-08-17 06:21:55 +08:00
|
|
|
if (printed++) {
|
2016-02-24 16:46:47 +08:00
|
|
|
strcat(out, " or ");
|
|
|
|
l += 4;
|
|
|
|
}
|
2016-02-24 16:46:51 +08:00
|
|
|
l += scnprintf(out + l, sz - l, mem_lvl[i]);
|
2016-02-24 16:46:47 +08:00
|
|
|
}
|
2017-08-17 06:21:55 +08:00
|
|
|
|
|
|
|
if (mem_info && mem_info->data_src.mem_lvl_num) {
|
|
|
|
int lvl = mem_info->data_src.mem_lvl_num;
|
|
|
|
if (printed++) {
|
|
|
|
strcat(out, " or ");
|
|
|
|
l += 4;
|
|
|
|
}
|
|
|
|
if (mem_lvlnum[lvl])
|
|
|
|
l += scnprintf(out + l, sz - l, mem_lvlnum[lvl]);
|
|
|
|
else
|
|
|
|
l += scnprintf(out + l, sz - l, "L%d", lvl);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (l == 0)
|
|
|
|
l += scnprintf(out + l, sz - l, "N/A");
|
2016-02-24 16:46:47 +08:00
|
|
|
if (hit)
|
2016-02-24 16:46:51 +08:00
|
|
|
l += scnprintf(out + l, sz - l, " hit");
|
2016-02-24 16:46:47 +08:00
|
|
|
if (miss)
|
2016-02-24 16:46:51 +08:00
|
|
|
l += scnprintf(out + l, sz - l, " miss");
|
|
|
|
|
|
|
|
return l;
|
2016-02-24 16:46:47 +08:00
|
|
|
}
|
2016-02-24 16:46:48 +08:00
|
|
|
|
|
|
|
static const char * const snoop_access[] = {
|
|
|
|
"N/A",
|
|
|
|
"None",
|
|
|
|
"Hit",
|
2017-04-20 01:49:40 +08:00
|
|
|
"Miss",
|
2016-02-24 16:46:48 +08:00
|
|
|
"HitM",
|
|
|
|
};
|
|
|
|
|
2016-02-24 16:46:52 +08:00
|
|
|
int perf_mem__snp_scnprintf(char *out, size_t sz, struct mem_info *mem_info)
|
2016-02-24 16:46:48 +08:00
|
|
|
{
|
|
|
|
size_t i, l = 0;
|
|
|
|
u64 m = PERF_MEM_SNOOP_NA;
|
|
|
|
|
|
|
|
sz -= 1; /* -1 for null termination */
|
|
|
|
out[0] = '\0';
|
|
|
|
|
|
|
|
if (mem_info)
|
|
|
|
m = mem_info->data_src.mem_snoop;
|
|
|
|
|
|
|
|
for (i = 0; m && i < ARRAY_SIZE(snoop_access); i++, m >>= 1) {
|
|
|
|
if (!(m & 0x1))
|
|
|
|
continue;
|
|
|
|
if (l) {
|
|
|
|
strcat(out, " or ");
|
|
|
|
l += 4;
|
|
|
|
}
|
2016-02-24 16:46:52 +08:00
|
|
|
l += scnprintf(out + l, sz - l, snoop_access[i]);
|
2016-02-24 16:46:48 +08:00
|
|
|
}
|
2017-08-17 06:21:55 +08:00
|
|
|
if (mem_info &&
|
|
|
|
(mem_info->data_src.mem_snoopx & PERF_MEM_SNOOPX_FWD)) {
|
|
|
|
if (l) {
|
|
|
|
strcat(out, " or ");
|
|
|
|
l += 4;
|
|
|
|
}
|
|
|
|
l += scnprintf(out + l, sz - l, "Fwd");
|
|
|
|
}
|
2016-02-24 16:46:48 +08:00
|
|
|
|
|
|
|
if (*out == '\0')
|
2016-02-24 16:46:52 +08:00
|
|
|
l += scnprintf(out, sz - l, "N/A");
|
|
|
|
|
|
|
|
return l;
|
2016-02-24 16:46:48 +08:00
|
|
|
}
|
2016-02-24 16:46:49 +08:00
|
|
|
|
2016-02-24 16:46:53 +08:00
|
|
|
int perf_mem__lck_scnprintf(char *out, size_t sz, struct mem_info *mem_info)
|
2016-02-24 16:46:49 +08:00
|
|
|
{
|
|
|
|
u64 mask = PERF_MEM_LOCK_NA;
|
2016-02-24 16:46:53 +08:00
|
|
|
int l;
|
2016-02-24 16:46:49 +08:00
|
|
|
|
|
|
|
if (mem_info)
|
|
|
|
mask = mem_info->data_src.mem_lock;
|
|
|
|
|
|
|
|
if (mask & PERF_MEM_LOCK_NA)
|
2016-02-24 16:46:53 +08:00
|
|
|
l = scnprintf(out, sz, "N/A");
|
2016-02-24 16:46:49 +08:00
|
|
|
else if (mask & PERF_MEM_LOCK_LOCKED)
|
2016-02-24 16:46:53 +08:00
|
|
|
l = scnprintf(out, sz, "Yes");
|
2016-02-24 16:46:49 +08:00
|
|
|
else
|
2016-02-24 16:46:53 +08:00
|
|
|
l = scnprintf(out, sz, "No");
|
|
|
|
|
|
|
|
return l;
|
2016-02-24 16:46:49 +08:00
|
|
|
}
|
2016-02-24 16:46:54 +08:00
|
|
|
|
|
|
|
int perf_script__meminfo_scnprintf(char *out, size_t sz, struct mem_info *mem_info)
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
i += perf_mem__lvl_scnprintf(out, sz, mem_info);
|
|
|
|
i += scnprintf(out + i, sz - i, "|SNP ");
|
|
|
|
i += perf_mem__snp_scnprintf(out + i, sz - i, mem_info);
|
|
|
|
i += scnprintf(out + i, sz - i, "|TLB ");
|
|
|
|
i += perf_mem__tlb_scnprintf(out + i, sz - i, mem_info);
|
|
|
|
i += scnprintf(out + i, sz - i, "|LCK ");
|
|
|
|
i += perf_mem__lck_scnprintf(out + i, sz - i, mem_info);
|
|
|
|
|
|
|
|
return i;
|
|
|
|
}
|
2016-09-22 23:36:30 +08:00
|
|
|
|
|
|
|
int c2c_decode_stats(struct c2c_stats *stats, struct mem_info *mi)
|
|
|
|
{
|
|
|
|
union perf_mem_data_src *data_src = &mi->data_src;
|
|
|
|
u64 daddr = mi->daddr.addr;
|
|
|
|
u64 op = data_src->mem_op;
|
|
|
|
u64 lvl = data_src->mem_lvl;
|
|
|
|
u64 snoop = data_src->mem_snoop;
|
|
|
|
u64 lock = data_src->mem_lock;
|
2017-08-24 16:57:32 +08:00
|
|
|
/*
|
|
|
|
* Skylake might report unknown remote level via this
|
|
|
|
* bit, consider it when evaluating remote HITMs.
|
|
|
|
*/
|
|
|
|
bool mrem = data_src->mem_remote;
|
2016-09-22 23:36:30 +08:00
|
|
|
int err = 0;
|
|
|
|
|
2016-11-22 05:33:29 +08:00
|
|
|
#define HITM_INC(__f) \
|
|
|
|
do { \
|
|
|
|
stats->__f++; \
|
|
|
|
stats->tot_hitm++; \
|
|
|
|
} while (0)
|
|
|
|
|
2016-09-22 23:36:30 +08:00
|
|
|
#define P(a, b) PERF_MEM_##a##_##b
|
|
|
|
|
|
|
|
stats->nr_entries++;
|
|
|
|
|
|
|
|
if (lock & P(LOCK, LOCKED)) stats->locks++;
|
|
|
|
|
|
|
|
if (op & P(OP, LOAD)) {
|
|
|
|
/* load */
|
|
|
|
stats->load++;
|
|
|
|
|
|
|
|
if (!daddr) {
|
|
|
|
stats->ld_noadrs++;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lvl & P(LVL, HIT)) {
|
|
|
|
if (lvl & P(LVL, UNC)) stats->ld_uncache++;
|
|
|
|
if (lvl & P(LVL, IO)) stats->ld_io++;
|
|
|
|
if (lvl & P(LVL, LFB)) stats->ld_fbhit++;
|
|
|
|
if (lvl & P(LVL, L1 )) stats->ld_l1hit++;
|
|
|
|
if (lvl & P(LVL, L2 )) stats->ld_l2hit++;
|
|
|
|
if (lvl & P(LVL, L3 )) {
|
|
|
|
if (snoop & P(SNOOP, HITM))
|
2016-11-22 05:33:29 +08:00
|
|
|
HITM_INC(lcl_hitm);
|
2016-09-22 23:36:30 +08:00
|
|
|
else
|
|
|
|
stats->ld_llchit++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lvl & P(LVL, LOC_RAM)) {
|
|
|
|
stats->lcl_dram++;
|
|
|
|
if (snoop & P(SNOOP, HIT))
|
|
|
|
stats->ld_shared++;
|
|
|
|
else
|
|
|
|
stats->ld_excl++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((lvl & P(LVL, REM_RAM1)) ||
|
2017-08-24 16:57:32 +08:00
|
|
|
(lvl & P(LVL, REM_RAM2)) ||
|
|
|
|
mrem) {
|
2016-09-22 23:36:30 +08:00
|
|
|
stats->rmt_dram++;
|
|
|
|
if (snoop & P(SNOOP, HIT))
|
|
|
|
stats->ld_shared++;
|
|
|
|
else
|
|
|
|
stats->ld_excl++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((lvl & P(LVL, REM_CCE1)) ||
|
2017-08-24 16:57:32 +08:00
|
|
|
(lvl & P(LVL, REM_CCE2)) ||
|
|
|
|
mrem) {
|
2016-09-22 23:36:30 +08:00
|
|
|
if (snoop & P(SNOOP, HIT))
|
|
|
|
stats->rmt_hit++;
|
|
|
|
else if (snoop & P(SNOOP, HITM))
|
2016-11-22 05:33:29 +08:00
|
|
|
HITM_INC(rmt_hitm);
|
2016-09-22 23:36:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((lvl & P(LVL, MISS)))
|
|
|
|
stats->ld_miss++;
|
|
|
|
|
|
|
|
} else if (op & P(OP, STORE)) {
|
|
|
|
/* store */
|
|
|
|
stats->store++;
|
|
|
|
|
|
|
|
if (!daddr) {
|
|
|
|
stats->st_noadrs++;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lvl & P(LVL, HIT)) {
|
|
|
|
if (lvl & P(LVL, UNC)) stats->st_uncache++;
|
|
|
|
if (lvl & P(LVL, L1 )) stats->st_l1hit++;
|
|
|
|
}
|
|
|
|
if (lvl & P(LVL, MISS))
|
|
|
|
if (lvl & P(LVL, L1)) stats->st_l1miss++;
|
|
|
|
} else {
|
|
|
|
/* unparsable data_src? */
|
|
|
|
stats->noparse++;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!mi->daddr.map || !mi->iaddr.map) {
|
|
|
|
stats->nomap++;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef P
|
2016-11-22 05:33:29 +08:00
|
|
|
#undef HITM_INC
|
2016-09-22 23:36:30 +08:00
|
|
|
return err;
|
|
|
|
}
|
2016-09-22 23:36:31 +08:00
|
|
|
|
|
|
|
void c2c_add_stats(struct c2c_stats *stats, struct c2c_stats *add)
|
|
|
|
{
|
|
|
|
stats->nr_entries += add->nr_entries;
|
|
|
|
|
|
|
|
stats->locks += add->locks;
|
|
|
|
stats->store += add->store;
|
|
|
|
stats->st_uncache += add->st_uncache;
|
|
|
|
stats->st_noadrs += add->st_noadrs;
|
|
|
|
stats->st_l1hit += add->st_l1hit;
|
|
|
|
stats->st_l1miss += add->st_l1miss;
|
|
|
|
stats->load += add->load;
|
|
|
|
stats->ld_excl += add->ld_excl;
|
|
|
|
stats->ld_shared += add->ld_shared;
|
|
|
|
stats->ld_uncache += add->ld_uncache;
|
|
|
|
stats->ld_io += add->ld_io;
|
|
|
|
stats->ld_miss += add->ld_miss;
|
|
|
|
stats->ld_noadrs += add->ld_noadrs;
|
|
|
|
stats->ld_fbhit += add->ld_fbhit;
|
|
|
|
stats->ld_l1hit += add->ld_l1hit;
|
|
|
|
stats->ld_l2hit += add->ld_l2hit;
|
|
|
|
stats->ld_llchit += add->ld_llchit;
|
|
|
|
stats->lcl_hitm += add->lcl_hitm;
|
|
|
|
stats->rmt_hitm += add->rmt_hitm;
|
2016-11-22 05:33:29 +08:00
|
|
|
stats->tot_hitm += add->tot_hitm;
|
2016-09-22 23:36:31 +08:00
|
|
|
stats->rmt_hit += add->rmt_hit;
|
|
|
|
stats->lcl_dram += add->lcl_dram;
|
|
|
|
stats->rmt_dram += add->rmt_dram;
|
|
|
|
stats->nomap += add->nomap;
|
|
|
|
stats->noparse += add->noparse;
|
|
|
|
}
|