From nobody Sun Feb 12 19:58:07 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 4PFJDr6DlRz3rBl1; Sun, 12 Feb 2023 19:58:20 +0000 (UTC) (envelope-from antoine.brodin.freebsd@gmail.com) Received: from mail-lj1-f182.google.com (mail-lj1-f182.google.com [209.85.208.182]) (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 4PFJDr4GH6z42R7; Sun, 12 Feb 2023 19:58:20 +0000 (UTC) (envelope-from antoine.brodin.freebsd@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-lj1-f182.google.com with SMTP id z37so2350015ljq.8; Sun, 12 Feb 2023 11:58:20 -0800 (PST) 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:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=eoNwjiSNe0S1uKLyMTxDZAQuU5rM5MsLgHFGQIMCxwg=; b=Rmds9JYeRBx5N8wUZfaGQoj23JdQzLYj4mRSxXDghwZULup1I+4ITG6aXXy4ana2XL a7YbFRhoJeprPJYkcqr4+QUWEujpUqlLglN4papdm+oq+I+RoC4EbDCPhGiLxkgnopt4 LsYozS3WKu3lWVL7n28nmHb8eKHnfDUK44a2Q+D9kS6O8Rdr9sHaTNvRf0OMgaQO20dK TakDrfLYtemWw8QkPvpGFay3Wp2F/ztEitHY6jZbM3MMfVJ71Ate5FGzr1fKTMMMoX28 Lt6v3BGdKmc1YiBBZ6P/paF7RxpeQezUvNVUcX2UIQehK+qkednimNyPzSVyeCxcSQFf WXHQ== X-Gm-Message-State: AO0yUKU6jOz/sSV8sH4X9xQGXbbaUjIc9qk9PspT0p3QVL1q/LdUi1aB bpgxeATgaVMhYo9JTlZjaQ6pV9lhxDC36n/1ToI= X-Google-Smtp-Source: AK7set/C/3cp/vVSEABW3mN+XsEKTWcNfWjUS9ArJnhfYW08PCTMUnxu86LZ3KUsLydKavfbVV9JUarJ8BS69qYCaco= X-Received: by 2002:a2e:b537:0:b0:28f:81a2:6eb with SMTP id z23-20020a2eb537000000b0028f81a206ebmr4160023ljm.118.1676231898022; Sun, 12 Feb 2023 11:58:18 -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 References: <202301291318.30TDIq4Q008231@gitrepo.freebsd.org> In-Reply-To: From: Antoine Brodin Date: Sun, 12 Feb 2023 19:58:07 +0000 Message-ID: Subject: Re: git: c21b080f3dc2 - main - cpuset: Fix sched_[g|s]etaffinity() for better compatibility with Linux. To: Dmitry Chagin Cc: Dmitry Chagin , 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: 4PFJDr4GH6z42R7 X-Spamd-Bar: ---- X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; TAGGED_FROM(0.00)[] X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-ThisMailContainsUnwantedMimeParts: N On Sun, Feb 12, 2023 at 11:13 AM Dmitry Chagin wrote: > > On Sun, Feb 12, 2023 at 01:40:59PM +0300, Dmitry Chagin wrote: > > On Sun, Feb 12, 2023 at 09:47:15AM +0000, Antoine Brodin wrote: > > > On Sun, Jan 29, 2023 at 1:18 PM Dmitry Chagin wrote: > > > > > > > > The branch main has been updated by dchagin: > > > > > > > > URL: https://cgit.FreeBSD.org/src/commit/?id=c21b080f3dc2f5e91ada608d4385b7ed6538ba9b > > > > > > > > commit c21b080f3dc2f5e91ada608d4385b7ed6538ba9b > > > > Author: Dmitry Chagin > > > > AuthorDate: 2023-01-29 13:17:33 +0000 > > > > Commit: Dmitry Chagin > > > > CommitDate: 2023-01-29 13:17:33 +0000 > > > > > > > > cpuset: Fix sched_[g|s]etaffinity() for better compatibility with Linux. > > > > > > > > Under Linux to sched_[g|s]etaffinity() functions the value returned from a call > > > > to gettid(2) (thread id) can be passed in the argument pid. Specifying pid as 0 > > > > will set the attribute for the calling thread, and passing the value returned > > > > from a call to getpid(2) (process id) will set the attribute for the main thread > > > > of the thread group. > > > > > > > > Native cpuset(2) family of system calls has "which" argument to determine how > > > > the value of id argument is interpreted, i.e., CPU_WHICH_TID is used to pass > > > > a thread id and CPU_WHICH_PID - to pass a process id. > > > > > > > > For now native sched_[g|s]etaffinity() implementation is wrong as uses "which" > > > > CPU_WHICH_PID to pass both (process and thread id) to the kernel. To fix this > > > > adding a new "which" CPU_WHICH_TIDPID intended to handle both id's. > > > > > > > > Reviewed by: kib > > > > Differential Revision: https://reviews.freebsd.org/D38209 > > > > MFC after: 1 week > > > > --- > > > > lib/libc/gen/sched_getaffinity.c | 2 +- > > > > lib/libc/gen/sched_setaffinity.c | 2 +- > > > > lib/libc/sys/cpuset.2 | 4 +++- > > > > sys/kern/kern_cpuset.c | 42 +++++++++++++++++++++++++++++++++++++++- > > > > sys/sys/cpuset.h | 1 + > > > > 5 files changed, 47 insertions(+), 4 deletions(-) > > > > > > > > > Hello, > > > > > > This broke math/py-numpy on main and stable/13 > > > > > > https://pkg-status.freebsd.org/gohan03/data/main-amd64-default-baseline/p52768539d46f_scd3193f640/logs/errors/py39-numpy-1.24.1,1.log > > > https://pkg-status.freebsd.org/gohan02/data/13stable-amd64-quarterly-baseline/841610d9bfc6/logs/errors/py39-numpy-1.23.5_1,1.log > > > > > > File "/wrkdirs/usr/ports/math/py-numpy/work-py39/numpy-1.23.5/numpy/distutils/misc_util.py", > > > line 93, in get_num_build_jobs > > > cpu_count = len(os.sched_getaffinity(0)) > > > OverflowError: could not allocate a large enough CPU set > > > > hi, Antoine, > > > > on stable/13 > > dchagin@heemeyer:~ % uname -a > > FreeBSD heemeyer.club 13.2-STABLE FreeBSD 13.2-STABLE #268 stable/13-n254471-51485f81b01a-dirty: Sat Feb 11 12:16:21 MSK 2023 dchagin@heemeyer.club:/usr/home/dchagin/tmp/obj/usr/home/dchagin/freebsd/amd64.amd64/sys/YOY amd64 > > dchagin@heemeyer:~ % python3.9 > > Python 3.9.16 (main, Dec 18 2022, 01:15:32) > > [Clang 13.0.0 (git@github.com:llvm/llvm-project.git llvmorg-13.0.0-0-gd7b669b3a on freebsd13 > > Type "help", "copyright", "credits" or "license" for more information. > > >>> import os > > >>> len(os.sched_getaffinity(0)) > > 1 > > >>> os.sched_getaffinity(0) > > {0} > > >>> exit() > > dchagin@heemeyer:~ % > > > > on current: > > dchagin@mordor:~/freebsd % uname -a > > FreeBSD mordor.heemeyer.club 14.0-CURRENT FreeBSD 14.0-CURRENT #458 futex-n260850-52456667491d-dirty: Sat Feb 11 14:24:46 MSK 2023 dchagin@mordor.heemeyer.club:/home/dchagin/tmp/obj/home/dchagin/freebsd/amd64.amd64/sys/YOY amd64 > > dchagin@mordor:~/freebsd % python3.9 > > Python 3.9.16 (main, Dec 18 2022, 01:24:21) > > [Clang 14.0.5 (https://github.com/llvm/llvm-project.git llvmorg-14.0.5-0-gc1238 on freebsd14 > > Type "help", "copyright", "credits" or "license" for more information. > > >>> import os > > >>> len(os.sched_getaffinity(0)) > > 16 > > >>> os.sched_getaffinity(0) > > {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15} > > >>> exit() > > dchagin@mordor:~/freebsd % > > > > > > could you please show out of os.sched_getaffinity(0) ? > > and os.cpu_count() > also sysctl kern.smp Here is what I have in the head jail: >>> len(os.sched_getaffinity(0)) Traceback (most recent call last): File "", line 1, in OverflowError: could not allocate a large enough CPU set >>> os.sched_getaffinity(0) Traceback (most recent call last): File "", line 1, in OverflowError: could not allocate a large enough CPU set >>> os.cpu_count() 64 >>> root@mainamd64PR269425-default:~ # sysctl kern.smp kern.smp.forward_signal_enabled: 1 kern.smp.topology: 0 kern.smp.cores: 32 kern.smp.threads_per_core: 2 kern.smp.cpus: 64 kern.smp.disabled: 0 kern.smp.active: 1 kern.smp.maxcpus: 256 kern.smp.maxid: 63 Antoine