From nobody Thu Feb 09 01:05:47 2023 X-Original-To: dev-commits-src-main@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 4PBzFV0MGbz3nbS4; Thu, 9 Feb 2023 01:05:50 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-oa1-x2e.google.com (mail-oa1-x2e.google.com [IPv6:2001:4860:4864:20::2e]) (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 4PBzFT2DYnz4Kqx; Thu, 9 Feb 2023 01:05:49 +0000 (UTC) (envelope-from mjguzik@gmail.com) Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20210112 header.b=WZQxBg0z; spf=pass (mx1.freebsd.org: domain of mjguzik@gmail.com designates 2001:4860:4864:20::2e as permitted sender) smtp.mailfrom=mjguzik@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-oa1-x2e.google.com with SMTP id 586e51a60fabf-16a291b16bfso754710fac.7; Wed, 08 Feb 2023 17:05:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:references:in-reply-to:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=ws3ZZQ3iRR1FtNmufgaa50GdLbD6DxbB0CdAe5RupOk=; b=WZQxBg0zj6CZ2gAZJhNJ9ENNA1vjcgcnWHXHEoLWraKaKo4ovdAcqW0saJkjB+qhWJ 1VrbKPF6MKZmWhvh0RyuTDWDgpKHOzg+puhFKtQrP4vhUEJruUg2bMPfdYFzyoSvxZi/ 6GvdGz5x+rBUx7hILjGRjqub3RPlSQ6wb5f0Bnl+hdFpnt5X3EZArroNV60TD0VCX0em 0vEyURhVM840XhpYYOdGT5E+LRhUINSjQVv8Xn2AfSp/u0XMbLeC2G3Fuj9xAjfSdjVB RkIn1YStGIVG7TmYeFg2ZsjJcndp7UWUqLQwh3lk30lWVeXFg0H9J5tRV1SpKIah6fLF rgvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=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=ws3ZZQ3iRR1FtNmufgaa50GdLbD6DxbB0CdAe5RupOk=; b=arUtzS7lhKuSzNVhPZs68cUcZszHn1yZiQfHSIin1/fwLsEklGeDFEAicPPr4rkS0B yEvLNYAmccBtc2SqnAkALSiJ59iwzK8xvNyh2UBgi18peBnyU9OhaMB38gq+2W0CY0vQ +dcHWlM9pn2OZBVdPQz+Oy2W6c8UDK2Th0uUScJwJF0H7djJphaqGIJ5A9Y8elp28t/E SJyiKk09vc971BOycwSFMD1F+1ZbjuYFzQ+M6R6zBYiN15WBnOAX4MJ2fzkNVt2+3Sfj syZZ886E2Mgp2XmjAWL8+qttiMNsq7FeTMQwbaZNo4VyYcC7cSjUh0o85QTQCPiTrLtv 59wQ== X-Gm-Message-State: AO0yUKVpH2/FW1gcy1MWWmEqeLn77DtRO0OkKokI6kr0UNVhomI+qGfB soYQBMf+o2J0niigLPu3HI+9xyxa3jDYYwKWtnnsG2sY X-Google-Smtp-Source: AK7set+N3UT7k+skbh75pCfIbs8z4EJZ4DsRRREp9Ge/xRsvrSVsyJhXiUru0ugO422Vmkmw5/cv31u3t1srCIE4JgQ= X-Received: by 2002:a05:6870:1257:b0:16a:9099:3868 with SMTP id 23-20020a056870125700b0016a90993868mr462261oao.81.1675904747769; Wed, 08 Feb 2023 17:05:47 -0800 (PST) List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Received: by 2002:ac9:6c92:0:b0:4b3:d953:974c with HTTP; Wed, 8 Feb 2023 17:05:47 -0800 (PST) In-Reply-To: <20230208202736.L7hpB%steffen@sdaoden.eu> References: <202302081947.318Jlbt6052826@gitrepo.freebsd.org> <20230208202736.L7hpB%steffen@sdaoden.eu> From: Mateusz Guzik Date: Thu, 9 Feb 2023 02:05:47 +0100 Message-ID: Subject: Re: git: 48bfd3597654 - main - Add nproc(1) To: Mateusz Guzik , src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Spamd-Result: default: False [-4.00 / 15.00]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_SHORT(-1.00)[-0.999]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; R_SPF_ALLOW(-0.20)[+ip6:2001:4860:4000::/36:c]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20210112]; MIME_GOOD(-0.10)[text/plain]; MLMMJ_DEST(0.00)[dev-commits-src-all@freebsd.org,dev-commits-src-main@freebsd.org]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2001:4860:4864::/48, country:US]; RCVD_IN_DNSWL_NONE(0.00)[2001:4860:4864:20::2e:from]; FROM_EQ_ENVFROM(0.00)[]; ARC_NA(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; MID_RHS_MATCH_FROMTLD(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; FROM_HAS_DN(0.00)[]; DKIM_TRACE(0.00)[gmail.com:+]; FREEMAIL_FROM(0.00)[gmail.com]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_LAST(0.00)[]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim] X-Rspamd-Queue-Id: 4PBzFT2DYnz4Kqx X-Spamd-Bar: --- X-ThisMailContainsUnwantedMimeParts: N On 2/8/23, Steffen Nurpmeso wrote: > Mateusz Guzik wrote in > <202302081947.318Jlbt6052826@gitrepo.freebsd.org>: > ... > |URL: https://cgit.FreeBSD.org/src/commit/?id=48bfd3597654490cdc43bf0f591\ > |a539d3a28b590 > ... > | Add nproc(1) > > Hey! Great. (NPROC is mentioned in POSIX for environment > variables, as well as a make macro that did not make it, .. and > nproc(1) is commonly used on Linux it seems.) Thanks. > > | This program prints the number of CPU threads it can run on, while > | respecting cpusets (or not, depending on switches). > | > | It aims to be compatible with nproc as found in GNU coreutils. > > That, "however", > > ... > |+ 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 > #?0|kent:$ nproc > 4 > #?0|kent:$ nproc --all > 8 > #?0|kent:$ > Is this from disabling hyperthreading? I have a 40-way box, after doing it I see: NPROCESSORS_CONF: 20 NPROCESSORS_ONLN: 20 _NPROCESSORS_CONF: 20 _NPROCESSORS_ONLN: 20 iow it wont make a difference. I'm going to sleep on it, will probably add BUGS to the manpage. I do think linux nproc behavior on this is one peculiar at best though. Thanks for reporting. > > |+ if (cpus == -1) > |+ err(1, "sysconf"); > |+ } else { > |+ CPU_ZERO(&mask); > |+ if (cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_TID, -1, > |+ sizeof(mask), &mask) != 0) > |+ err(1, "cpuset_getaffinity"); > |+ cpus = CPU_COUNT(&mask); > > That is the right thing to do, imho! > > Thank you. > > --steffen > | > |Der Kragenbaer, The moon bear, > |der holt sich munter he cheerfully and one by one > |einen nach dem anderen runter wa.ks himself off > |(By Robert Gernhardt) > -- Mateusz Guzik