Re: [PATCH] rust: file: handle fd table teardown in file descriptor APIs
From: Gary Guo
Date: Tue Sep 22 2026 - 15:57:56 EST
On Tue Sep 22, 2026 at 7:30 PM BST, Georgios Androutsopoulos wrote:
> On Sun, Sep 20, 2026 at 4:48 PM Gary Guo <gary@xxxxxxxxxxx> wrote:
>> I think we want to add `unlikely()` on them (which is being added by
>> https://lore.kernel.org/rust-for-linux/20260406095820.465994-2-ojeda@xxxxxxxxxx/).
>
> I checked current `linux-next` and `rust-next`, but this does not seem to
> have landed yet. Should I leave these as regular checks for now and add a
> `TODO:` to use `unlikely()` once it is available?
Regular checks are fine, no need for TODO either. Just bring this up to nudge
Miguel to pick the patch :)
>
>> I wonder if we should upgrade this to `WARN_ONCE`. As code being executed when
>> exiting are cleanup code, for this code path to be hit, it would mean that some
>> code is installing FD descriptor while being dropped -- which is likely a bug.
>>
>> Putting a "BTW, some Rust code is installing a FD when process is exiting" in
>> dmesg is not going to be useful to understand what's going on. We'd want a full
>> backtrace.
>
> `WARN_ONCE` does not seem to be available on the Rust side yet either.
> `warn_on!()` is available on the current base and would give us the
> backtrace. Would you prefer using that here for now?
I would prefer `warn_on!()`.
Best,
Gary
>
>> I think we can remove this warning. Skipping put_unused_fd isn't actually
>> leaking anything as the files_struct is cleaned up.
>
> Agreed. I'll treat dropping the reservation after fd table teardown as
> normal cleanup, skip `put_unused_fd()`, and document that this can happen.
>
> Best,
> George