Skip to contentSkip to conversation

remove unlikely macros in workqueue.c/queue_delayed_work_on

PATCH In review [email protected] 3 participants 3 messages May 29, 2008 Workqueue

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 remove unlikely macros in workqueue.c/queue_delayed_work_on

cpufreq_ondemand governor call queue_delayed_work_on with entry parameter "cpu" every sample rate(every logical cpu during 20ms).check the value of "cpu","cpu>=0" condition meeting rate is over than 90%.

This patch remove the unlikely macros to benefit kernel schedule and reader comprehension.

---
 workqueue.c    |    2++++++
 1 file changed,     1 insertions(+), 1 deletions(-)
kernel/workqueue.c +0 -0
@@ -230,7 +230,7 @@
		timer->data = (unsigned long)dwork;
		timer->function = delayed_work_timer_fn;

- if (unlikely(cpu >= 0))
+ if (cpu >= 0)

			add_timer_on(timer, cpu);
		else
			add_timer(timer);
#1 lore raw
Quoted 16 lines · On Thu, 29 May 2008 00:02:50 -0700 (PDT) [email protected] wrote:

cpufreq_ondemand governor call queue_delayed_work_on with entry parameter "cpu" every sample rate(every logical cpu during 20ms).check the value of "cpu","cpu>=0" condition meeting rate is over than 90%.

This patch remove the unlikely macros to benefit kernel schedule and reader comprehension.

---
 workqueue.c    |    2++++++
 1 file changed,     1 insertions(+), 1 deletions(-)

kernel/workqueue.c line 236

Quoted 8 lines
kernel/workqueue.c +1 -1
@@ -230,7 +230,7 @@
 		timer->data = (unsigned long)dwork;
 		timer->function = delayed_work_timer_fn;
 
-		if (unlikely(cpu >= 0))
+		if (cpu >= 0)
 			add_timer_on(timer, cpu);
 		else
 			add_timer(timer);

This is very much dependent on what workload the machine is running.

There are 189 queue_delayed_work() callsites and they all want the unlikely() to be there.

There are six queue_delayed_work_on() callsites and they don't want the unlikely().

Don't know what to do here. Fortunately it doesn't matter much ;)

-mm has profile-likely-unlikely-macros.patch which can be used to instrument these things (that feature seems to get broken regularly though).

But the instrumentation should be performed across a broad range of workloads.

#2 lore raw
Quoted 37 lines · On Thu, 29 May 2008 13:29:15 -0700 Andrew Morton <[email protected]>…
Quoted 21 lines · On Thu, 29 May 2008 00:02:50 -0700 (PDT) [email protected] wrote:

cpufreq_ondemand governor call queue_delayed_work_on with entry parameter "cpu" every sample rate(every logical cpu during 20ms).check the value of "cpu","cpu>=0" condition meeting rate is over than 90%.

This patch remove the unlikely macros to benefit kernel schedule and reader comprehension.

---
 workqueue.c    |    2++++++
 1 file changed,     1 insertions(+), 1 deletions(-)

--- linux-2.6/kernel/workqueue.c 2008-05-13
10:10:11.000000000 -0400 +++
linux-2.6-new/kernel/workqueue.c 2008-05-29
09:46:16.000000000 -0400 @@ -230,7 +230,7 @@ timer->data = (unsigned long)dwork; timer->function = delayed_work_timer_fn;

(quoted diff) +1 -1
-		if (unlikely(cpu >= 0))
+		if (cpu >= 0)
Quoted 4 lines
			add_timer_on(timer, cpu);
		else
			add_timer(timer);

This is very much dependent on what workload the machine is running.

There are 189 queue_delayed_work() callsites and they all want the unlikely() to be there.

There are six queue_delayed_work_on() callsites and they don't want the unlikely().

Quoted 8 lines

Don't know what to do here. Fortunately it doesn't matter much ;)

-mm has profile-likely-unlikely-macros.patch which can be used to instrument these things (that feature seems to get broken regularly though).

But the instrumentation should be performed across a broad range of workloads.

and on x86 it barely makes any difference at all, at best you can handwave a little about icache footprint.

/me ponders checking if we get a code size reduction by defining these animals to be empty passthrough