Message ID | 20240122-dt-kselftest-dirname-perf-fix-v2-1-f1630532fd38@collabora.com |
---|---|
State | Accepted |
Commit | 6154fb9c2134f8d9534b2de10491aa3a22f3c9ff |
Headers | show |
Series | [v2] kselftest: dt: Stop relying on dirname to improve performance | expand |
On Mon, Jan 22, 2024 at 09:40:43AM -0600, Rob Herring wrote: > On Mon, Jan 22, 2024 at 11:29:18AM -0300, Nícolas F. R. A. Prado wrote: > > When walking directory trees, instead of looking for specific files and > > running dirname to get the parent folder, traverse all folders and > > ignore the ones not containing the desired files. This avoids the need > Applied, thanks. Is there any prospect of getting this merged as a fix? It's causing a massive number of false positives in my CI when run on slower boards with larger numbers of devices.
diff --git a/tools/testing/selftests/dt/test_unprobed_devices.sh b/tools/testing/selftests/dt/test_unprobed_devices.sh index b07af2a4c4de..7fae90293a9d 100755 --- a/tools/testing/selftests/dt/test_unprobed_devices.sh +++ b/tools/testing/selftests/dt/test_unprobed_devices.sh @@ -33,8 +33,8 @@ if [[ ! -d "${PDT}" ]]; then fi nodes_compatible=$( - for node_compat in $(find ${PDT} -name compatible); do - node=$(dirname "${node_compat}") + for node in $(find ${PDT} -type d); do + [ ! -f "${node}"/compatible ] && continue # Check if node is available if [[ -e "${node}"/status ]]; then status=$(tr -d '\000' < "${node}"/status) @@ -46,10 +46,11 @@ nodes_compatible=$( nodes_dev_bound=$( IFS=$'\n' - for uevent in $(find /sys/devices -name uevent); do - if [[ -d "$(dirname "${uevent}")"/driver ]]; then - grep '^OF_FULLNAME=' "${uevent}" | sed -e 's|OF_FULLNAME=||' - fi + for dev_dir in $(find /sys/devices -type d); do + [ ! -f "${dev_dir}"/uevent ] && continue + [ ! -d "${dev_dir}"/driver ] && continue + + grep '^OF_FULLNAME=' "${dev_dir}"/uevent | sed -e 's|OF_FULLNAME=||' done )