From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: Florian Weimer <fweimer@redhat.com>,
Adhemerval Zanella via Libc-alpha <libc-alpha@sourceware.org>
Cc: crrodriguez@opensuse.org
Subject: Re: [PATCH 3/4] linux: Use /sys/devices/system/cpu/possible on __get_nprocs_conf
Date: Fri, 7 May 2021 09:43:46 -0300 [thread overview]
Message-ID: <e6f42b2c-1c61-1185-a544-a9087536abbf@linaro.org> (raw)
In-Reply-To: <874kfeer8x.fsf@oldenburg.str.redhat.com>
On 07/05/2021 08:07, Florian Weimer wrote:
> * Adhemerval Zanella via Libc-alpha:
>
>> On 06/05/2021 10:51, Florian Weimer wrote:
>>> * Adhemerval Zanella via Libc-alpha:
>>>
>>>> On 05/05/2021 15:06, Florian Weimer wrote:
>>>>> * Florian Weimer:
>>>>>
>>>>>> * Adhemerval Zanella via Libc-alpha:
>>>>>>
>>>>>>> + /* The entry is in the form of '[cpuX]-[cpuY]'. */
>>>>>>> + char buf[2 * INT_STRLEN_BOUND (unsigned int) + 1];
>>>>>>> +
>>>>>>> + ssize_t n = __read_nocancel (fd, buf, sizeof (buf));
>>>>>>> + if (n > 0)
>>>>>>> + {
>>>>>>> + buf[n] = '\0';
>>>>>>> +
>>>>>>> + /* Start on the right, to find highest node number. */
>>>>>>> + int m = 1;
>>>>>>> + while (--n)
>>>>>>> + {
>>>>>>> + if ((buf[n] == ',') || (buf[n] == '-'))
>>>>>>> + break;
>>>>>>> + /* Ignore '\n' */
>>>>>>> + if (! isdigit (buf[n]))
>>>>>>> + continue;
>>>>>>> + result += (buf[n] - '0') * m;
>>>>>>> + m *= 10;
>>>>>>> + }
>>>>>>> + }
>>>>>>> +
>>>>>>> + __close_nocancel (fd);
>>>>>>> + return result + 1;
>>>>>>> }
>>>>>>
>>>>>> I think the /online and /possible files have the same layout, so you
>>>>>> could use both.
>>>>>
>>>>> Sorry, I meant to write: “so you could use *one parser for* both”
>>>>
>>>> I am not following, the second patch in this set *removed* the
>>>> /sys/devices/system/cpu/online parsing in favor of the sched_getaffinity.
>>>> So now it only parses /sys/devices/system/cpu/possible and fallbacks
>>>> to sched_getaffinity.
>>>
>>> Oh, right. So you removed the old implementation and bring bug a
>>> slightly different new one. Got it.
>>
>> Right, are you ok with the patch then?
>
> The new parser cannot handle gaps or ranges that do not start at 0, I
> think. The old parser could cope with that. The kernel data structures
> support gaps in the possible CPU mask. I don't know if they occur in
> practice, but firmware quirks in this area aren't exactly rare (e.g.,
> single-socket systems which report hundreds of hot-pluggable CPU cores).
Indeed I did not take this in consideration and it seems that using
/possible is more complicated than just opendir the directory. And
we will need to handle the possible unlikely issue of a truncated
value from kernel, since the buffer is limited to PAGE_SIZE.
I will drop this patch.
next prev parent reply other threads:[~2021-05-07 12:43 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-29 18:25 [PATCH 1/4] Remove architecture specific sched_cpucount optimizations Adhemerval Zanella
2021-03-29 18:25 ` [PATCH 2/4] linux: Use sched_getaffinity for __get_nprocs (BZ #27645) Adhemerval Zanella
2021-04-27 15:38 ` Florian Weimer
2021-03-29 18:25 ` [PATCH 3/4] linux: Use /sys/devices/system/cpu/possible on __get_nprocs_conf Adhemerval Zanella
2021-05-05 16:53 ` Adhemerval Zanella
2021-05-05 17:54 ` Florian Weimer
2021-05-05 18:06 ` Florian Weimer
2021-05-06 13:03 ` Adhemerval Zanella
2021-05-06 13:51 ` Florian Weimer
2021-05-06 20:07 ` Adhemerval Zanella
2021-05-07 11:07 ` Florian Weimer
2021-05-07 12:43 ` Adhemerval Zanella [this message]
2021-05-06 13:17 ` Adhemerval Zanella
2021-03-29 18:25 ` [PATCH 4/4] linux: Remove /proc/cpuinfo fallback on alpha and sparc Adhemerval Zanella
2021-05-05 16:53 ` Adhemerval Zanella
2021-05-05 16:52 ` [PATCH 1/4] Remove architecture specific sched_cpucount optimizations Adhemerval Zanella
2021-05-05 17:28 ` Florian Weimer
2021-05-05 18:25 ` Paul Eggert
2021-05-05 19:52 ` Noah Goldstein
2021-05-06 12:22 ` Adhemerval Zanella
2021-05-06 18:34 ` Noah Goldstein
2021-05-06 13:33 ` Adhemerval Zanella
2021-05-06 13:43 ` Florian Weimer
2021-05-06 16:16 ` Adhemerval Zanella
2021-05-06 16:42 ` Florian Weimer
2021-05-06 16:54 ` Adhemerval Zanella
2021-05-06 17:12 ` Paul Eggert
2021-05-06 17:51 ` 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=e6f42b2c-1c61-1185-a544-a9087536abbf@linaro.org \
--to=adhemerval.zanella@linaro.org \
--cc=crrodriguez@opensuse.org \
--cc=fweimer@redhat.com \
--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).