Re: [RFC PATCH v1 12/15] perf evlist: Add reference count

From: Arnaldo Carvalho de Melo

Date: Wed Oct 29 2025 - 12:25:17 EST


On Wed, Oct 29, 2025 at 01:22:21PM -0300, Arnaldo Carvalho de Melo wrote:
> On Tue, Oct 28, 2025 at 10:34:10PM -0700, Ian Rogers wrote:
> > This a no-op for most of the perf tool. The reference count is set to
> > 1 at allocation, the put will see the 1, decrement it and perform the
> > delete. The purpose for adding the reference count is for the python
> > code. Prior to this change the python code would clone evlists, but
> > this has issues if events are opened, etc. This change adds a
> > reference count for the evlists and a later change will add it to
> > evsels. The combination is needed for the python code to operate
> > correctly (not hit asserts in the evsel clone), but the changes are
> > broken apart for the sake of smaller patches.

> Looks ok, noisy for all the s/delete/put/ but that is ok, but then you
> are not using the RC_CHK_ACCESS stuff from the get go, why not?

> All the prep patches looks ok, assuming they build in succession.

Also I tried to run the test case before the patches on a 9950x3d, AMD,
with ibs and couldn't, some perf.data format error, then on Intel I had
to hit control+c and got a deprecation warning, both, of course
completely unrelated to your work, so just FYI:

root@five:~# perf mem record -a sleep 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 2.247 MB perf.data (12814 samples) ]
root@five:~# time perf script mem-phys-addr
/home/acme/libexec/perf-core/scripts/python/mem-phys-addr.py:49: DeprecationWarning: 'maxsplit' is passed as positional argument
m = re.split('-|:', line, 2)
^CWarning:
929 out of order events recorded.
Event: cpu_core/mem_inst_retired.all_loads/P
Memory type count percentage
---------------------------------------- ---------- ----------
100000000-8bfbfffff : System RAM 149050 87.4
2ac600000-2ad75cfff : Kernel rodata 1567 0.9
2ad800000-2adc6a47f : Kernel data 517 0.3
2ae7e8000-2aedfffff : Kernel bss 282 0.2
2ab000000-2ac54d27e : Kernel code 21 0.0
0-fff : Reserved 18990 11.1
100000-30093fff : System RAM 2566 1.5

real 11m46.282s
user 0m1.317s
sys 0m0.344s
root@five:~# grep -m1 'model name' /proc/cpuinfo
model name : Intel(R) Core(TM) i7-14700K
root@five:~# cat /etc/redhat-release
Fedora release 42 (Adams)
root@five:~# uname -a
Linux five 6.16.9-200.fc42.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Sep 25 18:05:50 UTC 2025 x86_64 GNU/Linux
root@five:~#

- Arnaldo