From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 3119C3857C74 for ; Fri, 7 May 2021 11:07:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 3119C3857C74 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-176-VPuJ5YjNMCWVlpGRrEXH6g-1; Fri, 07 May 2021 07:07:41 -0400 X-MC-Unique: VPuJ5YjNMCWVlpGRrEXH6g-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EC93210060D6; Fri, 7 May 2021 11:07:39 +0000 (UTC) Received: from oldenburg.str.redhat.com (ovpn-112-137.ams2.redhat.com [10.36.112.137]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F07F5687D1; Fri, 7 May 2021 11:07:38 +0000 (UTC) From: Florian Weimer To: Adhemerval Zanella via Libc-alpha Cc: Adhemerval Zanella , crrodriguez@opensuse.org Subject: Re: [PATCH 3/4] linux: Use /sys/devices/system/cpu/possible on __get_nprocs_conf References: <20210329182520.323665-1-adhemerval.zanella@linaro.org> <20210329182520.323665-3-adhemerval.zanella@linaro.org> <871ralcbha.fsf@oldenburg.str.redhat.com> <87sg31awd8.fsf@oldenburg.str.redhat.com> <87h7jggec3.fsf@oldenburg.str.redhat.com> <0b31aafd-b73b-fa82-ac1b-da04f8c68698@linaro.org> Date: Fri, 07 May 2021 13:07:58 +0200 In-Reply-To: <0b31aafd-b73b-fa82-ac1b-da04f8c68698@linaro.org> (Adhemerval Zanella via Libc-alpha's message of "Thu, 6 May 2021 17:07:02 -0300") Message-ID: <874kfeer8x.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 May 2021 11:07:44 -0000 * Adhemerval Zanella via Libc-alpha: > On 06/05/2021 10:51, Florian Weimer wrote: >> * Adhemerval Zanella via Libc-alpha: >>=20 >>> 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 =3D __read_nocancel (fd, buf, sizeof (buf)); >>>>>> + if (n > 0) >>>>>> +=09{ >>>>>> +=09 buf[n] =3D '\0'; >>>>>> + >>>>>> +=09 /* Start on the right, to find highest node number. */ >>>>>> +=09 int m =3D 1; >>>>>> +=09 while (--n) >>>>>> +=09 { >>>>>> +=09 if ((buf[n] =3D=3D ',') || (buf[n] =3D=3D '-')) >>>>>> +=09=09break; >>>>>> +=09 /* Ignore '\n' */ >>>>>> +=09 if (! isdigit (buf[n])) >>>>>> +=09=09continue; >>>>>> +=09 result +=3D (buf[n] - '0') * m; >>>>>> +=09 m *=3D 10; >>>>>> +=09 } >>>>>> +=09} >>>>>> + >>>>>> + __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: =E2=80=9Cso you could use *one parser for* bo= th=E2=80=9D >>> >>> I am not following, the second patch in this set *removed* the=20 >>> /sys/devices/system/cpu/online parsing in favor of the sched_getaffinit= y. >>> So now it only parses /sys/devices/system/cpu/possible and fallbacks >>> to sched_getaffinity. >>=20 >> 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). Thanks, Florian