scripts: get_abi.pl: add a graph to speedup the undefined algorithm
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Sat, 18 Sep 2021 09:52:17 +0000 (11:52 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 21 Sep 2021 16:32:53 +0000 (18:32 +0200)
commitca8e055c22155b262e14409a555bab41a52edfea
treebd9e4a3f8d744e1972256ff1a2d04afdacd10c0a
parent0b87a1b81ba9b9e2d1d2bc65b3b4318bb645a6e7
scripts: get_abi.pl: add a graph to speedup the undefined algorithm

Searching for symlinks is an expensive operation with the current
logic, as it is at the order of O(n^3). In practice, running the
check spends 2-3 minutes to check all symbols.

Fix it by storing the directory tree into a graph, and using
a Breadth First Search (BFS) to find the links for each sysfs node.

With such improvement, it can now report issues with ~11 seconds
on my machine.

It comes with a price, though: there are more symbols reported
as undefined after this change. I suspect it is due to some
sysfs circular loops that are dropped by BFS. Despite such
increase, it seems that the reports are now more coherent.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/f5c1e7b14a27132821c08f0459ba9aea3ed69028.1631957565.git.mchehab+huawei@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
scripts/get_abi.pl