Messages in this thread | | | Subject | Re: [RFC/RFT PATCH v3] sched: automated per tty task groups | From | Peter Zijlstra <> | Date | Mon, 15 Nov 2010 09:57:18 +0100 |
| |
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; }
| |