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

Commit edb39592 authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Thomas Gleixner
Browse files

perf: Fix sibling iteration



Mark noticed that the change to sibling_list changed some iteration
semantics; because previously we used group_list as list entry,
sibling events would always have an empty sibling_list.

But because we now use sibling_list for both list head and list entry,
siblings will report as having siblings.

Fix this with a custom for_each_sibling_event() iterator.

Fixes: 8343aae6 ("perf/core: Remove perf_event::group_entry")
Reported-by: default avatarMark Rutland <mark.rutland@arm.com>
Suggested-by: default avatarMark Rutland <mark.rutland@arm.com>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Cc: vincent.weaver@maine.edu
Cc: alexander.shishkin@linux.intel.com
Cc: torvalds@linux-foundation.org
Cc: alexey.budankov@linux.intel.com
Cc: valery.cherepennikov@intel.com
Cc: eranian@google.com
Cc: acme@redhat.com
Cc: linux-tip-commits@vger.kernel.org
Cc: davidcc@google.com
Cc: kan.liang@intel.com
Cc: Dmitry.Prohorov@intel.com
Cc: jolsa@redhat.com
Link: https://lkml.kernel.org/r/20180315170129.GX4043@hirez.programming.kicks-ass.net
parent 32ff77e8
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -351,7 +351,7 @@ static int collect_events(struct perf_event *group, int max_count,
		evtype[n] = group->hw.event_base;
		evtype[n] = group->hw.event_base;
		current_idx[n++] = PMC_NO_INDEX;
		current_idx[n++] = PMC_NO_INDEX;
	}
	}
	list_for_each_entry(pe, &group->sibling_list, sibling_list) {
	for_each_sibling_event(pe, group) {
		if (!is_software_event(pe) && pe->state != PERF_EVENT_STATE_OFF) {
		if (!is_software_event(pe) && pe->state != PERF_EVENT_STATE_OFF) {
			if (n >= max_count)
			if (n >= max_count)
				return -1;
				return -1;
+1 −1
Original line number Original line Diff line number Diff line
@@ -269,7 +269,7 @@ static bool mmdc_pmu_group_is_valid(struct perf_event *event)
			return false;
			return false;
	}
	}


	list_for_each_entry(sibling, &leader->sibling_list, sibling_list) {
	for_each_sibling_event(sibling, leader) {
		if (!mmdc_pmu_group_event_is_valid(sibling, pmu, &counter_mask))
		if (!mmdc_pmu_group_event_is_valid(sibling, pmu, &counter_mask))
			return false;
			return false;
	}
	}
+1 −1
Original line number Original line Diff line number Diff line
@@ -293,7 +293,7 @@ static bool l2x0_pmu_group_is_valid(struct perf_event *event)
	else if (!is_software_event(leader))
	else if (!is_software_event(leader))
		return false;
		return false;


	list_for_each_entry(sibling, &leader->sibling_list, sibling_list) {
	for_each_sibling_event(sibling, leader) {
		if (sibling->pmu == pmu)
		if (sibling->pmu == pmu)
			num_hw++;
			num_hw++;
		else if (!is_software_event(sibling))
		else if (!is_software_event(sibling))
+1 −1
Original line number Original line Diff line number Diff line
@@ -711,7 +711,7 @@ static int validate_group(struct perf_event *event)
	if (mipsxx_pmu_alloc_counter(&fake_cpuc, &leader->hw) < 0)
	if (mipsxx_pmu_alloc_counter(&fake_cpuc, &leader->hw) < 0)
		return -EINVAL;
		return -EINVAL;


	list_for_each_entry(sibling, &leader->sibling_list, sibling_list) {
	for_each_sibling_event(sibling, leader) {
		if (mipsxx_pmu_alloc_counter(&fake_cpuc, &sibling->hw) < 0)
		if (mipsxx_pmu_alloc_counter(&fake_cpuc, &sibling->hw) < 0)
			return -EINVAL;
			return -EINVAL;
	}
	}
+1 −1
Original line number Original line Diff line number Diff line
@@ -1426,7 +1426,7 @@ static int collect_events(struct perf_event *group, int max_count,
		flags[n] = group->hw.event_base;
		flags[n] = group->hw.event_base;
		events[n++] = group->hw.config;
		events[n++] = group->hw.config;
	}
	}
	list_for_each_entry(event, &group->sibling_list, sibling_list) {
	for_each_sibling_event(event, group) {
		if (event->pmu->task_ctx_nr == perf_hw_context &&
		if (event->pmu->task_ctx_nr == perf_hw_context &&
		    event->state != PERF_EVENT_STATE_OFF) {
		    event->state != PERF_EVENT_STATE_OFF) {
			if (n >= max_count)
			if (n >= max_count)
Loading