From: Peter Zijlstra <peterz@infradead.org>
To: Cong Wang <xiyou.wangcong@gmail.com>
Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org,
Paul Mackerras <paulus@samba.org>, Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Cong Wang <cwang@twopensource.com>
Subject: Re: [Patch] perf_event: fix a race condition in perf_remove_from_context()
Date: Mon, 1 Sep 2014 10:38:28 +0200 [thread overview]
Message-ID: <20140901083828.GA27892@worktop.ger.corp.intel.com> (raw)
In-Reply-To: <1409268455-11807-1-git-send-email-xiyou.wangcong@gmail.com>
On Thu, Aug 28, 2014 at 04:27:35PM -0700, Cong Wang wrote:
> From: Cong Wang <cwang@twopensource.com>
>
> We saw a kernel soft lockup in perf_remove_from_context(),
> it looks like the `perf` process, when exiting, could not go
> out of the retry loop. Meanwhile, the target process was forking
> a child. So either the target process should execute the smp
> function call to deactive the event (if it was running) or it should
> do a context switch which deactives the event.
>
> It seems we optimize out a context switch in perf_event_context_sched_out(),
> and what's more important, we still test an obsolete task pointer when
> retrying, so no one actually would deactive that event in this situation.
> Fix it directly by reloading the task pointer in perf_remove_from_context().
> This should fix the above soft lockup.
> ---
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index f9c1ed0..c4141a0 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -1524,6 +1524,11 @@ retry:
Please use either:
.gitconfig:
[diff "default"]
xfuncname = "^[[:alpha:]$_].*[^:]$"
.quiltrc:
QUILT_DIFF_OPTS="-F ^[[:alpha:]\$_].*[^:]\$"
> */
> if (ctx->is_active) {
> raw_spin_unlock_irq(&ctx->lock);
> + /*
> + * Reload the task pointer, it might have been changed by
> + * a concurrent perf_event_context_sched_out() without switching
> + */
> + task = ctx->task;
> goto retry;
> }
You forgot to check if that same error happened in other places (it
does), please fix all of them.
next prev parent reply other threads:[~2014-09-01 8:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-28 23:27 Cong Wang
2014-09-01 8:38 ` Peter Zijlstra [this message]
2014-09-02 22:15 ` Cong Wang
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=20140901083828.GA27892@worktop.ger.corp.intel.com \
--to=peterz@infradead.org \
--cc=acme@kernel.org \
--cc=cwang@twopensource.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=paulus@samba.org \
--cc=stable@vger.kernel.org \
--cc=xiyou.wangcong@gmail.com \
/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
Powered by JetHome