Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp1183735rdb; Fri, 1 Dec 2023 09:02:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IHHjPu/viaV0MrFdcyka85McD70dkAGV9CMNsIc1ADp8tqeIC16A6/cpNPCutZxH1wnJk5V X-Received: by 2002:a17:902:e84d:b0:1cf:c37f:7161 with SMTP id t13-20020a170902e84d00b001cfc37f7161mr23027227plg.61.1701450156597; Fri, 01 Dec 2023 09:02:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701450156; cv=none; d=google.com; s=arc-20160816; b=kjCscg350fTbnKCrg6ikkkmrpp2W6As9vRRNA1wHQqS0AKS3h7nVRA5c5T0j+3l4GF XvreWLM4ypumF5yQ/Mfv8WK0X8xMcPn2DYBMwD6iiDlmcxrsRgFOwUKu7LolQJrZQmRY RM35DVRLZ24dh4/XbJrXbdCT8HN7+9ry8KnK6GZrnUeMWGSgS1nJ8E6nh5r+HEh3xJhl 8qrk2LmolC1l+Tu19l8NAOO17I45e0s1zral3PJOACnFv8MXDNreHsigwkkMtuZD3ACU yCKh9EAROHcBG+uZNtY0FRn+ZS05b29Ng2DedEAHm+qJu3X9lop7wwsc5Hr81SPyPBPS Mzxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=NpA84vksmxuARJ4l0SU4BXOleb5NWuPZuLKMhpImIO8=; fh=gX/nx9f9MEdNBAh0sibvkzRKLp1k3vYGwhrDo0m4SQc=; b=yfOmTZv73h6Lar+lNIuZvnlPugGjZc43cpQ0LZxTaRxhn7BjncdilFJEyjqCGAObeO I1Uy6zoV/7r078ySPa39FLt+DTlbUKMz7p5DTVe6Ha0mGC/uruxJflZwLnRwG7g0n/B7 LPNiDbFc48ttugceG9E5QVq2DeideCqHkb90frVgSlL5iyiMDkHRoNnM2amQChMk+F8B gfmwt9jx/atjlN5GdE/nkh8JMvGeQ1TJ5z+J0gOlngsK9xwQ7LvnzM12RaJYz0zPBfE0 f+0ivz4pzzw0+9nGStb+u4gXS9a87qK0aoFSpouXCwGk66U3kp5cm0SPlGiqmQncKUvx 5B8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Qk7/+Mmh"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id y20-20020a1709027c9400b001cff3536eb6si3322880pll.463.2023.12.01.09.02.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 09:02:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Qk7/+Mmh"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 396A280DEA7F; Fri, 1 Dec 2023 09:02:08 -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 S1378635AbjLARB4 (ORCPT + 99 others); Fri, 1 Dec 2023 12:01:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229504AbjLARBz (ORCPT ); Fri, 1 Dec 2023 12:01:55 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30FF9106 for ; Fri, 1 Dec 2023 09:02:01 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 94609C433C8; Fri, 1 Dec 2023 17:02:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701450120; bh=y7kiPIdMJ/eHRHRKfNv778aTflt1jqgDvDpBOIx25i8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Qk7/+MmhgtRaOSV3nMg2hBe9LMIviJrooLIwyhArHVbQegd6wgxG7ggpgUri5+FF9 SIs8mNRQqX1iDqAWeRcRoQXWYA6nCSDkQUtvllR7KSQrW3tJQxyJ+t+DT0RmPu2UVl PenZWXCm30cBL4KiL8L2KHCrEnrVFjLvPx7HaaQJLklVmuhRkEftssFwPzIYS2aKn8 cm8AHoOou/Z8Ol8u/e/Cb9cQ0HSbjT94qaR5WcweEtHlRA8suG3K79jT21HcJfIhBO nZuNVlEpPS2lenVtkdIj9sgCnltzmtV7m01UMKotFlWjb/JW7ALin/eLabr6eaxUEK 0Aa6we3I13Kyw== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id CAD9340094; Fri, 1 Dec 2023 14:01:57 -0300 (-03) Date: Fri, 1 Dec 2023 14:01:57 -0300 From: Arnaldo Carvalho de Melo To: David Laight Cc: Namhyung Kim , Ian Rogers , Adrian Hunter , Jiri Olsa , "linux-perf-users@vger.kernel.org" , Linux Kernel Mailing List Subject: Re: [PATCH 1/1] perf beauty: Don't use 'find ... -printf' as it isn't available in busybox Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Url: http://acmel.wordpress.com X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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, 01 Dec 2023 09:02:08 -0800 (PST) Em Fri, Dec 01, 2023 at 12:05:31PM +0000, David Laight escreveu: > ... > > # Create list of architectures that have a specific errno.h. > > archlist="" > > -for arch in $(find $toolsdir/arch -maxdepth 1 -mindepth 1 -type d -printf "%f\n" | sort -r); do > > +for arch in $(find $toolsdir/arch -maxdepth 1 -mindepth 1 -type d | while read arch ; do basename > > $arch ; done | sort -r); do > > test -f $toolsdir/arch/$arch/include/uapi/asm/errno.h && archlist="$archlist $arch" > > done > > Jeepers ... > Does this work? > for f in $toolsdir/arch/*/include/uapi/asm/errno.h; do > [ ! -f $f ] && break > d=${f%/include/uapi/asm/errno.h} > archlist="${d##*/} $archlist" > done > No fork()s or exec()s. > I think it only differs in having a trailing space instead of a leading one. ⬢[acme@toolbox perf-tools-next]$ for f in tools/arch/*/include/uapi/asm/errno.h; do d=${f%/include/uapi/asm/errno.h} ; arch="${d##*/}" ; echo "'$arch'" ; done 'alpha' 'mips' 'parisc' 'powerpc' 'sparc' 'x86' ⬢[acme@toolbox perf-tools-next]$ for arch in $(find tools/arch -maxdepth 1 -mindepth 1 -type d | while read arch ; do basename $arch ; done | sort -r) ; do test -f tools/arch/$arch/include/uapi/asm/errno.h && echo "'$arch'" ; done 'x86' 'sparc' 'powerpc' 'parisc' 'mips' 'alpha' ⬢[acme@toolbox perf-tools-next]$ There was a reason for having x86 first, lemme dig it... Just to have as the first strcmp in: const char *arch_syscalls__strerrno(const char *arch, int err) { if (!strcmp(arch, "x86")) return errno_to_name__x86(err); if (!strcmp(arch, "sparc")) return errno_to_name__sparc(err); if (!strcmp(arch, "powerpc")) return errno_to_name__powerpc(err); if (!strcmp(arch, "parisc")) return errno_to_name__parisc(err); if (!strcmp(arch, "mips")) return errno_to_name__mips(err); if (!strcmp(arch, "alpha")) return errno_to_name__alpha(err); return errno_to_name__generic(err); } But that is a weak reason, we better make users resolve the right errno_to_name__$arch() pointer just once and use it without that strcmp. Will do it in a follow up patch. Thanks, the resulting diff is below, but I'll first do changes that will remove the need for arch_syscalls__strerrno. diff --git a/tools/perf/trace/beauty/arch_errno_names.sh b/tools/perf/trace/beauty/arch_errno_names.sh index 3ec8781344db13ba..b6e0767b4b34e46a 100755 --- a/tools/perf/trace/beauty/arch_errno_names.sh +++ b/tools/perf/trace/beauty/arch_errno_names.sh @@ -76,7 +76,9 @@ EoHEADER # Create list of architectures that have a specific errno.h. archlist="" -for arch in $(find $toolsdir/arch -maxdepth 1 -mindepth 1 -type d | while read arch ; do basename $arch ; done | sort -r); do +for f in $toolsdir/arch/*/include/uapi/asm/errno.h; do + d=${f%/include/uapi/asm/errno.h} + arch="${d##*/}" test -f $toolsdir/arch/$arch/include/uapi/asm/errno.h && archlist="$archlist $arch" done