From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751162AbdFAUC5 (ORCPT ); Thu, 1 Jun 2017 16:02:57 -0400 Received: from mail-pf0-f179.google.com ([209.85.192.179]:36775 "EHLO mail-pf0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751024AbdFAUC4 (ORCPT ); Thu, 1 Jun 2017 16:02:56 -0400 From: David Carrillo-Cisneros To: linux-kernel@vger.kernel.org Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , David Windsor , Tejun Heo , Elena Reshetova , Stephane Eranian , Paul Turner , David Carrillo-Cisneros Subject: [PATCH] perf tool cgroup: initialize cgroup refcnt with refcount_set Date: Thu, 1 Jun 2017 13:02:14 -0700 Message-Id: <20170601200214.23859-1-davidcc@google.com> X-Mailer: git-send-email 2.13.0.219.gdb65acc882-goog Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Atomic reference counters were replaced by refcount_t in commit 79c5fe6db8c7 ("perf/core: Fix error handling in perf_event_alloc()") In util/cgroup.c atomic_inc was replaced by refcount_inc, but the latter is not mean to initiliaze refcounts with zero value. Add a path to initialize cgrp->refcnt == 0 using refcount_set. Before this patch: $ perf stat -e cycles -C 0 -G / perf_before: /usr/local/.../tools/include/linux/refcount.h:108: refcount_inc: Assertion `!(!refcount_inc_not_zero(r))' failed. Aborted (core dumped) After this patch: $ perf stat -e cycles -C 0 -G / Performance counter stats for 'CPU(s) 0': 17,516,664 cycles / Signed-off-by: David Carrillo-Cisneros Change-Id: I8f00f61aaecce876e7df448bd7f850b20db13ef1 --- tools/perf/util/cgroup.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/cgroup.c b/tools/perf/util/cgroup.c index 03347748f3fa..7bbc19b3caf3 100644 --- a/tools/perf/util/cgroup.c +++ b/tools/perf/util/cgroup.c @@ -133,7 +133,10 @@ static int add_cgroup(struct perf_evlist *evlist, char *str) return -1; found: - refcount_inc(&cgrp->refcnt); + if (refcount_read(&cgrp->refcnt) == 0) + refcount_set(&cgrp->refcnt, 1); + else + refcount_inc(&cgrp->refcnt); counter->cgrp = cgrp; return 0; } -- 2.13.0.219.gdb65acc882-goog