Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751982AbbLIPZb (ORCPT ); Wed, 9 Dec 2015 10:25:31 -0500 Received: from mga02.intel.com ([134.134.136.20]:22617 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751419AbbLIPZ3 convert rfc822-to-8bit (ORCPT ); Wed, 9 Dec 2015 10:25:29 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,404,1444719600"; d="scan'208";a="868082575" From: "Liang, Kan" To: Peter Zijlstra CC: "linux-kernel@vger.kernel.org" , "hpa@zytor.com" , "torvalds@linux-foundation.org" , "acme@kernel.org" , "mingo@kernel.org" , "paulus@samba.org" , "tglx@linutronix.de" , "linux-tip-commits@vger.kernel.org" Subject: RE: [tip:perf/core] perf: Add pmu specific data for perf task context Thread-Topic: [tip:perf/core] perf: Add pmu specific data for perf task context Thread-Index: AQHQS56FtwqUg90vnEyKXKxk9n6Q0J7Dm10AgADvnyD//4BCAIAAiOPw Date: Wed, 9 Dec 2015 15:25:25 +0000 Message-ID: <37D7C6CF3E00A74B8858931C1DB2F077019ABF1D@shsmsx102.ccr.corp.intel.com> References: <1415156173-10035-6-git-send-email-kan.liang@intel.com> <20151209083402.GK6356@twins.programming.kicks-ass.net> <37D7C6CF3E00A74B8858931C1DB2F077019AAE28@SHSMSX103.ccr.corp.intel.com> <20151209151428.GQ6356@twins.programming.kicks-ass.net> In-Reply-To: <20151209151428.GQ6356@twins.programming.kicks-ass.net> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsIiwiaWQiOiI2ZTg2NzM5ZS0wODk0LTQ2MDUtYTkxOS05N2U2YjFkM2I0MGUiLCJwcm9wcyI6W3sibiI6IkludGVsRGF0YUNsYXNzaWZpY2F0aW9uIiwidmFscyI6W3sidmFsdWUiOiJDVFBfSUMifV19XX0sIlN1YmplY3RMYWJlbHMiOltdLCJUTUNWZXJzaW9uIjoiMTUuNC4xMC4xOSIsIlRydXN0ZWRMYWJlbEhhc2giOiJKbEEydGphSlY1MWNRdlwvXC9ORFwvOEFHd3pEbEp4MjF3Q3pja1VvV0ZMcmZrPSJ9 x-inteldataclassification: CTP_IC x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2056 Lines: 67 > > On Wed, Dec 09, 2015 at 02:59:21PM +0000, Liang, Kan wrote: > > > diff --git a/kernel/events/core.c b/kernel/events/core.c index > > > 36babfd..97aa610 100644 > > > --- a/kernel/events/core.c > > > +++ b/kernel/events/core.c > > > @@ -3508,11 +3515,6 @@ retry: > > > if (!ctx) > > > goto errout; > > > > > > - if (task_ctx_data) { > > > - ctx->task_ctx_data = task_ctx_data; > > > - task_ctx_data = NULL; > > > - } > > > - > > > err = 0; > > > mutex_lock(&task->perf_event_mutex); > > > /* > > > @@ -3526,6 +3528,10 @@ retry: > > > else { > > > get_ctx(ctx); > > > ++ctx->pin_count; > > > + if (task_ctx_data) { > > > + ctx->task_ctx_data = task_ctx_data; > > > + task_ctx_data = NULL; > > > + } > > > rcu_assign_pointer(task->perf_event_ctxp[ctxn], > > > ctx); > > > } > > > mutex_unlock(&task->perf_event_mutex); > > > > > > > > > Does that make sense? No point in setting task_ctx_data if we're > > > going to free the ctx and try again. > > > > The task_ctx_data will be checked before use. So it wouldn't crash the > > system if it's NULL. > > Yeah, I know, I checked :-) > > > The problem is that LBR stack info will not be save/store on context > > switch anymore. The user probably get wrong call stack information. > > Yep > > > May I know why you want to do that? > > Because this seemed like a less fragile construct. When there's multiple > event creations racing it seems possible (ableit entirely unlikely) to assign > the allocated task_ctx_data to a ctx that we'll delete, and on the second go > around re-allocate a ctx, but are left wihtout task_ctx_data to assign to it. > > So by only assigning the task_ctx_data when we _know_ we've succeeded, > we'll avoid this scenario. Yes, I think it make sense to that. Thanks, Kan -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/