2011-04-21 13:15:59

by Hillf Danton

[permalink] [raw]
Subject: [PATCH] sched: deduplicate mm checks in normalize_rt_tasks()

When normalizing realtime tasks, only user tasks are concerned by
checking their ->mm.
If the task is not realtime, the -mm is checked again, thus the
overwork could be removed.

Signed-off-by: Hillf Danton <[email protected]>
---

--- a/kernel/sched.c 2011-03-30 03:09:48.000000000 +0800
+++ b/kernel/sched.c 2011-04-21 20:59:28.000000000 +0800
@@ -8364,7 +8364,7 @@ void normalize_rt_tasks(void)
* Renice negative nice level userspace
* tasks back to 0:
*/
- if (TASK_NICE(p) < 0 && p->mm)
+ if (TASK_NICE(p) < 0)
set_user_nice(p, 0);
continue;
}


2011-04-21 13:29:15

by Yong Zhang

[permalink] [raw]
Subject: Re: [PATCH] sched: deduplicate mm checks in normalize_rt_tasks()

On Thu, Apr 21, 2011 at 09:15:56PM +0800, Hillf Danton wrote:
> When normalizing realtime tasks, only user tasks are concerned by
> checking their ->mm.
> If the task is not realtime, the -mm is checked again, thus the
> overwork could be removed.
>
> Signed-off-by: Hillf Danton <[email protected]>
> ---
>
> --- a/kernel/sched.c 2011-03-30 03:09:48.000000000 +0800
> +++ b/kernel/sched.c 2011-04-21 20:59:28.000000000 +0800
> @@ -8364,7 +8364,7 @@ void normalize_rt_tasks(void)
> * Renice negative nice level userspace
> * tasks back to 0:
> */
> - if (TASK_NICE(p) < 0 && p->mm)
> + if (TASK_NICE(p) < 0)

This looks good.

And we can also move TASK_NICE(p) < 0 to the upper if(),
like:
if (!rt_task(p) && TASK_NICE(p) < 0) {
set_user_nice(p, 0);
continue;
}

to reduce one level if() to make code cleaner :)

Thanks,
Yong

> set_user_nice(p, 0);
> continue;
> }
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/

2011-04-21 13:43:22

by Yong Zhang

[permalink] [raw]
Subject: Re: [PATCH] sched: deduplicate mm checks in normalize_rt_tasks()

On Thu, Apr 21, 2011 at 09:29:04PM +0800, Yong Zhang wrote:
> On Thu, Apr 21, 2011 at 09:15:56PM +0800, Hillf Danton wrote:
> > When normalizing realtime tasks, only user tasks are concerned by
> > checking their ->mm.
> > If the task is not realtime, the -mm is checked again, thus the
> > overwork could be removed.
> >
> > Signed-off-by: Hillf Danton <[email protected]>
> > ---
> >
> > --- a/kernel/sched.c 2011-03-30 03:09:48.000000000 +0800
> > +++ b/kernel/sched.c 2011-04-21 20:59:28.000000000 +0800
> > @@ -8364,7 +8364,7 @@ void normalize_rt_tasks(void)
> > * Renice negative nice level userspace
> > * tasks back to 0:
> > */
> > - if (TASK_NICE(p) < 0 && p->mm)
> > + if (TASK_NICE(p) < 0)
>
> This looks good.
>
> And we can also move TASK_NICE(p) < 0 to the upper if(),
> like:
> if (!rt_task(p) && TASK_NICE(p) < 0) {
> set_user_nice(p, 0);
> continue;
> }
>
> to reduce one level if() to make code cleaner :)

Damm, I'm wrong here, just ignore it.

Yours is good.

Reviewed-by: Yong Zhang <[email protected]>

>
> Thanks,
> Yong
>
> > set_user_nice(p, 0);
> > continue;
> > }
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> > the body of a message to [email protected]
> > More majordomo info at http://vger.kernel.org/majordomo-info.html
> > Please read the FAQ at http://www.tux.org/lkml/

2011-04-21 13:50:38

by Hillf Danton

[permalink] [raw]
Subject: Re: [PATCH] sched: deduplicate mm checks in normalize_rt_tasks()

On Thu, Apr 21, 2011 at 9:43 PM, Yong Zhang <[email protected]> wrote:
> On Thu, Apr 21, 2011 at 09:29:04PM +0800, Yong Zhang wrote:
>> On Thu, Apr 21, 2011 at 09:15:56PM +0800, Hillf Danton wrote:
>> > When normalizing realtime tasks, only user tasks are concerned by
>> > checking their ->mm.
>> > If the task is not realtime, the -mm is checked again, thus the
>> > overwork could be removed.
>> >
>> > Signed-off-by: Hillf Danton <[email protected]>
>> > ---
>> >
>> > --- a/kernel/sched.c        2011-03-30 03:09:48.000000000 +0800
>> > +++ b/kernel/sched.c        2011-04-21 20:59:28.000000000 +0800
>> > @@ -8364,7 +8364,7 @@ void normalize_rt_tasks(void)
>> >                      * Renice negative nice level userspace
>> >                      * tasks back to 0:
>> >                      */
>> > -                   if (TASK_NICE(p) < 0 && p->mm)
>> > +                   if (TASK_NICE(p) < 0)
>>
>> This looks good.
>>
>> And we can also move TASK_NICE(p) < 0 to the upper if(),
>> like:
>>               if (!rt_task(p) && TASK_NICE(p) < 0) {
>>                       set_user_nice(p, 0);
>>                       continue;
>>               }
>>
>> to reduce one level if() to make code cleaner :)
>
> Damm, I'm wrong here, just ignore it.
>
Hi Yong

We could not be fine every time, right?

thanks
Hillf

> Yours is good.
>
> Reviewed-by: Yong Zhang <[email protected]>
>
>>
>> Thanks,
>> Yong
>>
>> >                             set_user_nice(p, 0);
>> >                     continue;
>> >             }
>> > --
>> > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>> > the body of a message to [email protected]
>> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
>> > Please read the FAQ at  http://www.tux.org/lkml/