From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932890AbcFQOGW (ORCPT ); Fri, 17 Jun 2016 10:06:22 -0400 Received: from merlin.infradead.org ([205.233.59.134]:40503 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753413AbcFQOGV (ORCPT ); Fri, 17 Jun 2016 10:06:21 -0400 Date: Fri, 17 Jun 2016 16:06:06 +0200 From: Peter Zijlstra To: Vincent Guittot Cc: Yuyang Du , Ingo Molnar , linux-kernel , Mike Galbraith , Benjamin Segall , Paul Turner , Morten Rasmussen , Dietmar Eggemann , Matt Fleming Subject: Re: [PATCH 3/4] sched,cgroup: Fix cpu_cgroup_fork() Message-ID: <20160617140606.GR30154@twins.programming.kicks-ass.net> References: <20160617120136.064100812@infradead.org> <20160617120454.080767343@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 17, 2016 at 03:58:37PM +0200, Vincent Guittot wrote: > On 17 June 2016 at 14:01, Peter Zijlstra wrote: > > From: Vincent Guittot > > > > A new fair task is detached and attached from/to task_group with: > > > > cgroup_post_fork() > > ss->fork(child) := cpu_cgroup_fork() > > sched_move_task() > > task_move_group_fair() > > > > Which is wrong, because at this point in fork() the task isn't fully > > initialized and it cannot 'move' to another group, because its not > > attached to any group as yet. > > > > In fact, cpu_cgroup_fork needs a small part of sched_move_task so we > > can just call this small part directly instead sched_move_task. And > > the task doesn't really migrate because it is not yet attached so we > > need the sequence: > > > > do_fork() > > sched_fork() > > __set_task_cpu() > > > > cgroup_post_fork() > > set_task_rq() # set task group and runqueue > > > > wake_up_new_task() > > select_task_rq() can select a new cpu > > __set_task_cpu > > post_init_entity_util_avg > > attach_task_cfs_rq() > > activate_task > > enqueue_task > > > > This patch makes that happen. > > > > With this patch and patch 1, the fork sequence looks correct in my test > > > Maybe-Signed-off-by: Vincent Guittot > > You can remove the Maybe if you want Thanks!