Skip to contentSkip to conversation

tracing/workqueue: fix 32 bits unfriendly 64 bits division

GIT PULL Frederic Weisbecker 2 participants 2 messages Apr 30, 2009 Tracing

lore
Share & tools
lore
#0 lore raw

Hi Ingo,

Here is a fix for the build error you reported.
This branch can be pulled independantly or on top of tracing/workqueue from the previous pull-request.

Thanks.

The following changes since commit 10c494ea1b75f96d5fca78178732d79e68129cc0:
Frederic Weisbecker (1):
tracing/workqueue: fix 32 bits unfriendly 64 bits division

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing.git tracing/workqueue-2

---

Quoted 1 line

From 10c494ea1b75f96d5fca78178732d79e68129cc0 Mon Sep 17 00:00:00 2001

From: Frederic Weisbecker <[email protected]>
Date: Thu, 30 Apr 2009 16:07:59 +0200
Subject: [PATCH] tracing/workqueue: fix 32 bits unfriendly 64 bits division

To get the average of time consumed by each worklets, we do a direct 64 bits division on wfstat->total_time. This is fine on a 64 bits arch but not on a 32 one on which we can get the following warning:

kernel/built-in.o: In function `workqueue_stat_show':
trace_workqueue.c:(.text+0x74f57): undefined reference to `__udivdi3'

We must use do_div() here to ensure the division is supported on every archs.

[ Impact: fix a build error on 32 bits archs ]

---
 kernel/trace/trace_workqueue.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)
kernel/trace/trace_workqueue.c +11 -2
index eafb4a5..c67be60 100644
@@ -399,13 +399,22 @@ static int workqueue_stat_show(struct seq_file *s, void *p)
 	} else {
 		/* It is effect node, need to print workfunc info */
 		int lastwf = list_is_last(&wfstat->list, &cws->workfunclist);
+		unsigned long long avg_time;
+
+		if (wfstat->executed) {
+			avg_time = wfstat->total_time;
+			do_div(avg_time, wfstat->executed);
+			avg_time = ns2usecs(avg_time);
+		} else {
+			avg_time = 0;
+		}
+
 		seq_printf(s, "  %3d   %6d   %6u   %6llu   %6llu   %c-%pF\n",
 			cws->cpu,
 			wfstat->inserted,
 			wfstat->executed,
 			ns2usecs(wfstat->max_executed_time),
-			!wfstat->executed ? 0 :
-				ns2usecs(wfstat->total_time / wfstat->executed),
+			avg_time,
 			lastwf ? '`' : '|',
 			wfstat->func);
 	}
Signature · 1 line
1.6.2.3
#1 lore raw
Quoted 9 lines · Frederic Weisbecker

Hi Ingo,

Here is a fix for the build error you reported. This branch can be pulled independantly or on top of tracing/workqueue from the previous pull-request.

Thanks.

Quoted 7 lines

The following changes since commit 10c494ea1b75f96d5fca78178732d79e68129cc0:
Frederic Weisbecker (1):
tracing/workqueue: fix 32 bits unfriendly 64 bits division

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing.git tracing/workqueue-2

Thanks, i have pulled this into tip:tracing/workqueues - but that is a temporary branch, lets hold off on merging it into tracing/core, until some of the more fundamental criticisms of Andrew are addressed, ok?

Ing