Re: [PATCH v9 1/8] sched/core: Add __might_sleep_precision()
From: Peter Zijlstra <peterz@infradead.org>
Date: 2025-02-01 12:16:33
Also in:
lkml, rust-for-linux
On Wed, Jan 29, 2025 at 05:14:54PM -0800, Boqun Feng wrote:
On Thu, Jan 30, 2025 at 08:56:44AM +0900, FUJITA Tomonori wrote:quoted
On Tue, 28 Jan 2025 12:37:38 +0100 Peter Zijlstra [off-list ref] wrote:quoted
On Sat, Jan 25, 2025 at 07:18:46PM +0900, FUJITA Tomonori wrote:quoted
Add __might_sleep_precision(), Rust friendly version of __might_sleep(), which takes a pointer to a string with the length instead of a null-terminated string. Rust's core::panic::Location::file(), which gives the file name of a caller, doesn't provide a null-terminated string. __might_sleep_precision() uses a precision specifier in the printk format, which specifies the length of a string; a string doesn't need to be a null-terminated. Modify __might_sleep() to call __might_sleep_precision() but the impact should be negligible. strlen() isn't called in a normal case; it's called only when printing the error (sleeping function called from invalid context). Note that Location::file() providing a null-terminated string for better C interoperability is under discussion [1].Urgh :/Yeah... so not acceptable?
Just frustrated we 'need' more ugly to deal with Rust being stupid.
I would like to see some concrete and technical reasons for why it's not acceptable ;-) I'm not sure whether Peter was against this patch or just not happy about Location::file() providing a null-terminated string is a WIP.
The latter. I just hate on Rust for being designed by a bunch of C haters, not wanting to acknowledge the whole frigging world runs on C and they *have* to deal with interoperability. That got us a whole pile of ugly including this.