From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi1-x234.google.com (mail-oi1-x234.google.com [IPv6:2607:f8b0:4864:20::234]) by sourceware.org (Postfix) with ESMTPS id EF41B3858C83 for ; Mon, 7 Feb 2022 11:57:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EF41B3858C83 Received: by mail-oi1-x234.google.com with SMTP id 4so16579420oil.11 for ; Mon, 07 Feb 2022 03:57:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=kMVhmhSl3Uu+nLZd0kclR/isXZzb2NPWaMRxiw4fAO0=; b=PXZRtIMbp1oraW4VKJuMrhLfR1RloEnK1v6J2Kp7SXC/6ZIyuUqrPGtW7ZbQ33Lo2F ReYx0Vk4+YvERlRcTuAL34dEpautSC7ZuaulWlRo+rTovqOQcFFAOLKN5B1VOdlUwf/c bo/waA1hN7iVGTe09z6MesD5Rm2Wc+JyEHfsvbvPitvukh/81kwnG2QmfhvOj7IVwdyc +kcmaT87XjEqycQ7zX6wiBi9zN+6JvxTZdH/axHmmgnq/PaAJXBHGlp/Bt5xIFX18tsE TK+phSLMNVbFWLfWZiEs787eWGu7sSNLhe6wCxyQNS1i/OOSLxUZ/iGXeDxddrj85p6O EizQ== X-Gm-Message-State: AOAM5302x9ZxMQO1I9t9KPCz1MJnNHQbv4X8jhjRqNtuIL6CMcgsiGJc yTIAMdPvCZ7pEuNPa9LEMtlVsQ== X-Google-Smtp-Source: ABdhPJxseTD4jh9p/EMaGF6ytl0RBveu/oGy49v9yGgcRRpaVjhyw+UHA3MeayT2sm+FZY5cA6/cQQ== X-Received: by 2002:a05:6808:bc2:: with SMTP id o2mr6687070oik.206.1644235046469; Mon, 07 Feb 2022 03:57:26 -0800 (PST) Received: from ?IPV6:2804:431:c7ca:733:4cdc:e08a:54c6:5108? ([2804:431:c7ca:733:4cdc:e08a:54c6:5108]) by smtp.gmail.com with ESMTPSA id e192sm3913803oob.11.2022.02.07.03.57.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 07 Feb 2022 03:57:26 -0800 (PST) Message-ID: <1456654f-b143-85ff-4e48-a4500e0c67a1@linaro.org> Date: Mon, 7 Feb 2022 08:57:23 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.1 Subject: Re: [PATCH] linux: fix accuracy of get_nprocs and get_nprocs_conf [BZ #28865] Content-Language: en-US To: Florian Weimer , Adhemerval Zanella via Libc-alpha Cc: "Dmitry V. Levin" References: <20220205212402.GA5233@altlinux.org> <2f8633c5-6335-b7aa-e735-65dc36322d7f@linaro.org> <87a6f2c35m.fsf@oldenburg.str.redhat.com> From: Adhemerval Zanella In-Reply-To: <87a6f2c35m.fsf@oldenburg.str.redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.8 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, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Mon, 07 Feb 2022 11:57:30 -0000 On 07/02/2022 08:44, Florian Weimer wrote: > * Adhemerval Zanella via Libc-alpha: > >> On 05/02/2022 18:24, Dmitry V. Levin wrote: >>> get_nprocs() and get_nprocs_conf() use various methods to obtain an >>> accurate number of processors. Re-introduce __get_nprocs_sched() as >>> a source of information, and fix the order in which these methods are >>> used to return the most accurate information. The primary source of >>> information used in both functions remains unchanged. >>> >>> This also changes __get_nprocs_sched() error return value from 2 to 0, >>> but all its users are already prepared to handle that. >>> >>> Old behavior: >>> get_nprocs: >>> /sys/devices/system/cpu/online -> /proc/stat -> 2 >>> get_nprocs_conf: >>> /sys/devices/system/cpu/ -> /proc/stat -> 2 >>> >>> New behavior: >>> get_nprocs: >>> /sys/devices/system/cpu/online -> sched_getaffinity -> /proc/stat -> 2 >>> get_nprocs_conf: >>> /sys/devices/system/cpu/ -> /proc/stat -> sched_getaffinity -> 2 >>> >>> Fixes: 342298278e ("linux: Revert the use of sched_getaffinity on get_nproc") >>> Closes: BZ #28865 >> >> I think we are circling back on this, on BZ#27645 [1] we changed get_nprocs >> to use sched_getaffinity and then we have to revert it with BZ#28310 [2] because >> it introduced regression on some monitoring tools [3]. > > But I think using sched_getaffinity as a fallback when /sys and /proc > are not available makes somse. It's different form what we did > temporarily (sched_getaffinity first). My concern is we start to see BZ#27645 again on environments that filter out sysfs and provide a synthetic sched_getaffinity.