From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qt1-x835.google.com (mail-qt1-x835.google.com [IPv6:2607:f8b0:4864:20::835]) by sourceware.org (Postfix) with ESMTPS id EECA5388C014 for ; Thu, 6 May 2021 13:03:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org EECA5388C014 Received: by mail-qt1-x835.google.com with SMTP id y12so3869395qtx.11 for ; Thu, 06 May 2021 06:03:37 -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=BGX57l2C/l79xrpZhhISkLYj4bzFaOVHuIxYBM0JN5o=; b=dZciMoWQ/PPohRWZirsOOUbf9yVIoJD+kbx3jVvrf1RSu8stFje8fivlIcUNWzDUe4 bKzTA7Tt3mk/lNMQt46jiFhA94n2qOanf2AauRD8BuiAUOun3QQuVOlyGf4W4X9LR3Bi tl16ctZ2z5HdBsoKh4acZ8xVqOfwrIUhfb4d0RogxvQHwIlZHfGyw0ppMnd0eyyhtrqc oEDZyckcI7o4WEjRy8qO+ncx+KvD23jAj+8G/aAD7lMKQSmAttpIBjBeeqmyG5yD2iRe wt7olaYS/JoGRMw7UeO7dlOh3TjqjqH/Q4EofoOEeE/Rv5UT8jwrKUK/+tocMFFUe0vQ 5wAQ== X-Gm-Message-State: AOAM531fySuTrTfBWPWPOauY0TDPNUH/KLYaOClAY+vCFGIzzkTOHEhr KjC4fkUPn9VlER1BwUIUQnKZMQ== X-Google-Smtp-Source: ABdhPJwopBFD5TQ7TTBqfi355zayOS/Moje46E0H/hjBKl+8kJFy4VODUdkhfkyScm7SXHKiytdqYA== X-Received: by 2002:ac8:5cc5:: with SMTP id s5mr4144228qta.15.1620306217479; Thu, 06 May 2021 06:03:37 -0700 (PDT) Received: from [192.168.1.4] ([177.194.37.86]) by smtp.gmail.com with ESMTPSA id q13sm1939561qkj.43.2021.05.06.06.03.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 06 May 2021 06:03:36 -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> <87sg31awd8.fsf@oldenburg.str.redhat.com> From: Adhemerval Zanella Message-ID: Date: Thu, 6 May 2021 10:03:33 -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: <87sg31awd8.fsf@oldenburg.str.redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit 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:03:43 -0000 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.