lkml.org 
[lkml]   [2022]   [Feb]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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@suse.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

\
 
 \ /
  Last update: 2022-02-24 13:41    [W:0.098 / U:0.032 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site