Skip to contentSkip to conversation

hrtimer.c : Remove redundant thread state settings

PATCH In review Lizhe 2 participants 3 messages Jan 10, 2024 – Jan 12, 2024

Subsystems (2)
lore
Share & tools
lore

Lizhe

author
#0 lore raw

PATCH 1/1 hrtimer.c : Remove redundant thread state settings

After a thread is awakened, its state is already task_running

---
 kernel/time/hrtimer.c | 2 --
 1 file changed, 2 deletions(-)
kernel/time/hrtimer.c +0 -2
index 760793998cdd..b123e9f4401a 100644
@@ -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);
Signature · 1 line
2.25.1
#1 lore raw
Quoted 1 line · Lizhe

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

author
#2 lore raw

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

Lizhe
thanks

Quoted 10 lines · Thomas Gleixner
Quoted 1 line · Lizhe

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 <[email protected]>
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.

---
 drivers/md/dm-crypt.c | 1 -
 1 file changed, 1 deletion(-)
drivers/md/dm-crypt.c +0 -1
index 855b482cbff1..ab1e30630e64 100644
@@ -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;
 
Signature · 1 line
2.25.1