From nobody Sat Apr 11 04:50:31 2026 Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) (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 274FC387373 for ; Fri, 10 Apr 2026 21:36:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775856985; cv=none; b=Yoa4m0mKzUdCk4zBrsqzO/yASBYA+slJaM2jGaLC6GI0qIFP0nrr0bPMhBIiHK4CKcmrcy5d3iBGqWFNE20hcwIJ2VrvDeXYz26V2YxZ8CmHYBbguRkbRNNRij8Qnf2kI7ZHUVhTBazJnemBguZJ14E1OYz/MKebZuJWEo6KlOE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775856985; c=relaxed/simple; bh=LiqeN21hmlSzqeftoSl/GLCyPQV5RGEp+g7qmLBlTQE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mK0lEx4w44rYJiU4VvifVpufyCkQkoiSk7I7IKe9dvuBamZon4qmWpGuxHS5FXezS1lkUVIlVCBygYVJ1Sf+DprkaJFrlQFST852DVNaF/UoS1Fp9imkg6rTEAvwMh7rvlLkD/GK6M3yhjRPJSI2hYS6CNVwXZCDLYKT0lYsLLI= 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=pkbSpYJX; arc=none smtp.client-ip=209.85.215.169 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="pkbSpYJX" Received: by mail-pg1-f169.google.com with SMTP id 41be03b00d2f7-c7358a7a8d1so1701352a12.3 for ; Fri, 10 Apr 2026 14:36:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775856983; x=1776461783; 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=F+v45jw94JRi1dGGjjK8/w5xNCSncG1F0hGpE1jyeuw=; b=pkbSpYJXMWNg9DxqVm1BknGvL/jGfYBVdr9n6aAf+bAS67/PbwQK/5DbhiRMsMSSGl sTeskc/I+vbidZBKQ0CnRGCdvZOvbjy5TCDnVLeWMtZU70cGv6cL2gPNSIA/vok0BokC tHiddl6L9/ZZhmAY2UVxqgjuPm6aJhb0X/SLNeS4udtWFjlEp4u0vk02oSjid5Yt4HT4 OeThRKXEcZ2MCwlmpo2uZSwc5Rap0k8ZGs9trieYf25Ez/DJdT4HlOpY59HtYFU4urMN buuzb8aYkLjzYW1dpgH/uzQLbGoFsng9vJfq5C0AmFE6EpL059pLDVpt4amNPHIJVQxL IeyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775856983; x=1776461783; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=F+v45jw94JRi1dGGjjK8/w5xNCSncG1F0hGpE1jyeuw=; b=Z6phA4G/RJpHx18cx33UruC+23GOXHpYzz1bKnT8MYsMkG613Tvcj9V35P9fbop1Ln 2cXQkjgJpPoq8iUzuvTcYWDLrQe9GCLqZhfHbKC0gpcy10ZyWW9jDeRDSHGbJ2d3STHW VNR3Zh/VcSpGP4HqovGofG5ob538DThj2Q/1Lt4piIM35l6Y7WrCgFOVipDNLCkUjLRg Pbw3fHDNIxa6CB6riBWWUXFwYQr2Rky6XyE/vC9BWnPXgLLedYF96LG5APZeLke2kMu0 ckGbp5sYDHpIYkeEZxjNR8r2kf1JXlqgMOC1UY7hlLSpPdMn63bJrHvshUSYOwV7hLbS kSdQ== X-Forwarded-Encrypted: i=1; AJvYcCUbo7Ix8fdI3+rVK+aanmDzXsiKwzE2kD+lpAVdiPkpdmYeng0kL859h4Kh0NhInBKjQT0I/xXrtBX+ayw=@vger.kernel.org X-Gm-Message-State: AOJu0YwCdqnqd3PSssyKgPF01vF62an9ewowCX4XlE2wJT4nrEb2r7qH WRTZvtcIhD0BXryiGAnN+PACGM4+t1lKWAB+zcsICLbNHlIDDVWihguK X-Gm-Gg: AeBDiesREK5Vwp/t4Cdl8lHDUvH37RGqdCwrfnI4/zYY+jpyEBPSz9M6T6XYuQj1nzy IXlZYEceocdbAH1YbeH9QDq1jerwsx1LKzal/Cpbr1+F6mxnHqBP5FKOVYIqYzFRU1wHGJlrSLj MwOz9mXszeu54DvYCA1lmQ9PPuIAFIopQ5sCEbRXit+aEKgGwQ+fGMKm6Fzw7vLlBm+BtL0FJoU YFpGcBBHqoyLYOFUFYs4OosUli3tK+pA6vi0knQh1Y71tS1yr/23DD0uZTeqQmEbqi5MH4ctKX8 d+roDewBddawix9it0+GR/N2/uISB2tVd2GzGiH2JqcZUrZNXx7xpPg42h54wuQ1AFD289OQYY1 eosbQoUzFro9ifp3fauPDPCjtCA847GYnz12qfdh+zHTkSS6HIGMTkTHHjnCXMDuBHc3EZr4n56 l3zCEqLMfEW3WgKaS3++if1+Nbb/QgmIfe2KzSjTnLS5p5 X-Received: by 2002:a05:6a00:2d1c:b0:82c:9897:70e0 with SMTP id d2e1a72fcca58-82f0c37f54bmr5055454b3a.47.1775856983472; Fri, 10 Apr 2026 14:36:23 -0700 (PDT) Received: from mitchelllevy.localdomain ([131.107.1.135]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82f0c4e3d41sm5111551b3a.48.2026.04.10.14.36.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Apr 2026 14:36:22 -0700 (PDT) From: Mitchell Levy Date: Fri, 10 Apr 2026 14:35:33 -0700 Subject: [PATCH v5 3/8] rust: percpu: Add C bindings for per-CPU variable API 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: <20260410-rust-percpu-v5-3-4292380d7a41@gmail.com> References: <20260410-rust-percpu-v5-0-4292380d7a41@gmail.com> In-Reply-To: <20260410-rust-percpu-v5-0-4292380d7a41@gmail.com> To: Miguel Ojeda , Alex Gaynor , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Andreas Hindborg , Alice Ryhl , Trevor Gross , Andrew Morton , Dennis Zhou , Tejun Heo , Christoph Lameter , Danilo Krummrich , Benno Lossin , Yury Norov , Viresh Kumar , Boqun Feng Cc: Tyler Hicks , Allen Pais , linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-mm@kvack.org, Mitchell Levy X-Mailer: b4 0.15.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1775856978; l=1610; i=levymitchell0@gmail.com; s=20240719; h=from:subject:message-id; bh=LiqeN21hmlSzqeftoSl/GLCyPQV5RGEp+g7qmLBlTQE=; b=iUFnR3cUvYb+VI/DXA9Z3DypclDwajbL3MjM2j/sG8C8YCvKAUERXgFjlgI8fe1xS0FPR8yPj FaOyoJZfdzvBlVouoUriBmn4xf9cq/lvTRJ74Z9sbo/4C+GjPyslY/f X-Developer-Key: i=levymitchell0@gmail.com; a=ed25519; pk=n6kBmUnb+UNmjVkTnDwrLwTJAEKUfs2e8E+MFPZI93E= Add bindings necessary to implement a Rust per-CPU variable API, specifically per-CPU variable allocation and management of CPU preemption. Signed-off-by: Mitchell Levy --- rust/helpers/helpers.c | 2 ++ rust/helpers/percpu.c | 9 +++++++++ rust/helpers/preempt.c | 15 +++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/rust/helpers/helpers.c b/rust/helpers/helpers.c index e05c6e7e4abb..af661bb9be34 100644 --- a/rust/helpers/helpers.c +++ b/rust/helpers/helpers.c @@ -70,9 +70,11 @@ #include "of.c" #include "page.c" #include "pci.c" +#include "percpu.c" #include "pid_namespace.c" #include "platform.c" #include "poll.c" +#include "preempt.c" #include "processor.c" #include "property.c" #include "pwm.c" diff --git a/rust/helpers/percpu.c b/rust/helpers/percpu.c new file mode 100644 index 000000000000..463186b8af9d --- /dev/null +++ b/rust/helpers/percpu.c @@ -0,0 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include + +__rust_helper +void __percpu *rust_helper_alloc_percpu(size_t sz, size_t align) +{ + return __alloc_percpu(sz, align); +} diff --git a/rust/helpers/preempt.c b/rust/helpers/preempt.c new file mode 100644 index 000000000000..77dd5f10d8dc --- /dev/null +++ b/rust/helpers/preempt.c @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include + +__rust_helper +void rust_helper_preempt_disable(void) +{ + preempt_disable(); +} + +__rust_helper +void rust_helper_preempt_enable(void) +{ + preempt_enable(); +} --=20 2.34.1