rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andreas Hindborg <a.hindborg@kernel.org>
To: "FUJITA Tomonori" <fujita.tomonori@gmail.com>
Cc: <linux-kernel@vger.kernel.org>,  <rust-for-linux@vger.kernel.org>,
	<x86@kernel.org>,  <linux-riscv@lists.infradead.org>,
	<linux-arm-kernel@lists.infradead.org>,
	 <loongarch@lists.linux.dev>, <tglx@linutronix.de>,
	 <mingo@redhat.com>,  <bp@alien8.de>,
	<dave.hansen@linux.intel.com>,  <peterz@infradead.org>,
	 <hpa@zytor.com>, <paul.walmsley@sifive.com>,
	 <palmer@dabbelt.com>, <aou@eecs.berkeley.edu>,
	 <catalin.marinas@arm.com>,  <will@kernel.org>,
	<chenhuacai@kernel.org>,  <kernel@xen0n.name>,
	<tangyouling@loongson.cn>,  <hejinyang@loongson.cn>,
	<yangtiezhu@loongson.cn>,  <ojeda@kernel.org>,
	 <alex.gaynor@gmail.com>, <boqun.feng@gmail.com>,
	 <gary@garyguo.net>,  <bjorn3_gh@protonmail.com>,
	<benno.lossin@proton.me>,  <aliceryhl@google.com>,
	 <tmgross@umich.edu>
Subject: Re: [PATCH v3 0/5] rust: Add bug/warn abstractions
Date: Thu, 27 Feb 2025 09:28:11 +0100	[thread overview]
Message-ID: <87frjzu6zo.fsf@kernel.org> (raw)
In-Reply-To: <20250227.155417.1610168537890385926.fujita.tomonori@gmail.com> (FUJITA Tomonori's message of "Thu, 27 Feb 2025 15:54:17 +0900")

"FUJITA Tomonori" <fujita.tomonori@gmail.com> writes:

> On Wed, 26 Feb 2025 20:39:45 +0100
> Andreas Hindborg <a.hindborg@kernel.org> wrote:
>
>> How does this series compare/overlap with [1] ?
>>
>> [1] https://lore.kernel.org/all/20241126-pr_once_macros-v4-0-410b8ca9643e@tuta.io/
>
> No overlap. Each solves a different problem. Both are necessary.
>
> This patchset enables Rust code to call C's BUG/WARN properly.
>
> Currently, Rust's BUG() is a simple wrapper for C's BUG()
> (rust/helpers/bug.c). I added BUG() to rnull's init() and got the
> following:
>
> # insmod /root/rnull_mod.ko
> rnull_mod: Rust null_blk loaded
> ------------[ cut here ]------------
> kernel BUG at rust/helpers/bug.c:7!
> Oops: invalid opcode: 0000 [#1] SMP
> CPU: 0 UID: 0 PID: 31 Comm: insmod Not tainted 6.14.0-rc1+ #103
> RIP: 0010:rust_helper_BUG+0x8/0x10
> (snip)
>
> This is NOT debug information that we expect. The problem is that
> BUG/WARN feature (lib/bug.c) can only be used from assembly.
>
> This patchset includes only warn() but with bug() implementation on
> top of this patchset, I got:
>
> # insmod /root/rnull_mod.ko
> rnull_mod: Rust null_blk loaded
> ------------[ cut here ]------------
> WARNING: CPU: 0 PID: 31 at /home/fujita/git/linux-rust/drivers/block/rnull.rs:46 _RNvXCsafUg3oOYix8_5rnullNtB2_13NullBlkModu]
> Modules linked in: rnull_mod(+)
> CPU: 0 UID: 0 PID: 31 Comm: insmod Not tainted 6.14.0-rc1+ #104
> RIP: 0010:_RNvXCsafUg3oOYix8_5rnullNtB2_13NullBlkModuleNtCsaYBeKL739Xz_6kernel13InPlaceModule4init+0x71/0x4f0 [rnull_mod]
>
>
> The [1] patchset adds an abstraciton for include/linux/once_lite.h,
> 'call a function once' feature, with pr_*_once() implementation.
>
> pr_*_once() just calls printk() once. Unlike BUG/WARN, no debug
> information (call place, registers, stack trace, etc).
>
>
> The only connection between two patchset is that WARN_ONCE() can be
> built on top of both like the C side.

Awesome, thanks for explaining 👍


Best regards,
Andreas Hindborg



      reply	other threads:[~2025-02-27  8:28 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <yy_ESUuchCjlaGIJHzCPAcP_d9ucSD0CGXaoZNNkY7BmN5Ch1J8avsA9QpKO5LkTjlGpu99jl8NrFl5NFSQXuw==@protonmail.internalid>
2025-02-13 13:57 ` [PATCH v3 0/5] rust: Add bug/warn abstractions FUJITA Tomonori
2025-02-13 13:57   ` [PATCH v3 1/5] x86/bug: Add ARCH_WARN_ASM macro for BUG/WARN asm code sharing with Rust FUJITA Tomonori
2025-02-13 13:57   ` [PATCH v3 2/5] riscv/bug: " FUJITA Tomonori
2025-02-28 10:13     ` Alexandre Ghiti
2025-02-13 13:57   ` [PATCH v3 3/5] arm64/bug: " FUJITA Tomonori
2025-02-26 19:27     ` Catalin Marinas
2025-02-27  7:01       ` FUJITA Tomonori
2025-02-13 13:57   ` [PATCH v3 4/5] loongarch/bug: " FUJITA Tomonori
2025-02-13 13:57   ` [PATCH v3 5/5] rust: Add warn_on and warn_on_once FUJITA Tomonori
2025-03-03 13:33     ` Alice Ryhl
2025-03-05  5:13       ` FUJITA Tomonori
2025-03-05  8:42     ` Alice Ryhl
2025-03-05 10:24       ` FUJITA Tomonori
2025-03-05 10:36         ` Alice Ryhl
2025-02-26 19:39   ` [PATCH v3 0/5] rust: Add bug/warn abstractions Andreas Hindborg
2025-02-27  6:54     ` FUJITA Tomonori
2025-02-27  8:28       ` Andreas Hindborg [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87frjzu6zo.fsf@kernel.org \
    --to=a.hindborg@kernel.org \
    --cc=alex.gaynor@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=aou@eecs.berkeley.edu \
    --cc=benno.lossin@proton.me \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=bp@alien8.de \
    --cc=catalin.marinas@arm.com \
    --cc=chenhuacai@kernel.org \
    --cc=dave.hansen@linux.intel.com \
    --cc=fujita.tomonori@gmail.com \
    --cc=gary@garyguo.net \
    --cc=hejinyang@loongson.cn \
    --cc=hpa@zytor.com \
    --cc=kernel@xen0n.name \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=loongarch@lists.linux.dev \
    --cc=mingo@redhat.com \
    --cc=ojeda@kernel.org \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=peterz@infradead.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tangyouling@loongson.cn \
    --cc=tglx@linutronix.de \
    --cc=tmgross@umich.edu \
    --cc=will@kernel.org \
    --cc=x86@kernel.org \
    --cc=yangtiezhu@loongson.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).