From nobody Tue Feb 14 03:18:21 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PG5y85rzQz3q6YB; Tue, 14 Feb 2023 03:18:24 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-oa1-x29.google.com (mail-oa1-x29.google.com [IPv6:2001:4860:4864:20::29]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PG5y82Rx9z438t; Tue, 14 Feb 2023 03:18:24 +0000 (UTC) (envelope-from mjguzik@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-oa1-x29.google.com with SMTP id 586e51a60fabf-15ff0a1f735so17588558fac.5; Mon, 13 Feb 2023 19:18:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:references:in-reply-to :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=yjQRWCYAjbGrggh+wPiUwt+LWiuDYBWSsKPLjgQTk/I=; b=GxfDHZvNJBBVbskLfU7JybTZhL5UKmGudJRGUkkcwZW2zhLL5BtSCuAcqTRaJVgW7H BrN4Y04vZl8R00kbM4YUYhDwkab+L/3oWp46qZR2S+BJL+Y3nBeIREbtoR2GNKezSEiy TC1qP6S0vyUTaF9nL9gtmLElti3DgwVDBSEvAOq1NeGNPT9WUsHnKSZg7aNhE6yqyw+U QBbtHgEkUbifYcI99qkk0YY1ENI3n/LHBv+OSIlvb0PnilTWvMYWRkcHLjyki5zsFEde /YNNIN+F5xs9OLNopRvGZWmya690c4jhvx7bB64PAA42SqHhpPuNHnrySxW7dewJmbPa gimw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:references:in-reply-to :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=yjQRWCYAjbGrggh+wPiUwt+LWiuDYBWSsKPLjgQTk/I=; b=Mz7Iqs4Mn+dYpj0tUs4jpHE0q8Jvasznk+kylSZx8dUyqkm+unDLJHDRSrkBODTbZI dYACKsDzdguAko3W7tW3jf5wV013DOTUiN9pyucuPejLRII6CrFB/xT3g6IC7RBdxkEW S0NFNT85WdtkSayVhaVNV+41+cGwstzknxdAOJqrafK8yR7Mv6d/PZTSxN2mqvlN9qiS +SnqTd1LrfZh3KXc0TCL7NMWaUOmXaK8gKACuJeEEWYYPOKoT6eOOcl8r8OVRKHBbAQy OuJTMJ4egSu9v7d8B17GYX3ygIRnjoifmqZ47ybMRTGLEQUCRyNbL0dBbZJHZLN0EQRQ 9yZg== X-Gm-Message-State: AO0yUKVvgia1xSgeBlq8VkjtbifTsFUd4XmPZN0JTAQiZjJxhCz2far2 xSEJvXpjxiG7T/QX0ZmGs4wc4Y+NV4Ev1dV387t/W05F X-Google-Smtp-Source: AK7set99I8Yk6TpUelIQJi3hxgyCauBMmtTMdtTbfzbuMVLCjZpm9XnuBZSczbGtEuhWmyVZS7x56bl+TJCegAUMR58= X-Received: by 2002:a05:6870:13d0:b0:16e:25e:f294 with SMTP id 16-20020a05687013d000b0016e025ef294mr29914oat.81.1676344702099; Mon, 13 Feb 2023 19:18:22 -0800 (PST) List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Received: by 2002:ac9:4381:0:b0:4b9:9c2d:ce62 with HTTP; Mon, 13 Feb 2023 19:18:21 -0800 (PST) In-Reply-To: References: <202302081947.318Jlbt6052826@gitrepo.freebsd.org> <20230208202736.L7hpB%steffen__28609.3347867549$1675888077$gmane$org@sdaoden.eu> <1qmt-6s1w-wny@FreeBSD.org> From: Mateusz Guzik Date: Tue, 14 Feb 2023 04:18:21 +0100 Message-ID: Subject: Re: git: 48bfd3597654 - main - Add nproc(1) To: Jan Beich Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4PG5y82Rx9z438t X-Spamd-Bar: ---- X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15169, ipnet:2001:4860:4864::/48, country:US] X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-ThisMailContainsUnwantedMimeParts: N On 2/14/23, Jan Beich wrote: > Mateusz Guzik writes: > >> On 2/14/23, Jan Beich wrote: >> >>> Steffen Nurpmeso writes: >>> >>>> |+ if (all_flag) { >>>> |+ cpus = sysconf(_SC_NPROCESSORS_ONLN); >>>> >>>> is not compatible -- note i like the FreeBSD way better, and maybe >>>> someone should make a bug report even. >>>> >>>> #?0|kent:$ getconf -a|grep NPROC >>>> _NPROCESSORS_CONF 8 >>>> _NPROCESSORS_ONLN 4 >>> >>> See also https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=230330 >>> >>> $ cpuset -l 2-5 -- getconf -a | fgrep _NPROC >>> _NPROCESSORS_CONF: 8 >>> _NPROCESSORS_ONLN: 4 >>> >> >> As I mentioned previously in the thread, on linux these *don't* react >> to cpusets (or tasksets in linux parlance): >> >> $ getconf -a | grep _NPROC >> _NPROCESSORS_CONF 4 >> _NPROCESSORS_ONLN 4 >> $ taskset --cpu-list 0 getconf -a | grep _NPROC >> _NPROCESSORS_CONF 4 >> _NPROCESSORS_ONLN 4 >> >> consequently the patch proposed in the bz would introduce an >> incompatibility with linux > > I've used kern.smp.cpus in old patches but found musl more practical. > _SC_NPROCESSORS_ONLN is often used as a default number of jobs. > _SC_NPROCESSORS_ONLN is expected by real consumers to *not* be affected by cpuset et al. See below for musl. > glibc: > - /sys/devices/system/cpu/online > - /proc/stat Neither of these are affected by taskset/cpuset. > - sched_getaffinity where is this used? > > musl: > - sched_getaffinity > From the commit I don't think the choice was thought out whatsoever. https://git.musl-libc.org/cgit/musl/commit/?id=9a7fac7934975338449b63eb4d0409b472251dfa the code went from returning -1 to glibc-incompatible taskset-affected count, and there are people complaining it breaks compat: https://marc.info/?l=musl&w=2&r=1&s=_SC_NPROCESSORS_ONLN&q=b > bionic: > - /sys/devices/system/cpu/online > - /proc/stat (Android < 7) > Neither of these are affected by taskset/cpuset. All in all, the *current* state is broadly linux+glibc-compatible. The one incompatibility concerns disabled HT, which on linux still reports those cpu threads, while they are completely absent from the count on freebsd. This is not taskset/cpuset-related. -- Mateusz Guzik