Skip to contentSkip to conversation

oom_kill: fix calculation of the cpu_time and the run_time

PATCH In review Naohiro Ooiwa 2 participants 3 messages Oct 7, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 oom_kill: fix calculation of the cpu_time and the run_time

Hi all

The cpu-time is in tens of seconds
and the run-time is in thousands of secounds.

but the source code doesn't follow it.

I fixed it and also some white-spaces.
Could you please check this patch.

---
 mm/oom_kill.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
mm/oom_kill.c +5 -5
index 64e5b4b..bddab74 100644
@@ -100,14 +100,14 @@ unsigned long badness(struct task_struct *p, unsigned long uptime)
 
 	/*
 	 * CPU time is in tens of seconds and run time is in thousands
-         * of seconds. There is no particular reason for this other than
-         * that it turned out to work very well in practice.
+	 * of seconds. There is no particular reason for this other than
+	 * that it turned out to work very well in practice.
 	 */
-	cpu_time = (cputime_to_jiffies(p->utime) + cputime_to_jiffies(p->stime))
-		>> (SHIFT_HZ + 3);
+	cpu_time = ((cputime_to_jiffies(p->utime) + cputime_to_jiffies(p->stime))
+		>> SHIFT_HZ) / 10UL;
 
 	if (uptime >= p->start_time.tv_sec)
-		run_time = (uptime - p->start_time.tv_sec) >> 10;
+		run_time = (uptime - p->start_time.tv_sec) / 1000UL;
 	else
 		run_time = 0;
 
Signature · 1 line
1.5.4.1
#1 lore raw
Quoted 6 lines

Hi all

The cpu-time is in tens of seconds
and the run-time is in thousands of secounds.

but the source code doesn't follow it.

Have you seen any trouble?

Quoted 23 lines

I fixed it and also some white-spaces.
Could you please check this patch.

---
 mm/oom_kill.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
mm/oom_kill.c +2 -2
index 64e5b4b..bddab74 100644
@@ -100,14 +100,14 @@ unsigned long badness(struct task_struct *p, unsigned long uptime)
 
 	/*
 	 * CPU time is in tens of seconds and run time is in thousands
-         * of seconds. There is no particular reason for this other than
-         * that it turned out to work very well in practice.
+	 * of seconds. There is no particular reason for this other than
+	 * that it turned out to work very well in practice.
 	 */

mm/oom_kill.c unsigned long badness(struct task_struct *p, unsigned long uptime) · line 112

Quoted 10 lines
mm/oom_kill.c +3 -3
-	cpu_time = (cputime_to_jiffies(p->utime) + cputime_to_jiffies(p->stime))
-		>> (SHIFT_HZ + 3);
+	cpu_time = ((cputime_to_jiffies(p->utime) + cputime_to_jiffies(p->stime))
+		>> SHIFT_HZ) / 10UL;
 
 	if (uptime >= p->start_time.tv_sec)
-		run_time = (uptime - p->start_time.tv_sec) >> 10;
+		run_time = (uptime - p->start_time.tv_sec) / 1000UL;
 	else
 		run_time = 0;

in some architecture, shift-op outperfom divide-op largely. why do you need this change?

#2 lore raw

Hi KOSAKI-san

Thank you for quick reply and checking my patch.

Quoted 1 line

Have you seen any trouble?

No I haven't.

Quoted 1 line

in some architecture, shift-op outperfom divide-op largely.

Of course, but I think that the oom-killer doesn't need high performance. Do you think oom-killer needs it ?

Quoted 1 line

why do you need this change?

Nothing special,
but I write a tips about oom-killer now.

The comments and the source code don't match.
so I think how to write about badness point now.

Therefore, I only think the source code should conform to the comments.

Regards,
Naohiro Ooiwa.

KOSAKI Motohiro さんは書きました:

Quoted 47 lines
Quoted 6 lines

Hi all

The cpu-time is in tens of seconds
and the run-time is in thousands of secounds.

but the source code doesn't follow it.

Have you seen any trouble?

Quoted 22 lines

I fixed it and also some white-spaces.
Could you please check this patch.

---
 mm/oom_kill.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
mm/oom_kill.c +2 -2
index 64e5b4b..bddab74 100644
@@ -100,14 +100,14 @@ unsigned long badness(struct task_struct *p, unsigned long uptime)
 
 	/*
 	 * CPU time is in tens of seconds and run time is in thousands
-         * of seconds. There is no particular reason for this other than
-         * that it turned out to work very well in practice.
+	 * of seconds. There is no particular reason for this other than
+	 * that it turned out to work very well in practice.
 	 */

mm/oom_kill.c unsigned long badness(struct task_struct *p, unsigned long uptime) · line 112

Quoted 10 lines
mm/oom_kill.c +3 -3
-	cpu_time = (cputime_to_jiffies(p->utime) + cputime_to_jiffies(p->stime))
-		>> (SHIFT_HZ + 3);
+	cpu_time = ((cputime_to_jiffies(p->utime) + cputime_to_jiffies(p->stime))
+		>> SHIFT_HZ) / 10UL;
 
 	if (uptime >= p->start_time.tv_sec)
-		run_time = (uptime - p->start_time.tv_sec) >> 10;
+		run_time = (uptime - p->start_time.tv_sec) / 1000UL;
 	else
 		run_time = 0;

in some architecture, shift-op outperfom divide-op largely. why do you need this change?