Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756088AbdIRQSn convert rfc822-to-8bit (ORCPT ); Mon, 18 Sep 2017 12:18:43 -0400 Received: from mga05.intel.com ([192.55.52.43]:14254 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754789AbdIRQSm (ORCPT ); Mon, 18 Sep 2017 12:18:42 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,413,1500966000"; d="scan'208";a="1015664355" From: "Liang, Kan" To: Jiri Olsa CC: "acme@kernel.org" , "peterz@infradead.org" , "mingo@redhat.com" , "linux-kernel@vger.kernel.org" , "jolsa@kernel.org" , "namhyung@kernel.org" , "Hunter, Adrian" , "Odzioba, Lukasz" , "ak@linux.intel.com" Subject: RE: [PATCH RFC V2 05/10] perf tools: lock to protect thread list Thread-Topic: [PATCH RFC V2 05/10] perf tools: lock to protect thread list Thread-Index: AQHTKqUHT9xvs96CVk2dgyJQtYXoIKK52xcAgADr0HA= Date: Mon, 18 Sep 2017 16:18:26 +0000 Message-ID: <37D7C6CF3E00A74B8858931C1DB2F077537C389A@SHSMSX103.ccr.corp.intel.com> References: <1505096603-215017-1-git-send-email-kan.liang@intel.com> <1505096603-215017-6-git-send-email-kan.liang@intel.com> <20170918085058.GB17203@krava> In-Reply-To: <20170918085058.GB17203@krava> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYmY5NTdkMWUtNTBkYi00ZDY2LTg4NTktNDEyZTdjY2MzNGZlIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6IllcL1plK2pRSkYwaDRsRkc0V1JETlhVckxJU0F5WUNic3JqQjZMUzNXRFRNPSJ9 x-ctpclassification: CTP_IC dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action 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: 1113 Lines: 41 > > SNIP > > > + pthread_mutex_unlock(&thread->namespaces_lock); > > + > > return 0; > > } > > > > -void thread__namespaces_id(const struct thread *thread, > > +void thread__namespaces_id(struct thread *thread, > > u64 *dev, u64 *ino) > > { > > struct namespaces *ns; > > > > + pthread_mutex_lock(&thread->namespaces_lock); > > ns = thread__namespaces(thread); > > isn't it just thread__namespaces that needs this lock? I also wanted to protect *dev = ns ? ns->link_info[CGROUP_NS_INDEX].dev : 0; *ino = ns ? ns->link_info[CGROUP_NS_INDEX].ino : 0; Because I was not sure if ns is still accurate when we try to use it later. But for our case (perf top event synthesizing), it looks I worried too much. Namespaces event isn't processed at all. So yes, we don't need patch 4 for the optimization. Based on the same reason, I used comm_str in patch 3. It's not help for the optimization either, but should be useful for future. Anyway, I think I will drop patch 3 & 4 for V3. Thanks, Kan > > if that's the case we don't need the change for __hists__add_entry in > previous patch > > jirka