From: Anju T Sudhakar <hidden> Date: 2017-10-04 06:51:05
Nest/core pmu units are enabled only when it is used. A reference count is
maintained for the events which uses the nest/core pmu units. Currently in
*_imc_counters_release function a WARN() is used for notification of any
underflow of ref count.
The case where event ref count hit a negative value is, when perf session is
started, followed by offlining of all cpus in a given core.
i.e. in cpuhotplug offline path ppc_core_imc_cpu_offline() function set the
ref->count to zero, if the current cpu which is about to offline is the last
cpu in a given core and make an OPAL call to disable the engine in that core.
And on perf session termination, perf->destroy (core_imc_counters_release) will
first decrement the ref->count for this core and based on the ref->count value
an opal call is made to disable the core-imc engine.
Now, since cpuhotplug path already clears the ref->count for core and disabled
the engine, perf->destroy() decrementing again at event termination make it
negative which in turn fires the WARN_ON. The same happens for nest units.
Add a check to see if the reference count is alreday zero, before decrementing
the count, so that the ref count will not hit a negative value.
Signed-off-by: Anju T Sudhakar <redacted>
---
arch/powerpc/perf/imc-pmu.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
@@ -399,6 +399,20 @@ static void nest_imc_counters_release(struct perf_event *event)/* Take the mutex lock for this node and then decrement the reference count */mutex_lock(&ref->lock);+if(ref->refc==0){+/*+*Thescenariowherethisistrueis,whenperfsessionis+*started,followedbyoffliningofallcpusinagivennode.+*+*Inthecpuhotplugofflinepath,ppc_nest_imc_cpu_offline()+*functionsettheref->counttozero,ifthecpuwhichis+*abouttoofflineisthelastcpuinagivennodeandmake+*anOPALcalltodisabletheengineinthatnode.+*+*/+mutex_unlock(&ref->lock);+return;+}ref->refc--;if(ref->refc==0){rc=opal_imc_counters_stop(OPAL_IMC_COUNTERS_NEST,
* Anju T Sudhakar [off-list ref] wrote (on 2017-10-04 06:50:52 +0000):
Nest/core pmu units are enabled only when it is used. A reference count is
maintained for the events which uses the nest/core pmu units. Currently in
*_imc_counters_release function a WARN() is used for notification of any
underflow of ref count.
The case where event ref count hit a negative value is, when perf session is
started, followed by offlining of all cpus in a given core.
i.e. in cpuhotplug offline path ppc_core_imc_cpu_offline() function set the
ref->count to zero, if the current cpu which is about to offline is the last
cpu in a given core and make an OPAL call to disable the engine in that core.
And on perf session termination, perf->destroy (core_imc_counters_release) will
first decrement the ref->count for this core and based on the ref->count value
an opal call is made to disable the core-imc engine.
Now, since cpuhotplug path already clears the ref->count for core and disabled
the engine, perf->destroy() decrementing again at event termination make it
negative which in turn fires the WARN_ON. The same happens for nest units.
Add a check to see if the reference count is alreday zero, before decrementing
the count, so that the ref count will not hit a negative value.
Signed-off-by: Anju T Sudhakar <redacted>
@@ -399,6 +399,20 @@ static void nest_imc_counters_release(struct perf_event *event)/* Take the mutex lock for this node and then decrement the reference count */mutex_lock(&ref->lock);+if(ref->refc==0){+/*+*Thescenariowherethisistrueis,whenperfsessionis+*started,followedbyoffliningofallcpusinagivennode.+*+*Inthecpuhotplugofflinepath,ppc_nest_imc_cpu_offline()+*functionsettheref->counttozero,ifthecpuwhichis+*abouttoofflineisthelastcpuinagivennodeandmake+*anOPALcalltodisabletheengineinthatnode.+*+*/+mutex_unlock(&ref->lock);+return;+}ref->refc--;if(ref->refc==0){rc=opal_imc_counters_stop(OPAL_IMC_COUNTERS_NEST,
From: Anju T Sudhakar <hidden> Date: 2017-10-05 09:51:57
Hi Santosh,
On Thursday 05 October 2017 03:20 PM, Santosh Sivaraj wrote:
* Anju T Sudhakar [off-list ref] wrote (on 2017-10-04 06:50:52 +0000):
quoted
Nest/core pmu units are enabled only when it is used. A reference count is
maintained for the events which uses the nest/core pmu units. Currently in
*_imc_counters_release function a WARN() is used for notification of any
underflow of ref count.
The case where event ref count hit a negative value is, when perf session is
started, followed by offlining of all cpus in a given core.
i.e. in cpuhotplug offline path ppc_core_imc_cpu_offline() function set the
ref->count to zero, if the current cpu which is about to offline is the last
cpu in a given core and make an OPAL call to disable the engine in that core.
And on perf session termination, perf->destroy (core_imc_counters_release) will
first decrement the ref->count for this core and based on the ref->count value
an opal call is made to disable the core-imc engine.
Now, since cpuhotplug path already clears the ref->count for core and disabled
the engine, perf->destroy() decrementing again at event termination make it
negative which in turn fires the WARN_ON. The same happens for nest units.
Add a check to see if the reference count is alreday zero, before decrementing
the count, so that the ref count will not hit a negative value.
Signed-off-by: Anju T Sudhakar <redacted>
@@ -399,6 +399,20 @@ static void nest_imc_counters_release(struct perf_event *event)/* Take the mutex lock for this node and then decrement the reference count */mutex_lock(&ref->lock);+if(ref->refc==0){+/*+*Thescenariowherethisistrueis,whenperfsessionis+*started,followedbyoffliningofallcpusinagivennode.+*+*Inthecpuhotplugofflinepath,ppc_nest_imc_cpu_offline()+*functionsettheref->counttozero,ifthecpuwhichis+*abouttoofflineisthelastcpuinagivennodeandmake+*anOPALcalltodisabletheengineinthatnode.+*+*/+mutex_unlock(&ref->lock);+return;+}ref->refc--;if(ref->refc==0){rc=opal_imc_counters_stop(OPAL_IMC_COUNTERS_NEST,
From: Michael Ellerman <hidden> Date: 2017-10-13 12:32:44
On Wed, 2017-10-04 at 06:50:52 UTC, Anju T Sudhakar wrote:
Nest/core pmu units are enabled only when it is used. A reference count is
maintained for the events which uses the nest/core pmu units. Currently in
*_imc_counters_release function a WARN() is used for notification of any
underflow of ref count.
The case where event ref count hit a negative value is, when perf session is
started, followed by offlining of all cpus in a given core.
i.e. in cpuhotplug offline path ppc_core_imc_cpu_offline() function set the
ref->count to zero, if the current cpu which is about to offline is the last
cpu in a given core and make an OPAL call to disable the engine in that core.
And on perf session termination, perf->destroy (core_imc_counters_release) will
first decrement the ref->count for this core and based on the ref->count value
an opal call is made to disable the core-imc engine.
Now, since cpuhotplug path already clears the ref->count for core and disabled
the engine, perf->destroy() decrementing again at event termination make it
negative which in turn fires the WARN_ON. The same happens for nest units.
Add a check to see if the reference count is alreday zero, before decrementing
the count, so that the ref count will not hit a negative value.
Signed-off-by: Anju T Sudhakar <redacted>
Reviewed-by: Santosh Sivaraj <redacted>