From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qv1-xf2e.google.com (mail-qv1-xf2e.google.com [IPv6:2607:f8b0:4864:20::f2e]) by sourceware.org (Postfix) with ESMTPS id 8A08C388CC16 for ; Thu, 6 May 2021 13:17:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 8A08C388CC16 Received: by mail-qv1-xf2e.google.com with SMTP id z1so2985095qvo.4 for ; Thu, 06 May 2021 06:17:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=hj/o90TLwF4ESLBYNgKdotbtx8znqRxOqRMztQleTYQ=; b=Afwtp6TE2fYzXS/ainJ+GTiHZM6isC052Jp/C8pQqyRoq4fWPACK7J76vDq7+W/oUx b4qGst/HrNrIqy9aqv8X1KUkqNwVgPyN/fm+0Fk+rNXJ69cHhq5GK6pmzWPzgKFGXPQM St9E+bkPstg9ufjajeTHeU+gAN5lmVwMHwrjIO/ACrgYXacVs/OlOEhMKrfpRBr+Y4h+ YYoW2BeeQXpLBITdMbcCGru2hl5sspnnMbNVkYi27kpDGVzCaCZKMUeDT1EBoLkDSZDV 6d+RLJp4E5L109iQ8p7+mIy/PRVpmO/850IZeII658SlQunbtAm18SUMauoOyphJvOB3 AqDA== X-Gm-Message-State: AOAM530HmPgayFUSdVm+X8XtuCbmbwOJfJWnWGBFwgtg7s9sDr0uWh4b PnggM1juGFYYBX+MLB5drxfoyw== X-Google-Smtp-Source: ABdhPJzpHY3Fbi/fFEMUuWJnuC3DWs3w4DMMxnZ5iCekWQDNXKAO/kb/mwV/x/m9nqs/0RTzgu8Iyg== X-Received: by 2002:a0c:e412:: with SMTP id o18mr4173214qvl.33.1620307024865; Thu, 06 May 2021 06:17:04 -0700 (PDT) Received: from [192.168.1.4] ([177.194.37.86]) by smtp.gmail.com with ESMTPSA id c5sm1826710qkl.7.2021.05.06.06.17.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 06 May 2021 06:17:04 -0700 (PDT) Subject: Re: [PATCH 3/4] linux: Use /sys/devices/system/cpu/possible on __get_nprocs_conf To: Florian Weimer , Adhemerval Zanella via Libc-alpha Cc: crrodriguez@opensuse.org References: <20210329182520.323665-1-adhemerval.zanella@linaro.org> <20210329182520.323665-3-adhemerval.zanella@linaro.org> <871ralcbha.fsf@oldenburg.str.redhat.com> From: Adhemerval Zanella Message-ID: Date: Thu, 6 May 2021 10:17:01 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <871ralcbha.fsf@oldenburg.str.redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, 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:17:07 -0000 On 05/05/2021 14:54, Florian Weimer wrote: > * 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. I am not sure, but at least the /possible is properly documented as 'testing' (which should stable as indicated by own kernel documentation [1]) ABI [2]: What: /sys/devices/system/cpu/kernel_max /sys/devices/system/cpu/offline /sys/devices/system/cpu/online /sys/devices/system/cpu/possible /sys/devices/system/cpu/present Date: December 2008 Contact: Linux kernel mailing list Description: CPU topology files that describe kernel limits related to hotplug. Briefly: kernel_max: the maximum cpu index allowed by the kernel configuration. offline: cpus that are not online because they have been HOTPLUGGED off or exceed the limit of cpus allowed by the kernel configuration (kernel_max above). online: cpus that are online and being scheduled. possible: cpus that have been allocated resources and can be brought online if they are present. So I think we don't need to certify that directories entries do match /possible values. [1] https://github.com/torvalds/linux/tree/master/Documentation/ABI [2] https://github.com/torvalds/linux/blob/master/Documentation/ABI/testing/sysfs-devices-system-cpu