From patchwork Mon Sep 6 18:11:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 44869 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 492263857022 for ; Mon, 6 Sep 2021 18:12:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 492263857022 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1630951968; 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=SE0subj8063hpgQR9glEZtk7VxxDWeVVVv0PD8GoyaEn+0PUWpki93FsB/ALxQ86u W1GH1Rc+wedqUTAYEORfZrefD5WJwfU9tSvMgvy9EDZVbbdeIiQN49lLtFg3pLgyfL u02w2qNmuO0V0Sa2iakmRatdyHhI1MrkIKbEi7jk= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org 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 8C5733857022 for ; Mon, 6 Sep 2021 18:11:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8C5733857022 Received: by mail-qt1-x836.google.com with SMTP id l24so6018752qtj.4 for ; Mon, 06 Sep 2021 11:11:39 -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=nqoxl/S0Xc6A9oiZBWGZg2v5YyZufqmSYaHX5DUtHu5PKiO8pORmDeNnGZxDP1m58h KWu6ivCZCbDuAozQu3moN8+c9Yn5jsq8xWHZT0aNZPQkcZIbWZvZaD1KEN85Xt/pxtch vShEaK7azNPjfk9hzzadR2FuBYCOGrMBkF+qHoVnT1kvQpV3pWjHqCIRYHTL+JdnpYp8 ccHtKHZFYwADc+gcXlVfpONim0koWjkRL8ddgX7QMpKV61ZCBB5X8fD5gha+zwnt6vfY m6SPzsAidB+MNKymh5OTkpfcy813xTYW+HeQxM3arbt/2zLqeFsrbFByHRBd4pWf4fDL JIig== X-Gm-Message-State: AOAM530KIIQDTdgi7KCnW/Oer+iJ1qL/Z62QuNqbWSOIJ0G8iZQYaQ9p ltu3FdiTaHkUELvV2FA/O+L5af502AoDDQ== X-Google-Smtp-Source: ABdhPJwyGaqC3hhkaQhugbHXt+B86ewWvzCkxwj1GgCnYXBQ3ABRfwR2gos4NDsKrwnl2cO8b/ArrA== X-Received: by 2002:ac8:45cd:: with SMTP id e13mr12305246qto.18.1630951899063; Mon, 06 Sep 2021 11:11:39 -0700 (PDT) Received: from birita.. ([2804:431:c7cb:733d:210:e147:8627:2d6]) by smtp.gmail.com with ESMTPSA id j23sm7175647qkl.65.2021.09.06.11.11.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Sep 2021 11:11:38 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH 1/3] misc: Add __get_nprocs_sched Date: Mon, 6 Sep 2021 15:11:31 -0300 Message-Id: <20210906181133.1401140-2-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210906181133.1401140-1-adhemerval.zanella@linaro.org> References: <20210906181133.1401140-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP 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-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Reply-To: Adhemerval Zanella Cc: Florian Weimer , Nicolas Saenz Julienne Errors-To: libc-alpha-bounces+patchwork=sourceware.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. */