Re: [PATCH v5 1/7] perf dsos: Switch backing storage to array from rbtree/list

From: Arnaldo Carvalho de Melo
Date: Sat May 04 2024 - 14:28:46 EST


On Sat, May 04, 2024 at 11:14:52AM -0700, Ian Rogers wrote:
> On Fri, May 3, 2024 at 1:21 PM Arnaldo Carvalho de Melo <acme@xxxxxxxxxx> wrote:
> > On Mon, Apr 29, 2024 at 11:46:08AM -0700, Ian Rogers wrote:
> > > DSOs were held on a list for fast iteration and in an rbtree for fast
> > > finds. Switch to using a lazily sorted array where iteration is just
> > > iterating through the array and binary searches are the same
> > > complexity as searching the rbtree. The find may need to sort the
> > > array first which does increase the complexity, but add operations
> > > have lower complexity and overall the complexity should remain about
> > > the same.

> > With just this first one applied:

> > ⬢[acme@toolbox perf-tools-next]$ git log --oneline -10
> > 325557715f1d8593 (HEAD) perf dsos: Switch backing storage to array from rbtree/list
> > 7b6dd7a923281a7c perf pmu: Assume sysfs events are always the same case
> > 6debc5aa326fa2ee perf test pmu: Test all sysfs PMU event names are the same case
> > 18eb2ca8c18f0612 perf test pmu: Add an eagerly loaded event test
> > aa1551f299ba414c perf test pmu: Refactor format test and exposed test APIs
> > 785623ee855e893d perf Document: Sysfs event names must be lower or upper case
> > 97c48ea8ff1cd70f perf test pmu-events: Make it clearer that pmu-events tests JSON events
> > 3cdd98b42d212160 (x1/perf-tools-next) perf maps: Remove check_invariants() from maps__lock()
> > e3123079b906dc2e perf cs-etm: Improve version detection and error reporting
> > bc5e0e1b93565e37 perf cs-etm: Remove repeated fetches of the ETM PMU
> > ⬢[acme@toolbox perf-tools-next]$

> > root@number:~# perf -v
> > perf version 6.9.rc5.g325557715f1d
> > root@number:~# perf probe -l
> > DSO [kernel.kallsyms] is still in rbtree when being deleted!
> > DSO /lib/modules/6.8.7-200.fc39.x86_64/kernel/drivers/hid/hid-sensor-hub.ko.xz is still in rbtree when being deleted!
> > DSO /lib/modules/6.8.7-200.fc39.x86_64/kernel/drivers/hid/uhid.ko.xz is still in rbtree when being deleted!
> > DSO /lib/modules/6.8.7-200.fc39.x86_64/kernel/drivers/net/tun.ko.xz is still in rbtree when being deleted!
> > DSO /lib/modules/6.8.7-200.fc39.x86_64/kernel/fs/overlayfs/overlay.ko.xz is still in rbtree when being deleted!
> > DSO /lib/modules/6.8.7-200.fc39.x86_64/kernel/net/bluetooth/rfcomm/rfcomm.ko.xz is still in rbtree when being deleted!
> > DSO /lib/modules/6.8.7-200.fc39.x86_64/kernel/drivers/input/misc/uinput.ko.xz is still in rbtree when being deleted!
> > DSO /lib/modules/6.8.7-200.fc39.x86_64/kernel/sound/core/seq/snd-seq-dummy.ko.xz is still in rbtree when being deleted!
> > <SNIP a lot of other modules, probably all of them>

> Right, we don't have a test on this and this motivates the addition of
> reference count checking on DSO in the later patches. With the series
> applied, fixing the rebase issue, I see:

> $ git log --oneline
> eabe5dd91331 (HEAD) perf dso: Use container_of to avoid a pointer in dso_data
> fd47ec98a05c perf dso: Reference counting related fixes
> 962af2d2b092 perf dso: Add reference count checking and accessor functions
> 48664a9a6ca4 perf dsos: Switch hand code to bsearch
> ae7a9854dabd perf dsos: Remove __dsos__findnew_link_by_longname_id
> e616a6b3739d perf dsos: Remove __dsos__addnew
> e789368716dd perf dsos: Switch backing storage to array from rbtree/list
> 7b6dd7a92328 (ptn/tmp.perf-tools-next, ptn/perf-tools-next) perf pmu:
> Assume sysfs events are always the same case
> ...
> $ sudo /tmp/perf/perf -v
> perf version 6.9.rc5.geabe5dd91331
> $ sudo /tmp/perf/perf probe -l
> $

> I'll see if I can find a fix to backport before sending a new series
> to work around the 2 line rebase conflict.

Thanks a lot for doing that!

- Arnaldo