Message ID | ZWkEeqdmCHMLhLr2@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp707767vqy; Thu, 30 Nov 2023 13:54:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IGcE5HR0AQaTJHtI0cRnu4Hv68IonaJDc8p5LscmxXnB0qIxYO0RC1B7TBdFKTCbEg6Cvkr X-Received: by 2002:a17:90b:4b86:b0:286:3074:c632 with SMTP id lr6-20020a17090b4b8600b002863074c632mr4589006pjb.22.1701381256223; Thu, 30 Nov 2023 13:54:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701381256; cv=none; d=google.com; s=arc-20160816; b=Kk1M5OZ8M/xPWsqjAROTU+4TuHbmwpuaQqdvfrFmZY1DvOzbLBeYctXheayP9uiT7H cLcVQlnP6qrO3YTB6Qx1S1lEO1bnY1WOrzH4jj7LnMVQ2WM0JHTBFQXqavo//SihsX/6 TlTFbQEzzqWBuIcALV8mf3muda4RZDQXCTPpiKtLp5aYlBSiTvlX4l17135Ffni6bXOX Gxr9hoLTKUab6LK69iCbA0as+wVp6cNkE2sktCfkt5ChJmY1bUI19e+8H8PYP0fU5sS2 ENpZJHziGaR0wJ6ljykGBuE+H3qPfFkqS3K6i7Gy5AWCWndJj8muQ2NLOExNsR7K9/nt XQkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=ZM2u/8rmCHS4olM4qKkg8ZXrmWiQjjOQqKAdy2iYOo4=; fh=ik2mhaIslLDHn1mohImbQkNIva2tX1kMC7mQihJPCHA=; b=l6nbg4CHRkMkr+MeZBgmCmoIOuKdWZZO0u3tbTgqowefvPs6wXNVcQ6JkNXrbL3sbw jI7q8DWgXI/brbU+LcabvocEAHdhdEGGR9FTukn+IESc32MaMBpDYvh+gsVdrg7R3rQe NNcLlsNgxsHDEo5QwrfHM4kdJj/Au37IySbViimqKA6LyzleFyrZI1yDgTrfgi01k6K1 VJzPsHoigoFQxNk9JH4kWcbDwgfBOhykT3iE+DTQWdk5LrePGSQG8tgpOkpZwdt1njB4 WXKsXqvppFTQk4ky2lvwaIquDbbpbM4VWIr9DbDU7bHvOGkEHEDYGsKT6izIH6JqeWoW lx/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=L3WmLLwK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id pb16-20020a17090b3c1000b002800b13adb7si2265353pjb.72.2023.11.30.13.54.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 13:54:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=L3WmLLwK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id 5224182DF4B4; Thu, 30 Nov 2023 13:54:13 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377051AbjK3VyB (ORCPT <rfc822;ruipengqi7@gmail.com> + 99 others); Thu, 30 Nov 2023 16:54:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377044AbjK3VyA (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 30 Nov 2023 16:54:00 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3ECE910DE for <linux-kernel@vger.kernel.org>; Thu, 30 Nov 2023 13:54:06 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3B9BC433C7; Thu, 30 Nov 2023 21:54:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701381245; bh=F2LL2tyOMkM/IejxRX2kitlYZIvwjcdRDFnefjDcVMo=; h=Date:From:To:Cc:Subject:From; b=L3WmLLwKh6NeT6J3aFK04LeUyBmhvgtceb3N2UdBsAEFPqpkZOB3zyvWbbw+Hq4Dc Rli7HkGd9iISYnWSlPmGAX/r/ehPthTjh5wnA5j+cCqVhqusdbfZwh+olX93f86CcF 5PkcEYEUKjHoFDRP4roToQ7yNujOT5CKQfu1TaIh0YzjqonF8s2RNdOFEVNWS1KTEf 9v/YABzrUPxHCJqioVWp+6b0MeCqNTKv9bgAGY8w/O+y2dLO3XzYOLUNowwo3v0qTw Bf631bglYGUt7OF2TAsMIHeJzu7Ho2Ug+d+Ykud+wUw675mpTPoiRGcGho9S++mzBA qqmBHRAf7rnDQ== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id CF8D940094; Thu, 30 Nov 2023 18:54:02 -0300 (-03) Date: Thu, 30 Nov 2023 18:54:02 -0300 From: Arnaldo Carvalho de Melo <acme@kernel.org> To: Namhyung Kim <namhyung@kernel.org> Cc: Ian Rogers <irogers@google.com>, Adrian Hunter <adrian.hunter@intel.com>, Jiri Olsa <jolsa@kernel.org>, linux-perf-users@vger.kernel.org, Linux Kernel Mailing List <linux-kernel@vger.kernel.org> Subject: [PATCH 1/1] perf beauty: Don't use 'find ... -printf' as it isn't available in busybox Message-ID: <ZWkEeqdmCHMLhLr2@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Thu, 30 Nov 2023 13:54:13 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784027552528052697 X-GMAIL-MSGID: 1784027552528052697 |
Series |
[1/1] perf beauty: Don't use 'find ... -printf' as it isn't available in busybox
|
|
Commit Message
Arnaldo Carvalho de Melo
Nov. 30, 2023, 9:54 p.m. UTC
Namhyung reported:
I'm seeing a build error on my Alpine linux image which uses busybox +
musl libc:
In file included from trace/beauty/arch_errno_names.c:1,
from builtin-trace.c:899:
/build/trace/beauty/generated/arch_errno_name_array.c: In function 'arch_syscalls__strerrno':
/build/trace/beauty/generated/arch_errno_name_array.c:142:49: error: unused parameter 'arch' [-Werror=unused-parameter]
142 | const char *arch_syscalls__strerrno(const char *arch, int err)
It looks like busybox find command doesn't have -printf option
find: unrecognized: -printf
, Yesterday 9:16 PM
,
BusyBox v1.36.1 (2023-07-27 17:12:24 UTC) multi-call binary.
Usage: find [-HL] [PATH]... [OPTIONS] [ACTIONS]
Search for files and perform actions on them.
First failed action stops processing of current file.
Defaults: PATH is current directory, action is '-print'
So just remove it and pipe find's entry to a basename loop to produce
the same result.
Fixes: 0337cf74ccf2a434 ("perf util: Introduce architecture specific errno/name mapping")
Reported-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Thomas Richter <tmricht@linux.vnet.ibm.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/trace/beauty/arch_errno_names.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
Hi Arnaldo, On Thu, Nov 30, 2023 at 1:54 PM Arnaldo Carvalho de Melo <acme@kernel.org> wrote: > > Namhyung reported: > > I'm seeing a build error on my Alpine linux image which uses busybox + > musl libc: > > In file included from trace/beauty/arch_errno_names.c:1, > from builtin-trace.c:899: > /build/trace/beauty/generated/arch_errno_name_array.c: In function 'arch_syscalls__strerrno': > /build/trace/beauty/generated/arch_errno_name_array.c:142:49: error: unused parameter 'arch' [-Werror=unused-parameter] > 142 | const char *arch_syscalls__strerrno(const char *arch, int err) > > It looks like busybox find command doesn't have -printf option > > find: unrecognized: -printf > , Yesterday 9:16 PM > , > BusyBox v1.36.1 (2023-07-27 17:12:24 UTC) multi-call binary. > > Usage: find [-HL] [PATH]... [OPTIONS] [ACTIONS] > > Search for files and perform actions on them. > First failed action stops processing of current file. > Defaults: PATH is current directory, action is '-print' > > So just remove it and pipe find's entry to a basename loop to produce > the same result. > > Fixes: 0337cf74ccf2a434 ("perf util: Introduce architecture specific errno/name mapping") > Reported-by: Namhyung Kim <namhyung@kernel.org> > Cc: Adrian Hunter <adrian.hunter@intel.com> > Cc: Hendrik Brueckner <brueckner@linux.vnet.ibm.com> > Cc: Ian Rogers <irogers@google.com> > Cc: Jiri Olsa <jolsa@kernel.org> > Cc: Michael Petlan <mpetlan@redhat.com> > Cc: Thomas Richter <tmricht@linux.vnet.ibm.com> > Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Thanks for the fix! Tested-by: Namhyung Kim <namhyung@kernel.org> Thanks, Namhyung > --- > tools/perf/trace/beauty/arch_errno_names.sh | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tools/perf/trace/beauty/arch_errno_names.sh b/tools/perf/trace/beauty/arch_errno_names.sh > index cc09dcaa891e04bb..3ec8781344db13ba 100755 > --- a/tools/perf/trace/beauty/arch_errno_names.sh > +++ b/tools/perf/trace/beauty/arch_errno_names.sh > @@ -76,7 +76,7 @@ EoHEADER > > # 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 > > -- > 2.41.0 >
... > # 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. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
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
From: Arnaldo Carvalho de Melo > Sent: 01 December 2023 17:02 > > 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: I reversed the order by adding the names at the front of $archlist - so the order would still be reverse sorted (the shell sorts filename globs). The '[ -f $f ] || break' line is only there in case there are no matching files. If that can happen putting [ "$archlist" = "* " ] && archlist= after the loop would be slightly better. But with only 6 item the extra stat() will be noise. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
diff --git a/tools/perf/trace/beauty/arch_errno_names.sh b/tools/perf/trace/beauty/arch_errno_names.sh index cc09dcaa891e04bb..3ec8781344db13ba 100755 --- a/tools/perf/trace/beauty/arch_errno_names.sh +++ b/tools/perf/trace/beauty/arch_errno_names.sh @@ -76,7 +76,7 @@ EoHEADER # 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