From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qv1-f47.google.com (mail-qv1-f47.google.com [209.85.219.47]) (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 0120A33B6E9 for ; Sun, 11 Jan 2026 12:02:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768132950; cv=none; b=taKNdHeGlKfV/c7piFvg04PNUW311w0SIlVTakwGbi9IrOwQ2ulzyLoZEBAt7uwdV4jv8pUgyAtp6eog5QquAK5Pyui+hGre+bQ142EcK9ocR1zdqkzP+mU+bULGy3XfZnsYKCxOiUFTUxVq01dW6ITRKH6Cchipkn/0isck3SQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768132950; c=relaxed/simple; bh=tA8WSnFev3PqsJMCN28WcDg8n5GCieuM0ZLEg+l/zQs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FFIbpyT/IU8o3g6KnfS7zFh4uCSMl/mGpu68nr7NSbBlUDJyuyPMEiBTxEo+mUXMocMZosMxYL7CNoIvqBExSNVFJEuzeamAygPHXO+7DHBEdtTgOs5J0yqjFO8XyICP6zNOyjsdofmEEOCbfMu8kxv+3RspXO8OqbB4/8dUNuo= 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=krrqhczq; arc=none smtp.client-ip=209.85.219.47 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="krrqhczq" Received: by mail-qv1-f47.google.com with SMTP id 6a1803df08f44-88a3d2f3299so65943596d6.2 for ; Sun, 11 Jan 2026 04:02:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768132948; x=1768737748; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:feedback-id:from:to:cc:subject :date:message-id:reply-to; bh=Fbl+ZOYOSkLBAoxkQYcc6P4fQm3wpIW6+HUNF874534=; b=krrqhczqRrFr5J3aXn7oSRIUFO6QFWDYhvW8j92klE++O8FXu6LSKq6hMagBav24tD L9Ii4/OKGRkIDCKgRufJaMNqz6oZpP0pAJu5GWeb37ZOLpqg9r5/YG+4fYLDA0AszlkC 5kIQMyEjUcTZq7Ly5KMeDsjxVz7B9Z19EZdDNvRM091bHvPvVT8x/l5Y1e5MxzkCbHwk JkxxE+EJb2erGP/wvQ0N75dPoW1Vrg2XmIl68hSqMNr8okcBga0JpJ/UblLICTFHfde4 J8fHHmydVuXbhGsDQTje81khh16sajyVr2vF2uSl+QTEQppXN98nRbkNMDQbarM4kKhf bP0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768132948; x=1768737748; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:feedback-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Fbl+ZOYOSkLBAoxkQYcc6P4fQm3wpIW6+HUNF874534=; b=eEYze3rb13OA0goXDBkewfVNdRbYQqzERr9eMibwZhd+A3sTuuuI0TbVrPeHPRmaEW NXOhNiRw6K3ZaEmzspGc4XTwtJ/SBNJ0Ty3Yu8j4GLpQbov0esVCYEgQfT5j+7pOMH4E uhlaJSfSPuZYqdGm3v3canHcSvxKE/SdBOLDFZ2gs4Q5jTyoCYpHoWz9T55OiGDn3R/Y X7BP5LkPACrQUrl5lhr8zrAtF8I0vwYSEZijj54DYQCpbv16mryLsuncoPXUCv2IzQSz nBP0GcXUq0qDh97Rq1FfraixTqH7Bs4j3y7XQTfKOxd+ra8D646gUSmEGDyEaB2TO9nj IYuQ== X-Forwarded-Encrypted: i=1; AJvYcCW0Khnhsv6Z3sR/07BEx3G3T0ffBdwogCpBuLcnl45DA0BlHdoLRrsylpPO7rZPXP7xrfXfl+GeavGQgho=@vger.kernel.org X-Gm-Message-State: AOJu0YwvmmAleeMbsANfQn7xTRQdjuKVxmPCJ62bqsWsg5VUOfgZyzcg GVBTAzwd/i/ljdHleXy1QHboeMcZDNnVXc0o1NAOHi4374TKD9M3YOSD X-Gm-Gg: AY/fxX5zeRouSWOnNl+66DUsprikhIo3lwV5BpLZ/XB6alzIvj6kqZoE2gz7tH+2bf2 SVy1tz7otu7Q3g+Rb1GdvoaEZVC2MDICH9C+UaoKLvHfPl5J6gu1HZaJRYYL8GigQVPqjxdOGOT wlEkHnRFhBDsj/05l2nDfQ8tkmbXybqZn48bI5xyOyOO6qssVYcKohBnyTWU41QXq71pU8NBhnn HdgmMaGmsCjOM25/oguLtJsSaR0XCCVgP7QiZjNDQsFSs6e3q4WJGp7a+OwSLdDrJcqGzJ6jCjO /GLhxji1DFoR58DzTZ6B+JnFBEeKzTrm7wYIkBB42bokRORvNsUm271u64lHYXXmqhRO/E/2Nqp oUsZchdLFArCc25UZgCc1Srehj+lz2ZbImHYaxvjiFYQ8/pCLkjGJEwZytYAqqtHSq/h4hq9/v1 xQigacMcQu7QkIivCKL2Y/LpzTKSI8wr+296DsIi+7Xr0F5lF+YnSQCLE/+UFkiJChDwPG+2Asu 0oVt7i30fzArNI= X-Google-Smtp-Source: AGHT+IHkzElXUUJuscQ/wDDpK92Hh4txXMepRXC/UngYSNhWXXGPfBZwtZ5jPxjFCa5XmtTe+6dw+g== X-Received: by 2002:a05:6214:492:b0:890:60f:f8ed with SMTP id 6a1803df08f44-8908418eefemr221418256d6.19.1768132947658; Sun, 11 Jan 2026 04:02:27 -0800 (PST) Received: from fauth-a2-smtp.messagingengine.com (fauth-a2-smtp.messagingengine.com. [103.168.172.201]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8907724ef14sm116797236d6.38.2026.01.11.04.02.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Jan 2026 04:02:27 -0800 (PST) Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfauth.phl.internal (Postfix) with ESMTP id B1D3AF40068; Sun, 11 Jan 2026 07:02:26 -0500 (EST) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-05.internal (MEProxy); Sun, 11 Jan 2026 07:02:26 -0500 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgdduudeghedvucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepuehoqhhunhcu hfgvnhhguceosghoqhhunhdrfhgvnhhgsehgmhgrihhlrdgtohhmqeenucggtffrrghtth gvrhhnpedvveekvddtffelffelfedvudefffeuheejgeeivedufffgledvgeduveffueeh leenucffohhmrghinhepmhhsghhiugdrlhhinhhknecuvehluhhsthgvrhfuihiivgepud enucfrrghrrghmpehmrghilhhfrhhomhepsghoqhhunhdomhgvshhmthhprghuthhhphgv rhhsohhnrghlihhthidqieelvdeghedtieegqddujeejkeehheehvddqsghoqhhunhdrfh gvnhhgpeepghhmrghilhdrtghomhesfhhigihmvgdrnhgrmhgvpdhnsggprhgtphhtthho peduiedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepphgvthgvrhiisehinhhfrh gruggvrggurdhorhhgpdhrtghpthhtohepmhhinhhgoheskhgvrhhnvghlrdhorhhgpdhr tghpthhtoheprhhushhtqdhfohhrqdhlihhnuhigsehvghgvrhdrkhgvrhhnvghlrdhorh hgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdho rhhgpdhrtghpthhtohepfihilhhlsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehmrg hrkhdrrhhuthhlrghnugesrghrmhdrtghomhdprhgtphhtthhopehtghhlgieslhhinhhu thhrohhnihigrdguvgdprhgtphhtthhopehojhgvuggrsehkvghrnhgvlhdrohhrghdprh gtphhtthhopehgrghrhiesghgrrhihghhuohdrnhgvth X-ME-Proxy: Feedback-ID: iad51458e:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 11 Jan 2026 07:02:26 -0500 (EST) From: Boqun Feng To: "Peter Zijlstra" , "Ingo Molnar" Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, "Will Deacon" , "Mark Rutland" , "Thomas Gleixner" , "Miguel Ojeda" , "Gary Guo" , "Alice Ryhl" , "Andreas Hindborg" , "Benno Lossin" , "Danilo Krummrich" , FUJITA Tomonori , Joel Fernandes , Boqun Feng Subject: [PATCH 06/36] rust: helpers: Add i8/i16 relaxed atomic helpers Date: Sun, 11 Jan 2026 20:01:39 +0800 Message-ID: <20260111120209.6133-4-boqun.feng@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260111120209.6133-1-boqun.feng@gmail.com> References: <20260111115808.5702-1-boqun.feng@gmail.com> <20260111120209.6133-1-boqun.feng@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: FUJITA Tomonori Add READ_ONCE/WRITE_ONCE based helpers for i8 and i16 types to support relaxed atomic operations in Rust. While relaxed operations could be implemented purely in Rust using read_volatile() and write_volatile(), using C's READ_ONCE() and WRITE_ONCE() macros ensures complete consistency with the kernel memory model. These helpers expose different symbol names than their C counterparts so they are split into atomic_ext.c instead of atomic.c. The symbol names; the names make the interface Rust/C clear, consistent with i32/i64. [boqun: Rename the functions from {load,store} to {read,set} to avoid future adjustment] Signed-off-by: FUJITA Tomonori Reviewed-by: Gary Guo Reviewed-by: Joel Fernandes Signed-off-by: Boqun Feng Link: https://patch.msgid.link/20251211113826.1299077-3-fujita.tomonori@gmail.com --- rust/helpers/atomic_ext.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/rust/helpers/atomic_ext.c b/rust/helpers/atomic_ext.c index 1fb624147aa4..02e05b4246ae 100644 --- a/rust/helpers/atomic_ext.c +++ b/rust/helpers/atomic_ext.c @@ -1,22 +1,43 @@ // SPDX-License-Identifier: GPL-2.0 #include +#include + +__rust_helper s8 rust_helper_atomic_i8_read(s8 *ptr) +{ + return READ_ONCE(*ptr); +} __rust_helper s8 rust_helper_atomic_i8_read_acquire(s8 *ptr) { return smp_load_acquire(ptr); } +__rust_helper s16 rust_helper_atomic_i16_read(s16 *ptr) +{ + return READ_ONCE(*ptr); +} + __rust_helper s16 rust_helper_atomic_i16_read_acquire(s16 *ptr) { return smp_load_acquire(ptr); } +__rust_helper void rust_helper_atomic_i8_set(s8 *ptr, s8 val) +{ + WRITE_ONCE(*ptr, val); +} + __rust_helper void rust_helper_atomic_i8_set_release(s8 *ptr, s8 val) { smp_store_release(ptr, val); } +__rust_helper void rust_helper_atomic_i16_set(s16 *ptr, s16 val) +{ + WRITE_ONCE(*ptr, val); +} + __rust_helper void rust_helper_atomic_i16_set_release(s16 *ptr, s16 val) { smp_store_release(ptr, val); -- 2.51.0