Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752362AbbKYTvr (ORCPT ); Wed, 25 Nov 2015 14:51:47 -0500 Received: from mail-yk0-f175.google.com ([209.85.160.175]:34326 "EHLO mail-yk0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751380AbbKYTvp (ORCPT ); Wed, 25 Nov 2015 14:51:45 -0500 Date: Wed, 25 Nov 2015 14:51:38 -0500 From: Tejun Heo To: Oleg Nesterov Cc: Aleksa Sarai , Johannes Weiner , Li Zefan , linux-kernel@vger.kernel.org Subject: Re: [PATCH?] race between cgroup_subsys->fork() and cgroup_migrate() Message-ID: <20151125195138.GC14240@htj.duckdns.org> References: <20151125163427.GA8139@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20151125163427.GA8139@redhat.com> User-Agent: Mutt/1.5.23 (2015-06-09) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1704 Lines: 48 Hello, Oleg. On Wed, Nov 25, 2015 at 05:34:27PM +0100, Oleg Nesterov wrote: > IOW. Suppose that the new child is moved right before cgroup_post_fork() does > > for_each_subsys_which(...) > ss->fork(child); > > doesn't this mean that after ss->fork() we do the same sequence > > pids_uncharge(old_pids, 1); > pids_charge(pids, 1); You're absolutely right. > twice? Note that threadgroup_change_begin/end depends on CLONE_THREAD. > So we can actually hit WARN_ON() in pids_cancel(). > > However, we can't simply remove this uncharge/charge afaics. We need this in > case when the parent was moved to another cgroup before cgroup_post_fork(), > and then css_set_move_task() moves the child. > > I know almost nothing about cgroups, perhaps I missed something, please > correct me. I can't think of anything better than what you're proposing. Thanks a lot for tracking it down and fixing it. > If am right. How about the patch below? percpu_down_read() is cheap. And > we can simplify cgroup_pids after this change. > > And. We can probably unify cgroup_threadgroup_rwsem and dup_mmap_sem. > Note that if we take cgroup_threadgroup_rwsem for reading if CLONE_THREAD, > otherwise we take another percpu-rwsem in dup_mmap(), dup_mmap_sem. Sounds perfect. As this needs to go through -stable, can you please resend the patch with proper description and SOB? Please also update the now incorrect comment in can_attach. Thanks a lot! -- tejun -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/