Message ID | 20221031125113.72980-3-zhangqiao22@huawei.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2285298wru; Mon, 31 Oct 2022 05:33:29 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7yNfykrJ9kOsSMKsmRqULLO/Kb70J69/V3juYcGC7ay73EzTfpBGOJ/pQRbq8MxBB2nSl0 X-Received: by 2002:a17:907:2c67:b0:78d:49d2:6297 with SMTP id ib7-20020a1709072c6700b0078d49d26297mr13148079ejc.21.1667219609150; Mon, 31 Oct 2022 05:33:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667219609; cv=none; d=google.com; s=arc-20160816; b=ADTAvgTXbel36aPC0FwYe+TsE8PC+JVoQ8hasZ/4OhsT6w8b1qUn4WBzX/vNlS8WQV fzSb63ULPB3F+dXuZ7ZC6G3fh80V8n1LxbZFMErKJyy5PKxu17Atemro9b08wgiZgtKV dZ2X1QYTwNPKowZt8ZyMi6laUi+NLFCiRiY9VUujOUmyhF/GMhkl1Wuc33nojrPr5pAZ /onYi+/3BPkue0XVJ+0j9jMtAjyldMgkMfhE7jMEuue+NZidvS+lQTwFXDFktkP2xKTZ Cb0yggSYxMrtNa6uTbyumfZpz1HnmFqdnJE1rmoztefV5cTMtVivnG5hr0H2hWl8CVQd lMlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=lSPZpYby2b6UH/F6EZ/aIVQmyJFUJUfRu2BvlNOzVsc=; b=hV3kYdTtoOeM3rHvt0sswiUTFJ4eWJK2487BOXDICQqeVT/u8LGnmSwLlGPznYYPgy 1WrjQYfk/8FcZ+uRfcg8jTC/OqM6NOJjqnBNgX756IcNtb2soWJtanoZn91uuu/3GhAR YVJ4ow7fyyE5cXS0TbwUFUwVHGuLcHxNe1/BIGTlLQ2HL2xwkCnIyumu56uSX1ueTMRh +xJgj9IXfLHaoubhvgNByue5Ohwap5i26nVTXG4bdVmPGU3TbZ+a7LoySOGSfMeqRNjy PWpSy0ZYp0sPsYEbIytd9lmzPpsUOVKpiRZ6+ZSHChOl7eF8e6hQ0aHTRCSwCn0oJO7W W5kg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dm5-20020a170907948500b0077ef3eece57si7797661ejc.144.2022.10.31.05.33.03; Mon, 31 Oct 2022 05:33:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231343AbiJaMWw (ORCPT <rfc822;kartikey406@gmail.com> + 99 others); Mon, 31 Oct 2022 08:22:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231336AbiJaMWt (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 31 Oct 2022 08:22:49 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2574F039 for <linux-kernel@vger.kernel.org>; Mon, 31 Oct 2022 05:22:15 -0700 (PDT) Received: from dggpeml500026.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4N1Bwv2Wv0zVjBx; Mon, 31 Oct 2022 20:17:19 +0800 (CST) Received: from dggpeml500018.china.huawei.com (7.185.36.186) by dggpeml500026.china.huawei.com (7.185.36.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 31 Oct 2022 20:22:14 +0800 Received: from huawei.com (10.67.174.191) 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.2375.31; Mon, 31 Oct 2022 20:22:13 +0800 From: Zhang Qiao <zhangqiao22@huawei.com> To: <mingo@redhat.com>, <peterz@infradead.org>, <juri.lelli@redhat.com>, <vincent.guittot@linaro.org> CC: <zhangqiao22@huawei.com>, <dietmar.eggemann@arm.com>, <rostedt@goodmis.org>, <bsegall@google.com>, <mgorman@suse.de>, <bristot@redhat.com>, <vschneid@redhat.com>, <brauner@kernel.org>, <linux-kernel@vger.kernel.org> Subject: [PATCH next 2/2] sched: Fix sched_child_runs_first Date: Mon, 31 Oct 2022 20:51:13 +0800 Message-ID: <20221031125113.72980-3-zhangqiao22@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221031125113.72980-1-zhangqiao22@huawei.com> References: <20221031125113.72980-1-zhangqiao22@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.174.191] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpeml500018.china.huawei.com (7.185.36.186) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748206469354949744?= X-GMAIL-MSGID: =?utf-8?q?1748206469354949744?= |
Series |
sched: sched_fork() optimizations
|
|
Commit Message
Zhang Qiao
Oct. 31, 2022, 12:51 p.m. UTC
There are two cases that the sched_child_runs_first maybe not
work fine:
1) when call clone3() with CLONE_INTO_CGROUP flags, will creating
the child task into a cgroup different from the parent's cgroup,
so that child and parent's cfs_rq is diffent.
2) Assign a different cpu to the new task when fork balancing.
Above two case, the child and the parent will attach to different
cpu and cfs_rq. At this time, we can't swap the child and parent's
vruntime, and i think only do swap vruntime when the parent and
child in the same cfs_rq. This patch will add the cfs_rq check
before swap vruntime.
Signed-off-by: Zhang Qiao <zhangqiao22@huawei.com>
---
kernel/sched/fair.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 34845d425180..6061ceb1b7cb 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -11612,7 +11612,9 @@ static void task_fork_fair(struct task_struct *p) } place_entity(cfs_rq, se, 1); - if (sysctl_sched_child_runs_first && curr && entity_before(curr, se)) { + if (sysctl_sched_child_runs_first && + cfs_rq == task_cfs_rq(current) && + curr && entity_before(curr, se)) { /* * Upon rescheduling, sched_class::put_prev_task() will place * 'current' within the tree based on its new key value.