Re: [PATCH v2] sched/rt: Rework for_each_process_thread() iterations in tg_has_rt_tasks()
From: Peter Zijlstra
Date: Wed Apr 25 2018 - 15:49:28 EST
On Fri, Apr 20, 2018 at 01:06:31PM +0300, Kirill Tkhai wrote:
> @@ -2406,12 +2407,15 @@ static inline int tg_has_rt_tasks(struct task_group *tg)
> if (task_group_is_autogroup(tg))
> return 0;
>
> - for_each_process_thread(g, p) {
> - if (rt_task(p) && task_group(p) == tg)
> - return 1;
> - }
> + css_task_iter_start(&tg->css, 0, &it);
> + while ((task = css_task_iter_next(&it)))
> + if (rt_task(task)) {
> + ret = 1;
> + break;
> + }
Aside from the missing {} there, the patch looks OK I suppose.
The races found seems somewhat dodgy, but like you argue, they're not in
fact new :/
> + css_task_iter_end(&it);
>
> - return 0;
> + return ret;
> }
>