From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/13979 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Jonathan Rajotte-Julien Newsgroups: gmane.linux.lib.musl.general Subject: sysconf(_SC_NPROCESSORS_CONF) returns the wrong value Date: Fri, 15 Mar 2019 17:02:02 -0400 Message-ID: <20190315210202.GD6994@joraj-alpa> Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="191315"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.9.5 (2018-04-13) Cc: Michael Jeanson , Richard Purdie , Mathieu Desnoyers To: musl@lists.openwall.com Original-X-From: musl-return-13995-gllmg-musl=m.gmane.org@lists.openwall.com Fri Mar 15 22:02:19 2019 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.89) (envelope-from ) id 1h4ty6-000nfA-AM for gllmg-musl@m.gmane.org; Fri, 15 Mar 2019 22:02:18 +0100 Original-Received: (qmail 13370 invoked by uid 550); 15 Mar 2019 21:02:15 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 13333 invoked from network); 15 Mar 2019 21:02:14 -0000 DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com 6B6261C966E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1552683722; bh=hnxGfN8f983B5MYJtlqVJia1N1dFzTlU3MwjOr1MyP8=; h=Date:From:To:Message-ID:MIME-Version; b=UnYd0vVaYHpb7+z9SLEF5Ma6HG/QC6SnRF8GRftr3SBS5jte3kcoh3XNPZYCxqiKV P1Gc9R14QE+k6Ey+JB4pvcdfNyeNahMcawfrbzwnROO1eE9f6C9xaZkN4O0szHBiwk 0+VLo/Il5mdcEt6B7okOH6Qq/UHwbDwP+5bo/MB8gUaLxk1L4yi9T+KpcMWXe+now9 OzAiLL1wUy1OO7WVd5w6V8RancAQWymDlSBXFX5qBEPGgs0mPGsC2ir64vCd+Va+/d TnWrr21ME/pMmdV3y3CLfp8rSSMZw80NEFm1I27qKaExK3ZmuQ8GmqgjZkCzys0Z2D mm1+IMx8grOHA== X-Virus-Scanned: amavisd-new at efficios.com Content-Disposition: inline Xref: news.gmane.org gmane.linux.lib.musl.general:13979 Archived-At: Hi all, We are currently in the process of making sure that lttng [1] (linux tracer) run smoothly on system using musl (Yocto, Alpine etc.). Most things work fine. Still, we currently have tests that are failing due to an issue regarding the reported number of configured processors on the system (__SC_NPROCESSORS_CONF). Note that users of LTTng are also affected by this if they chose to modify the sched affinity of their instrumented apps. This is relatively a big deal for us. Long story short, we start an app with "taskset -c 0" and we need to allocate data structure internally but using the number of configured processors not the number of online processors. To do so we call sysconf(__SC_NPROCESSORS_CONF). Slight problem: the value returned is the _SC_NPROCESSORS_ONLN value instead of __SC_NPROCESSORS_CONF. >From src/conf/sysconf.c:196 case JT_NPROCESSORS_CONF & 255: case JT_NPROCESSORS_ONLN & 255: ; unsigned char set[128] = {1}; int i, cnt; __syscall(SYS_sched_getaffinity, 0, sizeof set, set); for (i=cnt=0; i