Re: [PATCH net-next v2 5/6] rust: Add read_poll_timeout function

From: FUJITA Tomonori
Date: Mon Oct 07 2024 - 02:24:58 EST


On Sun, 6 Oct 2024 16:45:21 +0200
Andrew Lunn <andrew@xxxxxxx> wrote:

> On Sat, Oct 05, 2024 at 03:22:23PM -0700, Boqun Feng wrote:
>> On Sat, Oct 05, 2024 at 08:32:01PM +0200, Andrew Lunn wrote:
>> > > might_sleep() is called via a wrapper so the __FILE__ and __LINE__
>> > > debug info with CONFIG_DEBUG_ATOMIC_SLEEP enabled isn't what we
>> > > expect; the wrapper instead of the caller.
>> >
>> > So not very useful. All we know is that somewhere in Rust something is
>> > sleeping in atomic context. Is it possible to do better? Does __FILE__
>> > and __LINE__ exist in Rust?
>> >
>>
>> Sure, you can use:
>>
>> https://doc.rust-lang.org/core/macro.line.html
>
> So i guess might_sleep() needs turning into some sort of macro, calling
> __might_sleep(__FILE__, __LINE__); might_resched();

Yeah, I think we could do such.

Or we could drop the might_sleep call here? We might be able to expect
the improvement C support in Rust in the future.