Re: [RFC/RFT PATCH v3] sched: automated per tty task groups
From: Peter Zijlstra
Date: Mon Nov 15 2010 - 03:57:18 EST
On Sun, 2010-11-14 at 18:13 -0700, Mike Galbraith wrote:
> +static inline struct task_group *
> +autogroup_task_group(struct task_struct *p, struct task_group *tg)
> +{
> + int enabled = ACCESS_ONCE(sysctl_sched_autogroup_enabled);
> +
> + enabled &= (tg == &root_task_group);
> + enabled &= (p->sched_class == &fair_sched_class);
> + enabled &= (!(p->flags & PF_EXITING));
> +
> + if (enabled)
> + return p->signal->autogroup->tg;
> +
> + return tg;
> +}
That made me go wtf.. curious way of writing things.
I guess the usual way of writing that (which is admittedly a little more
verbose) would be something like:
static bool
task_wants_autogroup(struct task_struct *tsk, struct task_group *tg)
{
if (tg != &root_task_group)
return false;
if (tsk->sched_class != &fair_sched_class)
return false;
if (tsk->flags & PF_EXITING)
return false;
return true;
}
static inline struct task_group *
autogroup_task_group(struct task_struct *tsk, struct task_group *tg)
{
if (task_wants_autogroup(tsk, tg))
return tsk->signal->autogroup->tg;
return tg;
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/