From: Florian Weimer <fweimer@redhat.com>
To: Adhemerval Zanella via Libc-alpha <libc-alpha@sourceware.org>
Cc: "Dmitry V. Levin" <ldv@altlinux.org>,
Adhemerval Zanella <adhemerval.zanella@linaro.org>
Subject: Re: [PATCH] linux: fix accuracy of get_nprocs and get_nprocs_conf [BZ #28865]
Date: Mon, 07 Feb 2022 12:44:05 +0100 [thread overview]
Message-ID: <87a6f2c35m.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <2f8633c5-6335-b7aa-e735-65dc36322d7f@linaro.org> (Adhemerval Zanella via Libc-alpha's message of "Mon, 7 Feb 2022 08:25:11 -0300")
* Adhemerval Zanella via Libc-alpha:
> On 05/02/2022 18:24, Dmitry V. Levin wrote:
>> get_nprocs() and get_nprocs_conf() use various methods to obtain an
>> accurate number of processors. Re-introduce __get_nprocs_sched() as
>> a source of information, and fix the order in which these methods are
>> used to return the most accurate information. The primary source of
>> information used in both functions remains unchanged.
>>
>> This also changes __get_nprocs_sched() error return value from 2 to 0,
>> but all its users are already prepared to handle that.
>>
>> Old behavior:
>> get_nprocs:
>> /sys/devices/system/cpu/online -> /proc/stat -> 2
>> get_nprocs_conf:
>> /sys/devices/system/cpu/ -> /proc/stat -> 2
>>
>> New behavior:
>> get_nprocs:
>> /sys/devices/system/cpu/online -> sched_getaffinity -> /proc/stat -> 2
>> get_nprocs_conf:
>> /sys/devices/system/cpu/ -> /proc/stat -> sched_getaffinity -> 2
>>
>> Fixes: 342298278e ("linux: Revert the use of sched_getaffinity on get_nproc")
>> Closes: BZ #28865
>
> I think we are circling back on this, on BZ#27645 [1] we changed get_nprocs
> to use sched_getaffinity and then we have to revert it with BZ#28310 [2] because
> it introduced regression on some monitoring tools [3].
But I think using sched_getaffinity as a fallback when /sys and /proc
are not available makes somse. It's different form what we did
temporarily (sched_getaffinity first).
Thanks,
Florian
next prev parent reply other threads:[~2022-02-07 11:44 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-05 21:24 Dmitry V. Levin
2022-02-07 11:25 ` Adhemerval Zanella
2022-02-07 11:44 ` Florian Weimer [this message]
2022-02-07 11:57 ` Adhemerval Zanella
2022-02-07 12:01 ` Florian Weimer
2022-02-07 12:07 ` Adhemerval Zanella
2022-02-07 11:51 ` Dmitry V. Levin
2022-02-07 12:01 ` Adhemerval Zanella
2022-02-07 13:45 ` Dmitry V. Levin
2022-02-07 13:57 ` [PATCH v2] " Dmitry V. Levin
2022-02-08 19:34 ` Adhemerval Zanella
2022-02-08 22:40 ` Dmitry V. Levin
2022-02-08 22:58 ` Adhemerval Zanella
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=87a6f2c35m.fsf@oldenburg.str.redhat.com \
--to=fweimer@redhat.com \
--cc=adhemerval.zanella@linaro.org \
--cc=ldv@altlinux.org \
--cc=libc-alpha@sourceware.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 read-only IMAP folder(s) and NNTP newsgroup(s).