Skip to content

Commit 54a3cf5

Browse files
avaginacmel
authored andcommitted
perf inject: Mark a dso if it's used
Otherwise they will be not written in an output file. Signed-off-by: Andrew Vagin <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Paul Mackerras <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: http://lkml.kernel.org/r/[email protected] [ committer note: Fixed up wrt changes made in the immediate previous patches ] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 26a031e commit 54a3cf5

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

tools/perf/builtin-inject.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "util/session.h"
1515
#include "util/tool.h"
1616
#include "util/debug.h"
17+
#include "util/build-id.h"
1718

1819
#include "util/parse-options.h"
1920

@@ -116,6 +117,8 @@ static int perf_event__repipe_sample(struct perf_tool *tool,
116117
return f(tool, event, sample, evsel, machine);
117118
}
118119

120+
build_id__mark_dso_hit(tool, event, sample, evsel, machine);
121+
119122
return perf_event__repipe_synth(tool, event, machine);
120123
}
121124

@@ -310,6 +313,7 @@ static int perf_inject__sched_stat(struct perf_tool *tool,
310313
sample_sw.time = sample->time;
311314
perf_event__synthesize_sample(event_sw, evsel->attr.sample_type,
312315
&sample_sw, false);
316+
build_id__mark_dso_hit(tool, event_sw, &sample_sw, evsel, machine);
313317
return perf_event__repipe(tool, event_sw, &sample_sw, machine);
314318
}
315319

@@ -342,8 +346,7 @@ static int __cmd_inject(struct perf_inject *inject)
342346

343347
signal(SIGINT, sig_handler);
344348

345-
if (inject->build_ids) {
346-
inject->tool.sample = perf_event__inject_buildid;
349+
if (inject->build_ids || inject->sched_stat) {
347350
inject->tool.mmap = perf_event__repipe_mmap;
348351
inject->tool.fork = perf_event__repipe_fork;
349352
inject->tool.tracing_data = perf_event__repipe_tracing_data;
@@ -353,7 +356,9 @@ static int __cmd_inject(struct perf_inject *inject)
353356
if (session == NULL)
354357
return -ENOMEM;
355358

356-
if (inject->sched_stat) {
359+
if (inject->build_ids) {
360+
inject->tool.sample = perf_event__inject_buildid;
361+
} else if (inject->sched_stat) {
357362
struct perf_evsel *evsel;
358363

359364
inject->tool.ordered_samples = true;

tools/perf/util/build-id.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
#include "session.h"
1717
#include "tool.h"
1818

19-
static int build_id__mark_dso_hit(struct perf_tool *tool __maybe_unused,
20-
union perf_event *event,
21-
struct perf_sample *sample __maybe_unused,
22-
struct perf_evsel *evsel __maybe_unused,
23-
struct machine *machine)
19+
int build_id__mark_dso_hit(struct perf_tool *tool __maybe_unused,
20+
union perf_event *event,
21+
struct perf_sample *sample __maybe_unused,
22+
struct perf_evsel *evsel __maybe_unused,
23+
struct machine *machine)
2424
{
2525
struct addr_location al;
2626
u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;

tools/perf/util/build-id.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,8 @@ extern struct perf_tool build_id__mark_dso_hit_ops;
77

88
char *dso__build_id_filename(struct dso *self, char *bf, size_t size);
99

10+
int build_id__mark_dso_hit(struct perf_tool *tool, union perf_event *event,
11+
struct perf_sample *sample, struct perf_evsel *evsel,
12+
struct machine *machine);
13+
1014
#endif

0 commit comments

Comments
 (0)