From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1E1031D7989; Tue, 1 Jul 2025 08:44:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751359448; cv=none; b=lJ4oMhOUIrdjTOIK4tiyzU/s+zPUbWdbcgSSva4oYKYzvxJjEuk5dRZPwp0dNILoZj9Tsx4jFJOq8CARI+U8vwrFAFVpOIJYq6G5A2mIt2VBVmI5EM4EzIk9RmLNGPCUIbq64i8Z36M1XXV7f/dlIBKmCXPbpCegWllEaSHkMdc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751359448; c=relaxed/simple; bh=JQnJ50WwtWPmuUmhqUal++GEN46ier5irpKnyb6pzhk=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=AIt+ApAqQKorU/heenE2hWNmo7aa1sOElvDgiS2sYL5gMNUXW2NdH+7LmNssW3RvTLsOp8dmhjb1z7WeFtuUpiattq3jES8s1K0Ks1bcrdP1xxta6lDIZW+EEPQ4WQ10l11eJ8PRQB+gF4zvagTgscsR9N4Az4zXBlPG/Rj+1Bo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=W5FB23ln; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="W5FB23ln" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1DF3AC4CEEB; Tue, 1 Jul 2025 08:44:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1751359447; bh=JQnJ50WwtWPmuUmhqUal++GEN46ier5irpKnyb6pzhk=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=W5FB23lnRmqMblxQRYfHg3U8Cb96WoRZP9N91S7HABOR21skwzV5IaYGRpc3SMCED 0jmWPuRHRM9Of1mZsV142+GoRxobrpP+f2JUis8pCQX8jsHc2hToAqMlDSA4cEQc6W 7zmUtc+x8mJc0qKbiE5E/u17/kIbXirUJOaHd88F33v/Qv43qtn6ngBW8W5yiZw2qc +zBd1BXmKL1Fr/5+eieLu+o+5OhUZ8nVt1L6qP3xR+StIRlCaLYZ75R6+sguURrD8a VJpWu8tLOa/LXp4BPDOKn97dd/kfB7eDKmTmFb5/nEKuMmcejKsXNuueOLc3ZdR+GD KAXHLMCtD9EHw== From: Andreas Hindborg To: "Benno Lossin" Cc: "Miguel Ojeda" , "Alex Gaynor" , "Boqun Feng" , "Gary Guo" , =?utf-8?Q?Bj=C3=B6rn?= Roy Baron , "Alice Ryhl" , "Masahiro Yamada" , "Nathan Chancellor" , "Luis Chamberlain" , "Danilo Krummrich" , "Nicolas Schier" , "Trevor Gross" , "Adam Bratschi-Kaye" , , , , "Petr Pavlu" , "Sami Tolvanen" , "Daniel Gomez" , "Simona Vetter" , "Greg KH" , "Fiona Behrens" , "Daniel Almeida" , Subject: Re: [PATCH v13 2/6] rust: introduce module_param module In-Reply-To: (Benno Lossin's message of "Mon, 30 Jun 2025 21:02:37 +0200") References: <20250612-module-params-v3-v13-0-bc219cd1a3f8@kernel.org> <87ikkq648o.fsf@kernel.org> <877c126bce.fsf@kernel.org> <87v7om4jhq.fsf@kernel.org> <878qlh4aj1.fsf@kernel.org> <87plepzke5.fsf@kernel.org> <87wm8txysl.fsf@kernel.org> <9G3W1seaM7elcwWXaeoaa2nfpFYCf-AmBdvZhACGP13KGUtTPVMwGNYdTQsdtp8ru7GIP3-UYTzXscC1MRUKrg==@protonmail.internalid> <87h5zxxtdw.fsf@kernel.org> User-Agent: mu4e 1.12.9; emacs 30.1 Date: Tue, 01 Jul 2025 10:43:56 +0200 Message-ID: <87bjq4xpv7.fsf@kernel.org> Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain "Benno Lossin" writes: > On Mon Jun 30, 2025 at 3:15 PM CEST, Andreas Hindborg wrote: >> "Benno Lossin" writes: >>> On Mon Jun 30, 2025 at 1:18 PM CEST, Andreas Hindborg wrote: >>>> "Benno Lossin" writes: >>>>> (no idea if the orderings are correct, I always have to think way to >>>>> much about that... especially since our atomics seem to only take one >>>>> ordering in compare_exchange?) >>>>> >>>>>> As far as I can tell, atomics may not land in v6.17, so this series >>>>>> will probably not be ready for merge until v6.18 at the earliest. >>>>> >>>>> Yeah, sorry about that :( >>>> >>>> Actually, perhaps we could aim at merging this code without this >>>> synchronization? >>> >>> I won't remember this issue in a few weeks and I fear that it will just >>> get buried. In fact, I already had to re-read now what the actual issue >>> was... >>> >>>> The lack of synchronization is only a problem if we >>>> support custom parsing. This patch set does not allow custom parsing >>>> code, so it does not suffer this issue. >>> >>> ... In doing that, I saw my original example of UB: >>> >>> module! { >>> // ... >>> params: { >>> my_param: i64 { >>> default: 0, >>> description: "", >>> }, >>> }, >>> } >>> >>> static BAD: &'static i64 = module_parameters::my_param.get(); >>> >>> That can happen without custom parsing, so it's still a problem... >> >> Ah, got it. Thanks. > > On second thought, we *could* just make the accessor function `unsafe`. > Of course with a pinky promise to make the implementation safe once > atomics land. But I think if it helps you get your driver faster along, > then we should do it. No, I am OK for now with configfs. But, progress is still great. How about if we add a copy accessor instead for now, I think you proposed that a few million emails ago: pub fn get(&self) -> T; or maybe rename: pub fn copy(&self) -> T; Then we are fine safety wise for now, right? It is even sensible for these `T: Copy` types. Best regards, Andreas Hindborg