Skip to contentSkip to conversation

cpuidle: Remove unnecessary TIF_NR_POLLING clear/TIF_NEED_RESCHED folding

PATCH In review Frederic Weisbecker 1 participant 4 messages Nov 13, 2023 – Nov 22, 2023 CPU idle time management framework

lore
Share & tools
lore
#0 lore raw

cover cpuidle: Remove unnecessary TIF_NR_POLLING clear/TIF_NEED_RESCHED folding

Hi Rafael,

Those are cpuidle patches that you acked from a previous posting. I figured they would be best routed through you so I'm reposting those strict cpuidle bits from the series.

Thanks.

Frederic Weisbecker (2):
cpuidle: Remove unnecessary current_clr_polling_and_test() from
haltpoll
cpuidle: Remove unnecessary current_clr_polling() on poll_idle()

 drivers/cpuidle/cpuidle-haltpoll.c | 5 +----
 drivers/cpuidle/poll_state.c       | 2 --
 2 files changed, 1 insertion(+), 6 deletions(-)
Signature · 1 line
2.42.1
#1 lore raw

PATCH 1/2 cpuidle: Remove unnecessary current_clr_polling_and_test() from haltpoll

When cpuidle drivers ->enter() callback are called, the TIF_NR_POLLING flag is cleared already and TIF_NEED_RESCHED checked by call_cpuidle().

Therefore calling current_clr_polling_and_test() is redundant here and further setting of TIF_NEED_RESCHED will result in an IPI and thus an idle loop exit. This call can be safely removed.

---
 drivers/cpuidle/cpuidle-haltpoll.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/cpuidle/cpuidle-haltpoll.c +1 -4
index e66df22f9695..b641bc535102 100644
@@ -28,11 +28,8 @@ static enum cpuhp_state haltpoll_hp_state;
 static int default_enter_idle(struct cpuidle_device *dev,
 			      struct cpuidle_driver *drv, int index)
 {
-	if (current_clr_polling_and_test()) {
-		local_irq_enable();
-		return index;
-	}
 	arch_cpu_idle();
+
 	return index;
 }
 
Signature · 1 line
2.42.1
#2 lore raw

PATCH 2/2 cpuidle: Remove unnecessary current_clr_polling() on poll_idle()

In reply to Frederic Weisbecker

There is no point in clearing TIF_NR_POLLING and folding TIF_NEED_RESCHED upon poll_idle() exit because cpuidle_idle_call() is going to set again TIF_NR_POLLING anyway. Also if TIF_NEED_RESCHED is set, it will be folded and TIF_NR_POLLING will be cleared at the end of do_idle().

---
 drivers/cpuidle/poll_state.c | 2 --
 1 file changed, 2 deletions(-)
drivers/cpuidle/poll_state.c +0 -2
index 9b6d90a72601..d5cb3eb85a54 100644
@@ -40,8 +40,6 @@ static int __cpuidle poll_idle(struct cpuidle_device *dev,
 	}
 	raw_local_irq_disable();
 
-	current_clr_polling();
-
 	return index;
 }
 
Signature · 1 line
2.42.1
#3 lore raw

Re: [PATCH 2/2] cpuidle: Remove unnecessary current_clr_polling() on poll_idle()

Quoted 7 lines · Frederic Weisbecker

There is no point in clearing TIF_NR_POLLING and folding TIF_NEED_RESCHED upon poll_idle() exit because cpuidle_idle_call() is going to set again TIF_NR_POLLING anyway. Also if TIF_NEED_RESCHED is set, it will be folded and TIF_NR_POLLING will be cleared at the end of do_idle().

Please discard this one, I'm taking a new way to deal with that.

Thanks.

Quoted 20 lines
---
 drivers/cpuidle/poll_state.c | 2 --
 1 file changed, 2 deletions(-)
drivers/cpuidle/poll_state.c +0 -2
index 9b6d90a72601..d5cb3eb85a54 100644
@@ -40,8 +40,6 @@ static int __cpuidle poll_idle(struct cpuidle_device *dev,
 	}
 	raw_local_irq_disable();
 
-	current_clr_polling();
-
 	return index;
 }
 
Signature · 1 line
2.42.1