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

Commit 6fcf8774 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman
Browse files

Revert "perf/cgroups: Don't rotate events for cgroups unnecessarily"



This reverts commit 0b4c9255 as it
breaks the abi.

Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
Change-Id: I3a4cbfa1cfbef15a6aaabf759dc2bbfaa8f2b47a
parent 5e002cfc
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -761,11 +761,6 @@ struct perf_event_context {
	int				nr_stat;
	int				nr_freq;
	int				rotate_disable;
	/*
	 * Set when nr_events != nr_active, except tolerant to events not
	 * necessary to be active due to scheduling constraints, such as cgroups.
	 */
	int				rotate_necessary;
	atomic_t			refcount;
	struct task_struct		*task;

+20 −22
Original line number Diff line number Diff line
@@ -2952,12 +2952,6 @@ static void ctx_sched_out(struct perf_event_context *ctx,
	if (!ctx->nr_active || !(is_active & EVENT_ALL))
		return;

	/*
	 * If we had been multiplexing, no rotations are necessary, now no events
	 * are active.
	 */
	ctx->rotate_necessary = 0;

	perf_pmu_disable(ctx->pmu);
	if (is_active & EVENT_PINNED) {
		list_for_each_entry_safe(event, tmp, &ctx->pinned_active, active_list)
@@ -3325,13 +3319,10 @@ static int flexible_sched_in(struct perf_event *event, void *data)
		return 0;

	if (group_can_go_on(event, sid->cpuctx, sid->can_add_hw)) {
		int ret = group_sched_in(event, sid->cpuctx, sid->ctx);
		if (ret) {
			sid->can_add_hw = 0;
			sid->ctx->rotate_necessary = 1;
			return 0;
		}
		if (!group_sched_in(event, sid->cpuctx, sid->ctx))
			list_add_tail(&event->active_list, &sid->ctx->flexible_active);
		else
			sid->can_add_hw = 0;
	}

	return 0;
@@ -3699,17 +3690,24 @@ ctx_first_active(struct perf_event_context *ctx)
static bool perf_rotate_context(struct perf_cpu_context *cpuctx)
{
	struct perf_event *cpu_event = NULL, *task_event = NULL;
	struct perf_event_context *task_ctx = NULL;
	int cpu_rotate, task_rotate;
	bool cpu_rotate = false, task_rotate = false;
	struct perf_event_context *ctx = NULL;

	/*
	 * Since we run this from IRQ context, nobody can install new
	 * events, thus the event count values are stable.
	 */

	cpu_rotate = cpuctx->ctx.rotate_necessary;
	task_ctx = cpuctx->task_ctx;
	task_rotate = task_ctx ? task_ctx->rotate_necessary : 0;
	if (cpuctx->ctx.nr_events) {
		if (cpuctx->ctx.nr_events != cpuctx->ctx.nr_active)
			cpu_rotate = true;
	}

	ctx = cpuctx->task_ctx;
	if (ctx && ctx->nr_events) {
		if (ctx->nr_events != ctx->nr_active)
			task_rotate = true;
	}

	if (!(cpu_rotate || task_rotate))
		return false;
@@ -3718,7 +3716,7 @@ static bool perf_rotate_context(struct perf_cpu_context *cpuctx)
	perf_pmu_disable(cpuctx->ctx.pmu);

	if (task_rotate)
		task_event = ctx_first_active(task_ctx);
		task_event = ctx_first_active(ctx);
	if (cpu_rotate)
		cpu_event = ctx_first_active(&cpuctx->ctx);

@@ -3726,17 +3724,17 @@ static bool perf_rotate_context(struct perf_cpu_context *cpuctx)
	 * As per the order given at ctx_resched() first 'pop' task flexible
	 * and then, if needed CPU flexible.
	 */
	if (task_event || (task_ctx && cpu_event))
		ctx_sched_out(task_ctx, cpuctx, EVENT_FLEXIBLE);
	if (task_event || (ctx && cpu_event))
		ctx_sched_out(ctx, cpuctx, EVENT_FLEXIBLE);
	if (cpu_event)
		cpu_ctx_sched_out(cpuctx, EVENT_FLEXIBLE);

	if (task_event)
		rotate_ctx(task_ctx, task_event);
		rotate_ctx(ctx, task_event);
	if (cpu_event)
		rotate_ctx(&cpuctx->ctx, cpu_event);

	perf_event_sched_in(cpuctx, task_ctx, current);
	perf_event_sched_in(cpuctx, ctx, current);

	perf_pmu_enable(cpuctx->ctx.pmu);
	perf_ctx_unlock(cpuctx, cpuctx->task_ctx);