Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp107187pxb; Tue, 14 Sep 2021 20:11:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMf0WrbRon7uscaEDgCGsG/V+JAAs6yDPSrisPz2tW7fcKIR14oxOrV7nwaXj+U0vl9TQO X-Received: by 2002:a92:c241:: with SMTP id k1mr14965213ilo.270.1631675506273; Tue, 14 Sep 2021 20:11:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631675506; cv=none; d=google.com; s=arc-20160816; b=VXwkmvedF4M1OGU+GNphnw2lNjiL4w4VfTeuPd/uYPrfhSKNcN6IugR+IUVXrn+1Fd foaLEh+EcUU6PFENaQrMeMF1E1EGeedD9RBk3jTIIkCTv84/ojUqU92wFvqaVt/eg1Lh GxsjH507U5RlcQtcB2lsLlPNF5sgNzF4FZe4o+IEjTMIk7D7vLB423P56UzUmfHNaUyb S5kr83sF1lqy3/77Duk2RnuknOtI/vcM7YdcpEcTCB2PY+/9qdMsSBSNCwYOagpQQtHR Sl4R6Biu9hZ0UCNE7klb7UiIOCtkAbuJL62zzxfFV3s2aP/DDtnAOYQ4GEILpazV7Qe5 utYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=Ab6ux2FHgVPUs7TmYfjvnmFM9/9wyMxrTgEVhZFQijo=; b=VIp1vIejgfVVPlRVQC/PZLFyhLtTzWeTssRMJ9Z+xzxYbXb4ru0zZ2u3VYLlJ9FwXR OEdzXb1rsZnCWVR6P+TNPq/SUgGDMtsz8vpPO03ZMN2rJB12XpTnJ7CPZdPONsvUA8uV aBj4fUInHv2+MtMMy3jYJuq18sJzwLHWNGUjnAUHwDD7QivDPpnszpXiGJ2RcrtWCh4O hsuLCmYuCiHKyOiuq9jZlaxjHVYKOzQ3e4TFhGmDOW/EBJRQzMq5N7cQkQxj+oSgpy48 qoPLjolJVVbo8WN+/RLhriKphjJJkNHMAt0MXs4TD4hW6GFkbrOAj4SDlcqwhz2Zazmf 1exA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x17si12137524ilc.170.2021.09.14.20.11.34; Tue, 14 Sep 2021 20:11:46 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234031AbhIODMD (ORCPT + 99 others); Tue, 14 Sep 2021 23:12:03 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:19976 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229888AbhIODMD (ORCPT ); Tue, 14 Sep 2021 23:12:03 -0400 Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4H8Q992wfFzblrD; Wed, 15 Sep 2021 11:06:37 +0800 (CST) Received: from dggpeml500018.china.huawei.com (7.185.36.186) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.8; Wed, 15 Sep 2021 11:10:43 +0800 Received: from [10.67.101.251] (10.67.101.251) by dggpeml500018.china.huawei.com (7.185.36.186) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.8; Wed, 15 Sep 2021 11:10:43 +0800 Subject: Re: [PATCH v2] kernel/sched: Fix sched_fork() access an invalid sched_task_group To: Tejun Heo CC: , , , , , , , , , References: <20210911075054.6358-1-zhangqiao22@huawei.com> From: Zhang Qiao Message-ID: <65e75c42-e846-c571-582f-b52938b26973@huawei.com> Date: Wed, 15 Sep 2021 11:10:42 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="gbk" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.101.251] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpeml500018.china.huawei.com (7.185.36.186) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ?? 2021/9/15 0:23, Tejun Heo ะด??: > On Tue, Sep 14, 2021 at 04:20:02PM +0800, Zhang Qiao wrote: >> Perhaps we can fix this bug at sched_post_fork(), which is executed between cgroup_can_fork() >> and cgroup_post_fork(). Relocate the fectching of task_group and access it at sched_post_fork(). > > Can't we just add a can_fork callback in cpu_cgrp_subsys? Because __set_task_cpu and task_fork callback need access the sched_task_group field, so the task_fork callback must be called after update the child's sched_task_group, if perform these operations in the newly added can_fork callback, it may lead to some dependencies(the can_fork will not be executed when !CONFIG_CGROUP_SCHED). __set_task_cpu and task_fork callback mainly do some field initialization and vruntime calculation, these things just need to be done before waking up the new task. So i think it is no problem to defer do this things at sched_post_fork(). thanks. >