[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Yhd8f93+Pw/7KdRV@alley>
Date: Thu, 24 Feb 2022 13:39:27 +0100
From: Petr Mladek <pmladek@...e.com>
To: Miguel Ojeda <miguel.ojeda.sandonis@...il.com>
Cc: Miguel Ojeda <ojeda@...nel.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
rust-for-linux <rust-for-linux@...r.kernel.org>,
linux-kernel <linux-kernel@...r.kernel.org>,
Wedson Almeida Filho <wedsonaf@...gle.com>,
Alex Gaynor <alex.gaynor@...il.com>,
Geoffrey Thomas <geofft@...reload.com>,
Finn Behrens <me@...enk.de>,
Adam Bratschi-Kaye <ark.email@...il.com>,
Michael Ellerman <mpe@...erman.id.au>,
Sumera Priyadarsini <sylphrenadin@...il.com>,
Sven Van Asbroeck <thesven73@...il.com>,
Gary Guo <gary@...yguo.net>,
Boris-Chengbiao Zhou <bobo1239@....de>,
Boqun Feng <boqun.feng@...il.com>,
Fox Chen <foxhlchen@...il.com>,
Dan Robertson <daniel.robertson@...rlab.io>,
Viktor Garske <viktor@...ar.de>,
Dariusz Sosnowski <dsosnowski@...snowski.pl>,
Léo Lanteri Thauvin
<leseulartichaut@...il.com>, Niklas Mohrin <dev@...lasmohrin.de>,
Gioh Kim <gurugio@...il.com>, Daniel Xu <dxu@...uu.xyz>,
Milan Landaverde <milan@...verde.com>,
Morgan Bartlett <mjmouse9999@...il.com>,
Maciej Falkowski <m.falkowski@...sung.com>,
Jiapeng Chong <jiapeng.chong@...ux.alibaba.com>,
Sergey Senozhatsky <senozhatsky@...omium.org>,
Steven Rostedt <rostedt@...dmis.org>,
John Ogness <john.ogness@...utronix.de>
Subject: Re: [PATCH v4 10/20] rust: add `kernel` crate
On Tue 2022-02-22 13:48:16, Miguel Ojeda wrote:
> Hi Petr,
>
> On Tue, Feb 22, 2022 at 10:06 AM Petr Mladek <pmladek@...e.com> wrote:
> >
> > What exactly should we keep in sync, please?
> >
> > I see only handling of KERN_* prefix in print.rs. I do not see there
> > any counter part of LOG_LINE_MAX, CONSOLE_LOG_MAX, or PREFIX_MAX.
>
> Good catch! We had a buffer on the Rust side in the past, but that is
> not the case anymore since commit 9e8bd679ecf2 ("Support Rust
> `core::fmt::Argument` in vsprintf") on our side, so we will remove the
> comment.
Great :-)
> > I am sorry but I am not familiar with rust. What are these limits
> > 2 and 10 used for, please?
> >
> > I guess that 2 is the size of a single KERN_* identifier.
> > But what is 10?
> >
> > Note that printk() format prefix is typically just a single KERN_*
> > identifier. But there might be more. Well, in practice only the
> > following combination makes sense: KERN_CONT + KERN_<LEVEL>.
>
> What we are doing here is generating compile-time format strings that
> are then used by the `pr_*!` macros (which call the C side `printk()`
> with one of the strings).
I see. We are on the safe side then.
> In other words, this is not parsing arbitrary `printk()` format
> strings (which I am guessing something like that is your concern --
> please let me know if I got it wrong).
Yes, this was my concern.
> > Finally, is there any way to test whether any change in the printk
> > code breaks the rust support?
>
> One way is to compile the code, e.g. the `assert!`s in the `generate`
> function run at compile-time, thus they provide a first layer of
> defense.
>
> Another way is to use `samples/rust/print.rs` which we run in the CI
> as a black box test.
>
> Is that what you had in mind? Or something like unit tests or self tests?
I had in mind any tests that I might run [*] to be sure that changes in
the native printk code does not break Rust support.
The compile test and samples/rust/print.rs do some basic tests and
might enough for now.
[*] To make it clear. I am not going to run the tests at this stage.
But I might be useful once this patchset is accepted upstream.
But it also might be enough to wait for results from your CI.
I hope that we will not break it that often.
Best Regards,
Petr
Powered by blists - more mailing lists