public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Liang, Kan" <kan.liang@linux.intel.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: mingo@redhat.com, linux-kernel@vger.kernel.org,
	irogers@google.com, eranian@google.com, ak@linux.intel.com
Subject: Re: [PATCH] perf/core: Fix endless multiplex timer
Date: Thu, 5 Mar 2020 12:56:49 -0500	[thread overview]
Message-ID: <5c5b7fd1-4b85-8cce-b263-4a421b00f6df@linux.intel.com> (raw)
In-Reply-To: <20200305123851.GX2596@hirez.programming.kicks-ass.net>



On 3/5/2020 7:38 AM, Peter Zijlstra wrote:
> On Wed, Mar 04, 2020 at 09:20:42AM -0500, Liang, Kan wrote:
>>
>> NMI watchdog is pinned event.
>> ctx_event_to_rotate() will only pick an event from the flexible_groups.
>> So the cpu_ctx_sched_out() in perf_rotate_context() will never be called.
> 
> Surely that's fixable; same principle.
> 

Yes, after applying this patch, the issue has gone.

Tested-by: Kan Liang <kan.liang@linux.intel.com>

Thanks,
Kan
> ---
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index 3f1f77de7247..595fb3decd43 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -2182,6 +2182,7 @@ __perf_remove_from_context(struct perf_event *event,
>   
>   	if (!ctx->nr_events && ctx->is_active) {
>   		ctx->is_active = 0;
> +		ctx->rotate_necessary = 0;
>   		if (ctx->task) {
>   			WARN_ON_ONCE(cpuctx->task_ctx != ctx);
>   			cpuctx->task_ctx = NULL;
> @@ -3077,12 +3078,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)
> @@ -3092,6 +3087,13 @@ static void ctx_sched_out(struct perf_event_context *ctx,
>   	if (is_active & EVENT_FLEXIBLE) {
>   		list_for_each_entry_safe(event, tmp, &ctx->flexible_active, active_list)
>   			group_sched_out(event, cpuctx, ctx);
> +
> +		/*
> +		 * Since we cleared EVENT_FLEXIBLE, also clear
> +		 * rotate_necessary, is will be reset by
> +		 * ctx_flexible_sched_in() when needed.
> +		 */
> +		ctx->rotate_necessary = 0;
>   	}
>   	perf_pmu_enable(ctx->pmu);
>   }
> @@ -3841,6 +3843,12 @@ ctx_event_to_rotate(struct perf_event_context *ctx)
>   				      typeof(*event), group_node);
>   	}
>   
> +	/*
> +	 * Unconditionally clear rotate_necessary; if ctx_flexible_sched_in()
> +	 * finds there are unschedulable events, it will set it again.
> +	 */
> +	ctx->rotate_necessary = 0;
> +
>   	return event;
>   }
>   
> 

  reply	other threads:[~2020-03-05 17:56 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-03 20:28 [PATCH] perf/core: Fix endless multiplex timer kan.liang
2020-03-03 21:08 ` Peter Zijlstra
2020-03-04  1:40   ` Liang, Kan
2020-03-04  9:33     ` Peter Zijlstra
2020-03-04 14:20       ` Liang, Kan
2020-03-05 12:38         ` Peter Zijlstra
2020-03-05 17:56           ` Liang, Kan [this message]
2020-03-20 12:58           ` [tip: perf/core] " tip-bot2 for Peter Zijlstra
2020-08-06 18:11             ` Robin Murphy
2020-08-06 18:53               ` Greg KH
2020-08-06 20:40                 ` Robin Murphy
2020-03-24  6:00 ` [perf/core] 92b1f046a2: BUG:kernel_NULL_pointer_dereference,address kernel test robot
2020-03-24 12:52   ` Liang, Kan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5c5b7fd1-4b85-8cce-b263-4a421b00f6df@linux.intel.com \
    --to=kan.liang@linux.intel.com \
    --cc=ak@linux.intel.com \
    --cc=eranian@google.com \
    --cc=irogers@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox