Message ID | 20231115113341.13261-1-CruzZhao@linux.alibaba.com |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp2474008vqg; Wed, 15 Nov 2023 03:34:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IGEUohvjroL3vRCYYBJytyO3N0bc/ewUGKUjd4PRAFunBOJ8y7ff7x/BxDKq8GscNLmupXC X-Received: by 2002:a05:6a20:244b:b0:13e:fb5e:b460 with SMTP id t11-20020a056a20244b00b0013efb5eb460mr7045815pzc.0.1700048063735; Wed, 15 Nov 2023 03:34:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700048063; cv=none; d=google.com; s=arc-20160816; b=gk4JZ/MStOWDD8Xo0zzh76MgayZiOqLmc/OE6JeGcRU55zTu2c9llw3rbgb/8dgkB+ 1cC9nJySWqX3vKT/8Ku1Cm8ikyE5ExLVuAicumx3XQdRsmsco0yVgXXNQiuy7q0iOUsa Uw/CHHEgbYWtkAdq9axVScHHApQ6XcBJ61WyKMEu4ip4gD37lFcTnfuJShZg3Jd0/mUi ErCfAKiZLSLWNZlS5sytgNmF/mIr9d3xPWivCCW29WF9kJawGKI5S1BYKwZOfWhrh+Ol hcrS1VyYNuqHK8IuuHZ8TqqFGDguyix5yjfPxkAlO7hI/jXQ3MH8UNCp4nUpFKiJWAaI I0zQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=Lk9nxR1+tPNpbHnDbEc0soLCyhir+WCzlzWR8FAvJmo=; fh=QlmRtWuTYJDhaxF0GCu0nvK7RUqeTMNKD6hMg0kv7eo=; b=vQa4yYoY7g88d0B+zTjxrM6xle332Hud7wDI9l5XZkNiYMR54dJ5rFv5iCSwaSOyqh vY39hRzXwv7CN+Ip7Kpayc1EJV+9uFUVXHsqd48eLk9DCDlN2M9WMl8hiskQigun3zOx o+bUFTWMKZY1oB7iQ+jxoizW1n5ZnIVrSV33kyLUgYJ0JEnw4Mfd+w2RvyPVudFPoNal WlO2MCTJzo0hwj4oiJde/Kzq9+pfKRePx3rq0bzYG3adADW4ISl3sRBJSuKaBGppwxjh zafvQA2Mb/aM+WY4h7czcyj78rogSOOvW0aKLYZ6vFCrP1tGaH6bxtQpZWG/YNkdDmyX 0OXQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id w2-20020a636202000000b005b967ddd984si10131820pgb.781.2023.11.15.03.34.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 03:34:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 35A69801C184; Wed, 15 Nov 2023 03:34:14 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234924AbjKOLd7 (ORCPT <rfc822;heyuhang3455@gmail.com> + 28 others); Wed, 15 Nov 2023 06:33:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234114AbjKOLd5 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 15 Nov 2023 06:33:57 -0500 Received: from out30-130.freemail.mail.aliyun.com (out30-130.freemail.mail.aliyun.com [115.124.30.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5107C109 for <linux-kernel@vger.kernel.org>; Wed, 15 Nov 2023 03:33:53 -0800 (PST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R191e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045176;MF=cruzzhao@linux.alibaba.com;NM=1;PH=DS;RN=12;SR=0;TI=SMTPD_---0VwSxxJq_1700048021; Received: from localhost.localdomain(mailfrom:CruzZhao@linux.alibaba.com fp:SMTPD_---0VwSxxJq_1700048021) by smtp.aliyun-inc.com; Wed, 15 Nov 2023 19:33:50 +0800 From: Cruz Zhao <CruzZhao@linux.alibaba.com> To: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, joel@joelfernandes.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH 0/4] sched/core: fix cfs_prio_less Date: Wed, 15 Nov 2023 19:33:37 +0800 Message-Id: <20231115113341.13261-1-CruzZhao@linux.alibaba.com> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Wed, 15 Nov 2023 03:34:14 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782629598665677537 X-GMAIL-MSGID: 1782629598665677537 |
Series | sched/core: fix cfs_prio_less | |
Message
cruzzhao
Nov. 15, 2023, 11:33 a.m. UTC
The update of vruntime snapshot will cause unfair sched, especially when tasks enqueue/dequeue frequently. Consider the following case: - Task A1 and A2 share a cookie, and task B has another cookie. - A1 is a short task, waking up frequently but running short everytime. - A2 and B are long tasks. - A1 and B runs on ht0 and A2 runs on ht1. ht0 ht1 fi_before fi update switch to A1 switch to A2 0 0 1 A1 sleeps switch to B A2 force idle 0 1 1 A1 wakes up switch to A1 switch to A1 1 0 1 A1 sleeps switch to B A2 force idle 0 1 1 In this case, cfs_rq->min_vruntime_fi will update every schedule, and prio of B and A2 will be pulled to the same level, no matter how long A2 and B have run before, which is not fair enough. Extramely, we observed that the latency of a task became several minutes due to this reason, which should be 100ms. To fix this problem, a possible approach is to maintain another vruntime relative to the core, called core_vruntime, and we compare the priority of ses using core_vruntime directly, instead of vruntime snapshot. To achieve this goal, we need to introduce cfs_rq->core, similarity to rq->core, and record core_min_vruntime in cfs_rq->core. Cruz Zhao (4): sched/core: Introduce core_id sched: Introduce cfs_rq->core sched: introduce core_vruntime and core_min_vruntime fix vruntime snapshot include/linux/sched.h | 3 ++ kernel/sched/core.c | 37 +++++++--------- kernel/sched/fair.c | 98 ++++++++++++++++++++++++++----------------- kernel/sched/sched.h | 5 ++- 4 files changed, 81 insertions(+), 62 deletions(-)