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 D4D00388C02F for ; Thu, 6 May 2021 13:51:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D4D00388C02F 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-152-zLV61jAuMrGXxzNPrTFq0w-1; Thu, 06 May 2021 09:51:24 -0400 X-MC-Unique: zLV61jAuMrGXxzNPrTFq0w-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D817A50207; Thu, 6 May 2021 13:51:23 +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 C43865C1C5; Thu, 6 May 2021 13:51:22 +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> Date: Thu, 06 May 2021 15:51:40 +0200 In-Reply-To: (Adhemerval Zanella via Libc-alpha's message of "Thu, 6 May 2021 10:03:33 -0300") Message-ID: <87h7jggec3.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.16 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: Thu, 06 May 2021 13:51:28 -0000 * Adhemerval Zanella via Libc-alpha: > On 05/05/2021 15:06, Florian Weimer wrote: >> * Florian Weimer: >>=20 >>> * 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. >>=20 >> Sorry, I meant to write: =E2=80=9Cso you could use *one parser for* both= =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_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. Thanks, Florian