From: Junio C Hamano <gitster@pobox.com>
To: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Cc: git@vger.kernel.org, Eric Sunshine <sunshine@sunshineco.com>,
Sam James <sam@gentoo.org>,
Andreas Larsson <andreas@gaisler.com>
Subject: Re: [PATCH] chainlint.pl: Extend regexp pattern for /proc/cpuinfo on Linux SPARC
Date: Mon, 20 May 2024 09:16:47 -0700 [thread overview]
Message-ID: <xmqqseyclaq8.fsf@gitster.g> (raw)
In-Reply-To: <20240520111109.99882-1-glaubitz@physik.fu-berlin.de> (John Paul Adrian Glaubitz's message of "Mon, 20 May 2024 13:11:09 +0200")
John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de> writes:
> On SPARC systems running Linux, individual processors are denoted with
> "CPUnn:" in /proc/cpuinfo instead of the usual "processor NN:" so that
> the current regexp in ncores() returns 0. Extend the regexp to match
> lines with "CPUnn:" as well to properly detect the number of available
> cores on these systems.
>
> Signed-off-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
> ---
> t/chainlint.pl | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/t/chainlint.pl b/t/chainlint.pl
> index 556ee91a15..63cac942ac 100755
> --- a/t/chainlint.pl
> +++ b/t/chainlint.pl
> @@ -718,7 +718,7 @@ sub ncores {
> # Windows
> return $ENV{NUMBER_OF_PROCESSORS} if exists($ENV{NUMBER_OF_PROCESSORS});
> # Linux / MSYS2 / Cygwin / WSL
> - do { local @ARGV='/proc/cpuinfo'; return scalar(grep(/^processor[\s\d]*:/, <>)); } if -r '/proc/cpuinfo';
> + do { local @ARGV='/proc/cpuinfo'; return scalar(grep(/^processor[\s\d]*:||^CPU[\d]*:/, <>)); } if -r '/proc/cpuinfo';
Is the doubled || intended? Doesn't it introduce an empty pattern
that slurps every single line of /proc/cpuinfo?
I was wondering if we want to first add the "reasonable fallback"
Eric mentioned ealier, and then build on top, whose result may look
like the attached. You can enable the STDERR thing with your double
"||" added back and see what "cd t && perl chainlint.pl" produces.
Thanks.
diff --git i/t/chainlint.pl w/t/chainlint.pl
index 556ee91a15..775f06281b 100755
--- i/t/chainlint.pl
+++ w/t/chainlint.pl
@@ -718,7 +718,13 @@ sub ncores {
# Windows
return $ENV{NUMBER_OF_PROCESSORS} if exists($ENV{NUMBER_OF_PROCESSORS});
# Linux / MSYS2 / Cygwin / WSL
- do { local @ARGV='/proc/cpuinfo'; return scalar(grep(/^processor[\s\d]*:/, <>)); } if -r '/proc/cpuinfo';
+ do {
+ local @ARGV='/proc/cpuinfo';
+ my @num = grep(/^processor[\s\d]*:|^CPU[\d]*:/, <>);
+# print STDERR "FOUND <@num>\n";
+ return 1 if (!@num);
+ return scalar(@num);
+ } if -r '/proc/cpuinfo';
# macOS & BSD
return qx/sysctl -n hw.ncpu/ if $^O =~ /(?:^darwin$|bsd)/;
return 1;
next prev parent reply other threads:[~2024-05-20 16:16 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-20 11:11 [PATCH] chainlint.pl: Extend regexp pattern for /proc/cpuinfo on Linux SPARC John Paul Adrian Glaubitz
2024-05-20 16:16 ` Junio C Hamano [this message]
2024-05-20 16:48 ` John Paul Adrian Glaubitz
2024-05-20 16:52 ` Eric Sunshine
2024-05-20 16:50 ` Eric Sunshine
2024-05-20 17:07 ` Eric Sunshine
2024-05-20 17:23 ` Junio C Hamano
2024-05-20 19:01 ` [PATCH 0/3] improve chainlint.pl CPU count computation Eric Sunshine
2024-05-20 19:01 ` [PATCH 1/3] chainlint.pl: make CPU count computation more robust Eric Sunshine
2024-05-20 19:01 ` [PATCH 2/3] chainlint.pl: fix incorrect CPU count on Linux SPARC Eric Sunshine
2024-05-22 8:32 ` Carlo Marcelo Arenas Belón
2024-05-22 8:47 ` John Paul Adrian Glaubitz
2024-05-22 9:05 ` Eric Sunshine
2024-05-22 19:00 ` Junio C Hamano
2024-05-22 19:11 ` Eric Sunshine
2024-05-27 19:48 ` John Paul Adrian Glaubitz
2024-05-27 20:12 ` Eric Sunshine
2024-05-20 19:01 ` [PATCH 3/3] chainlint.pl: latch CPU count directly reported by /proc/cpuinfo Eric Sunshine
2024-05-20 19:17 ` [PATCH 0/3] improve chainlint.pl CPU count computation John Paul Adrian Glaubitz
2024-05-20 19:19 ` Eric Sunshine
2024-05-20 19:23 ` John Paul Adrian Glaubitz
2024-05-21 14:28 ` John Paul Adrian Glaubitz
2024-05-21 16:18 ` Eric Sunshine
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=xmqqseyclaq8.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=andreas@gaisler.com \
--cc=git@vger.kernel.org \
--cc=glaubitz@physik.fu-berlin.de \
--cc=sam@gentoo.org \
--cc=sunshine@sunshineco.com \
/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).