From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) (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 2E86E30FC3D for ; Fri, 20 Feb 2026 10:20:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771582830; cv=none; b=I6frn/W5s0MylC+rxQCExXvVj4zHJtQGm9YB/SbWEQOg1PoJkHjR2PJQaL8AcMUQG5arRG617N0T8ovTQD+xTTYTfI0Z5/Sw3y6PYl4COsIqdxEfH5XWceF5+cd4tu3SJK8QOca3KT51jmGUlnRoEleYUgHWxvNl1UpMIbRQIzM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771582830; c=relaxed/simple; bh=6KmU1AWVJiEbouJMx51Kj0j5yR+X1ELGGptVwWk1JuQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=dJ8QjpRe/VmT1ahZzIrlmgucvmzzTvCMAda2/45+qAegyMJUKquwhvXzMHuNgsHwuE+WfgL2Hi3h8AogmraFHMYaenwoE6enTdTPjPR3yu4YB3a43kHB6tySfOhGUE8OEku5cJAfHyg1wLyG68EWzSdYNyS+eiDaXBj0qzjAWcI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=rRG9JM//; arc=none smtp.client-ip=209.85.128.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="rRG9JM//" Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-4836bf1a920so22200825e9.3 for ; Fri, 20 Feb 2026 02:20:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1771582826; x=1772187626; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=ZgOF25WsqAV2m3jmjI8ZSzjN6VVlBAtKwBvn34jgo2I=; b=rRG9JM//t9y8LpEYP9CMggKYCo2/f2lelOyadsm7+0hQKylOgJTCnE+GlfUQkPZCem OXU+3pq1CEJ3qQ81sHTB35bREzaMYfvGoDjg3iqUoB/45DkSCwSqbXwy9SIcyBNeQN+1 GDGwKadmhNY4l80sG5fQVSHqZIZ6qfWfwOkMSz0FjFytAPP29Ux8bE/+C3g6L8Sj+7uy LwF/KEUxjqMwYL2MOJLDTWrgVrT9stxju9SQASfKn8gBJxe9oQa5f9rjJv53bVX5gnHd Fonili8nFokyQLyjQZoY0SK9qXQ8Vb/FkrLn98aD6qYACRkeT4Tmw0r2Rqh75XebdRjM re+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771582826; x=1772187626; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ZgOF25WsqAV2m3jmjI8ZSzjN6VVlBAtKwBvn34jgo2I=; b=GvjbJPwEl5xe6YT2BFXTdSTdmwH6y5FNFf6sIOoB2KNBk+cn8C7HTkJaDZNg89eEck e27kW5zSCLfYn583rPkmCdCm/rhluAWchcJPWx1MU+C0fk/W+CoAzUllhqqqn33KnTNm 4rfUOcL1kTbuhTykaDnAjJKW+XGKUKf0WOu1RmMor8S1ujmYEqbWj9e1QClTPna4qPHD dvHfbilfKWr3oZZyJSOS1ZugqbIxvk1FW9xQyx5pFtkm3g+GoPeC93SffEPE3IVzQiSU zr++9umWcUCDg047ptgNPe6X2C+NT68VWZ++Ro87tUTleOlouiQWEtqbtCG03yHWiOyA Yhgw== X-Forwarded-Encrypted: i=1; AJvYcCVwLSFnmSdunFfALErUhynMwhq73ueiMWRQS0YvQQicH1bamnNxATWRaEf+5rr4C+oB4ZslZ3kyjXyW478=@vger.kernel.org X-Gm-Message-State: AOJu0YxcXmWkdRdcjDdLuxYImYJ8Q7J8CEJCwlCN/0LacldjWBVPUTYd z2cX16cHv7alnoOY88ci3Bo6USxmL51D4JnRSQKpxUIvU3l/h8MGXapWSn4UvjoiTIyRjrmY9wU DnwoyZcuSxCtOIMkXcw== X-Received: from wmpr35.prod.google.com ([2002:a05:600c:3223:b0:477:9f92:40da]) (user=aliceryhl job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:8b61:b0:480:1b65:b744 with SMTP id 5b1f17b1804b1-48379bf7907mr315705125e9.28.1771582826283; Fri, 20 Feb 2026 02:20:26 -0800 (PST) Date: Fri, 20 Feb 2026 10:20:25 +0000 In-Reply-To: <20260220-atomic-sub-v3-3-e63cbed1d2aa@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260220-atomic-sub-v3-0-e63cbed1d2aa@kernel.org> <20260220-atomic-sub-v3-3-e63cbed1d2aa@kernel.org> Message-ID: Subject: Re: [PATCH v3 3/3] rust: atomic: update a safety comment in impl of `fetch_add` From: Alice Ryhl To: Andreas Hindborg Cc: Will Deacon , Peter Zijlstra , Boqun Feng , Mark Rutland , Gary Guo , Miguel Ojeda , "=?utf-8?B?QmrDtnJu?= Roy Baron" , Benno Lossin , Trevor Gross , Danilo Krummrich , linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org Content-Type: text/plain; charset="utf-8" On Fri, Feb 20, 2026 at 09:06:22AM +0100, Andreas Hindborg wrote: > The safety comment used in the implementation of `fetch_add` could be read > as just saying something it is true without justifying it. Update the > safety comment to include justification. > > Signed-off-by: Andreas Hindborg Reviewed-by: Alice Ryhl > rust/kernel/sync/atomic/internal.rs | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/rust/kernel/sync/atomic/internal.rs b/rust/kernel/sync/atomic/internal.rs > index a094f704be0ce..67745c44e710b 100644 > --- a/rust/kernel/sync/atomic/internal.rs > +++ b/rust/kernel/sync/atomic/internal.rs > @@ -258,7 +258,7 @@ fn add[](a: &AtomicRepr, v: Self::Delta) { > /// Atomically updates `*a` to `(*a).wrapping_add(v)`, and returns the value of `*a` > /// before the update. > fn fetch_add[acquire, release, relaxed](a: &AtomicRepr, v: Self::Delta) -> Self { > - // SAFETY: `a.as_ptr()` is valid and properly aligned. > + // SAFETY: `a.as_ptr()` guarantees the returned pointer is valid and properly aligned. Perhaps more natural wording is: SAFETY: `a.as_ptr()` always returns a pointer that is valid and properly aligned. Because I doubt `as_ptr()` documents these things explicitly. (To be clear, I don't think as_ptr() needs to do so - that'd be really verbose.) Anyway, it's fine like this too. Alice