Re: [PATCH v7 6/7] rust: Add read_poll_timeout functions

From: FUJITA Tomonori
Date: Mon Dec 30 2024 - 20:33:24 EST


On Mon, 30 Dec 2024 10:43:52 -0800
Boqun Feng <boqun.feng@xxxxxxxxx> wrote:

>> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
>> index 3e5a6bf587f9..6ed70c801172 100644
>> --- a/kernel/sched/core.c
>> +++ b/kernel/sched/core.c
>> @@ -8670,7 +8670,10 @@ void __init sched_init(void)
>>
>> #ifdef CONFIG_DEBUG_ATOMIC_SLEEP
>>
>> -void __might_sleep(const char *file, int line)
>> +extern inline void __might_resched_precision(const char *file, int len,
>> + int line, unsigned int offsets);
>
> Instead of declaring this as an "extern inline" I think you can just
> make it a static inline and move the function body up here. It should
> resolve the sparse warning.

I made __might_resched_precision() static and simply fixed declaration
in the following way.

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 6ed70c801172..d9ac66dc66d3 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -8670,8 +8670,8 @@ void __init sched_init(void)

#ifdef CONFIG_DEBUG_ATOMIC_SLEEP

-extern inline void __might_resched_precision(const char *file, int len,
- int line, unsigned int offsets);
+static void __might_resched_precision(const char *file, int len,
+ int line, unsigned int offsets);

void __might_sleep_precision(const char *file, int len, int line)
{
@@ -8719,7 +8719,8 @@ static inline bool resched_offsets_ok(unsigned int offsets)
return nested == offsets;
}

-void __might_resched_precision(const char *file, int len, int line, unsigned int offsets)
+static void __might_resched_precision(const char *file, int len, int line,
+ unsigned int offsets)
{
/* Ratelimiting timestamp: */
static unsigned long prev_jiffy;