From nobody Sun Feb 8 22:58:13 2026 Received: from mail-qv1-f41.google.com (mail-qv1-f41.google.com [209.85.219.41]) (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 8E26450095C for ; Sun, 11 Jan 2026 12:02:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768132941; cv=none; b=Z1sdwqkK48WP2kNilRjEwOOvCdJF1WggCNQ4Sjsyis/Ih9LTgLkTKdD8Rkrciw0MS0C9CSTg2xGRShK+gVz0YZ01BGETNkkZbnKHRcVVPppPr2JGsr//oVseGzZzwgt6l/Nn2lSuKPaEOwFJ1PpIaQEHZeoSEucG52NRlJQURuM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768132941; c=relaxed/simple; bh=J8jEqYImou1342n+h9orCB4S2P8EKiJpYHDWIeigkz0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AiLWeAz6r45I1KMGt0rQWdiGCoZnobB6hV8jNZbiPz2C3ZjzX/r4gvSn2UqumVmYvqsPpU40qWyDatPSSZgpqNsqFldkqNGFe4btYX5s81cYAUkrWhN+tcEpAH44P2quZIQFd/nygipcKNXA0sm7lzK2XX+VpyXnrgS1qYcmaB8= 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=d8U0pc68; arc=none smtp.client-ip=209.85.219.41 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="d8U0pc68" Received: by mail-qv1-f41.google.com with SMTP id 6a1803df08f44-88a37cb5afdso53472036d6.0 for ; Sun, 11 Jan 2026 04:02:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768132939; x=1768737739; 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=NZHFKyJrPzbKT61vScnyjQJctx0QqGgZF1Rj9YqOnNQ=; b=d8U0pc68WOJ6XbON4inInM0GWbtq1VdWw82d9N88CPO8EoyQtRdw/mOKTOAaoVMonC TJIya5YZ9YTVwgbDAlAPz2VZRFKAtWTxSXrWz6nzxZNMe97Jf0/lP+PflCor95EKUq3S Xrwdc+/DMYU+pgSCni52yL2miVaCB4sGK8CO+ej34OhWnXGmWxnsWOVQ0VVyeCDDGfd/ SXwtA7PkT9qa1sdzeY18gMrFo6pwxeLtBmXBIRq37pV4i/hbBK9OnP7sCyX+EgqG+Hbr BBYv41mub/A7I9TP6vxp4iS9EkAZmg0eQiBEpXbzvHsS2shT8eHXDOEBwDXUQi7L/wEA bU6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768132939; x=1768737739; 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=NZHFKyJrPzbKT61vScnyjQJctx0QqGgZF1Rj9YqOnNQ=; b=PBXW3pvwwPWxqU4mWaReQ6yraOsIzEztXlsMwxyoI+0Xy6fsfEOb1mo9IVsgXalDfQ tIP1luRdrRqtMYheWyS+gcKYbL1SMqazSniney8VncQuacq0D6lZ5DTeYlGJaxc/Hdkd wS6gXppUInGu5C4cJeWZY2sdIJxNbjJ97wqVKpf4CYQNKYIStz7i1piVmaao66ERkxd9 I+PC2/38/axFi6aYDegZRqohwl5G7D2FGh9/LtYFOra2QvYZsxySItVvjAINP+bt8KZ+ J32Zn3cVcoGsQINo3g+//gw03h3r1keQJWpRZOjtsIc2Q5T+B7g5+FT4OmfBugIHesrT k0sg== X-Forwarded-Encrypted: i=1; AJvYcCUPXSKJJPnCnT3hr40GF6Go3L/9UFyJaGxbCOfeHTavmCUA3/m4cRZbbDNDvKBcH6JW/gctKxoit33XYOs=@vger.kernel.org X-Gm-Message-State: AOJu0Yx63p7c4nlUwjHC/0Vl7abq61c4srvn7azfHoguz3I1oi7wCrzu KMKWUx5WvQG4C6lRUmZyPrEhjZUc33IGEe8zavPvc8AHi/oE2Pjjn0K1bWnynrUL X-Gm-Gg: AY/fxX7OesKQ6J/dCekYQKqHcKXlnA/zaq2yhtqgZR+mqLhRw8G/kPy3+0Aid07B33O DeYBKksgL0tZikSQsTzNxqdS0tfI9NzfbScHJud33YyhF4jlHTQwOgNi0yHvA3EvlS6USiK6J8b lOA04bNfpDRG1Eke1Cyq/Q6TVmxeS2CSj6bK5IwB2j4SNOQJA4C0exr0XNyal23OwBqkzEIljE5 Sh7tR7f6CWX5POB4FJzX28mECgl2YPf9Gke+cYdNMEVt8LIuO2uzVyjf0HUQl4zCQyziVYu+udj 2Z74w+UnfVJhe+SOzW1yiWHR5EvXhkc6H2pnFJ1FIMykvLZpm66RYJc7mVoJoIg6sfk6f3BS1/e RERcmWgyh09HbxJEt/g0dZ4ebvqiL2ano+KX40nxM4uXaWkpCcsMD6F1rGicM2Q6H7yu3LU8FqW SYrDoOHEWKL9vfOQZU0CQMBdOiEemv67KvrTQkwD0lL205ByRhwHTgFETWDTEEX2G/l9b+S5HA8 u4zDc6IMhpMmKA= X-Google-Smtp-Source: AGHT+IEuXLidREjP8FSfwA32NxDViLdSQSKAm3cQgwfGzcdT55QWjpq3OvYjcAVJltzLZ7WBjUZmoQ== X-Received: by 2002:a05:6214:c4b:b0:88a:316e:dad6 with SMTP id 6a1803df08f44-89076a02528mr256783346d6.23.1768132939465; Sun, 11 Jan 2026 04:02:19 -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-890770e8cfasm116935636d6.21.2026.01.11.04.02.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Jan 2026 04:02:18 -0800 (PST) Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfauth.phl.internal (Postfix) with ESMTP id 650F1F40068; Sun, 11 Jan 2026 07:02:18 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-05.internal (MEProxy); Sun, 11 Jan 2026 07:02:18 -0500 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgdduudeghedvucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepuehoqhhunhcu hfgvnhhguceosghoqhhunhdrfhgvnhhgsehgmhgrihhlrdgtohhmqeenucggtffrrghtth gvrhhnpedvveekvddtffelffelfedvudefffeuheejgeeivedufffgledvgeduveffueeh leenucffohhmrghinhepmhhsghhiugdrlhhinhhknecuvehluhhsthgvrhfuihiivgeptd enucfrrghrrghmpehmrghilhhfrhhomhepsghoqhhunhdomhgvshhmthhprghuthhhphgv rhhsohhnrghlihhthidqieelvdeghedtieegqddujeejkeehheehvddqsghoqhhunhdrfh gvnhhgpeepghhmrghilhdrtghomhesfhhigihmvgdrnhgrmhgvpdhnsggprhgtphhtthho peduhedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepphgvthgvrhiisehinhhfrh 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:17 -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 , Boqun Feng Subject: [PATCH 03/36] rust: sync: set_once: Implement Send and Sync Date: Sun, 11 Jan 2026 20:01:36 +0800 Message-ID: <20260111120209.6133-1-boqun.feng@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260111115808.5702-1-boqun.feng@gmail.com> References: <20260111115808.5702-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: quoted-printable Content-Type: text/plain; charset="utf-8" From: FUJITA Tomonori Implement Send and Sync for SetOnce to allow it to be used across thread boundaries. Send: SetOnce can be transferred across threads when T: Send, as the contained value is also transferred and will be dropped on the destination thread. Sync: SetOnce can be shared across threads when T: Sync, as as_ref() provides shared references &T and atomic operations ensure proper synchronization. Since the inner T may be dropped on any thread, we also require T: Send. Signed-off-by: FUJITA Tomonori Reviewed-by: Andreas Hindborg Reviewed-by: Gary Guo Signed-off-by: Boqun Feng Link: https://patch.msgid.link/20251216000901.221375-1-fujita.tomonori@gmai= l.com --- rust/kernel/sync/set_once.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rust/kernel/sync/set_once.rs b/rust/kernel/sync/set_once.rs index bdba601807d8..139cef05e935 100644 --- a/rust/kernel/sync/set_once.rs +++ b/rust/kernel/sync/set_once.rs @@ -123,3 +123,11 @@ fn drop(&mut self) { } } } + +// SAFETY: `SetOnce` can be transferred across thread boundaries iff the d= ata it contains can. +unsafe impl Send for SetOnce {} + +// SAFETY: `SetOnce` synchronises access to the inner value via atomic ope= rations, +// so shared references are safe when `T: Sync`. Since the inner `T` may b= e dropped +// on any thread, we also require `T: Send`. +unsafe impl Sync for SetOnce {} --=20 2.51.0