linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: David Laight <David.Laight@aculab.com>
Cc: Namhyung Kim <namhyung@kernel.org>,
	Ian Rogers <irogers@google.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Jiri Olsa <jolsa@kernel.org>,
	"linux-perf-users@vger.kernel.org"
	<linux-perf-users@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/1] perf beauty: Don't use 'find ... -printf' as it isn't available in busybox
Date: Fri, 1 Dec 2023 14:01:57 -0300	[thread overview]
Message-ID: <ZWoRhbyvClv0TffR@kernel.org> (raw)
In-Reply-To: <ecad5dffa8474ed8a5367e917610e707@AcuMS.aculab.com>

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
 



  reply	other threads:[~2023-12-01 17:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-30 21:54 [PATCH 1/1] perf beauty: Don't use 'find ... -printf' as it isn't available in busybox Arnaldo Carvalho de Melo
2023-11-30 22:12 ` Namhyung Kim
2023-12-01 12:05 ` David Laight
2023-12-01 17:01   ` Arnaldo Carvalho de Melo [this message]
2023-12-01 17:16     ` David Laight

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZWoRhbyvClv0TffR@kernel.org \
    --to=acme@kernel.org \
    --cc=David.Laight@aculab.com \
    --cc=adrian.hunter@intel.com \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=namhyung@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).