[PATCH] hrtimer.c : Remove redundant thread state settings

Lizhe posted 1 patch 1 year, 11 months ago
kernel/time/hrtimer.c | 2 --
1 file changed, 2 deletions(-)
[PATCH] hrtimer.c : Remove redundant thread state settings
Posted by Lizhe 1 year, 11 months ago
After a thread is awakened, its state is already task_running

Signed-off-by: Lizhe <sensor1010@163.com>
---
 kernel/time/hrtimer.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index 760793998cdd..b123e9f4401a 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -2310,8 +2310,6 @@ schedule_hrtimeout_range_clock(ktime_t *expires, u64 delta,
 	hrtimer_cancel(&t.timer);
 	destroy_hrtimer_on_stack(&t.timer);
 
-	__set_current_state(TASK_RUNNING);
-
 	return !t.task ? 0 : -EINTR;
 }
 EXPORT_SYMBOL_GPL(schedule_hrtimeout_range_clock);
-- 
2.25.1
Re: [PATCH] hrtimer.c : Remove redundant thread state settings
Posted by Thomas Gleixner 1 year, 11 months ago
On Wed, Jan 10 2024 at 06:13, Lizhe wrote:
> After a thread is awakened, its state is already task_running

That's correct, but please look at hrtimer_wakeup() and the conditional
schedule() invocation in schedule_hrtimeout_range_clock(). You break the
guarantee that this function returns with task state == TASK_RUNNING.

Thanks,

        tglx
Re:Re: [PATCH] hrtimer.c : Remove redundant thread state settings
Posted by lizhe 1 year, 11 months ago





Hi, 
    Please review this patch, It does not check the condition when executing the scheduler() function.
       
                                                                                                       Lizhe
                                                                                           thanks











At 2024-01-12 00:44:20, "Thomas Gleixner" <tglx@linutronix.de> wrote:
>On Wed, Jan 10 2024 at 06:13, Lizhe wrote:
>> After a thread is awakened, its state is already task_running
>
>That's correct, but please look at hrtimer_wakeup() and the conditional
>schedule() invocation in schedule_hrtimeout_range_clock(). You break the
>guarantee that this function returns with task state == TASK_RUNNING.
>
>Thanks,
>
>        tglx
From 81a6920517e5e2d9ac6f5b3e464b64b550f07049 Mon Sep 17 00:00:00 2001
From: Lizhe <sensor1010@163.com>
Date: Thu, 11 Jan 2024 20:57:01 -0800
Subject: [PATCH] drivers/dm-crypt.c : remove redundant state settings after
 waking up

The task status has been set to TASK_RUNNING in schedule().
No need to set again here.

Signed-off-by: Lizhe <sensor1010@163.com>
---
 drivers/md/dm-crypt.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index 855b482cbff1..ab1e30630e64 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -1948,7 +1948,6 @@ static int dmcrypt_write(void *data)
 
 		schedule();
 
-		set_current_state(TASK_RUNNING);
 		spin_lock_irq(&cc->write_thread_lock);
 		goto continue_locked;
 
-- 
2.25.1