[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAH5fLggH_uThjbdNW6pwOTT72ogLbyZGXDAnTLoJyvmfZ8kf_A@mail.gmail.com>
Date: Tue, 1 Oct 2024 11:10:07 +0200
From: Alice Ryhl <aliceryhl@...gle.com>
To: Christian Brauner <brauner@...nel.org>, Alexander Viro <viro@...iv.linux.org.uk>,
Miguel Ojeda <ojeda@...nel.org>, Andrew Morton <akpm@...ux-foundation.org>
Cc: Kees Cook <kees@...nel.org>, Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Alex Gaynor <alex.gaynor@...il.com>, Boqun Feng <boqun.feng@...il.com>,
Gary Guo <gary@...yguo.net>, Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <benno.lossin@...ton.me>, Andreas Hindborg <a.hindborg@...nel.org>,
Trevor Gross <tmgross@...ch.edu>, linux-kernel@...r.kernel.org,
linux-fsdevel@...r.kernel.org, rust-for-linux@...r.kernel.org
Subject: Re: [PATCH] rust: add seqfile abstraction
On Tue, Oct 1, 2024 at 11:07 AM Alice Ryhl <aliceryhl@...gle.com> wrote:
>
> This adds a simple seq file abstraction that lets you print to a seq
> file using ordinary Rust printing syntax.
>
> An example user from Rust Binder:
>
> pub(crate) fn full_debug_print(
> &self,
> m: &SeqFile,
> owner_inner: &mut ProcessInner,
> ) -> Result<()> {
> let prio = self.node_prio();
> let inner = self.inner.access_mut(owner_inner);
> seq_print!(
> m,
> " node {}: u{:016x} c{:016x} pri {}:{} hs {} hw {} cs {} cw {}",
> self.debug_id,
> self.ptr,
> self.cookie,
> prio.sched_policy,
> prio.prio,
> inner.strong.has_count,
> inner.weak.has_count,
> inner.strong.count,
> inner.weak.count,
> );
> if !inner.refs.is_empty() {
> seq_print!(m, " proc");
> for node_ref in &inner.refs {
> seq_print!(m, " {}", node_ref.process.task.pid());
> }
> }
> seq_print!(m, "\n");
> for t in &inner.oneway_todo {
> t.debug_print_inner(m, " pending async transaction ");
> }
> Ok(())
> }
>
> The `SeqFile` type is marked not thread safe so that `call_printf` can
> be a `&self` method. The alternative is to use `self: Pin<&mut Self>`
> which is inconvenient, or to have `SeqFile` wrap a pointer instead of
> wrapping the C struct directly.
>
> Signed-off-by: Alice Ryhl <aliceryhl@...gle.com>
It's supposed to say this below the --- line:
This series is based on top of vfs.rust.file for the NotThreadSafe type.
I have no idea why b4 decided to drop this information ...
Alice
Powered by blists - more mailing lists