From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f74.google.com (mail-ej1-f74.google.com [209.85.218.74]) (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 53A71244694 for ; Thu, 1 Jan 2026 00:53:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767228828; cv=none; b=tKMObGSeAkiWkwLWcdPEpmi++x1P1FljBYuIhuDOVkiUBbIyjtmj97BNh0SUnkCYgAMc7+/s6kEsuct5x56UP5v2iWZ9womhuf7hhMmqxKxuY1H39lIqF/qZNQ22E3yMKb4fzH1w/K8o+jTsU9hYYzyxkxfWAKSY34NLTU8azzc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767228828; c=relaxed/simple; bh=FJxmCTvLM25zFfWpcNP5yBD/9nFfmtlGgUOBfBuzQiM=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=WpkM1NTbcvOrsFmd+HiwFqLDSErdbHCfAVX1e+UfHoplgYhsLlZbPDF18bY6Jgl4bnQIBQAa8in5pjj0or+ps1ikDKD3mSTRkCdJY+PDBxZxJQapsNhzwvSYBrsJJJuDEsRPVyFpL04P7P72Nyf10ybYXIXVbySFbMdv8HcXTIk= 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=iJvmc6iA; arc=none smtp.client-ip=209.85.218.74 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="iJvmc6iA" Received: by mail-ej1-f74.google.com with SMTP id a640c23a62f3a-b70b1778687so974238466b.0 for ; Wed, 31 Dec 2025 16:53:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1767228821; x=1767833621; 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=ALybukQ368MxKZuRBiA6l9FsoHeskqo5LiIi7UTqkwI=; b=iJvmc6iAlq+AGWwQlMfFpUv590zRrBmK9KHqa/L+nel4mOmog6irZk1MSKC7Z2r19y rT8zEbz4u7YdtSJkKJcmltsqALqK+hrSYeB7E48uQM8gugOrXeCxGhousoIe5uyCxnQZ 2+YwvXiL1iRtvRt2RBjS3JfLHtn97je52gO5gazY1dQvKNsvphb6H9qD0UKtUnHcGJsQ md1zNznurxGuorqpsB21pNxmyx84nhAiTnDOQcP8TdUkSZN6IZt/RUV2iu0UjrUXB61V DsZYu+AG9Jb4apwuHJa8OznjSivAOVrbOZgEm96FRa1/ptCViI4sdMnn4j9y/3EJyl5o CxRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767228821; x=1767833621; 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=ALybukQ368MxKZuRBiA6l9FsoHeskqo5LiIi7UTqkwI=; b=gLshgkroS1yyo8fayUf12741S3bxXyhx1vUoxcc8w3K2zHRWByi2K01C0Cr0aESlAX J6+pCzRwPuQ6kSJqxB+uiS3IGH/2g9EsK2dKlBs5pQEIrBgLMRcOn4tH6s+5LENHdEJ7 ypPsyJFO/ICFoOJ1XoMMGfN2Q56UAF7Ph05Fm0qXTMFiYo5WfCS13a4pfA2IWS2gJwbW SDOGRP+cb4JF9x6qLcQoo1a4WciZA8vQoIQaeJkEXjHpk0fQjHURvr0FldpJrJ/O0xxR OU1uz1ncZB9elEWzEmvVk+wwXvXMsV61IUsLjnUZ9VSRtoJC1cW0UHUpAP1rNY+F4goH 95lg== X-Forwarded-Encrypted: i=1; AJvYcCVUPRaQFi+DoJxAYbSqMJlVvt2x5H6WpDMt5Ucxp3AHpGWSRlPdu1AhLlHYcdJMy4F3DNKQ37BUu2d2MUU=@vger.kernel.org X-Gm-Message-State: AOJu0YymOZB34KRRtm1teszO/a/wWz8rJdCX6cf4xQKQ9OPlDREwSjMh XbWzJYi3UntIunKCA1OhfkdY8ByrAzUDAF9MEfqy+coyS9W5RpFNJKKPo8dU5MaN4CiLD6nPsaA wQchQnTHm/7ADCNBiBQ== X-Google-Smtp-Source: AGHT+IEWmy8RAXCgqnhUehDWXxrrCi36bifjxhWe3kp7T+r3sxEL7vClkSWEcaAst8kVOoT68CYG7PpgofIxyHk= X-Received: from ejcul5.prod.google.com ([2002:a17:907:ca85:b0:b7f:fed7:3bc2]) (user=aliceryhl job=prod-delivery.src-stubby-dispatcher) by 2002:a17:907:3f23:b0:b76:6020:ed2b with SMTP id a640c23a62f3a-b80371970a2mr3724571266b.45.1767228820647; Wed, 31 Dec 2025 16:53:40 -0800 (PST) Date: Thu, 1 Jan 2026 00:53:39 +0000 In-Reply-To: <20251231151216.23446b64.gary@garyguo.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251231-rwonce-v1-0-702a10b85278@google.com> <20251231151216.23446b64.gary@garyguo.net> Message-ID: Subject: Re: [PATCH 0/5] Add READ_ONCE and WRITE_ONCE to Rust From: Alice Ryhl To: Gary Guo Cc: Boqun Feng , Will Deacon , Peter Zijlstra , "Paul E. McKenney" , Richard Henderson , Matt Turner , Magnus Lindholm , Catalin Marinas , Miguel Ojeda , "=?utf-8?B?QmrDtnJu?= Roy Baron" , Benno Lossin , Andreas Hindborg , Trevor Gross , Danilo Krummrich , Mark Rutland , FUJITA Tomonori , Frederic Weisbecker , Lyude Paul , Thomas Gleixner , Anna-Maria Behnsen , John Stultz , Stephen Boyd , Alexander Viro , Christian Brauner , Jan Kara , linux-kernel@vger.kernel.org, linux-alpha@vger.kernel.org, linux-arm-kernel@lists.infradead.org, rust-for-linux@vger.kernel.org, linux-fsdevel@vger.kernel.org Content-Type: text/plain; charset="utf-8" On Wed, Dec 31, 2025 at 03:12:16PM +0000, Gary Guo wrote: > On Wed, 31 Dec 2025 12:22:24 +0000 > Alice Ryhl wrote: > > > There are currently a few places in the kernel where we use volatile > > reads when we really should be using `READ_ONCE`. To make it possible to > > replace these with proper `READ_ONCE` calls, introduce a Rust version of > > `READ_ONCE`. > > > > A new config option CONFIG_ARCH_USE_CUSTOM_READ_ONCE is introduced so > > that Rust is able to use conditional compilation to implement READ_ONCE > > in terms of either a volatile read, or by calling into a C helper > > function, depending on the architecture. > > > > This series is intended to be merged through ATOMIC INFRASTRUCTURE. > > Hi Alice, > > I would prefer not to expose the READ_ONCE/WRITE_ONCE functions, at > least not with their atomic semantics. > > Both callsites that you have converted should be using > > Atomic::from_ptr().load(Relaxed) > > Please refer to the documentation of `Atomic` about this. Fujita has a > series that expand the type to u8/u16 if you need narrower accesses. Why? If we say that we're using the LKMM, then it seems confusing to not have a READ_ONCE() for cases where we interact with C code, and that C code documents that READ_ONCE() should be used. Alice