Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1007091rwd; Thu, 15 Jun 2023 05:17:44 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4Vg8eCE/xFhHsSKX8O3zk0/pT4etkKMx3eH7J6W5bc7Ehn2QfTBGvexoTTLc//VnhwjxmW X-Received: by 2002:a17:90b:286:b0:25b:d0c9:9f00 with SMTP id az6-20020a17090b028600b0025bd0c99f00mr3409764pjb.9.1686831463870; Thu, 15 Jun 2023 05:17:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686831463; cv=none; d=google.com; s=arc-20160816; b=Wr7yshEDf0kzoepCSshtx3D6z37ptxLk//Lz0CWnG2i5jBwCm0QjMcARYJP4jZphmQ i5np6aYNeXc6mZrcujpSkO+HtMS1SDHoqN7eKwqXNm6WDWxudaGdZXj5DvOj5QaOU9pJ BJgvPP9iFO8OGZG8uOFj2ga+VLT7yY+kErY9ciONUmI08nuKUj4eyKehUm8lQXwLTPpS IndSjVCs8ZpMEH6MaFGKYWsyjxZGKkBu0V4bNZT1DieaMaR3apyqGfQS0ilPuW56ppL4 lhCdUjc0gUIF8frQHjjJfm7nXNdn0N40ZGHEuyxgNHUn/2b+ah2Si7c9hBk5Jw0cVhuH jmIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=xKw1YBpgHN/11BK0WoeM1YbOvRJ2iSF8stqvZRVIrRU=; b=BhrqUPxWUaY7vY/9NN43p9LS0bTBA5kx1a04W3+wKDvuuW+IxKLC0GdjSAqSU4pmoW UGxUXiyNsuFyroCNepLhZtGndp9fqcFGBmEId7QTw87UzUpahU3hCvKmzDUiKByL4zzo 88OWJikd0tvFqLBH5SG3XMQ+Tt2RgEPz7LInbsiregZ6EAzah64rPmlVFLvr0/lhcQ+G 9QiRZE79r0Twz4Kxsy4il2mntW0MG2OUdCWTAclXFLzJv2KobozHOaRbe7xIFPjhnS0a NBPiWWvjXV//3LZz6xk2rH9tJTEMDn676i5VTxSpcQU5aORD5Qd6vDWvUwEfCSrQ7tKJ V7OA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=lLKRgL3N; dkim=neutral (no key) header.i=@linutronix.de; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lg5-20020a170902fb8500b001b3e1c8da79si3778852plb.606.2023.06.15.05.17.30; Thu, 15 Jun 2023 05:17:43 -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; dkim=pass header.i=@linutronix.de header.s=2020 header.b=lLKRgL3N; dkim=neutral (no key) header.i=@linutronix.de; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344088AbjFOLkW (ORCPT + 99 others); Thu, 15 Jun 2023 07:40:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343981AbjFOLi4 (ORCPT ); Thu, 15 Jun 2023 07:38:56 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64CE530F7; Thu, 15 Jun 2023 04:38:16 -0700 (PDT) Date: Thu, 15 Jun 2023 11:38:14 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1686829094; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xKw1YBpgHN/11BK0WoeM1YbOvRJ2iSF8stqvZRVIrRU=; b=lLKRgL3NHZgHESBg49E9zH/g2+Oo0EQDbu5yFKqRlU9E2uGzxJfUVCCzXqTgH+43GZqgZO Gskjwh5Ra/e50Illa+B/cA8YE5YiW3035gds4FD9VOTkV/0peIZKsNRBqAEDUR6KYiAL6I SQBmCRmmpN2/gwZJHwHhWdo1orIKwcqV6Z9JHm7ozPQjXEeHd6NTA9WixlbNGkk4PEwP1d KfJ722v948kf6dGJ5LEbhACN+zcAhImAktXkz00Pj6b6+zxzzlj6lkUqo5IwYYb7YvXYqX 0DkQ/vsSLl55Bx7Gh0cws4hDDR6OOi5fpS4Izj4RkjDTJQDSQJw+tAb4qaWrbw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1686829095; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xKw1YBpgHN/11BK0WoeM1YbOvRJ2iSF8stqvZRVIrRU=; b=Ds0y7YF+T/dBSLMHzoh2EF0U4lCu7L094KcC24iirQ+h6mnhSwLBDJPeK7XYsDZFzQXcyp DBRGAxNeNJwJHsDA== From: "tip-bot2 for Josh Don" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] sched: Don't account throttle time for empty groups Cc: Josh Don , "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230612232748.3948659-1-joshdon@google.com> References: <20230612232748.3948659-1-joshdon@google.com> MIME-Version: 1.0 Message-ID: <168682909442.404.8265948687296102348.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the sched/core branch of tip: Commit-ID: eed673d4f701e17b8f887dbcbfd3b4bcc53503ec Gitweb: https://git.kernel.org/tip/eed673d4f701e17b8f887dbcbfd3b4bcc53503ec Author: Josh Don AuthorDate: Mon, 12 Jun 2023 16:27:47 -07:00 Committer: Peter Zijlstra CommitterDate: Thu, 15 Jun 2023 13:28:19 +02:00 sched: Don't account throttle time for empty groups It is easy for a cfs_rq to become throttled even when it has no enqueued entities (for example, if we have just put_prev()'d the last runnable task of the cfs_rq, and the cfs_rq is out of quota). Avoid accounting this time towards total throttle time, since it otherwise falsely inflates the stats. Note that the dequeue path is special, since we normally disallow migrations when a task is in a throttled hierarchy (see throttled_lb_pair()). Signed-off-by: Josh Don Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/20230612232748.3948659-1-joshdon@google.com --- kernel/sched/fair.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 6189d1a..b56c86c 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -4873,8 +4873,14 @@ enqueue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags) if (cfs_rq->nr_running == 1) { check_enqueue_throttle(cfs_rq); - if (!throttled_hierarchy(cfs_rq)) + if (!throttled_hierarchy(cfs_rq)) { list_add_leaf_cfs_rq(cfs_rq); + } else { +#ifdef CONFIG_CFS_BANDWIDTH + if (!cfs_rq->throttled_clock) + cfs_rq->throttled_clock = rq_clock(rq_of(cfs_rq)); +#endif + } } } @@ -5480,7 +5486,9 @@ done: * throttled-list. rq->lock protects completion. */ cfs_rq->throttled = 1; - cfs_rq->throttled_clock = rq_clock(rq); + SCHED_WARN_ON(cfs_rq->throttled_clock); + if (cfs_rq->nr_running) + cfs_rq->throttled_clock = rq_clock(rq); return true; } @@ -5498,7 +5506,10 @@ void unthrottle_cfs_rq(struct cfs_rq *cfs_rq) update_rq_clock(rq); raw_spin_lock(&cfs_b->lock); - cfs_b->throttled_time += rq_clock(rq) - cfs_rq->throttled_clock; + if (cfs_rq->throttled_clock) { + cfs_b->throttled_time += rq_clock(rq) - cfs_rq->throttled_clock; + cfs_rq->throttled_clock = 0; + } list_del_rcu(&cfs_rq->throttled_list); raw_spin_unlock(&cfs_b->lock);