Re: [PATCH v10 1/8] sched/core: Add __might_sleep_precision()

From: FUJITA Tomonori
Date: Mon Feb 17 2025 - 01:45:10 EST


On Sun, 16 Feb 2025 17:51:32 -0800
Boqun Feng <boqun.feng@xxxxxxxxx> wrote:

>> > >> + unsigned int offsets)
>> > >> {
>> > >> /* Ratelimiting timestamp: */
>> > >> static unsigned long prev_jiffy;
>> > >> @@ -8740,8 +8723,10 @@ void __might_resched(const char *file, int line, unsigned int offsets)
>> > >> /* Save this before calling printk(), since that will clobber it: */
>> > >> preempt_disable_ip = get_preempt_disable_ip(current);
>> > >>
>> > >> - pr_err("BUG: sleeping function called from invalid context at %s:%d\n",
>> > >> - file, line);
>> > >> + if (len < 0)
>> > >> + len = strlen(file);
>> > >
>> > > No need for strlen(), just use a big number instead of -1.
>> > > Anything bigger than a sane upper limit on the filename length will do.
>> >
>> > Ah, that's right. Just passing the maximum precision (1<<15-1) works.
>> >
>> > The precision specifies the maximum length. vsnprintf() always
>> > iterates through a string until it reaches the maximum length or
>> > encounters the null terminator. So strlen() here is useless.
>> >
>> > Alice and Boqun, the above change is fine? Can I keep the tags?
>>
>> I'd probably like a comment explaining the meaning of this constant
>> somewhere, but sure ok with me.
>>
>
> Agreed. The code should be fine but need some comments.

Of course, I'll add some in the next version.

Thanks!