From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8FF00C433F5 for ; Wed, 15 Sep 2021 03:10:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 70BFF61184 for ; Wed, 15 Sep 2021 03:10:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235897AbhIODMD (ORCPT ); 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. >