John Hubbard
2025-Nov-26 01:39 UTC
[PATCH v2 1/3] rust: helpers: Add list helpers for C linked list operations
On 11/25/25 5:16 PM, Alexandre Courbot wrote:> On Wed Nov 26, 2025 at 3:16 AM JST, Joel Fernandes wrote: >>> On Nov 25, 2025, at 9:52?AM, Alexandre Courbot <acourbot at nvidia.com> wrote: >>> ?On Wed Nov 12, 2025 at 2:13 AM JST, Joel Fernandes wrote:...>> Correct, but it makes sense to add the most obvious/common ones (also to make it clear that using these are supported). > > "It makes sense" is subjective, and in this case I am confident it is > not the right intuition to add dead code just for the sake of it.Yes. I am increasingly uneasy with the Rust for Linux approach, and now the Nova approach, of adding in "things we might need". The kernel, for example linux-mm, is usually quite fiercely pushing for "prove you need this, by adding in the calling code as part of your series". Drifting away from this makes it hard to know how the calling code *actually* looks.> > Each of these helpers adds a potential breakage point from the C API > should the latter change, so we should only add them if they are indeed > necessary. >Yes please! Just add what you need. Other goodies can come later.> Actually, some of these helpers are not used when they could have been - > you have a `is_empty` method that rewrites the C function instead of > calling the helper. The only helpers that are unjustified as of now as > `list_add` and `list_del`, and these are easy to add when they become > necessary. > > But this raises an interesting dilemma: these helpers cannot be inlined > and add the overhead of a function call. On the other hand, the > definition of `list_head` is so excessively simple that manipulating it > directly is virtually as intuitive as invoking the helper - and doesn't > bear the overhead. So should we double-down on these helpers, or just > drop them completely and re-implement the list functionality we need for > increased performance?Do the "it runs faster" thing. :) thanks, -- John Hubbard
Miguel Ojeda
2025-Nov-26 10:07 UTC
[PATCH v2 1/3] rust: helpers: Add list helpers for C linked list operations
On Wed, Nov 26, 2025 at 2:39?AM John Hubbard <jhubbard at nvidia.com> wrote:> > Yes. I am increasingly uneasy with the Rust for Linux approach, and > now the Nova approach, of adding in "things we might need".Excuse me, what "Rust for Linux approach"? No, we do not add dead code unless justified, just like everywhere else in the Linux kernel. Yes, there are a few exceptional cases, but it is just that, exceptional. Cheers, Miguel
John Hubbard
2025-Nov-26 18:15 UTC
[PATCH v2 1/3] rust: helpers: Add list helpers for C linked list operations
On 11/26/25 2:06 AM, Miguel Ojeda wrote:> On Wed, Nov 26, 2025 at 2:39?AM John Hubbard <jhubbard at nvidia.com> wrote: >> >> Yes. I am increasingly uneasy with the Rust for Linux approach, and >> now the Nova approach, of adding in "things we might need". > > Excuse me, what "Rust for Linux approach"? > > No, we do not add dead code unless justified, just like everywhere > else in the Linux kernel. > > Yes, there are a few exceptional cases, but it is just that, exceptional. >I stand corrected (and relieved)! :) Thanks, Miguel. thanks, -- John Hubbard