Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp3786369pxb; Mon, 30 Aug 2021 10:34:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvB7/mFBiwUwFweuSRvx4mJuqKx1q98qC2Ll8HDjnEx/hH0iO29GultMwXEQSliGvNY7BI X-Received: by 2002:a17:906:6d85:: with SMTP id h5mr26091729ejt.305.1630344881627; Mon, 30 Aug 2021 10:34:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630344881; cv=none; d=google.com; s=arc-20160816; b=Ee4aIZMSYGefjeZn0RTghk4S17r/08UEcsgqqLPybBj67t0GsPq5OF4YFQ2a914tQi TUJZ+4I/Z31x508qjOe6PPQc4QwDrASLhamZ0ozxYnChpBumu9g//lIF/gCgxIRF/8Hr rg6fEXoqz0StrrNUabLvcHXCwGsUlHiloXmHi4W2mBaUvlW0GXqtzctUMBuoOx7s6pbV R6VZ6ql4CAa6R9vKpYPdQPz/Avus9FWuqCcnbXi1Q3VVSUQW1/iZOjD2oyVEeRlvOx+F f00FyrQ297DgdBt4LgBuheygUEw0KvcpBZUU60USdDKb9EGYAMm/S6Zl/rwKNeEf7Ex8 gVsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:sender:dkim-signature; bh=epWKvD5razLbtGdMxCSBlYu5hXhP+qig9FZSIVuI3tE=; b=BdKZCPUUQfQkqdvPHS1cm3TsI2KZFwNahnLddTgWv3BaakmOaO53uRfiv/zoA5ytz2 e2AAE9idtLT+08XDn0zY5tPRSk4SdO08FGFWLDIyRcK17qXnyUV34E9lCwnF1+N4Luig aF+p6+odj2iFUN+z/PFGHogTBYkrA6tEl1RGvb7NmrJ3hln0aJ//1rNpGwGNAZf2ui5u UncMuCbGrB21HEIbu1Aj8sBvKc8gk8D6THaF81Ce5UKwiaroBcbZhQPvNqzig+qIwImQ eV3syTX5OAQyFVS3U7wM8d4SrVmPGqIZ3mek6xYdT7/iHqnKQj2Lb96iYUhiQFR6s7/D GNaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=G+Q7gtX7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jg36si2411928ejc.753.2021.08.30.10.33.50; Mon, 30 Aug 2021 10:34:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=G+Q7gtX7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238123AbhH3RdE (ORCPT + 99 others); Mon, 30 Aug 2021 13:33:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234721AbhH3RdD (ORCPT ); Mon, 30 Aug 2021 13:33:03 -0400 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4928C061575 for ; Mon, 30 Aug 2021 10:32:09 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id u1so5155531plq.5 for ; Mon, 30 Aug 2021 10:32:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=epWKvD5razLbtGdMxCSBlYu5hXhP+qig9FZSIVuI3tE=; b=G+Q7gtX70nbZ/LBCjYyjOz1aV5GGQ1isjpzbr+PXzvtB2/4iP/j0NqnV7xwI/FumTm /iYzz8JW/fg5RDkv0PaLg8EyxQLmr/FK2ID0atZPyvp5oHA//X+4djFV61pgLqOuvCQI xRkh4CMy8ztoRmz37kcvRA4WYC3WcwAVud73mwcbZatUFKII3B/jExPr0STb+0qhdA5z rrxNFCnhFcr9HCKPoOFpGH8eJZtlbnzQe/2dLGaUDdR5+vqtdKh732ZZ9BCkX5gaS/3V XEj74L2ltpg1E9FOqxc7kbkZimyxdRCJrX59w5wuBhiXkti2sSRvaFk5CXqLqNQZmdop jS5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=epWKvD5razLbtGdMxCSBlYu5hXhP+qig9FZSIVuI3tE=; b=MbCsMy5yQ4DfkbOoMumxSu2Hd5n/kVjxA+HyT1FLGzVIMKA2YdhLfeAbnsmP2qGUjQ p9F13KAW/bEF+/J5d/AIe0urdyAmp74KA6sfhmUurqMHlHG2B2vrj1MwLIMqMgiyL6yN FjqF2kUAcKxiGsO1RKmcvbjw3owYKmM5vf1XLdPA8LpBm5hnkcdHmeAsjZn/L04jiGo4 B4QsKAkBSHsHv6cbwa7ArP3E7ZmZWcMx8ErMj6oUxJuLhkrGGq1VBRK1C/0VN0S6wQaL K3ln3w2V92tBsLzY4c+BSl2M5FdqhPnLWwq0Tmy5RHaE0ezm2lQTsBnlCoSYu//5K9v5 LeQg== X-Gm-Message-State: AOAM533UqjY37P5H7ZPAHi6pXggz8q052siVZtxUOgMiukQnIM5NxZc6 IJ97odyZqX3P1nUfF5veUgN+jPk65UsRdA== X-Received: by 2002:a17:90a:d187:: with SMTP id fu7mr213232pjb.106.1630344729218; Mon, 30 Aug 2021 10:32:09 -0700 (PDT) Received: from localhost (2603-800c-1a02-1bae-44e6-6a58-44be-40a6.res6.spectrum.com. [2603:800c:1a02:1bae:44e6:6a58:44be:40a6]) by smtp.gmail.com with ESMTPSA id y3sm10665124pge.44.2021.08.30.10.32.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Aug 2021 10:32:08 -0700 (PDT) Sender: Tejun Heo Date: Mon, 30 Aug 2021 07:32:07 -1000 From: Tejun Heo To: Peter Zijlstra Cc: Zhang Qiao , mingo@redhat.com, juri.lelli@redhat.com, vincent.guittot@linaro.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] kernel/sched: Fix sched_fork() access an invalid sched_task_group Message-ID: References: <20210826112635.7404-1-zhangqiao22@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On Mon, Aug 30, 2021 at 04:39:54PM +0200, Peter Zijlstra wrote: > > When a new process is forked, cgroup_post_fork() associates it > > with the cgroup of its parent. Therefore this commit move the > > __set_task_cpu() and task_fork() that access some cgroup-related > > fields(sched_task_group and cfs_rq) to sched_post_fork() and > > call sched_post_fork() after cgroup_post_fork(). I think this would allow cgroup migrations to take place before sched_post_fork() is run, which likely will break stuff. The right thing to do likely is taking sched_task_group (and whatever other fields) after cgroup_can_fork(), which fixates the cgroup memberships, is run. For other controllers, operations like this would be performed from cgroup_subsys->fork() callback but it's tricky for sched due to autogroup. > > Fixes: 8323f26ce342 ("sched: Fix race in task_group") > > Signed-off-by: Zhang Qiao > > Hmm, I think you're right. Did something recently chagne in cgroup land > to make this more visible? This code hasn't changed in like 9 years. I can't think of any remotely recent change either. I guess ppl just don't try to migrate the parent while fork is in progress. Thanks. -- tejun