Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752545AbdF2KkJ (ORCPT ); Thu, 29 Jun 2017 06:40:09 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:56190 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751703AbdF2KkC (ORCPT ); Thu, 29 Jun 2017 06:40:02 -0400 Date: Thu, 29 Jun 2017 12:39:59 +0200 (CEST) From: Thomas Gleixner To: Madhavan Srinivasan cc: Anju T Sudhakar , mpe@ellerman.id.au, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, ego@linux.vnet.ibm.com, bsingharora@gmail.com, anton@samba.org, sukadev@linux.vnet.ibm.com, mikey@neuling.org, stewart@linux.vnet.ibm.com, dja@axtens.net, eranian@google.com, hemant@linux.vnet.ibm.com Subject: Re: [PATCH v11 07/10] powerpc/perf: PMU functions for Core IMC and hotplugging In-Reply-To: <766e7d43-0ca9-1e34-2cbe-73d1cbb2ee14@linux.vnet.ibm.com> Message-ID: References: <1498676291-24002-1-git-send-email-anju@linux.vnet.ibm.com> <1498676291-24002-2-git-send-email-anju@linux.vnet.ibm.com> <766e7d43-0ca9-1e34-2cbe-73d1cbb2ee14@linux.vnet.ibm.com> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1097 Lines: 42 On Thu, 29 Jun 2017, Madhavan Srinivasan wrote: > On Thursday 29 June 2017 01:11 AM, Thomas Gleixner wrote: > Idea is to handle multiple event session for a given core and > yes, my bad, current implementation is racy/broken. > But an alternate approach is to have a per-core mutex and > per-core ref count to handle this. > > event_init path: > per-core mutex lock > if ( per-core[refcount] == 0) { > rc = opal call to start the engine; > if (rc on failure) { > per-core mutex unlock; > log error info; > return error; > } > } > increment the per-core[refcount]; > per-core mutex unlock; > > > event_destroy path: > per-core mutex lock > decrement the per-core[refcount]; > if ( per-core[refcount] == 0) { > rc = opal call to stop the engine; > if (rc on failure) { > per-core mutex unlock; > log the failure; > return error; > } > } else if ( per-core[refcount] < 0) { > WARN() > per-core[refcount] = 0; > } > per-core mutext unlock; Yes, that works and looks about right. Thanks, tglx