public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] oom_kill: fix calculation of the cpu_time and the run_time
@ 2008-10-07 10:34 Naohiro Ooiwa
  2008-10-07 11:15 ` KOSAKI Motohiro
  0 siblings, 1 reply; 3+ messages in thread
From: Naohiro Ooiwa @ 2008-10-07 10:34 UTC (permalink / raw)
  To: linux-kernel

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.


Signed-off-by: Naohiro Ooiwa <nooiwa@miraclelinux.com>
---
 mm/oom_kill.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 64e5b4b..bddab74 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -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;

-- 
1.5.4.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] oom_kill: fix calculation of the cpu_time and the run_time
  2008-10-07 10:34 [PATCH] oom_kill: fix calculation of the cpu_time and the run_time Naohiro Ooiwa
@ 2008-10-07 11:15 ` KOSAKI Motohiro
  2008-10-07 16:14   ` Naohiro Ooiwa
  0 siblings, 1 reply; 3+ messages in thread
From: KOSAKI Motohiro @ 2008-10-07 11:15 UTC (permalink / raw)
  To: Naohiro Ooiwa; +Cc: kosaki.motohiro, linux-kernel

> 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?

> 
> I fixed it and also some white-spaces.
> Could you please check this patch.
> 
> 
> Signed-off-by: Naohiro Ooiwa <nooiwa@miraclelinux.com>
> ---
>  mm/oom_kill.c |   10 +++++-----
>  1 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/mm/oom_kill.c b/mm/oom_kill.c
> index 64e5b4b..bddab74 100644
> --- a/mm/oom_kill.c
> +++ b/mm/oom_kill.c
> @@ -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;

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




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] oom_kill: fix calculation of the cpu_time and the run_time
  2008-10-07 11:15 ` KOSAKI Motohiro
@ 2008-10-07 16:14   ` Naohiro Ooiwa
  0 siblings, 0 replies; 3+ messages in thread
From: Naohiro Ooiwa @ 2008-10-07 16:14 UTC (permalink / raw)
  To: KOSAKI Motohiro; +Cc: linux-kernel

Hi KOSAKI-san

Thank you for quick reply and checking my patch.


> Have you seen any trouble?

No I haven't.

> 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 ?

> 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 さんは書きました:
>> 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?
> 
>> I fixed it and also some white-spaces.
>> Could you please check this patch.
>>
>>
>> Signed-off-by: Naohiro Ooiwa <nooiwa@miraclelinux.com>
>> ---
>>  mm/oom_kill.c |   10 +++++-----
>>  1 files changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/mm/oom_kill.c b/mm/oom_kill.c
>> index 64e5b4b..bddab74 100644
>> --- a/mm/oom_kill.c
>> +++ b/mm/oom_kill.c
>> @@ -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;
> 
> in some architecture, shift-op outperfom divide-op largely.
> why do you need this change?
> 
> 
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-10-07 16:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-07 10:34 [PATCH] oom_kill: fix calculation of the cpu_time and the run_time Naohiro Ooiwa
2008-10-07 11:15 ` KOSAKI Motohiro
2008-10-07 16:14   ` Naohiro Ooiwa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox