public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kernel/fork.c: define reset_task_cputimes()
@ 2009-02-26  5:17 Gustavo F. Padovan
  2009-02-26 22:53 ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: Gustavo F. Padovan @ 2009-02-26  5:17 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel

Group all vars that receive cputime_zero in the same static function.
This also cleans the code.

Signed-off-by: Gustavo F. Padovan <gustavo@las.ic.unicamp.br>
---
 include/linux/sched.h |   11 +++++++++++
 kernel/fork.c         |    8 +-------
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/include/linux/sched.h b/include/linux/sched.h
index 8981e52..1a64587 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1595,6 +1595,17 @@ extern cputime_t task_utime(struct task_struct *p);
 extern cputime_t task_stime(struct task_struct *p);
 extern cputime_t task_gtime(struct task_struct *p);
 
+static inline void reset_task_cputimes(struct task_struct *t)
+{
+	t->utime = cputime_zero;
+	t->stime = cputime_zero;
+	t->gtime = cputime_zero;
+	t->utimescaled = cputime_zero;
+	t->stimescaled = cputime_zero;
+	t->prev_utime = cputime_zero;
+	t->prev_stime = cputime_zero;
+}
+
 /*
  * Per process flags
  */
diff --git a/kernel/fork.c b/kernel/fork.c
index a66fbde..9856abe 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1031,13 +1031,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
 	clear_tsk_thread_flag(p, TIF_SIGPENDING);
 	init_sigpending(&p->pending);
 
-	p->utime = cputime_zero;
-	p->stime = cputime_zero;
-	p->gtime = cputime_zero;
-	p->utimescaled = cputime_zero;
-	p->stimescaled = cputime_zero;
-	p->prev_utime = cputime_zero;
-	p->prev_stime = cputime_zero;
+	reset_task_cputimes(p);
 
 	p->default_timer_slack_ns = current->timer_slack_ns;
 
-- 
1.6.0.6


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

* Re: [PATCH] kernel/fork.c: define reset_task_cputimes()
  2009-02-26  5:17 [PATCH] kernel/fork.c: define reset_task_cputimes() Gustavo F. Padovan
@ 2009-02-26 22:53 ` Andrew Morton
  2009-02-28  2:50   ` Gustavo F. Padovan
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2009-02-26 22:53 UTC (permalink / raw)
  To: Gustavo F. Padovan; +Cc: linux-kernel

On Thu, 26 Feb 2009 02:17:55 -0300
"Gustavo F. Padovan" <gustavo@las.ic.unicamp.br> wrote:

> Group all vars that receive cputime_zero in the same static function.
> This also cleans the code.
> 
> Signed-off-by: Gustavo F. Padovan <gustavo@las.ic.unicamp.br>
> ---
>  include/linux/sched.h |   11 +++++++++++
>  kernel/fork.c         |    8 +-------
>  2 files changed, 12 insertions(+), 7 deletions(-)
> 
> diff --git a/include/linux/sched.h b/include/linux/sched.h
> index 8981e52..1a64587 100644
> --- a/include/linux/sched.h
> +++ b/include/linux/sched.h
> @@ -1595,6 +1595,17 @@ extern cputime_t task_utime(struct task_struct *p);
>  extern cputime_t task_stime(struct task_struct *p);
>  extern cputime_t task_gtime(struct task_struct *p);
>  
> +static inline void reset_task_cputimes(struct task_struct *t)
> +{
> +	t->utime = cputime_zero;
> +	t->stime = cputime_zero;
> +	t->gtime = cputime_zero;
> +	t->utimescaled = cputime_zero;
> +	t->stimescaled = cputime_zero;
> +	t->prev_utime = cputime_zero;
> +	t->prev_stime = cputime_zero;
> +}
> +
>  /*
>   * Per process flags
>   */
> diff --git a/kernel/fork.c b/kernel/fork.c
> index a66fbde..9856abe 100644
> --- a/kernel/fork.c
> +++ b/kernel/fork.c
> @@ -1031,13 +1031,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
>  	clear_tsk_thread_flag(p, TIF_SIGPENDING);
>  	init_sigpending(&p->pending);
>  
> -	p->utime = cputime_zero;
> -	p->stime = cputime_zero;
> -	p->gtime = cputime_zero;
> -	p->utimescaled = cputime_zero;
> -	p->stimescaled = cputime_zero;
> -	p->prev_utime = cputime_zero;
> -	p->prev_stime = cputime_zero;
> +	reset_task_cputimes(p);
>  
>  	p->default_timer_slack_ns = current->timer_slack_ns;
>  

I cannot see much point in doing this, unless you have some other patch
which adds a second caller of reset_task_cputimes()?



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

* Re: [PATCH] kernel/fork.c: define reset_task_cputimes()
  2009-02-26 22:53 ` Andrew Morton
@ 2009-02-28  2:50   ` Gustavo F. Padovan
  0 siblings, 0 replies; 3+ messages in thread
From: Gustavo F. Padovan @ 2009-02-28  2:50 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

On Thu, Feb 26, 2009 at 7:53 PM, Andrew Morton
<akpm@linux-foundation.org> wrote:
> On Thu, 26 Feb 2009 02:17:55 -0300
> "Gustavo F. Padovan" <gustavo@las.ic.unicamp.br> wrote:
>
>> Group all vars that receive cputime_zero in the same static function.
>> This also cleans the code.
>>
>> Signed-off-by: Gustavo F. Padovan <gustavo@las.ic.unicamp.br>
>> ---
>>  include/linux/sched.h |   11 +++++++++++
>>  kernel/fork.c         |    8 +-------
>>  2 files changed, 12 insertions(+), 7 deletions(-)
>>
>> diff --git a/include/linux/sched.h b/include/linux/sched.h
>> index 8981e52..1a64587 100644
>> --- a/include/linux/sched.h
>> +++ b/include/linux/sched.h
>> @@ -1595,6 +1595,17 @@ extern cputime_t task_utime(struct task_struct *p);
>>  extern cputime_t task_stime(struct task_struct *p);
>>  extern cputime_t task_gtime(struct task_struct *p);
>>
>> +static inline void reset_task_cputimes(struct task_struct *t)
>> +{
>> +     t->utime = cputime_zero;
>> +     t->stime = cputime_zero;
>> +     t->gtime = cputime_zero;
>> +     t->utimescaled = cputime_zero;
>> +     t->stimescaled = cputime_zero;
>> +     t->prev_utime = cputime_zero;
>> +     t->prev_stime = cputime_zero;
>> +}
>> +
>>  /*
>>   * Per process flags
>>   */
>> diff --git a/kernel/fork.c b/kernel/fork.c
>> index a66fbde..9856abe 100644
>> --- a/kernel/fork.c
>> +++ b/kernel/fork.c
>> @@ -1031,13 +1031,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
>>       clear_tsk_thread_flag(p, TIF_SIGPENDING);
>>       init_sigpending(&p->pending);
>>
>> -     p->utime = cputime_zero;
>> -     p->stime = cputime_zero;
>> -     p->gtime = cputime_zero;
>> -     p->utimescaled = cputime_zero;
>> -     p->stimescaled = cputime_zero;
>> -     p->prev_utime = cputime_zero;
>> -     p->prev_stime = cputime_zero;
>> +     reset_task_cputimes(p);
>>
>>       p->default_timer_slack_ns = current->timer_slack_ns;
>>
>
> I cannot see much point in doing this, unless you have some other patch
> which adds a second caller of reset_task_cputimes()?

No. I don't have. So, cancel the patch.

>
>
>



-- 
Gustavo F. Padovan

Computer Engineering Student
Institute of Computing - IC
University of Campinas - UNICAMP

email: gustavo@las.ic.unicamp.br
gtalk: gfpadovan@gmail.com
mobile: +55 19 81030803

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

end of thread, other threads:[~2009-02-28  2:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-26  5:17 [PATCH] kernel/fork.c: define reset_task_cputimes() Gustavo F. Padovan
2009-02-26 22:53 ` Andrew Morton
2009-02-28  2:50   ` Gustavo F. Padovan

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