Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp2343773rdb; Fri, 8 Dec 2023 05:41:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IEOR9ZPkSpDWRX0fSq6I1QGSGZRmjLBE0/B6T3GUeBbWkLN9kpYRcMWGPAOcTfvPk8VkYlO X-Received: by 2002:a17:903:482:b0:1d0:8686:b68b with SMTP id jj2-20020a170903048200b001d08686b68bmr51674plb.26.1702042889238; Fri, 08 Dec 2023 05:41:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702042889; cv=none; d=google.com; s=arc-20160816; b=j5natoGQ3z8hMGARq6ppLBq9zZ6MbrTVrNw8mc22+uKIuYC8t2c896V/AyL03v7u1X lm1uKUjOYs0XU9jh16yyp9tk7na1IzZqdPZ8DFeZslp0PVRNKZSpn/+Lyr1VYw84i+cR fkueHGX/g+FPEr/Sdhm0dBroxZAJ0BRAdgsvBUtJlr6AuGoPzOfWnrRQWgJ07dkvfxyw hPgB7ocoa5SAYq2KCH9sglCzg2GRhyjfSlMEGNnMkB3RyAAtIrYNrvbqhfamov3vjNIg N+1nAvXJm1vulBaEWCmfpwpFII0LVAg5i52Tyht3XF0Reb4XPCm0Dcg+QDkhsiPKOmvo b18g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=SXZNYSUEyiAFyppGLNPpSvYerD98c7vbeYuRRz+x8H0=; fh=TZicdjC5Y7jQrL5JafeePj08TCl8W2+jPedtq1uaCYo=; b=KpnL5XWZNW4XmNuCenD+gc+l7JiGnhwTo1XIJri11gZSUIieC9+brlqt6wEDTgSQNu DBvJePkVwQFKySKpK/+PaWcxvLZRxvIgR/W3CfgHrsH/eCKSXWvLczBb8+Ntp8V7Q23n J37B7vi2LOXKYvLEZmQriu41UA86iYAiv1doES3oAQ1q2kaeB3sTlEaFhAJat2YMIlBg X0t+YCg51ly4wAOGk446wYky4E9CqErXkiKUwpLXbIlkXxpB6U77YyKI5F23ILrJneBO VY+UyIOiwlBM7OpJKKRaFD+kbAE07aoZX619KAzVtNiznk/NwRtTepbiqXxpVQlYoYNK vZBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=hwp9A3Wr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id t6-20020a170902e84600b001d0a0a9a997si1635375plg.25.2023.12.08.05.41.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 05:41:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=hwp9A3Wr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 4076D8087252; Fri, 8 Dec 2023 05:40:11 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233545AbjLHNkB (ORCPT + 99 others); Fri, 8 Dec 2023 08:40:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229844AbjLHNkA (ORCPT ); Fri, 8 Dec 2023 08:40:00 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48B021706; Fri, 8 Dec 2023 05:40:06 -0800 (PST) Received: from localhost.localdomain (zone.collabora.co.uk [167.235.23.81]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: nfraprado) by madras.collabora.co.uk (Postfix) with ESMTPSA id 0B32A66073AA; Fri, 8 Dec 2023 13:40:01 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1702042805; bh=XyWarEWJXpA/T9XhTV+onEShyeWe+9A2yodWAKUFUJI=; h=From:To:Cc:Subject:Date:From; b=hwp9A3WrBnaVFqsUWe+3crnvYWmhKfcMaI94XY4ocrQvK2T0rc8PLVSHNO2jl6QRk OBiYSCn1CFviR5Nie9vd4o1l1dL8pYZJuPm+qGCAiTVEZT4eRGme+t17/y5YOHq+9l GLgYDgqP8UgabULhins15CaD/wIgQTRPG5gIN3tP3MMjGjsG22Znbo5IaiNfn0jwQK eDj0q8BpRMNsaYhpaEBjQdF/NlR9c4zEXzqfrr5vpd+XlHRrjVPDZbJhtYRoMG19SO YPvJlFcz3bBSD8LhFtMiCZ0+k5JAXaNsmC4D3ghKEWpmbkkRaFoHEzV/6gq+R19xYM Si0G8GPrtgBkg== From: =?UTF-8?q?N=C3=ADcolas=20F=2E=20R=2E=20A=2E=20Prado?= To: Rob Herring , Shuah Khan Cc: Mark Brown , kernel@collabora.com, =?UTF-8?q?N=C3=ADcolas=20F=2E=20R=2E=20A=2E=20Prado?= , Frank Rowand , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH] kselftest: dt: Stop relying on dirname to improve performance Date: Fri, 8 Dec 2023 10:39:27 -0300 Message-ID: <20231208133955.483851-1-nfraprado@collabora.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 08 Dec 2023 05:40:11 -0800 (PST) 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 to call dirname inside the loop, which gives a big performance boost, approximately halving run time: Running locally on a mt8192-asurada-spherion, which reports 160 test cases, has gone from 5.5s to 2.9s, while running remotely with an nfsroot has gone from 13.5s to 5.5s. This change has a side-effect, which is that the root DT node now also shows in the output, even though it isn't expected to bind to a driver. However there shouldn't be a matching driver for the board compatible, so the end result will be just an extra skipped test: ok 1 / # SKIP Reported-by: Mark Brown Closes: https://lore.kernel.org/all/310391e8-fdf2-4c2f-a680-7744eb685177@sirena.org.uk Fixes: 14571ab1ad21 ("kselftest: Add new test for detecting unprobed Devicetree devices") Signed-off-by: NĂ­colas F. R. A. Prado --- tools/testing/selftests/dt/test_unprobed_devices.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) 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 ) -- 2.43.0