tools/perf/arch/x86/util/intel-pt.c

Source file repositories/reference/linux-study-clean/tools/perf/arch/x86/util/intel-pt.c

File Facts

System
Linux kernel
Corpus path
tools/perf/arch/x86/util/intel-pt.c
Extension
.c
Size
32256 bytes
Lines
1231
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: implementation source
Status
source implementation candidate

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

switch_evsel->core.attr.context_switch = 1;
				switch_evsel->immediate = true;

				evsel__set_sample_bit(switch_evsel, TID);
				evsel__set_sample_bit(switch_evsel, TIME);
				evsel__set_sample_bit(switch_evsel, CPU);
				evsel__reset_sample_bit(switch_evsel, BRANCH_STACK);

				opts->record_switch_events = false;
				ptr->have_sched_switch = 3;
			} else {
				opts->record_switch_events = true;
				need_immediate = true;
				if (cpu_wide)
					ptr->have_sched_switch = 3;
				else
					ptr->have_sched_switch = 2;
			}
		} else {
#ifdef HAVE_LIBTRACEEVENT
			err = intel_pt_track_switches(evlist);
			if (err == -EPERM)
				pr_debug2("Unable to select sched:sched_switch\n");
			else if (err)
				return err;
			else
				ptr->have_sched_switch = 1;
#endif
		}
	}

	if (have_timing_info && !intel_pt_evsel->core.attr.exclude_kernel &&
	    perf_can_record_text_poke_events() && perf_can_record_cpu_wide())
		opts->text_poke = true;

	if (intel_pt_evsel) {
		/*
		 * To obtain the auxtrace buffer file descriptor, the auxtrace
		 * event must come first.
		 */
		evlist__to_front(evlist, intel_pt_evsel);
		/*
		 * In the case of per-cpu mmaps, we need the CPU on the
		 * AUX event.
		 */
		if (!perf_cpu_map__is_any_cpu_or_is_empty(cpus))
			evsel__set_sample_bit(intel_pt_evsel, CPU);
	}

	/* Add dummy event to keep tracking */
	if (opts->full_auxtrace) {
		bool need_system_wide_tracking;
		struct evsel *tracking_evsel;

		/*
		 * User space tasks can migrate between CPUs, so when tracing
		 * selected CPUs, sideband for all CPUs is still needed.
		 */
		need_system_wide_tracking = opts->target.cpu_list &&
					    !intel_pt_evsel->core.attr.exclude_user;

		tracking_evsel = evlist__add_aux_dummy(evlist, need_system_wide_tracking);
		if (!tracking_evsel)
			return -ENOMEM;

		evlist__set_tracking_event(evlist, tracking_evsel);

		if (need_immediate)
			tracking_evsel->immediate = true;

		/* In per-cpu case, always need the time of mmap events etc */
		if (!perf_cpu_map__is_any_cpu_or_is_empty(cpus)) {
			evsel__set_sample_bit(tracking_evsel, TIME);
			/* And the CPU for switch events */
			evsel__set_sample_bit(tracking_evsel, CPU);
		}
		evsel__reset_sample_bit(tracking_evsel, BRANCH_STACK);
	}

	/*
	 * Warn the user when we do not have enough information to decode i.e.
	 * per-cpu with no sched_switch (except workload-only).
	 */
	if (!ptr->have_sched_switch && !perf_cpu_map__is_any_cpu_or_is_empty(cpus) &&
	    !target__none(&opts->target) &&
	    !intel_pt_evsel->core.attr.exclude_user)
		ui__warning("Intel Processor Trace decoding will not be possible except for kernel tracing!\n");

	return 0;
}

Annotation

Implementation Notes