• Arnaldo Carvalho de Melo's avatar
    perf cgroup: Fix refcount usage · cd8dd032
    Arnaldo Carvalho de Melo authored
    When converting from atomic_t to refcount_t we didn't follow the usual
    step of initializing it to one before taking any new reference, which
    trips over checking if taking a reference for a freed refcount_t, fix
    it.
    
    Brendan's report:
    
     ---
    It's 4.12-rc7, with node v4.4.1. I'm building 4.13-rc1 now, as I hit
    what I think is another unrelated perf bug and I'm starting to wonder
    what else is broken on that version:
    
    (root) /mnt/src/linux-4.12-rc7/tools/perf # ./perf record -F 99 -a -e
    cpu-clock --cgroup=docker/f9e9d5df065b14646e8a11edc837a13877fd90c171137b2ba3feb67a0201cb65
    -g
    perf: /mnt/src/linux-4.12-rc7/tools/include/linux/refcount.h:108:
    refcount_inc: Assertion `!(!refcount_inc_not_zero(r))' failed.
    Aborted
    
    that used to work...
     ---
    
    Testing it:
    
    Before:
    
      # perf stat -e cycles -C 0 --cgroup /
      perf: /home/acme/git/linux/tools/include/linux/refcount.h:108: refcount_inc: Assertion `!(!refcount_inc_not_zero(r))' failed.
      Aborted (core dumped)
      #
    
    After:
    
      # perf stat -e cycles -C 0 --cgroup /
    ^C
      Performance counter stats for 'CPU(s) 0':
    
           132,081,393      cycles                    /
    
           2.492942763 seconds time elapsed
    
      #
    Reported-by: default avatarBrendan Gregg <brendan.d.gregg@gmail.com>
    Acked-by: default avatarElena Reshetova <elena.reshetova@intel.com>
    Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Cc: David Ahern <dsahern@gmail.com>
    Cc: David Carrillo-Cisneros <davidcc@google.com>
    Cc: Kees Kook <keescook@chromium.org>
    Cc: Krister Johansen <kjlx@templeofstupid.com>
    Cc: Paul Turner <pjt@google.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Stephane Eranian <eranian@google.com>
    Cc: Sudeep Holla <Sudeep.Holla@arm.com>
    Cc: Thomas-Mich Richter <tmricht@linux.vnet.ibm.com>
    Cc: Wang Nan <wangnan0@huawei.com>
    Fixes: 79c5fe6d ("perf cgroup: Convert cgroup_sel.refcnt from atomic_t to refcount_t")
    Link: http://lkml.kernel.org/n/tip-l7ovfblq14ip2i08m1g0fkhv@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    cd8dd032
cgroup.c 3.49 KB