From nobody Fri Dec 19 14:36:48 2025 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 19F0629BD80 for ; Wed, 5 Nov 2025 23:16:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762384589; cv=none; b=QPIWOfMY9UlKXJiqAycpFQY4VrGsu23DWkwGK4QlRtkY7CpMXAxLio1l9QH/bIPu84n6z7w62lngJZPW4rDT90iLtA38tw7uFRS7bnkz/FLo2w45Psgzwz0xOkNZG/OWiP8y3FjVXdvjEyVqR+IIbofuz9wyDHwfkdmZuRZ6nQI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762384589; c=relaxed/simple; bh=O+TJ1giWcgX8q8AVGe652HR0hPyTAH9TmZB/EtY9dHk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=uo8D4++ZlFEzPncKhE5yRkH4ctZmbdYdPFr10j/mLNCnB3CCEiq/lXfpX+si7mRjWh4CH+yXJbdLuFygvIsdO5yiMn0YbqXCzHJO/ECzaUwDhSB3dr4ar4YtZPG6JTXcBfBjG5lf0turgfSj1TwhGVlVYGZ1o8ubl+bFkgagAME= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=BVtUUUh/; arc=none smtp.client-ip=209.85.214.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BVtUUUh/" Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-295f937d4c3so2983895ad.3 for ; Wed, 05 Nov 2025 15:16:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1762384587; x=1762989387; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=WwAIlG6TTHwluLnC19ePK0hNp9oFcPVSx2rVuCQMRhQ=; b=BVtUUUh/aDbMLHmIIZEDEYstH8FyN9cBcBDRcNaoeie1FSYuNLgX0mmt6J8yztSVnb XwNFGxGV/bt/BUd1veam0dyIYGYk6Hci5+wc+vBjJy/BXQUAGmUpH4F4uwFkh4HakOW1 NvEhLZasBsPHpVqq6juCtqGtTDAlQKF03RafmsOCuAh9kxI5dRKS09nd7hdDpb2CYHLV zCVhOVChyYKM1GirGBTYGphqemQEf9OAcmFhx/xEBgsme81ZziRoXSLEXmf2egHI1iPe NZg7zU73/lFXqn7RNDnJxCpe2S4mRManvhNZeME9rO/NLLV2/ggdnGUgC5HIL4snj/RZ pypg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762384587; x=1762989387; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WwAIlG6TTHwluLnC19ePK0hNp9oFcPVSx2rVuCQMRhQ=; b=AjZh7Ky51tby1i5wezCti4iafyCLpOVD9Ak77F7hS1ve8Vz1p+d5nTq+qU5YziZYEU FFtN3eNhjO4KYDSlN2pGylX3pZmf+vHgiaqMBqRzSpBmeM8idHCdb82QnKTysATEjBqz JbKXoweuA+L1InSNSdE14ZJBw3T78fqn8gFEWMLVl+j26tzdW9XtcRUl49IJvqwEzAPc 8KRL6qee2ndHbrGg47bRT3g2m2Sd5rQ9H9xs6oddLlWHSovv2r665lVDfjtPDl49NKc0 HSVBnDS4L02DczHecHyP0b92A03hMZ0uvsKkLqos8eLcwUXr2uILBVDjBSy98nyutVT7 qowQ== X-Forwarded-Encrypted: i=1; AJvYcCWDnbaR1AlTJ7WJ8zd1mrJjSCzqzamTXQr/AiIguqzsrqK+HcDXQx1FFJQtDh2itxokaERzOacFOvbkesQ=@vger.kernel.org X-Gm-Message-State: AOJu0YzPXkMIoX+1r/Pic8kx4v/iEgUDK4Xfom7lUw4nJWFT6k+72w/B 6Tsf4XcFkKahz5MZiLuLG2668GjSLqCPD5nTbBgAPRHD2Tm8vYVA6KxH X-Gm-Gg: ASbGncuZP5bb2TU+/2AeFEF2yXrGTeBlFN/Z2e3WjqAx0qPidIB7RSTPrtkxdqBDbw5 d7tuRgCnY5bdxHDbmudqkASYdQG3/m1R1PToi2HXuINqc5KxnV2+iTMDGNsfpgO4S7aTiZ2A/8J KpOoJNufNgxneby7cnw+t/gbneRFL2z6+QK4Fbq6vZCFaFndMPUohKJVts7JBW+nhLWAOAGiO1S wFdYX91me1BQKzqCLJ8FROvC8cvb/AyJvdQIOoPdSqbygAfIShzRdV3Bm1xpodt4yAwWIOatOIZ BTi4/zHB1s+DZtyrXjc5lA8kOiMnxevnphEjSDZJRlgPpDdoT1AqnqaLzpEoP2zUo0ZlrQU/7E7 7K5Bxjq9q46Vi8+7qF8FPXexi2EoVTVRBhvUBkG0kka9attK0Dnh5RlvYVXGCxSfv9QY26saWgg T/azle/PsfFiYQ5Ci4NNvR X-Google-Smtp-Source: AGHT+IEepHklLDAxqKXJps4E9hwL8Bs3tisjtWzu/YVvcP91A5CkpsqwgRxYF4+8t3q3DKAyo0BvYA== X-Received: by 2002:a17:902:ea10:b0:295:24ab:fb08 with SMTP id d9443c01a7336-2962adb27d6mr72654555ad.47.1762384587205; Wed, 05 Nov 2025 15:16:27 -0800 (PST) Received: from mitchelllevy.localdomain ([131.107.1.211]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-29651c93ce0sm6391925ad.88.2025.11.05.15.16.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Nov 2025 15:16:26 -0800 (PST) From: Mitchell Levy Date: Wed, 05 Nov 2025 15:16:14 -0800 Subject: [PATCH 1/2] rust: cpumask: Add a `Cpumask` iterator Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251105-cpumask-iter-v1-1-7536f906d7ed@gmail.com> References: <20251105-cpumask-iter-v1-0-7536f906d7ed@gmail.com> In-Reply-To: <20251105-cpumask-iter-v1-0-7536f906d7ed@gmail.com> To: Yury Norov , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Viresh Kumar Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Mitchell Levy X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1762384584; l=2630; i=levymitchell0@gmail.com; s=20240719; h=from:subject:message-id; bh=O+TJ1giWcgX8q8AVGe652HR0hPyTAH9TmZB/EtY9dHk=; b=sTFswU9v+NtwvD+1ATeGBxN3/kjtiLHvd6VJ9Q0ZY2hC8iqQZALO24cBW53aj3K6RF0bQCBqb G5lUorisoS2CtF+TJVAineCbVSChP8vZR54FiCfFK5HTHuvH8txb4Wx X-Developer-Key: i=levymitchell0@gmail.com; a=ed25519; pk=n6kBmUnb+UNmjVkTnDwrLwTJAEKUfs2e8E+MFPZI93E= Add an iterator for `Cpumask` making use of C's `cpumask_next`. Acked-by: Viresh Kumar Signed-off-by: Mitchell Levy --- rust/helpers/cpumask.c | 5 +++++ rust/kernel/cpumask.rs | 48 ++++++++++++++++++++++++++++++++++++++++++++++= +- 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/rust/helpers/cpumask.c b/rust/helpers/cpumask.c index eb10598a0242..d95bfa111191 100644 --- a/rust/helpers/cpumask.c +++ b/rust/helpers/cpumask.c @@ -42,6 +42,11 @@ bool rust_helper_cpumask_full(struct cpumask *srcp) return cpumask_full(srcp); } =20 +unsigned int rust_helper_cpumask_next(int n, struct cpumask *srcp) +{ + return cpumask_next(n, srcp); +} + unsigned int rust_helper_cpumask_weight(struct cpumask *srcp) { return cpumask_weight(srcp); diff --git a/rust/kernel/cpumask.rs b/rust/kernel/cpumask.rs index 3fcbff438670..b7401848f59e 100644 --- a/rust/kernel/cpumask.rs +++ b/rust/kernel/cpumask.rs @@ -6,7 +6,7 @@ =20 use crate::{ alloc::{AllocError, Flags}, - cpu::CpuId, + cpu::{self, CpuId}, prelude::*, types::Opaque, }; @@ -161,6 +161,52 @@ pub fn copy(&self, dstp: &mut Self) { } } =20 +/// Iterator for a `Cpumask`. +pub struct CpumaskIter<'a> { + mask: &'a Cpumask, + last: Option, +} + +impl<'a> CpumaskIter<'a> { + /// Creates a new `CpumaskIter` for the given `Cpumask`. + fn new(mask: &'a Cpumask) -> CpumaskIter<'a> { + Self { mask, last: None } + } +} + +impl<'a> Iterator for CpumaskIter<'a> { + type Item =3D CpuId; + + fn next(&mut self) -> Option { + // SAFETY: By the type invariant, `self.mask.as_raw` is a `struct = cpumask *`. + let next =3D unsafe { + bindings::cpumask_next( + if let Some(last) =3D self.last { + last.try_into().unwrap() + } else { + -1 + }, + self.mask.as_raw(), + ) + }; + + if next =3D=3D cpu::nr_cpu_ids() { + None + } else { + self.last =3D Some(next); + // SAFETY: `cpumask_next` returns either `nr_cpu_ids` or a val= id CPU ID. + unsafe { Some(CpuId::from_u32_unchecked(next)) } + } + } +} + +impl Cpumask { + /// Returns an iterator over the set bits in the cpumask. + pub fn iter(&self) -> CpumaskIter<'_> { + CpumaskIter::new(self) + } +} + /// A CPU Mask pointer. /// /// Rust abstraction for the C `struct cpumask_var_t`. --=20 2.34.1 From nobody Fri Dec 19 14:36:48 2025 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 02A4B2F4A12 for ; Wed, 5 Nov 2025 23:16:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762384590; cv=none; b=He275x8l0WJkJF7eoWMhKIs6a4UqK/cXxnZQLvQmHSGNRJRvrPXMLKEwbPZ/WtulqGk3NjtIX1F+47z6zvAhIbp+HHWhiWU4hFlbqhTYhZiZEs7mZK0a+sc1nfgyevd04A1f84568Lw8UcvDPJEYVWH8jN7tKFudKYp0CJpKuT0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762384590; c=relaxed/simple; bh=YISdcADBQqzuvoNcCs3nt3kan2jGJvuSVytELmc4hYw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EddsDd3ZVMcjuFbMGEAaCuQh3j3JGHOSkD3V7yQBT3UFcVqXwxB6sO5OZy6u9m+jCD/IZFSZUeW99e7mmgWYeNu2xDIzsKdDD3k1YImQRiDxg9oNUz80brDdsUHQCV35cpj1pPb17SZYOKfzR0jzUrWvCU6SuRbNC1KBj4bP0xo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=FiFn2Kb2; arc=none smtp.client-ip=209.85.214.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FiFn2Kb2" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-29568d93e87so3684275ad.2 for ; Wed, 05 Nov 2025 15:16:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1762384588; x=1762989388; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=N6ObyT3Tt6gveKOeNa7NjmSIElr//qB7g+FJoPS22Qs=; b=FiFn2Kb2islhrWGo1x7AtCiM6O/QxzCAQGMxOa3dQrvZbEfcdFTWIn/VkKOPh7ISar b4Lx8OOiet/FwnLJDrzbD6pv9dWPCAevDeH54T/+2yC/5Ms//tRqOAQPMwfG//t6VsFW 03fnb+GYRQVfby4d1d6A5mUcxBYR4Uw0b1FpSEMprU2X/ZJcLuG+ZN/nVHVUMacvYjjg AaqyaL/+yGGVSuq33iJ2oU0JT+UhjGC3BRHzaJBsDmQnkyKQSlp2SKfFc8jnI+zb/oR9 5fA+FsnY2J8xpGdcgnDPAJxnND6twCihak9H9cvGQ9fs0FugkLxG6Wsto6beOIKVe87E Vx4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762384588; x=1762989388; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=N6ObyT3Tt6gveKOeNa7NjmSIElr//qB7g+FJoPS22Qs=; b=oYMkWfOuHRiSdmZODDk/P8W+0wIW09qOKXJW7R0jOC0Muh08CIHmqeU06zExaadmvc jNAqsQ5US6K5dVuxmH/mUTQ7e9KZAqpgmDsYWNPUrDctRdS3zypRl9P4IMp4Ux0xGKwV BOjYezTZ+YvIwUT65wh/sZaWKfWmmOfxzr7FpVMBJTDhaQS0vnZIFjQB+/y37TSYPMQj cFCTUVSupi4zAU40W5qXY8ZkpniHsb+bp3tW9uuRnpObBRZjvo74OTr9HlMhOweC2qrj PVmEOV7BPm4zK8YMC8qyoP0BWDpkvfI6n6dRkArm/4QZrWhwHr83k6I8/9A+PxboL5PA iTzQ== X-Forwarded-Encrypted: i=1; AJvYcCX0KrZ6PBzSs33w7TsqB+nmOLhnqE00L1OLTaNdUztvWgvFL1AIYB+xZch4eYW2vCo3c7+WStM3xbIq358=@vger.kernel.org X-Gm-Message-State: AOJu0YxrtsnQCKCFZpU970k9d5kkC3KmKAcsO9HmfkypvE1gER37XJh7 15/Eu7kZeSfeEzxcokNOlyixDy1/ReltktZSE1CuDaAlmjyjSXsyXfKU X-Gm-Gg: ASbGncvMvuNpvSXrY5gqk7XEIPQzzOlE1ux5p6bVkbgSt+7nThgF+AmJ/ZfeZahFU/1 9BaDNnxmspwivRnlmgW1KZoNrSb92A87tA8LGQU/iN5o211kJam/XuhjqifKlT66tGkqIAI48A+ Pdw6X/8T7KOJj8DvXjyhqJC3yrFYFm/B1RPYnliIMjhAdnJuI72DsziuADbMSu6+OL+XEyKcfN8 n8RxRE6YZG4OyORaE9iz2CdXJZFkQcYyk0Y09CT2XIyTD30yg54kjB6NXmnf0/kDEQq4DjfwXnn jrrrUZ8fGH+/zkmJx30KO/vlLIP6eGoQysfFTw8TFZniq2AlcBAskicUaEJeALnVPbXKaMxfFM9 CWrgZ0Dii/ssG0DQITD/MDCHi8T59VmwNcN4fkctHEzP0y/6IsTgWzu11kz2Fi8+tVf+FQ3NCug 6xL1ziXXlP7J7dT1iE5yoa6qurYyZ/3d4= X-Google-Smtp-Source: AGHT+IErnpQ9NEon4sLnfm43ewHu1WQPnKlmXQx64IUma2bPMa0syB8oJXoKEKJnh6FdaNt8aobyMg== X-Received: by 2002:a17:902:ce91:b0:295:bba8:3c4d with SMTP id d9443c01a7336-2962ae4c366mr66913885ad.35.1762384588147; Wed, 05 Nov 2025 15:16:28 -0800 (PST) Received: from mitchelllevy.localdomain ([131.107.1.211]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-29651c93ce0sm6391925ad.88.2025.11.05.15.16.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Nov 2025 15:16:27 -0800 (PST) From: Mitchell Levy Date: Wed, 05 Nov 2025 15:16:15 -0800 Subject: [PATCH 2/2] rust: cpumask: Add getters for globally defined cpumasks Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251105-cpumask-iter-v1-2-7536f906d7ed@gmail.com> References: <20251105-cpumask-iter-v1-0-7536f906d7ed@gmail.com> In-Reply-To: <20251105-cpumask-iter-v1-0-7536f906d7ed@gmail.com> To: Yury Norov , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Viresh Kumar Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Mitchell Levy X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1762384584; l=3255; i=levymitchell0@gmail.com; s=20240719; h=from:subject:message-id; bh=YISdcADBQqzuvoNcCs3nt3kan2jGJvuSVytELmc4hYw=; b=uWbL7USdtFPgH46WxrNbQZ+7YvwlQnivbiloF3uMV8bMyInBPeqFjbQKvOxXYBDa7D6TidaKB dNHrZoxQBYzA/019iZJHr8ErSir7cF+0H6gpVhXBhlzP00RmajPrcVx X-Developer-Key: i=levymitchell0@gmail.com; a=ed25519; pk=n6kBmUnb+UNmjVkTnDwrLwTJAEKUfs2e8E+MFPZI93E= Add getters for the global cpumasks documented in `include/linux/cpumask.h`, specifically: - cpu_possible_mask - cpu_online_mask - cpu_enabled_mask - cpu_present_mask - cpu_active_mask Acked-by: Viresh Kumar Suggested-by: Yury Norov Signed-off-by: Mitchell Levy --- rust/kernel/cpumask.rs | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/rust/kernel/cpumask.rs b/rust/kernel/cpumask.rs index b7401848f59e..a6a130092fcb 100644 --- a/rust/kernel/cpumask.rs +++ b/rust/kernel/cpumask.rs @@ -77,6 +77,52 @@ pub unsafe fn as_ref<'a>(ptr: *const bindings::cpumask) = -> &'a Self { unsafe { &*ptr.cast() } } =20 + /// Get a CPU mask representing possible CPUs; has bit `cpu` set iff c= pu is populatable + #[inline] + pub fn possible_cpus() -> &'static Self { + // SAFETY: `__cpu_possible_mask` is a valid global provided by the= kernel that lives + // forever. + unsafe { Cpumask::as_ref(&raw const bindings::__cpu_possible_mask)= } + } + + /// Get a CPU mask representing online CPUs; has bit `cpu` set iff cpu= available to the + /// scheduler + #[inline] + pub fn online_cpus() -> &'static Self { + // SAFETY: `__cpu_online_mask` is a valid global provided by the k= ernel that lives forever. + // Since we wrap the returned pointer in an `Opaque`, it's ok that= `__cpu_online_mask` + // may change its value. + unsafe { Cpumask::as_ref(&raw const bindings::__cpu_online_mask) } + } + + /// Get a CPU mask representing enabled CPUs; has bit `cpu` set iff cp= u can be brought online + #[inline] + pub fn enabled_cpus() -> &'static Self { + // SAFETY: `__cpu_enabled_mask` is a valid global provided by the = kernel that lives forever. + // Since we wrap the returned pointer in an `Opaque`, it's ok that= `__cpu_enabled_mask` + // may change its value. + unsafe { Cpumask::as_ref(&raw const bindings::__cpu_enabled_mask) } + } + + /// Get a CPU mask representing present CPUs; has bit `cpu` set iff cp= u is populated + #[inline] + pub fn present_cpus() -> &'static Self { + // SAFETY: `__cpu_present_mask` is a valid global provided by the = kernel that lives + // forever. Since we wrap the returned pointer in an `Opaque`, it'= s ok that + // `__cpu_present_mask` may change its value. + unsafe { Cpumask::as_ref(&raw const bindings::__cpu_present_mask) } + } + + /// Get a CPU mask representing active CPUs; has bit `cpu` set iff cpu= is available to + /// migration. + #[inline] + pub fn active_cpus() -> &'static Self { + // SAFETY: `__cpu_active_mask` is a valid global provided by the k= ernel that lives forever. + // Since we wrap the returned pointer in an `Opaque`, it's ok that= `__cpu_active_mask` + // may change its value. + unsafe { Cpumask::as_ref(&raw const bindings::__cpu_active_mask) } + } + /// Obtain the raw `struct cpumask` pointer. pub fn as_raw(&self) -> *mut bindings::cpumask { let this: *const Self =3D self; --=20 2.34.1