]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
misc: Add __get_nprocs_sched
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Mon, 6 Sep 2021 15:22:54 +0000 (12:22 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Mon, 27 Sep 2021 12:13:06 +0000 (09:13 -0300)
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.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
include/sys/sysinfo.h
malloc/arena.c
misc/getsysstats.c
sysdeps/mach/getsysstats.c
sysdeps/unix/sysv/linux/getsysstats.c

index 7388356a192693352bb0c0302edd37f7b20b6aa4..c490561581733038fa4ac0377143125bb133a8be 100644 (file)
@@ -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)
index 4c398753aeadbb9db759e997581e601a21f8a3e6..78ef4cf18c780dfc7d733532a4afbf51a3e6b685 100644 (file)
@@ -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);
index 2986d62247cf98ca41881d704a06437885e4a399..5cbba0f9bd93bd788bcd83ea5e668ba44036aa4a 100644 (file)
@@ -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)
 {
index 1267f39da26aee38f934b6b3eb9237313bb81be5..cc8023f979bf6f74b63bc1878ecad39ffeedd959 100644 (file)
@@ -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)
index 8a5d342f0c8bbeae357254b874526ba6d5e76e8c..e9c0dc4d83d4fb2a5b326a93a0d5505ae14bc751 100644 (file)
@@ -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.  */