Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 19 Nov 2018 18:24:09 +0000 (UTC)
From:      Edward Tomasz Napierala <trasz@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r340642 - head/lib/libthr/thread
Message-ID:  <201811191824.wAJIO9LP094171@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: trasz
Date: Mon Nov 19 18:24:08 2018
New Revision: 340642
URL: https://svnweb.freebsd.org/changeset/base/340642

Log:
  Make libthr(3) use sysconf(_SC_NPROCESSORS_CONF); this shaves off
  two calls to sysctl(2) from the binary startup.
  
  Reviewed by:	kib
  MFC after:	2 weeks
  Sponsored by:	DARPA, AFRL
  Differential Revision:	https://reviews.freebsd.org/D18046

Modified:
  head/lib/libthr/thread/thr_init.c

Modified: head/lib/libthr/thread/thr_init.c
==============================================================================
--- head/lib/libthr/thread/thr_init.c	Mon Nov 19 18:23:17 2018	(r340641)
+++ head/lib/libthr/thread/thr_init.c	Mon Nov 19 18:24:08 2018	(r340642)
@@ -474,8 +474,9 @@ init_private(void)
 				PANIC("Cannot get stack rlimit");
 			_thr_stack_initial = rlim.rlim_cur;
 		}
-		len = sizeof(_thr_is_smp);
-		sysctlbyname("kern.smp.cpus", &_thr_is_smp, &len, NULL, 0);
+		_thr_is_smp = sysconf(_SC_NPROCESSORS_CONF);
+		if (_thr_is_smp == -1)
+			PANIC("Cannot get _SC_NPROCESSORS_CONF");
 		_thr_is_smp = (_thr_is_smp > 1);
 		_thr_page_size = getpagesize();
 		_thr_guard_default = _thr_page_size;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201811191824.wAJIO9LP094171>