Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f701d860 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull perf fixes from Ingo Molnar:
 "This is mostly tooling fixes, plus an instruction pointer filtering
  fix.

  It's more fixes than usual - Arnaldo got back from a longer vacation
  and there was a backlog"

* 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (27 commits)
  perf symbols: Kill dso__build_id_is_kmod()
  perf symbols: Keep DSO->symtab_type after decompress
  perf tests: Decompress kernel module before objdump
  perf tools: Consolidate error path in __open_dso()
  perf tools: Decompress kernel module when reading DSO data
  perf annotate: Use dso__decompress_kmodule_path()
  perf tools: Introduce dso__decompress_kmodule_{fd,path}
  perf tools: Fix a memory leak in __open_dso()
  perf annotate: Fix symbolic link of build-id cache
  perf/core: Drop kernel samples even though :u is specified
  perf script python: Remove dups in documentation examples
  perf script python: Updated trace_unhandled() signature
  perf script python: Fix wrong code snippets in documentation
  perf script: Fix documentation errors
  perf script: Fix outdated comment for perf-trace-python
  perf probe: Fix examples section of documentation
  perf report: Ensure the perf DSO mapping matches what libdw sees
  perf report: Include partial stacks unwound with libdw
  perf annotate: Add missing powerpc triplet
  perf test: Disable breakpoint signal tests for powerpc
  ...
parents 9376906c 47c1ded7
Loading
Loading
Loading
Loading
+21 −0
Original line number Original line Diff line number Diff line
@@ -7316,6 +7316,21 @@ int perf_event_account_interrupt(struct perf_event *event)
	return __perf_event_account_interrupt(event, 1);
	return __perf_event_account_interrupt(event, 1);
}
}


static bool sample_is_allowed(struct perf_event *event, struct pt_regs *regs)
{
	/*
	 * Due to interrupt latency (AKA "skid"), we may enter the
	 * kernel before taking an overflow, even if the PMU is only
	 * counting user events.
	 * To avoid leaking information to userspace, we must always
	 * reject kernel samples when exclude_kernel is set.
	 */
	if (event->attr.exclude_kernel && !user_mode(regs))
		return false;

	return true;
}

/*
/*
 * Generic event overflow handling, sampling.
 * Generic event overflow handling, sampling.
 */
 */
@@ -7336,6 +7351,12 @@ static int __perf_event_overflow(struct perf_event *event,


	ret = __perf_event_account_interrupt(event, throttle);
	ret = __perf_event_account_interrupt(event, throttle);


	/*
	 * For security, drop the skid kernel samples if necessary.
	 */
	if (!sample_is_allowed(event, regs))
		return ret;

	/*
	/*
	 * XXX event_limit might not quite work as expected on inherited
	 * XXX event_limit might not quite work as expected on inherited
	 * events
	 * events
+6 −2
Original line number Original line Diff line number Diff line
@@ -240,7 +240,11 @@ Add a probe on schedule() function 12th line with recording cpu local variable:
 or
 or
 ./perf probe --add='schedule:12 cpu'
 ./perf probe --add='schedule:12 cpu'


 this will add one or more probes which has the name start with "schedule".
Add one or more probes which has the name start with "schedule".

 ./perf probe schedule*
 or
 ./perf probe --add='schedule*'


Add probes on lines in schedule() function which calls update_rq_clock().
Add probes on lines in schedule() function which calls update_rq_clock().


+1 −1
Original line number Original line Diff line number Diff line
@@ -39,7 +39,7 @@ EVENT HANDLERS
When perf script is invoked using a trace script, a user-defined
When perf script is invoked using a trace script, a user-defined
'handler function' is called for each event in the trace.  If there's
'handler function' is called for each event in the trace.  If there's
no handler function defined for a given event type, the event is
no handler function defined for a given event type, the event is
ignored (or passed to a 'trace_handled' function, see below) and the
ignored (or passed to a 'trace_unhandled' function, see below) and the
next event is processed.
next event is processed.


Most of the event's field values are passed as arguments to the
Most of the event's field values are passed as arguments to the
+9 −14
Original line number Original line Diff line number Diff line
@@ -149,10 +149,8 @@ def raw_syscalls__sys_enter(event_name, context, common_cpu,
		print "id=%d, args=%s\n" % \
		print "id=%d, args=%s\n" % \
		(id, args),
		(id, args),


def trace_unhandled(event_name, context, common_cpu, common_secs, common_nsecs,
def trace_unhandled(event_name, context, event_fields_dict):
		common_pid, common_comm):
		print ' '.join(['%s=%s'%(k,str(v))for k,v in sorted(event_fields_dict.items())])
		print_header(event_name, common_cpu, common_secs, common_nsecs,
		common_pid, common_comm)


def print_header(event_name, cpu, secs, nsecs, pid, comm):
def print_header(event_name, cpu, secs, nsecs, pid, comm):
	print "%-20s %5u %05u.%09u %8u %-20s " % \
	print "%-20s %5u %05u.%09u %8u %-20s " % \
@@ -321,7 +319,7 @@ So those are the essential steps in writing and running a script. The
process can be generalized to any tracepoint or set of tracepoints
process can be generalized to any tracepoint or set of tracepoints
you're interested in - basically find the tracepoint(s) you're
you're interested in - basically find the tracepoint(s) you're
interested in by looking at the list of available events shown by
interested in by looking at the list of available events shown by
'perf list' and/or look in /sys/kernel/debug/tracing events for
'perf list' and/or look in /sys/kernel/debug/tracing/events/ for
detailed event and field info, record the corresponding trace data
detailed event and field info, record the corresponding trace data
using 'perf record', passing it the list of interesting events,
using 'perf record', passing it the list of interesting events,
generate a skeleton script using 'perf script -g python' and modify the
generate a skeleton script using 'perf script -g python' and modify the
@@ -334,7 +332,7 @@ right place, you can have your script listed alongside the other
scripts listed by the 'perf script -l' command e.g.:
scripts listed by the 'perf script -l' command e.g.:


----
----
root@tropicana:~# perf script -l
# perf script -l
List of available trace scripts:
List of available trace scripts:
  wakeup-latency                       system-wide min/max/avg wakeup latency
  wakeup-latency                       system-wide min/max/avg wakeup latency
  rw-by-file <comm>                    r/w activity for a program, by file
  rw-by-file <comm>                    r/w activity for a program, by file
@@ -383,8 +381,6 @@ source tree:


----
----
# ls -al kernel-source/tools/perf/scripts/python
# ls -al kernel-source/tools/perf/scripts/python

root@tropicana:/home/trz/src/tip# ls -al tools/perf/scripts/python
total 32
total 32
drwxr-xr-x 4 trz trz 4096 2010-01-26 22:30 .
drwxr-xr-x 4 trz trz 4096 2010-01-26 22:30 .
drwxr-xr-x 4 trz trz 4096 2010-01-26 22:29 ..
drwxr-xr-x 4 trz trz 4096 2010-01-26 22:29 ..
@@ -399,7 +395,7 @@ otherwise your script won't show up at run-time), 'perf script -l'
should show a new entry for your script:
should show a new entry for your script:


----
----
root@tropicana:~# perf script -l
# perf script -l
List of available trace scripts:
List of available trace scripts:
  wakeup-latency                       system-wide min/max/avg wakeup latency
  wakeup-latency                       system-wide min/max/avg wakeup latency
  rw-by-file <comm>                    r/w activity for a program, by file
  rw-by-file <comm>                    r/w activity for a program, by file
@@ -437,7 +433,7 @@ EVENT HANDLERS
When perf script is invoked using a trace script, a user-defined
When perf script is invoked using a trace script, a user-defined
'handler function' is called for each event in the trace.  If there's
'handler function' is called for each event in the trace.  If there's
no handler function defined for a given event type, the event is
no handler function defined for a given event type, the event is
ignored (or passed to a 'trace_handled' function, see below) and the
ignored (or passed to a 'trace_unhandled' function, see below) and the
next event is processed.
next event is processed.


Most of the event's field values are passed as arguments to the
Most of the event's field values are passed as arguments to the
@@ -532,7 +528,7 @@ can implement a set of optional functions:
gives scripts a chance to do setup tasks:
gives scripts a chance to do setup tasks:


----
----
def trace_begin:
def trace_begin():
    pass
    pass
----
----


@@ -541,7 +537,7 @@ def trace_begin:
 as display results:
 as display results:


----
----
def trace_end:
def trace_end():
    pass
    pass
----
----


@@ -550,8 +546,7 @@ def trace_end:
 of common arguments are passed into it:
 of common arguments are passed into it:


----
----
def trace_unhandled(event_name, context, common_cpu, common_secs,
def trace_unhandled(event_name, context, event_fields_dict):
        common_nsecs, common_pid, common_comm):
    pass
    pass
----
----


+1 −0
Original line number Original line Diff line number Diff line
@@ -26,6 +26,7 @@ const char *const arm64_triplets[] = {


const char *const powerpc_triplets[] = {
const char *const powerpc_triplets[] = {
	"powerpc-unknown-linux-gnu-",
	"powerpc-unknown-linux-gnu-",
	"powerpc-linux-gnu-",
	"powerpc64-unknown-linux-gnu-",
	"powerpc64-unknown-linux-gnu-",
	"powerpc64-linux-gnu-",
	"powerpc64-linux-gnu-",
	"powerpc64le-linux-gnu-",
	"powerpc64le-linux-gnu-",
Loading