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 DC4B1293B61; Fri, 4 Jul 2025 10:09:57 +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=1751623798; cv=none; b=XBdrhpDa/+z3W56N2gbnzZhJllid9a+HCRKtMsdD97Hugb2PDGjMAcrMRwiVUpKrhwiQfJcQvjpMb5TgGYpm1cVwOzpq87bbbdwCpObo1UDUPL0ljJHkmmAK39tHHHEj/gt+jIhU0+sTZTLwNSIA0/c6avMPOPr9/GzAW8BR4eU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751623798; c=relaxed/simple; bh=sErifeomiBisSrJ5F/Z1EiOE+yjyaoOoLVJmALiwIss=; h=Mime-Version:Content-Type:Date:Message-Id:Subject:From:To:Cc: References:In-Reply-To; b=QBSQrQtDxl3khpvRlIPU5qS8NjGQcj8bGfiG/4VLzik4oLgXwc2074TM6uBfJ6SgTIqix4uNEDSeMVkZzCLHc0Rh6MdthBE2RcCXqdqwRLBxsoLarlHh4+ZwhuqZwHzHjigPU/LkbovziNf9+Nbw1oaGQuvoXCNP18CP7DrmY1g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bjHFAeZa; 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="bjHFAeZa" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9EB26C4CEE3; Fri, 4 Jul 2025 10:09:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1751623797; bh=sErifeomiBisSrJ5F/Z1EiOE+yjyaoOoLVJmALiwIss=; h=Date:Subject:From:To:Cc:References:In-Reply-To:From; b=bjHFAeZaJFAnmlfy0BXQom4D2g8nROdZRV9VSgmHVyp34hx86laW5qYZ9hJt1xRQW 0K0KO2yByzLe4dQZLFhD35Ow6d8OFCvrtXqBJsfVoIIfyv2UGdJYm4h3q0G5Jkpw5z wGhbmAF7CZg/+Usn4oPgUWLuVpcLqO00+9bczIkO/xSH+5IJAtnA1+gQ91n+wiBcP6 B7oDcHjP2qL77G1iVen1zde1nv2qXrbY4ckstCIFg4BI/BrUjKystwvqi6oNlmq8/O 6gVbjWvcNhrRjps2Q90t25m0FTomyUvTA0EnLcqcQEkGdXcBV9HXEB+8pGkJCpLBEg +vGw4nMjPXgxg== Precedence: bulk X-Mailing-List: devicetree@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 Date: Fri, 04 Jul 2025 12:09:43 +0200 Message-Id: Subject: Re: [PATCH v13 2/5] rust: support formatting of foreign types From: "Benno Lossin" To: "Tamir Duberstein" Cc: "Michal Rostecki" , "Miguel Ojeda" , "Alex Gaynor" , "Boqun Feng" , "Gary Guo" , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , "Andreas Hindborg" , "Alice Ryhl" , "Trevor Gross" , "Brendan Higgins" , "David Gow" , "Rae Moar" , "Danilo Krummrich" , "Maarten Lankhorst" , "Maxime Ripard" , "Thomas Zimmermann" , "David Airlie" , "Simona Vetter" , "Greg Kroah-Hartman" , "Rafael J. Wysocki" , "Luis Chamberlain" , "Russ Weight" , "FUJITA Tomonori" , "Rob Herring" , "Saravana Kannan" , "Peter Zijlstra" , "Ingo Molnar" , "Will Deacon" , "Waiman Long" , "Nathan Chancellor" , "Nick Desaulniers" , "Bill Wendling" , "Justin Stitt" , "Andrew Lunn" , "Heiner Kallweit" , "Russell King" , "David S. Miller" , "Eric Dumazet" , "Jakub Kicinski" , "Paolo Abeni" , "Bjorn Helgaas" , "Arnd Bergmann" , "Jens Axboe" , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , "Dave Ertman" , "Ira Weiny" , "Leon Romanovsky" , "Breno Leitao" , "Viresh Kumar" , "Michael Turquette" , "Stephen Boyd" , , , , , , , , , , , , , X-Mailer: aerc 0.20.1 References: <20250701-cstr-core-v13-0-29f7d3eb97a6@gmail.com> <20250701-cstr-core-v13-2-29f7d3eb97a6@gmail.com> In-Reply-To: On Fri Jul 4, 2025 at 1:23 AM CEST, Tamir Duberstein wrote: > On Thu, Jul 3, 2025 at 6:41=E2=80=AFPM Tamir Duberstein wrote: >> On Thu, Jul 3, 2025 at 4:36=E2=80=AFPM Benno Lossin = wrote: >> > >> > I don't understand, can't you just do: >> > >> > * add `rust/kernel/fmt.rs`, >> > * add `rust/macros/fmt.rs`, >> > * change all occurrences of `core::fmt` to `kernel::fmt` and >> > `format_args!` to `fmt!`. >> >> Yes, such a split could be done - I will do so in the next spin >> >> >> > The last one could be split by subsystem, no? Some subsystems might >> > interact and thus need simultaneous splitting, but there should be som= e >> > independent ones. >> >> Yes, it probably can. As you say, some subsystems might interact - the >> claimed benefit of doing this subsystem-by-subsystem split is that it >> avoids conflicts with ongoing work that will conflict with a large >> patch, but this is also the downside; if ongoing work changes the set >> of interactions between subsystems then a maintainer may find >> themselves unable to emit the log message they want (because one >> subsystem is using kernel::fmt while another is still on core::fmt). > > I gave this a try. I ran into the problem that `format_args!` (and, > after this patch, `fmt!`) is at the center of `print_macro!`, which > itself underpins various other formatting macros. This means we'd have > to bifurcate the formatting infrastructure to support an incremental > migration. That's quite a bit of code, and likely quite a mess in the > resulting git history -- and that's setting aside the toil required to > figure out the correct combinations of subsystems that must migrate > together. So here is what we can do without duplicating the logic, though it requires multiple cycles: 1. We merge the two `fmt.rs` files & each subsystem merges an implementation of `kernel::fmt::Display` for their types, but keeps the `core::fmt::Display` impl around. 2. After all subsystems have merged the previous step, we change the implementations of `print_macro!` to use `fmt!` instead of `format_args!`. 3. We remove all occurrences of `core::fmt` (& replace them with `kernel::fmt`), removing the `core::fmt::Display` impls. --- Cheers, Benno