From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Status: No, score=-4.3 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 724411F8C6 for ; Tue, 7 Sep 2021 12:24:06 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id ABCB5385EC52 for ; Tue, 7 Sep 2021 12:24:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ABCB5385EC52 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1631017445; bh=liG1REC4YvqfZ9ESnrmJuIPu3gPIKaCLtiJKJBq6fCs=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=DXLjLE3n7eTbI+fM/m1Crd/LDumQzHU+rxYqVGeJZXSCw+F02bjw2hiZo2W50cS+d +tzisoY3Z4hq/dNnEVtEaW+7XF6p8kQoTjcqX7CGhZtFJxJo0lyo6mQ61YPrM2us6M //H5nd5r32T8DOBt1okwM1BsiFsNj3LUckEC1QEE= Received: from mail-qt1-x836.google.com (mail-qt1-x836.google.com [IPv6:2607:f8b0:4864:20::836]) by sourceware.org (Postfix) with ESMTPS id A461E3858003 for ; Tue, 7 Sep 2021 12:23:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A461E3858003 Received: by mail-qt1-x836.google.com with SMTP id r21so7703489qtw.11 for ; Tue, 07 Sep 2021 05:23:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=liG1REC4YvqfZ9ESnrmJuIPu3gPIKaCLtiJKJBq6fCs=; b=R/DEzt9daxlAkDqP9CmGW6r2TUXPMWCRQ7wm7couqkYnSSAUnRdZbxogCBPuQeZ/gA 6TkaDGhX95JDFQrgdXVXslUEN3hthNrKdnu2/4oE6ASCykGosA9fPFIv4No7jqx/exH4 FhterKBH5/Vo74GTwCE+YXxkYt4ixUW6DP+7cZUnUZ2c4Lcc8elQWgEqPiZ8SCLX2cDG Bm3dQiN7mbLJ/iSGIINNxL4Pu99nJlJf+TK4ly3mPIs3OrMLJu1Q6O6IsvzysL8ynKVh p8sdYk/v2Dz1/PfcDyR8GO3SRopRCsYHy/8T0skZ8hhmJZO8CxrQ4D3bvNqYbD1Ux8UJ 6OOg== X-Gm-Message-State: AOAM531DtpubmLP2oIhYSCvrZkzfhKJ6kINiOSBQFDBVbWS95Gb0Q1F3 BEIZujrhXMhEfx0ncldQzeOkmOljPqiQvg== X-Google-Smtp-Source: ABdhPJywAD25WXTf6gm4a7t/EiHwYeTKHcqc5Iktmny0JzXtlHGNFjaKA7y5Shiy+3lIoLic+nmicQ== X-Received: by 2002:a05:622a:1908:: with SMTP id w8mr15320505qtc.269.1631017384143; Tue, 07 Sep 2021 05:23:04 -0700 (PDT) Received: from birita.. ([2804:431:c7cb:733d:f360:5bf3:9813:d8f5]) by smtp.gmail.com with ESMTPSA id r18sm6902148qtm.96.2021.09.07.05.23.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Sep 2021 05:23:03 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH v2 1/3] misc: Add __get_nprocs_sched Date: Tue, 7 Sep 2021 09:22:57 -0300 Message-Id: <20210907122259.79800-2-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210907122259.79800-1-adhemerval.zanella@linaro.org> References: <20210907122259.79800-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: , From: Adhemerval Zanella via Libc-alpha Reply-To: Adhemerval Zanella Cc: Florian Weimer , Nicolas Saenz Julienne Errors-To: libc-alpha-bounces+e=80x24.org@sourceware.org Sender: "Libc-alpha" This is an internal function meant to return the number of avaliable processor where the process can scheduled, different than the __get_nprocs which returns a the system available online CPU. The Linux implementation currently only calls __get_nprocs(), which in tuns calls sched_getaffinity. --- include/sys/sysinfo.h | 7 ++++++- malloc/arena.c | 2 +- misc/getsysstats.c | 6 ++++++ sysdeps/mach/getsysstats.c | 6 ++++++ sysdeps/unix/sysv/linux/getsysstats.c | 6 ++++++ 5 files changed, 25 insertions(+), 2 deletions(-) diff --git a/include/sys/sysinfo.h b/include/sys/sysinfo.h index 7388356a19..c490561581 100644 --- a/include/sys/sysinfo.h +++ b/include/sys/sysinfo.h @@ -9,10 +9,15 @@ extern int __get_nprocs_conf (void); libc_hidden_proto (__get_nprocs_conf) -/* Return number of available processors. */ +/* Return number of available processors (not all of them will be + available to the caller process). */ extern int __get_nprocs (void); libc_hidden_proto (__get_nprocs) +/* Return the number of available processors which the process can + be scheduled. */ +extern int __get_nprocs_sched (void) attribute_hidden; + /* Return number of physical pages of memory in the system. */ extern long int __get_phys_pages (void); libc_hidden_proto (__get_phys_pages) diff --git a/malloc/arena.c b/malloc/arena.c index 4c398753ae..78ef4cf18c 100644 --- a/malloc/arena.c +++ b/malloc/arena.c @@ -878,7 +878,7 @@ arena_get2 (size_t size, mstate avoid_arena) narenas_limit = mp_.arena_max; else if (narenas > mp_.arena_test) { - int n = __get_nprocs (); + int n = __get_nprocs_sched (); if (n >= 1) narenas_limit = NARENAS_FROM_NCORES (n); diff --git a/misc/getsysstats.c b/misc/getsysstats.c index 2986d62247..5cbba0f9bd 100644 --- a/misc/getsysstats.c +++ b/misc/getsysstats.c @@ -44,6 +44,12 @@ weak_alias (__get_nprocs, get_nprocs) link_warning (get_nprocs, "warning: get_nprocs will always return 1") +int +__get_nprocs_sched (void) +{ + return 1; +} + long int __get_phys_pages (void) { diff --git a/sysdeps/mach/getsysstats.c b/sysdeps/mach/getsysstats.c index 1267f39da2..cc8023f979 100644 --- a/sysdeps/mach/getsysstats.c +++ b/sysdeps/mach/getsysstats.c @@ -62,6 +62,12 @@ __get_nprocs (void) libc_hidden_def (__get_nprocs) weak_alias (__get_nprocs, get_nprocs) +int +__get_nprocs_sched (void) +{ + return __get_nprocs (); +} + /* Return the number of physical pages on the system. */ long int __get_phys_pages (void) diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c index 8a5d342f0c..e9c0dc4d83 100644 --- a/sysdeps/unix/sysv/linux/getsysstats.c +++ b/sysdeps/unix/sysv/linux/getsysstats.c @@ -87,6 +87,12 @@ __get_nprocs (void) libc_hidden_def (__get_nprocs) weak_alias (__get_nprocs, get_nprocs) +int +__get_nprocs_sched (void) +{ + return __get_nprocs (); +} + /* On some architectures it is possible to distinguish between configured and active cpus. */ -- 2.30.2