Message ID | 20230518013414.3053254-1-joshdon@google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp173865vqo; Wed, 17 May 2023 18:45:11 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4dNbqxmH/wN8d7UjpzPYkkrfMwD15Xjuez+3XjEBoHzR142wZHUAuHM8TinaeH3SxjBoTn X-Received: by 2002:a05:6a20:9144:b0:ff:ca91:68ee with SMTP id x4-20020a056a20914400b000ffca9168eemr148033pzc.9.1684374311087; Wed, 17 May 2023 18:45:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684374311; cv=none; d=google.com; s=arc-20160816; b=GN8ui/eSibWPfjJCX/bI7sRvHPjycsJZf0T0WxXLUYE9rs1etQBG9F9wRyxJRT34nd aHkdEIDNDTZhsRhnPwD5kT1upA9bFHkJsRyXcC2h2V2CT0Z14MRmGQ9pPECHKnvh+6Rb o+TBZBXvWzKNXFbpgAlF9m0nV4VdwT5/xaSY1ehE/yjsgNs/4HqU5sSNwNXhTYiZ+jh2 vCoLfhpXiOa3vY9H5/AE7mshyxo5+YjwzNkoTqZPz05jOJ7aapNsaoAmigwMpADurYZ8 klSDYMwghOhTi46I8w6r21Earh4dHtbvRBRNoYtl2UgaBKRdqALgz6RfsfkQtphPviOW mO0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:mime-version:date :dkim-signature; bh=YCkOGnN5VV+G0vc4oBgEXNSPP/cS4uflXB2VdW0nTDc=; b=uaj8bBbkhvOfudkLjKwMymIgScHMnqqiIdJO9Tw7n/gLBQb73wbX+PkEzH4VwbPpPn VbBrI/0xtH9kVW3tmvtTdCxWqIfHlVfI3IS/KUwY008G2w3u8JlAVGBBwSbIARM4Fe/x l9N3/BmzgXSUuU+XBcMq72ImSg9YfszWzQIgrBEwtWcmrN7HFyztgXAQobJE5MvwBNP6 H2tVo5p3SCg1i52SCakBHU62ygmcm10iGNZR1H7RWPtHj9Gofhq3nbgUr9WpTjZ/9+/5 pdxZjDUlbBVtEMroIYDJn0wEvzh9qmH31hXNk2+0E3T//IRcsyKeZ46gQit0NLMweb/5 PHvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=LV9SKqc9; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 3-20020a621703000000b006435b9bd9f0si452291pfx.45.2023.05.17.18.44.56; Wed, 17 May 2023 18:45:11 -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=@google.com header.s=20221208 header.b=LV9SKqc9; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229676AbjERBem (ORCPT <rfc822;abdi.embedded@gmail.com> + 99 others); Wed, 17 May 2023 21:34:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229621AbjERBek (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 17 May 2023 21:34:40 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 987D535BF for <linux-kernel@vger.kernel.org>; Wed, 17 May 2023 18:34:37 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-561abf855afso15762157b3.2 for <linux-kernel@vger.kernel.org>; Wed, 17 May 2023 18:34:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1684373677; x=1686965677; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=YCkOGnN5VV+G0vc4oBgEXNSPP/cS4uflXB2VdW0nTDc=; b=LV9SKqc9LLji/8d1D1nfFc5i5jRcnJLn+AfdqPiE8q/ZsW+08nHc91HNb4jIFg5d6H jgdmF4AsVk+sjFNbe6dNmj/yjWzAvlQoPbqzFzG1yAFkYJTm0tSE4JRPp2pkAbpk8Yzl sMwx5yX3xjLDUYEbTRyn1YgUs8/4CyPkDnd5i1xEg8U1TP4klX+n1KZZQP7nQ2rdYwLc sIkYfAezE/CJwAl1KHldUuPcIRJf1cXLC5Q2taC1S6LpVTa83YOcpVTVkwZz0l9o+njR AndVecG6UkuOC+ZGe3GQEYiXzhMOPnOp8lV1m5u//s0N+M6h7dNTW4jeFc87BXnBz6yA wdNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684373677; x=1686965677; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=YCkOGnN5VV+G0vc4oBgEXNSPP/cS4uflXB2VdW0nTDc=; b=kI2c7SMIZzfwqPmR1IvP9sLx9OjG7I36bndLiZYyyZmizg4EVb+nPLEv6WsdFxvCby 2u0futUAKUR+Vw3zqLXa+xcklGQhc7SWNfikNEZEmvv36kYS+61p11AtjgDgczNK8u4i mJSoRWOFbdUaSB4s2VSrBH6gNACylgfimXR4mBEvHUQc1OVIGQmlUwNqp2i+AJE9F30/ vnojCtHPGxNve1D+Gg1u+n6dE2tRgkdu1qJ47SvhtQJZNr+hNrq+0YHLvwoxV6qUpQWh VY0C0wjPuCVD0rEEztrbZcj3uQBO12lKgK4AFniuesgBPBqEZEYywQZJhBS4bptdpeQ1 t77g== X-Gm-Message-State: AC+VfDymT0+9j45GWoX+Pp3CO1nzeVenvhvKWCyC30WQT8Oifqt7+BBj fJLd05gyyATQATsB0LwJ6xCX1PY4/T78 X-Received: from joshdon-desktop.svl.corp.google.com ([2620:15c:2d4:203:53e2:12a7:c986:1d79]) (user=joshdon job=sendgmr) by 2002:a81:ae64:0:b0:561:2d82:7f08 with SMTP id g36-20020a81ae64000000b005612d827f08mr131225ywk.0.1684373676864; Wed, 17 May 2023 18:34:36 -0700 (PDT) Date: Wed, 17 May 2023 18:34:13 -0700 Mime-Version: 1.0 X-Mailer: git-send-email 2.40.1.606.ga4b1b128d6-goog Message-ID: <20230518013414.3053254-1-joshdon@google.com> Subject: [PATCH 1/2] sched: don't account throttle time for empty groups From: Josh Don <joshdon@google.com> To: Ingo Molnar <mingo@redhat.com>, Peter Zijlstra <peterz@infradead.org>, Juri Lelli <juri.lelli@redhat.com>, Vincent Guittot <vincent.guittot@linaro.org> Cc: Tejun Heo <tj@kernel.org>, Dietmar Eggemann <dietmar.eggemann@arm.com>, Steven Rostedt <rostedt@goodmis.org>, Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>, Daniel Bristot de Oliveira <bristot@redhat.com>, Valentin Schneider <vschneid@redhat.com>, linux-kernel@vger.kernel.org, Xiangling Kong <xiangling@google.com>, Josh Don <joshdon@google.com> Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL 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?1766194477971609020?= X-GMAIL-MSGID: =?utf-8?q?1766194477971609020?= |
Series |
[1/2] sched: don't account throttle time for empty groups
|
|
Commit Message
Josh Don
May 18, 2023, 1:34 a.m. UTC
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.
Signed-off-by: Josh Don <joshdon@google.com>
---
kernel/sched/fair.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
Comments
Hi Josh, kernel test robot noticed the following build errors: [auto build test ERROR on tip/sched/core] [also build test ERROR on tip/master tip/auto-latest linus/master v6.4-rc2 next-20230518] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Josh-Don/sched-add-throttled-time-stat-for-throttled-children/20230518-095541 base: tip/sched/core patch link: https://lore.kernel.org/r/20230518013414.3053254-1-joshdon%40google.com patch subject: [PATCH 1/2] sched: don't account throttle time for empty groups config: arm-randconfig-r025-20230517 compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project b0fb98227c90adf2536c9ad644a74d5e92961111) reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # install arm cross compiling tool for clang build # apt-get install binutils-arm-linux-gnueabi # https://github.com/intel-lab-lkp/linux/commit/9414859be598a05f1bb078f8bf83e132976384ea git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Josh-Don/sched-add-throttled-time-stat-for-throttled-children/20230518-095541 git checkout 9414859be598a05f1bb078f8bf83e132976384ea # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash kernel/ If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202305181547.BxmBDKPa-lkp@intel.com/ All errors (new ones prefixed by >>): >> kernel/sched/fair.c:4880:17: error: no member named 'throttled_clock' in 'struct cfs_rq' if (!cfs_rq->throttled_clock) ~~~~~~ ^ kernel/sched/fair.c:4881:13: error: no member named 'throttled_clock' in 'struct cfs_rq' cfs_rq->throttled_clock = rq_clock(rq); ~~~~~~ ^ kernel/sched/fair.c:6181:6: warning: no previous prototype for function 'init_cfs_bandwidth' [-Wmissing-prototypes] void init_cfs_bandwidth(struct cfs_bandwidth *cfs_b) {} ^ kernel/sched/fair.c:6181:1: note: declare 'static' if the function is not intended to be used outside of this translation unit void init_cfs_bandwidth(struct cfs_bandwidth *cfs_b) {} ^ static kernel/sched/fair.c:12617:6: warning: no previous prototype for function 'free_fair_sched_group' [-Wmissing-prototypes] void free_fair_sched_group(struct task_group *tg) { } ^ kernel/sched/fair.c:12617:1: note: declare 'static' if the function is not intended to be used outside of this translation unit void free_fair_sched_group(struct task_group *tg) { } ^ static kernel/sched/fair.c:12619:5: warning: no previous prototype for function 'alloc_fair_sched_group' [-Wmissing-prototypes] int alloc_fair_sched_group(struct task_group *tg, struct task_group *parent) ^ kernel/sched/fair.c:12619:1: note: declare 'static' if the function is not intended to be used outside of this translation unit int alloc_fair_sched_group(struct task_group *tg, struct task_group *parent) ^ static kernel/sched/fair.c:12624:6: warning: no previous prototype for function 'online_fair_sched_group' [-Wmissing-prototypes] void online_fair_sched_group(struct task_group *tg) { } ^ kernel/sched/fair.c:12624:1: note: declare 'static' if the function is not intended to be used outside of this translation unit void online_fair_sched_group(struct task_group *tg) { } ^ static kernel/sched/fair.c:12626:6: warning: no previous prototype for function 'unregister_fair_sched_group' [-Wmissing-prototypes] void unregister_fair_sched_group(struct task_group *tg) { } ^ kernel/sched/fair.c:12626:1: note: declare 'static' if the function is not intended to be used outside of this translation unit void unregister_fair_sched_group(struct task_group *tg) { } ^ static 5 warnings and 2 errors generated. vim +4880 kernel/sched/fair.c 4792 4793 /* 4794 * MIGRATION 4795 * 4796 * dequeue 4797 * update_curr() 4798 * update_min_vruntime() 4799 * vruntime -= min_vruntime 4800 * 4801 * enqueue 4802 * update_curr() 4803 * update_min_vruntime() 4804 * vruntime += min_vruntime 4805 * 4806 * this way the vruntime transition between RQs is done when both 4807 * min_vruntime are up-to-date. 4808 * 4809 * WAKEUP (remote) 4810 * 4811 * ->migrate_task_rq_fair() (p->state == TASK_WAKING) 4812 * vruntime -= min_vruntime 4813 * 4814 * enqueue 4815 * update_curr() 4816 * update_min_vruntime() 4817 * vruntime += min_vruntime 4818 * 4819 * this way we don't have the most up-to-date min_vruntime on the originating 4820 * CPU and an up-to-date min_vruntime on the destination CPU. 4821 */ 4822 4823 static void 4824 enqueue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags) 4825 { 4826 bool renorm = !(flags & ENQUEUE_WAKEUP) || (flags & ENQUEUE_MIGRATED); 4827 bool curr = cfs_rq->curr == se; 4828 struct rq *rq = rq_of(cfs_rq); 4829 4830 /* 4831 * If we're the current task, we must renormalise before calling 4832 * update_curr(). 4833 */ 4834 if (renorm && curr) 4835 se->vruntime += cfs_rq->min_vruntime; 4836 4837 update_curr(cfs_rq); 4838 4839 /* 4840 * Otherwise, renormalise after, such that we're placed at the current 4841 * moment in time, instead of some random moment in the past. Being 4842 * placed in the past could significantly boost this task to the 4843 * fairness detriment of existing tasks. 4844 */ 4845 if (renorm && !curr) 4846 se->vruntime += cfs_rq->min_vruntime; 4847 4848 /* 4849 * When enqueuing a sched_entity, we must: 4850 * - Update loads to have both entity and cfs_rq synced with now. 4851 * - For group_entity, update its runnable_weight to reflect the new 4852 * h_nr_running of its group cfs_rq. 4853 * - For group_entity, update its weight to reflect the new share of 4854 * its group cfs_rq 4855 * - Add its new weight to cfs_rq->load.weight 4856 */ 4857 update_load_avg(cfs_rq, se, UPDATE_TG | DO_ATTACH); 4858 se_update_runnable(se); 4859 update_cfs_group(se); 4860 account_entity_enqueue(cfs_rq, se); 4861 4862 if (flags & ENQUEUE_WAKEUP) 4863 place_entity(cfs_rq, se, 0); 4864 /* Entity has migrated, no longer consider this task hot */ 4865 if (flags & ENQUEUE_MIGRATED) 4866 se->exec_start = 0; 4867 4868 check_schedstat_required(); 4869 update_stats_enqueue_fair(cfs_rq, se, flags); 4870 check_spread(cfs_rq, se); 4871 if (!curr) 4872 __enqueue_entity(cfs_rq, se); 4873 se->on_rq = 1; 4874 4875 if (cfs_rq->nr_running == 1) { 4876 check_enqueue_throttle(cfs_rq); 4877 if (!throttled_hierarchy(cfs_rq)) { 4878 list_add_leaf_cfs_rq(cfs_rq); 4879 } else { > 4880 if (!cfs_rq->throttled_clock) 4881 cfs_rq->throttled_clock = rq_clock(rq); 4882 } 4883 } 4884 } 4885
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index f4b8b906d30a..85c2c0c3cab6 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -4768,6 +4768,7 @@ enqueue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags) { bool renorm = !(flags & ENQUEUE_WAKEUP) || (flags & ENQUEUE_MIGRATED); bool curr = cfs_rq->curr == se; + struct rq *rq = rq_of(cfs_rq); /* * If we're the current task, we must renormalise before calling @@ -4816,8 +4817,12 @@ 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 { + if (!cfs_rq->throttled_clock) + cfs_rq->throttled_clock = rq_clock(rq); + } } } @@ -5423,7 +5428,9 @@ static bool throttle_cfs_rq(struct cfs_rq *cfs_rq) * 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; } @@ -5441,7 +5448,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);