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 */
|
2009-12-28 07:37:00 +08:00
|
|
|
#ifndef __PERF_MAP_H
|
|
|
|
#define __PERF_MAP_H
|
|
|
|
|
2017-02-21 23:34:59 +08:00
|
|
|
#include <linux/refcount.h>
|
2009-12-28 07:37:00 +08:00
|
|
|
#include <linux/compiler.h>
|
|
|
|
#include <linux/list.h>
|
|
|
|
#include <linux/rbtree.h>
|
2015-05-23 00:45:24 +08:00
|
|
|
#include <pthread.h>
|
2010-03-26 06:58:58 +08:00
|
|
|
#include <stdio.h>
|
2010-04-28 08:17:50 +08:00
|
|
|
#include <stdbool.h>
|
2014-04-26 03:31:02 +08:00
|
|
|
#include <linux/types.h>
|
2017-04-05 00:15:04 +08:00
|
|
|
#include "rwsem.h"
|
2009-12-28 07:37:00 +08:00
|
|
|
|
|
|
|
enum map_type {
|
|
|
|
MAP__FUNCTION = 0,
|
|
|
|
MAP__VARIABLE,
|
|
|
|
};
|
|
|
|
|
|
|
|
#define MAP__NR_TYPES (MAP__VARIABLE + 1)
|
|
|
|
|
2010-02-23 03:15:39 +08:00
|
|
|
extern const char *map_type__name[MAP__NR_TYPES];
|
|
|
|
|
2009-12-28 07:37:00 +08:00
|
|
|
struct dso;
|
2011-11-28 17:56:39 +08:00
|
|
|
struct ip_callchain;
|
2010-02-04 02:52:00 +08:00
|
|
|
struct ref_reloc_sym;
|
|
|
|
struct map_groups;
|
2010-04-28 08:17:50 +08:00
|
|
|
struct machine;
|
2011-11-28 17:56:39 +08:00
|
|
|
struct perf_evsel;
|
2009-12-28 07:37:00 +08:00
|
|
|
|
|
|
|
struct map {
|
|
|
|
union {
|
|
|
|
struct rb_node rb_node;
|
|
|
|
struct list_head node;
|
|
|
|
};
|
|
|
|
u64 start;
|
|
|
|
u64 end;
|
perf tools: Don't keep unreferenced maps when unmaps are detected
For a file with:
[root@emilia linux-2.6-tip]# perf report -D -fi allmodconfig-j32.perf.data | grep events:
TOTAL events: 36933
MMAP events: 9056
LOST events: 0
COMM events: 1702
EXIT events: 1887
THROTTLE events: 8
UNTHROTTLE events: 8
FORK events: 1894
READ events: 0
SAMPLE events: 22378
ATTR events: 0
EVENT_TYPE events: 0
TRACING_DATA events: 0
BUILD_ID events: 0
[root@emilia linux-2.6-tip]#
Testing with valgrind and making perf_session__delete() a nop, so that
we can notice how many maps were actually deleted due to not having any
samples on it:
==== HEAP SUMMARY:
Before:
==10339== in use at exit: 8,909,997 bytes in 68,690 blocks
==10339== total heap usage: 78,696 allocs, 10,007 frees, 11,925,853 bytes allocated
After:
==10506== in use at exit: 8,902,605 bytes in 68,606 blocks
==10506== total heap usage: 78,696 allocs, 10,091 frees, 11,925,853 bytes allocated
I.e. just 84 detected unmaps with no hits out of 9056 for this workload,
not much, but in some other long running workload this may save more
bytes.
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
LKML-Reference: <new-submission>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2010-08-03 06:45:23 +08:00
|
|
|
u8 /* enum map_type */ type;
|
2012-03-27 23:55:57 +08:00
|
|
|
bool erange_warned;
|
2010-04-30 02:25:23 +08:00
|
|
|
u32 priv;
|
2014-05-20 03:13:49 +08:00
|
|
|
u32 prot;
|
|
|
|
u32 flags;
|
2009-12-28 07:37:00 +08:00
|
|
|
u64 pgoff;
|
2014-01-29 22:14:36 +08:00
|
|
|
u64 reloc;
|
2013-08-21 18:10:25 +08:00
|
|
|
u32 maj, min; /* only valid for MMAP2 record */
|
|
|
|
u64 ino; /* only valid for MMAP2 record */
|
|
|
|
u64 ino_generation;/* only valid for MMAP2 record */
|
perf annotate: Fix it for non-prelinked *.so
The problem was we were incorrectly calculating objdump
addresses for sym->start and sym->end, look:
For simple ET_DYN type DSO (*.so) with one function, objdump -dS
output is something like this:
000004ac <my_strlen>:
int my_strlen(const char *s)
4ac: 55 push %ebp
4ad: 89 e5 mov %esp,%ebp
4af: 83 ec 10 sub $0x10,%esp
{
i.e. we have relative-to-dso-mapping IPs (=RIP) there.
For ET_EXEC type and probably for prelinked libs as well (sorry
can't test - I don't use prelink) objdump outputs absolute IPs,
e.g.
08048604 <zz_strlen>:
extern "C"
int zz_strlen(const char *s)
8048604: 55 push %ebp
8048605: 89 e5 mov %esp,%ebp
8048607: 83 ec 10 sub $0x10,%esp
{
So, if sym->start is always relative to dso mapping(*), we'll
have to unmap it for ET_EXEC like cases, and leave as is for
ET_DYN cases.
(*) and it is - we've explicitely made it relative. Look for
adjust_symbols handling in dso__load_sym()
Previously we were always unmapping sym->start and for ET_DYN
dsos resulting addresses were wrong, and so objdump output was
empty.
The end result was that perf annotate output for symbols from
non-prelinked *.so had always 0.00% percents only, which is
wrong.
To fix it, let's introduce a helper for converting rip to
objdump address, and also let's document what map_ip() and
unmap_ip() do -- I had to study sources for several hours to
understand it.
Signed-off-by: Kirill Smelkov <kirr@landau.phys.spbu.ru>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
LKML-Reference: <1265223128-11786-8-git-send-email-acme@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-02-04 02:52:07 +08:00
|
|
|
|
|
|
|
/* ip -> dso rip */
|
2009-12-28 07:37:00 +08:00
|
|
|
u64 (*map_ip)(struct map *, u64);
|
perf annotate: Fix it for non-prelinked *.so
The problem was we were incorrectly calculating objdump
addresses for sym->start and sym->end, look:
For simple ET_DYN type DSO (*.so) with one function, objdump -dS
output is something like this:
000004ac <my_strlen>:
int my_strlen(const char *s)
4ac: 55 push %ebp
4ad: 89 e5 mov %esp,%ebp
4af: 83 ec 10 sub $0x10,%esp
{
i.e. we have relative-to-dso-mapping IPs (=RIP) there.
For ET_EXEC type and probably for prelinked libs as well (sorry
can't test - I don't use prelink) objdump outputs absolute IPs,
e.g.
08048604 <zz_strlen>:
extern "C"
int zz_strlen(const char *s)
8048604: 55 push %ebp
8048605: 89 e5 mov %esp,%ebp
8048607: 83 ec 10 sub $0x10,%esp
{
So, if sym->start is always relative to dso mapping(*), we'll
have to unmap it for ET_EXEC like cases, and leave as is for
ET_DYN cases.
(*) and it is - we've explicitely made it relative. Look for
adjust_symbols handling in dso__load_sym()
Previously we were always unmapping sym->start and for ET_DYN
dsos resulting addresses were wrong, and so objdump output was
empty.
The end result was that perf annotate output for symbols from
non-prelinked *.so had always 0.00% percents only, which is
wrong.
To fix it, let's introduce a helper for converting rip to
objdump address, and also let's document what map_ip() and
unmap_ip() do -- I had to study sources for several hours to
understand it.
Signed-off-by: Kirill Smelkov <kirr@landau.phys.spbu.ru>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
LKML-Reference: <1265223128-11786-8-git-send-email-acme@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-02-04 02:52:07 +08:00
|
|
|
/* dso rip -> ip */
|
2009-12-28 07:37:00 +08:00
|
|
|
u64 (*unmap_ip)(struct map *, u64);
|
perf annotate: Fix it for non-prelinked *.so
The problem was we were incorrectly calculating objdump
addresses for sym->start and sym->end, look:
For simple ET_DYN type DSO (*.so) with one function, objdump -dS
output is something like this:
000004ac <my_strlen>:
int my_strlen(const char *s)
4ac: 55 push %ebp
4ad: 89 e5 mov %esp,%ebp
4af: 83 ec 10 sub $0x10,%esp
{
i.e. we have relative-to-dso-mapping IPs (=RIP) there.
For ET_EXEC type and probably for prelinked libs as well (sorry
can't test - I don't use prelink) objdump outputs absolute IPs,
e.g.
08048604 <zz_strlen>:
extern "C"
int zz_strlen(const char *s)
8048604: 55 push %ebp
8048605: 89 e5 mov %esp,%ebp
8048607: 83 ec 10 sub $0x10,%esp
{
So, if sym->start is always relative to dso mapping(*), we'll
have to unmap it for ET_EXEC like cases, and leave as is for
ET_DYN cases.
(*) and it is - we've explicitely made it relative. Look for
adjust_symbols handling in dso__load_sym()
Previously we were always unmapping sym->start and for ET_DYN
dsos resulting addresses were wrong, and so objdump output was
empty.
The end result was that perf annotate output for symbols from
non-prelinked *.so had always 0.00% percents only, which is
wrong.
To fix it, let's introduce a helper for converting rip to
objdump address, and also let's document what map_ip() and
unmap_ip() do -- I had to study sources for several hours to
understand it.
Signed-off-by: Kirill Smelkov <kirr@landau.phys.spbu.ru>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
LKML-Reference: <1265223128-11786-8-git-send-email-acme@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-02-04 02:52:07 +08:00
|
|
|
|
2009-12-28 07:37:00 +08:00
|
|
|
struct dso *dso;
|
2010-04-19 13:32:50 +08:00
|
|
|
struct map_groups *groups;
|
2017-02-21 23:34:59 +08:00
|
|
|
refcount_t refcnt;
|
2009-12-28 07:37:00 +08:00
|
|
|
};
|
|
|
|
|
2010-02-04 02:52:00 +08:00
|
|
|
struct kmap {
|
|
|
|
struct ref_reloc_sym *ref_reloc_sym;
|
|
|
|
struct map_groups *kmaps;
|
|
|
|
};
|
|
|
|
|
2015-05-22 23:58:53 +08:00
|
|
|
struct maps {
|
|
|
|
struct rb_root entries;
|
2017-04-05 00:15:04 +08:00
|
|
|
struct rw_semaphore lock;
|
2015-05-22 23:58:53 +08:00
|
|
|
};
|
|
|
|
|
2010-04-19 13:32:50 +08:00
|
|
|
struct map_groups {
|
2015-05-22 23:58:53 +08:00
|
|
|
struct maps maps[MAP__NR_TYPES];
|
2010-04-28 08:17:50 +08:00
|
|
|
struct machine *machine;
|
2017-02-21 23:35:00 +08:00
|
|
|
refcount_t refcnt;
|
2010-04-19 13:32:50 +08:00
|
|
|
};
|
|
|
|
|
2014-10-22 04:29:02 +08:00
|
|
|
struct map_groups *map_groups__new(struct machine *machine);
|
2014-03-22 04:57:01 +08:00
|
|
|
void map_groups__delete(struct map_groups *mg);
|
2014-07-16 16:07:13 +08:00
|
|
|
bool map_groups__empty(struct map_groups *mg);
|
2014-03-22 04:57:01 +08:00
|
|
|
|
2014-03-26 02:26:44 +08:00
|
|
|
static inline struct map_groups *map_groups__get(struct map_groups *mg)
|
|
|
|
{
|
2015-05-16 02:20:44 +08:00
|
|
|
if (mg)
|
2017-02-21 23:35:00 +08:00
|
|
|
refcount_inc(&mg->refcnt);
|
2014-03-26 02:26:44 +08:00
|
|
|
return mg;
|
|
|
|
}
|
|
|
|
|
|
|
|
void map_groups__put(struct map_groups *mg);
|
|
|
|
|
2015-04-07 16:22:45 +08:00
|
|
|
struct kmap *map__kmap(struct map *map);
|
|
|
|
struct map_groups *map__kmaps(struct map *map);
|
2010-02-04 02:52:00 +08:00
|
|
|
|
2009-12-28 07:37:00 +08:00
|
|
|
static inline u64 map__map_ip(struct map *map, u64 ip)
|
|
|
|
{
|
|
|
|
return ip - map->start + map->pgoff;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline u64 map__unmap_ip(struct map *map, u64 ip)
|
|
|
|
{
|
|
|
|
return ip + map->start - map->pgoff;
|
|
|
|
}
|
|
|
|
|
2012-09-11 06:15:03 +08:00
|
|
|
static inline u64 identity__map_ip(struct map *map __maybe_unused, u64 ip)
|
2009-12-28 07:37:00 +08:00
|
|
|
{
|
|
|
|
return ip;
|
|
|
|
}
|
|
|
|
|
2018-03-27 19:09:56 +08:00
|
|
|
static inline size_t map__size(const struct map *map)
|
|
|
|
{
|
|
|
|
return map->end - map->start;
|
|
|
|
}
|
perf annotate: Fix it for non-prelinked *.so
The problem was we were incorrectly calculating objdump
addresses for sym->start and sym->end, look:
For simple ET_DYN type DSO (*.so) with one function, objdump -dS
output is something like this:
000004ac <my_strlen>:
int my_strlen(const char *s)
4ac: 55 push %ebp
4ad: 89 e5 mov %esp,%ebp
4af: 83 ec 10 sub $0x10,%esp
{
i.e. we have relative-to-dso-mapping IPs (=RIP) there.
For ET_EXEC type and probably for prelinked libs as well (sorry
can't test - I don't use prelink) objdump outputs absolute IPs,
e.g.
08048604 <zz_strlen>:
extern "C"
int zz_strlen(const char *s)
8048604: 55 push %ebp
8048605: 89 e5 mov %esp,%ebp
8048607: 83 ec 10 sub $0x10,%esp
{
So, if sym->start is always relative to dso mapping(*), we'll
have to unmap it for ET_EXEC like cases, and leave as is for
ET_DYN cases.
(*) and it is - we've explicitely made it relative. Look for
adjust_symbols handling in dso__load_sym()
Previously we were always unmapping sym->start and for ET_DYN
dsos resulting addresses were wrong, and so objdump output was
empty.
The end result was that perf annotate output for symbols from
non-prelinked *.so had always 0.00% percents only, which is
wrong.
To fix it, let's introduce a helper for converting rip to
objdump address, and also let's document what map_ip() and
unmap_ip() do -- I had to study sources for several hours to
understand it.
Signed-off-by: Kirill Smelkov <kirr@landau.phys.spbu.ru>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
LKML-Reference: <1265223128-11786-8-git-send-email-acme@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-02-04 02:52:07 +08:00
|
|
|
|
perf top: Fix annotate for userspace
First, for programs and prelinked libraries, annotate code was
fooled by objdump output IPs (src->eip in the code) being
wrongly converted to absolute IPs. In such case there were no
conversion needed, but in
src->eip = strtoull(src->line, NULL, 16);
src->eip = map->unmap_ip(map, src->eip); // = eip + map->start - map->pgoff
we were reading absolute address from objdump (e.g. 8048604) and
then almost doubling it, because eip & map->start are
approximately close for small programs.
Needless to say, that later, in record_precise_ip() there was no
matching with real runtime IPs.
And second, like with `perf annotate` the problem with
non-prelinked *.so was that we were doing rip -> objdump address
conversion wrong.
Also, because unlike `perf annotate`, `perf top` code does
annotation based on absolute IPs for performance reasons(*), new
helper for mapping objdump addresse to IP is introduced.
(*) we get samples info in absolute IPs, and since we do lots of
hit-testing on absolute IPs at runtime in record_precise_ip(), it's
better to convert objdump addresses to IPs once and do no conversion
at runtime.
I also had to fix how objdump output is parsed (with hardcoded
8/16 characters format, which was inappropriate for ET_DYN dsos
with small addresses like '4ac')
Also note, that not all objdump output lines has associtated
IPs, e.g. look at source lines here:
000004ac <my_strlen>:
extern "C"
int my_strlen(const char *s)
4ac: 55 push %ebp
4ad: 89 e5 mov %esp,%ebp
4af: 83 ec 10 sub $0x10,%esp
{
int len = 0;
4b2: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
4b9: eb 08 jmp 4c3 <my_strlen+0x17>
while (*s) {
++len;
4bb: 83 45 fc 01 addl $0x1,-0x4(%ebp)
++s;
4bf: 83 45 08 01 addl $0x1,0x8(%ebp)
So we mark them with eip=0, and ignore such lines in annotate
lookup code.
Signed-off-by: Kirill Smelkov <kirr@landau.phys.spbu.ru>
[ Note: one hunk of this patch was applied by Mike in 57d8188 ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
LKML-Reference: <1265550376-12665-1-git-send-email-acme@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-02-07 21:46:15 +08:00
|
|
|
/* rip/ip <-> addr suitable for passing to `objdump --start-address=` */
|
perf annotate: Fix it for non-prelinked *.so
The problem was we were incorrectly calculating objdump
addresses for sym->start and sym->end, look:
For simple ET_DYN type DSO (*.so) with one function, objdump -dS
output is something like this:
000004ac <my_strlen>:
int my_strlen(const char *s)
4ac: 55 push %ebp
4ad: 89 e5 mov %esp,%ebp
4af: 83 ec 10 sub $0x10,%esp
{
i.e. we have relative-to-dso-mapping IPs (=RIP) there.
For ET_EXEC type and probably for prelinked libs as well (sorry
can't test - I don't use prelink) objdump outputs absolute IPs,
e.g.
08048604 <zz_strlen>:
extern "C"
int zz_strlen(const char *s)
8048604: 55 push %ebp
8048605: 89 e5 mov %esp,%ebp
8048607: 83 ec 10 sub $0x10,%esp
{
So, if sym->start is always relative to dso mapping(*), we'll
have to unmap it for ET_EXEC like cases, and leave as is for
ET_DYN cases.
(*) and it is - we've explicitely made it relative. Look for
adjust_symbols handling in dso__load_sym()
Previously we were always unmapping sym->start and for ET_DYN
dsos resulting addresses were wrong, and so objdump output was
empty.
The end result was that perf annotate output for symbols from
non-prelinked *.so had always 0.00% percents only, which is
wrong.
To fix it, let's introduce a helper for converting rip to
objdump address, and also let's document what map_ip() and
unmap_ip() do -- I had to study sources for several hours to
understand it.
Signed-off-by: Kirill Smelkov <kirr@landau.phys.spbu.ru>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
LKML-Reference: <1265223128-11786-8-git-send-email-acme@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-02-04 02:52:07 +08:00
|
|
|
u64 map__rip_2objdump(struct map *map, u64 rip);
|
|
|
|
|
2013-10-14 18:43:44 +08:00
|
|
|
/* objdump address -> memory address */
|
|
|
|
u64 map__objdump_2mem(struct map *map, u64 ip);
|
|
|
|
|
2009-12-28 07:37:00 +08:00
|
|
|
struct symbol;
|
2014-07-22 21:18:00 +08:00
|
|
|
struct thread;
|
2009-12-28 07:37:00 +08:00
|
|
|
|
perf probe: Allow to add events on the local functions
Allow to add events on the local functions without debuginfo.
(With the debuginfo, we can add events even on inlined functions)
Currently, probing on local functions requires debuginfo to
locate actual address. It is also possible without debuginfo since
we have symbol maps.
Without this change;
----
# ./perf probe -a t_show
Added new event:
probe:t_show (on t_show)
You can now use it in all perf tools, such as:
perf record -e probe:t_show -aR sleep 1
# ./perf probe -x perf -a identity__map_ip
no symbols found in /kbuild/ksrc/linux-3/tools/perf/perf, maybe install a debug package?
Failed to load map.
Error: Failed to add events. (-22)
----
As the above results, perf probe just put one event
on the first found symbol for kprobe event. Moreover,
for uprobe event, perf probe failed to find local
functions.
With this change;
----
# ./perf probe -a t_show
Added new events:
probe:t_show (on t_show)
probe:t_show_1 (on t_show)
probe:t_show_2 (on t_show)
probe:t_show_3 (on t_show)
You can now use it in all perf tools, such as:
perf record -e probe:t_show_3 -aR sleep 1
# ./perf probe -x perf -a identity__map_ip
Added new events:
probe_perf:identity__map_ip (on identity__map_ip in /kbuild/ksrc/linux-3/tools/perf/perf)
probe_perf:identity__map_ip_1 (on identity__map_ip in /kbuild/ksrc/linux-3/tools/perf/perf)
probe_perf:identity__map_ip_2 (on identity__map_ip in /kbuild/ksrc/linux-3/tools/perf/perf)
probe_perf:identity__map_ip_3 (on identity__map_ip in /kbuild/ksrc/linux-3/tools/perf/perf)
You can now use it in all perf tools, such as:
perf record -e probe_perf:identity__map_ip_3 -aR sleep 1
----
Now we succeed to put events on every given local functions
for both kprobes and uprobes. :)
Note that this also introduces some symbol rbtree
iteration macros; symbols__for_each, dso__for_each_symbol,
and map__for_each_symbol. These are for walking through
the symbol list in a map.
Changes from v2:
- Fix add_exec_to_probe_trace_events() not to convert address
to tp->symbol any more.
- Fix to set kernel probes based on ref_reloc_sym.
Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: "David A. Long" <dave.long@linaro.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: yrl.pp-manager.tt@hitachi.com
Link: http://lkml.kernel.org/r/20140206053225.29635.15026.stgit@kbuild-fedora.yrl.intra.hitachi.co.jp
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2014-02-06 13:32:25 +08:00
|
|
|
/* map__for_each_symbol - iterate over the symbols in the given map
|
|
|
|
*
|
|
|
|
* @map: the 'struct map *' in which symbols itereated
|
|
|
|
* @pos: the 'struct symbol *' to use as a loop cursor
|
|
|
|
* @n: the 'struct rb_node *' to use as a temporary storage
|
|
|
|
* Note: caller must ensure map->dso is not NULL (map is loaded).
|
|
|
|
*/
|
|
|
|
#define map__for_each_symbol(map, pos, n) \
|
|
|
|
dso__for_each_symbol(map->dso, pos, n, map->type)
|
|
|
|
|
2015-01-17 03:40:25 +08:00
|
|
|
/* map__for_each_symbol_with_name - iterate over the symbols in the given map
|
|
|
|
* that have the given name
|
|
|
|
*
|
|
|
|
* @map: the 'struct map *' in which symbols itereated
|
|
|
|
* @sym_name: the symbol name
|
|
|
|
* @pos: the 'struct symbol *' to use as a loop cursor
|
|
|
|
*/
|
2016-09-02 06:25:52 +08:00
|
|
|
#define __map__for_each_symbol_by_name(map, sym_name, pos) \
|
|
|
|
for (pos = map__find_symbol_by_name(map, sym_name); \
|
perf symbols: Allow user probes on versioned symbols
Symbol versioning, as in glibc, results in symbols being defined as:
<real symbol>@[@]<version>
(Note that "@@" identifies a default symbol, if the symbol name is
repeated.)
perf is currently unable to deal with this, and is unable to create user
probes at such symbols:
--
$ nm /lib/powerpc64le-linux-gnu/libpthread.so.0 | grep pthread_create
0000000000008d30 t __pthread_create_2_1
0000000000008d30 T pthread_create@@GLIBC_2.17
$ /usr/bin/sudo perf probe -v -x /lib/powerpc64le-linux-gnu/libpthread.so.0 pthread_create
probe-definition(0): pthread_create
symbol:pthread_create file:(null) line:0 offset:0 return:0 lazy:(null)
0 arguments
Open Debuginfo file: /usr/lib/debug/lib/powerpc64le-linux-gnu/libpthread-2.19.so
Try to find probe point from debuginfo.
Probe point 'pthread_create' not found.
Error: Failed to add events. Reason: No such file or directory (Code: -2)
--
One is not able to specify the fully versioned symbol, either, due to
syntactic conflicts with other uses of "@" by perf:
--
$ /usr/bin/sudo perf probe -v -x /lib/powerpc64le-linux-gnu/libpthread.so.0 pthread_create@@GLIBC_2.17
probe-definition(0): pthread_create@@GLIBC_2.17
Semantic error :SRC@SRC is not allowed.
0 arguments
Error: Command Parse Error. Reason: Invalid argument (Code: -22)
--
This patch ignores versioning for default symbols, thus allowing probes to be
created for these symbols:
--
$ /usr/bin/sudo ./perf probe -x /lib/powerpc64le-linux-gnu/libpthread.so.0 pthread_create
Added new event:
probe_libpthread:pthread_create (on pthread_create in /lib/powerpc64le-linux-gnu/libpthread-2.19.so)
You can now use it in all perf tools, such as:
perf record -e probe_libpthread:pthread_create -aR sleep 1
$ /usr/bin/sudo ./perf record -e probe_libpthread:pthread_create -aR ./test 2
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.052 MB perf.data (2 samples) ]
$ /usr/bin/sudo ./perf script
test 2915 [000] 19124.260729: probe_libpthread:pthread_create: (3fff99248d38)
test 2916 [000] 19124.260962: probe_libpthread:pthread_create: (3fff99248d38)
$ /usr/bin/sudo ./perf probe --del=probe_libpthread:pthread_create
Removed event: probe_libpthread:pthread_create
--
Committer note:
Change the variable storing the result of strlen() to 'int', to fix the build
on debian:experimental-x-mipsel, fedora:24-x-ARC-uClibc, ubuntu:16.04-x-arm,
etc:
util/symbol.c: In function 'symbol__match_symbol_name':
util/symbol.c:422:11: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
if (len < versioning - name)
^
Signed-off-by: Paul A. Clarke <pc@us.ibm.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Link: http://lkml.kernel.org/r/c2b18d9c-17f8-9285-4868-f58b6359ccac@us.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2017-04-26 02:15:49 +08:00
|
|
|
pos && \
|
|
|
|
!symbol__match_symbol_name(pos->name, sym_name, \
|
|
|
|
SYMBOL_TAG_INCLUDE__DEFAULT_ONLY); \
|
2015-01-17 03:40:25 +08:00
|
|
|
pos = symbol__next_by_name(pos))
|
|
|
|
|
|
|
|
#define map__for_each_symbol_by_name(map, sym_name, pos) \
|
2016-09-02 06:25:52 +08:00
|
|
|
__map__for_each_symbol_by_name(map, sym_name, (pos))
|
2009-12-28 07:37:00 +08:00
|
|
|
|
2013-01-25 08:59:59 +08:00
|
|
|
void map__init(struct map *map, enum map_type type,
|
2009-12-28 07:37:00 +08:00
|
|
|
u64 start, u64 end, u64 pgoff, struct dso *dso);
|
2014-07-22 21:17:53 +08:00
|
|
|
struct map *map__new(struct machine *machine, u64 start, u64 len,
|
2017-07-06 09:48:09 +08:00
|
|
|
u64 pgoff, u32 d_maj, u32 d_min, u64 ino,
|
2014-05-20 03:13:49 +08:00
|
|
|
u64 ino_gen, u32 prot, u32 flags,
|
2014-07-22 21:18:00 +08:00
|
|
|
char *filename, enum map_type type, struct thread *thread);
|
2012-08-06 12:41:20 +08:00
|
|
|
struct map *map__new2(u64 start, struct dso *dso, enum map_type type);
|
2013-01-25 08:59:59 +08:00
|
|
|
void map__delete(struct map *map);
|
|
|
|
struct map *map__clone(struct map *map);
|
2015-05-26 03:59:56 +08:00
|
|
|
|
|
|
|
static inline struct map *map__get(struct map *map)
|
|
|
|
{
|
|
|
|
if (map)
|
2017-02-21 23:34:59 +08:00
|
|
|
refcount_inc(&map->refcnt);
|
2015-05-26 03:59:56 +08:00
|
|
|
return map;
|
|
|
|
}
|
|
|
|
|
|
|
|
void map__put(struct map *map);
|
|
|
|
|
2015-06-16 10:29:51 +08:00
|
|
|
static inline void __map__zput(struct map **map)
|
|
|
|
{
|
|
|
|
map__put(*map);
|
|
|
|
*map = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define map__zput(map) __map__zput(&map)
|
|
|
|
|
2009-12-28 07:37:00 +08:00
|
|
|
int map__overlap(struct map *l, struct map *r);
|
2013-01-25 08:59:59 +08:00
|
|
|
size_t map__fprintf(struct map *map, FILE *fp);
|
2012-01-30 12:42:57 +08:00
|
|
|
size_t map__fprintf_dsoname(struct map *map, FILE *fp);
|
2013-12-06 15:42:57 +08:00
|
|
|
int map__fprintf_srcline(struct map *map, u64 addr, const char *prefix,
|
|
|
|
FILE *fp);
|
2009-12-28 07:37:00 +08:00
|
|
|
|
2016-09-02 06:25:52 +08:00
|
|
|
int map__load(struct map *map);
|
|
|
|
struct symbol *map__find_symbol(struct map *map, u64 addr);
|
|
|
|
struct symbol *map__find_symbol_by_name(struct map *map, const char *name);
|
2013-01-25 08:59:59 +08:00
|
|
|
void map__fixup_start(struct map *map);
|
|
|
|
void map__fixup_end(struct map *map);
|
2009-12-28 07:37:00 +08:00
|
|
|
|
2013-01-25 08:59:59 +08:00
|
|
|
void map__reloc_vmlinux(struct map *map);
|
2010-02-04 02:52:00 +08:00
|
|
|
|
2014-07-15 05:46:47 +08:00
|
|
|
size_t __map_groups__fprintf_maps(struct map_groups *mg, enum map_type type,
|
|
|
|
FILE *fp);
|
2015-05-22 23:58:53 +08:00
|
|
|
void maps__insert(struct maps *maps, struct map *map);
|
|
|
|
void maps__remove(struct maps *maps, struct map *map);
|
|
|
|
struct map *maps__find(struct maps *maps, u64 addr);
|
|
|
|
struct map *maps__first(struct maps *maps);
|
2015-05-22 04:48:33 +08:00
|
|
|
struct map *map__next(struct map *map);
|
2015-09-30 04:34:46 +08:00
|
|
|
struct symbol *maps__find_symbol_by_name(struct maps *maps, const char *name,
|
2016-09-02 06:25:52 +08:00
|
|
|
struct map **mapp);
|
2014-10-22 04:29:02 +08:00
|
|
|
void map_groups__init(struct map_groups *mg, struct machine *machine);
|
2011-08-24 01:31:30 +08:00
|
|
|
void map_groups__exit(struct map_groups *mg);
|
2016-07-04 20:16:23 +08:00
|
|
|
int map_groups__clone(struct thread *thread,
|
2010-03-26 23:11:06 +08:00
|
|
|
struct map_groups *parent, enum map_type type);
|
2014-07-15 05:46:47 +08:00
|
|
|
size_t map_groups__fprintf(struct map_groups *mg, FILE *fp);
|
2010-03-26 06:58:58 +08:00
|
|
|
|
2011-11-28 17:56:39 +08:00
|
|
|
int maps__set_kallsyms_ref_reloc_sym(struct map **maps, const char *symbol_name,
|
|
|
|
u64 addr);
|
|
|
|
|
2011-08-24 01:31:30 +08:00
|
|
|
static inline void map_groups__insert(struct map_groups *mg, struct map *map)
|
2010-03-26 06:58:58 +08:00
|
|
|
{
|
2011-08-24 01:31:30 +08:00
|
|
|
maps__insert(&mg->maps[map->type], map);
|
|
|
|
map->groups = mg;
|
2010-03-26 06:58:58 +08:00
|
|
|
}
|
|
|
|
|
2011-08-24 01:31:30 +08:00
|
|
|
static inline void map_groups__remove(struct map_groups *mg, struct map *map)
|
perf session: Free the ref_reloc_sym memory at the right place
Which is at perf_session__destroy_kernel_maps, counterpart to the
perf_session__create_kernel_maps where the kmap structure is located, just
after the vmlinux_maps.
Make it also check if the kernel maps were actually created, which may not
be the case if, for instance, perf_session__new can't complete due to
permission problems in, for instance, a 'perf report' case, when a
segfault will take place, that is how this was noticed.
The problem was introduced in d65a458, thus post .35.
This also adds code to release guest machines as them are also created
in perf_session__create_kernel_maps, so should be deleted on this newly
introduced counterpart, perf_session__destroy_kernel_maps.
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
LKML-Reference: <new-submission>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2010-08-03 05:18:28 +08:00
|
|
|
{
|
2011-08-24 01:31:30 +08:00
|
|
|
maps__remove(&mg->maps[map->type], map);
|
perf session: Free the ref_reloc_sym memory at the right place
Which is at perf_session__destroy_kernel_maps, counterpart to the
perf_session__create_kernel_maps where the kmap structure is located, just
after the vmlinux_maps.
Make it also check if the kernel maps were actually created, which may not
be the case if, for instance, perf_session__new can't complete due to
permission problems in, for instance, a 'perf report' case, when a
segfault will take place, that is how this was noticed.
The problem was introduced in d65a458, thus post .35.
This also adds code to release guest machines as them are also created
in perf_session__create_kernel_maps, so should be deleted on this newly
introduced counterpart, perf_session__destroy_kernel_maps.
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
LKML-Reference: <new-submission>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2010-08-03 05:18:28 +08:00
|
|
|
}
|
|
|
|
|
2011-08-24 01:31:30 +08:00
|
|
|
static inline struct map *map_groups__find(struct map_groups *mg,
|
2010-03-26 06:58:58 +08:00
|
|
|
enum map_type type, u64 addr)
|
|
|
|
{
|
2011-08-24 01:31:30 +08:00
|
|
|
return maps__find(&mg->maps[type], addr);
|
2010-03-26 06:58:58 +08:00
|
|
|
}
|
|
|
|
|
2013-08-07 19:38:51 +08:00
|
|
|
static inline struct map *map_groups__first(struct map_groups *mg,
|
|
|
|
enum map_type type)
|
|
|
|
{
|
|
|
|
return maps__first(&mg->maps[type]);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct map *map_groups__next(struct map *map)
|
|
|
|
{
|
2015-05-22 04:48:33 +08:00
|
|
|
return map__next(map);
|
2013-08-07 19:38:51 +08:00
|
|
|
}
|
|
|
|
|
2011-08-24 01:31:30 +08:00
|
|
|
struct symbol *map_groups__find_symbol(struct map_groups *mg,
|
2010-03-26 06:58:58 +08:00
|
|
|
enum map_type type, u64 addr,
|
2016-09-02 06:25:52 +08:00
|
|
|
struct map **mapp);
|
2010-03-26 06:58:58 +08:00
|
|
|
|
2011-08-24 01:31:30 +08:00
|
|
|
struct symbol *map_groups__find_symbol_by_name(struct map_groups *mg,
|
2010-03-26 23:30:40 +08:00
|
|
|
enum map_type type,
|
|
|
|
const char *name,
|
2016-09-02 06:25:52 +08:00
|
|
|
struct map **mapp);
|
2010-03-26 23:30:40 +08:00
|
|
|
|
2013-10-14 18:43:38 +08:00
|
|
|
struct addr_map_symbol;
|
|
|
|
|
2016-09-02 06:25:52 +08:00
|
|
|
int map_groups__find_ams(struct addr_map_symbol *ams);
|
2013-10-14 18:43:38 +08:00
|
|
|
|
2010-03-26 23:30:40 +08:00
|
|
|
static inline
|
2011-08-24 01:31:30 +08:00
|
|
|
struct symbol *map_groups__find_function_by_name(struct map_groups *mg,
|
2016-09-02 06:25:52 +08:00
|
|
|
const char *name, struct map **mapp)
|
2010-03-26 06:58:58 +08:00
|
|
|
{
|
2016-09-02 06:25:52 +08:00
|
|
|
return map_groups__find_symbol_by_name(mg, MAP__FUNCTION, name, mapp);
|
2010-03-26 06:58:58 +08:00
|
|
|
}
|
|
|
|
|
2011-08-24 01:31:30 +08:00
|
|
|
int map_groups__fixup_overlappings(struct map_groups *mg, struct map *map,
|
2014-07-15 05:46:47 +08:00
|
|
|
FILE *fp);
|
2010-03-26 23:11:06 +08:00
|
|
|
|
2011-08-24 01:31:30 +08:00
|
|
|
struct map *map_groups__find_by_name(struct map_groups *mg,
|
2010-03-26 06:58:58 +08:00
|
|
|
enum map_type type, const char *name);
|
2010-04-19 13:32:50 +08:00
|
|
|
|
2015-07-23 22:06:16 +08:00
|
|
|
bool __map__is_kernel(const struct map *map);
|
|
|
|
|
|
|
|
static inline bool __map__is_kmodule(const struct map *map)
|
|
|
|
{
|
|
|
|
return !__map__is_kernel(map);
|
|
|
|
}
|
|
|
|
|
2009-12-28 07:37:00 +08:00
|
|
|
#endif /* __PERF_MAP_H */
|