All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Yan, Zheng" <zheng.z.yan@intel.com>
To: Stephane Eranian <eranian@google.com>,
	Peter Zijlstra <peterz@infradead.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@kernel.org>,
	Arnaldo Carvalho de Melo <acme@infradead.org>,
	Andi Kleen <andi@firstfloor.org>
Subject: Re: [PATCH 06/14] perf, core: always switch pmu specific data during context switch
Date: Thu, 06 Feb 2014 10:08:30 +0800	[thread overview]
Message-ID: <52F2EE9E.4070905@intel.com> (raw)
In-Reply-To: <CABPqkBTB3B817LBnY2pu0uLMhjHzJa8fL6a--iKe-2bKUxFZpQ@mail.gmail.com>

On 02/06/2014 02:35 AM, Stephane Eranian wrote:
> On Wed, Feb 5, 2014 at 6:55 PM, Peter Zijlstra <peterz@infradead.org> wrote:
>> On Wed, Feb 05, 2014 at 06:19:27PM +0100, Stephane Eranian wrote:
>>> On Fri, Jan 3, 2014 at 6:48 AM, Yan, Zheng <zheng.z.yan@intel.com> wrote:
>>>> If two tasks were both forked from the same parent task, Events in their perf
>>>> task contexts can be the same. Perf core optimizes context switch oout in this
>>>> case.
>>>>
>>>> Previous patch inroduces pmu specific data. The data is task specific, so we
>>>> should switch the data even when context switch is optimized out.
>>>>
>>> Reviwed-by: Stephane Eranian <eranian@google.com>
>>
>> You should look again.. that xchg() is an atomic op and a total waste of
>> time since the assignment back onto ctx->task_ctx_data is non-atomic.
>>
>> Complete fail there.
>>
> I admit, it was not clear to me why the xchg().

Sorry. I forget why I used xhcg(), maybe save a few lines of code.

Regards
Yan, Zheng

> 
>>>> Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
>>>> ---
>>>>  kernel/events/core.c | 2 ++
>>>>  1 file changed, 2 insertions(+)
>>>>
>>>> diff --git a/kernel/events/core.c b/kernel/events/core.c
>>>> index b6650ab..d6d8dea 100644
>>>> --- a/kernel/events/core.c
>>>> +++ b/kernel/events/core.c
>>>> @@ -2319,6 +2319,8 @@ static void perf_event_context_sched_out(struct task_struct *task, int ctxn,
>>>>                         next->perf_event_ctxp[ctxn] = ctx;
>>>>                         ctx->task = next;
>>>>                         next_ctx->task = task;
>>>> +                       ctx->task_ctx_data = xchg(&next_ctx->task_ctx_data,
>>>> +                                                 ctx->task_ctx_data);
>>>>                         do_switch = 0;
>>>>
>>>>                         perf_event_sync_stat(ctx, next_ctx);
>>>> --
>>>> 1.8.4.2
>>>>


  reply	other threads:[~2014-02-06  2:08 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-03  5:47 [PATCH 00/14] perf, x86: Haswell LBR call stack support Yan, Zheng
2014-01-03  5:47 ` [PATCH 01/14] perf, x86: Reduce lbr_sel_map size Yan, Zheng
2014-02-05 15:15   ` Stephane Eranian
2014-01-03  5:47 ` [PATCH 02/14] perf, core: introduce pmu context switch callback Yan, Zheng
2014-02-05 16:01   ` Stephane Eranian
2014-02-06  1:38     ` Yan, Zheng
2014-01-03  5:48 ` [PATCH 03/14] perf, x86: use context switch callback to flush LBR stack Yan, Zheng
2014-02-05 16:34   ` Stephane Eranian
2014-01-03  5:48 ` [PATCH 04/14] perf, x86: Basic Haswell LBR call stack support Yan, Zheng
2014-02-05 15:40   ` Stephane Eranian
2014-02-06  1:52     ` Yan, Zheng
2014-01-03  5:48 ` [PATCH 05/14] perf, core: allow pmu specific data for perf task context Yan, Zheng
2014-02-05 16:57   ` Stephane Eranian
2014-01-03  5:48 ` [PATCH 06/14] perf, core: always switch pmu specific data during context switch Yan, Zheng
2014-02-05 17:19   ` Stephane Eranian
2014-02-05 17:55     ` Peter Zijlstra
2014-02-05 18:35       ` Stephane Eranian
2014-02-06  2:08         ` Yan, Zheng [this message]
2014-01-03  5:48 ` [PATCH 07/14] perf: track number of events that use LBR callstack Yan, Zheng
2014-02-06 14:55   ` Stephane Eranian
2014-01-03  5:48 ` [PATCH 08/14] perf, x86: allocate space for storing LBR stack Yan, Zheng
2014-02-05 17:26   ` Stephane Eranian
2014-01-03  5:48 ` [PATCH 09/14] perf, x86: Save/resotre LBR stack during context switch Yan, Zheng
2014-02-05 17:45   ` Stephane Eranian
2014-02-06 15:09     ` Stephane Eranian
2014-02-10  8:45       ` Yan, Zheng
2014-01-03  5:48 ` [PATCH 10/14] perf, core: simplify need branch stack check Yan, Zheng
2014-02-06 15:35   ` Stephane Eranian
2014-01-03  5:48 ` [PATCH 11/14] perf, core: Pass perf_sample_data to perf_callchain() Yan, Zheng
2014-01-03  5:48 ` [PATCH 12/14] perf, x86: use LBR call stack to get user callchain Yan, Zheng
2014-02-06 15:46   ` Stephane Eranian
2014-01-03  5:48 ` [PATCH 13/14] perf, x86: enable LBR callstack when recording callchain Yan, Zheng
2014-02-06 15:50   ` Stephane Eranian
2014-01-03  5:48 ` [PATCH 14/14] perf, x86: Discard zero length call entries in LBR call stack Yan, Zheng
2014-02-06 15:57   ` Stephane Eranian
2014-01-21 13:17 ` [PATCH 00/14] perf, x86: Haswell LBR call stack support Stephane Eranian
2014-01-22  1:35   ` Yan, Zheng

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=52F2EE9E.4070905@intel.com \
    --to=zheng.z.yan@intel.com \
    --cc=acme@infradead.org \
    --cc=andi@firstfloor.org \
    --cc=eranian@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.