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 744DC385802B for ; Wed, 5 May 2021 17:54:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 744DC385802B 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-228-G-GyhKyRN82W4U-mn9ujRQ-1; Wed, 05 May 2021 13:54:26 -0400 X-MC-Unique: G-GyhKyRN82W4U-mn9ujRQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id ACAAC106BB38; Wed, 5 May 2021 17:54:25 +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 A124110190A7; Wed, 5 May 2021 17:54:24 +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> Date: Wed, 05 May 2021 19:54:41 +0200 In-Reply-To: <20210329182520.323665-3-adhemerval.zanella@linaro.org> (Adhemerval Zanella via Libc-alpha's message of "Mon, 29 Mar 2021 15:25:19 -0300") Message-ID: <871ralcbha.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.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain 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: Wed, 05 May 2021 17:54:29 -0000 * 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. Is there a way to tell whether the two data sources (/possible and the count of the cpu%d directory entries) actually agree? I tried to make sense of the kernel sources but didn't succeed. Thanks, Florian