NetBSD Problem Report #59101
From www@netbsd.org Mon Feb 24 21:59:36 2025
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange X25519 server-signature RSA-PSS (2048 bits)
client-signature RSA-PSS (2048 bits))
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id 6B49F1A923A
for <gnats-bugs@gnats.NetBSD.org>; Mon, 24 Feb 2025 21:59:36 +0000 (UTC)
Message-Id: <20250224215935.684321A923D@mollari.NetBSD.org>
Date: Mon, 24 Feb 2025 21:59:35 +0000 (UTC)
From: campbell+netbsd@mumble.net
Reply-To: campbell+netbsd@mumble.net
To: gnats-bugs@NetBSD.org
Subject: cpuset.c bugs
X-Send-Pr-Version: www-1.0
>Number: 59101
>Category: lib
>Synopsis: cpuset.c bugs
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: lib-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Feb 24 22:00:00 +0000 2025
>Last-Modified: Mon Feb 24 22:15:01 +0000 2025
>Originator: Taylor R Campbell
>Release: current, 10, 9, ...
>Organization:
The NetCPU Foundaset
>Environment:
>Description:
1. common/lib/libc/sys/cpuset.c is all under #ifndef _KERNEL, so it has no reason to live there; it should live instead in lib/libc/
2. missing memory barriers
>How-To-Repeat:
code inspection
>Fix:
1. move from common/lib/libc/ to lib/libc/
2. change `if (cpuset_size == 0) { ...; cpuset_size = CPUSET_SIZE(cpuset_nentries); }' to `if (atomic_load_acquire(&cpuset_size) == 0) { ...; atomic_store_release(&cpuset_size, CPUSET_SIZE(cpuset_nentries)); }' (except we don't have atomic_store_release or atomic_load_acquire exposed in userland yet)
>Audit-Trail:
From: Thomas Klausner <wiz@NetBSD.org>
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: lib/59101: cpuset.c bugs
Date: Mon, 24 Feb 2025 23:10:51 +0100
Not sure if it belongs in this bug report, but I think the API could
do with a cpuset_count() or similar that returns how many CPUs there
even are, so you can iterate over all of them easily. (No,
cpuset_size() returns something different.)
Thomas
(Contact us)
$NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2025
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.