Message ID | 20231117125624.16745-1-CruzZhao@linux.alibaba.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp504810vqn; Fri, 17 Nov 2023 04:57:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IEdqrJE+q288IAqzjiSkoCVf82eDnyEU1aPHA8lgY2AkV1neVFA3KWwiAnFSS1ZtNRxO3sK X-Received: by 2002:a05:6e02:16ce:b0:359:d1c4:b454 with SMTP id 14-20020a056e0216ce00b00359d1c4b454mr28690967ilx.20.1700225857929; Fri, 17 Nov 2023 04:57:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700225857; cv=none; d=google.com; s=arc-20160816; b=rtQZPa5D1YaVfB66uhuf+zt5oN9oQ8J9IgjFmhPqX42CAyAAY6SRj75xD91j482GEI /X8BKkpd0MenlS7i7n3ScE/Q5MJxlucSR708B6f3NBzbyBRDQZVzmjccvFBl+ceAPch4 IYB8K8E908asZFM/AYc+wB53E7pSJNX72d13tD8NcVlOYIQL+03eCEeHllURSQJ1zrq7 TwfRx7JPiUbVgZmRAkvB6eZMkGE1VHOT2HQBwHe7FP2dQKjZhycg1pzsVZafo5KO7YDz JKSRovJhOvdzkU0RoKhSI1ZkYKN0SvRx5eWa85F9Bv8pv2Fpwhqj3c4474DZxeGdH2Wc o0Hw== 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=s61n8AXGJhTyOEl5PeOYQoFt+Cwgw3MnrzmdvgoqEhw=; fh=QlmRtWuTYJDhaxF0GCu0nvK7RUqeTMNKD6hMg0kv7eo=; b=nKVAdryB/4HSKasjsBsOCskpizHPaGoX8M3hmV3ckAMmzo/cyFvf03mPK87sgpOFNd AAb/jLLxSeUeXmZa5zby9Uo4gCbRltwvxLXbK5n/eb9VBTmwM/nMKhhe/jvstudQSRjw uMENVg42zskFn37MDiySshhTWa6Tb4F4vdxXsJuII8L/iR/j0UYkh87wiBfkL+z26LJR LhHVTSFojlYbh0hD9+DsZYcBH5nlnop78qhpqOYE2f9Vs9Bl0oEer5UvnqRgArhum/zn h0ZcOEzREwRFDHQBRdWl5ykaS+17nb6QgeJMoWBk9ROhlBtK70CxrJnXdeN1Ubkptxhx oT7g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id d15-20020a63fd0f000000b005be232472easi1845746pgh.78.2023.11.17.04.57.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 04:57:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id A9A7780615D0; Fri, 17 Nov 2023 04:56:49 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346008AbjKQM4k (ORCPT <rfc822;jaysivo@gmail.com> + 30 others); Fri, 17 Nov 2023 07:56:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229543AbjKQM4i (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 17 Nov 2023 07:56:38 -0500 Received: from out30-110.freemail.mail.aliyun.com (out30-110.freemail.mail.aliyun.com [115.124.30.110]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D87CD5F for <linux-kernel@vger.kernel.org>; Fri, 17 Nov 2023 04:56:34 -0800 (PST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R781e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046056;MF=cruzzhao@linux.alibaba.com;NM=1;PH=DS;RN=12;SR=0;TI=SMTPD_---0VwZsbOP_1700225784; Received: from localhost.localdomain(mailfrom:CruzZhao@linux.alibaba.com fp:SMTPD_---0VwZsbOP_1700225784) by smtp.aliyun-inc.com; Fri, 17 Nov 2023 20:56:32 +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] sched/core: fix incorrect cpustat[CPUTIME_FORCEIDLE] update Date: Fri, 17 Nov 2023 20:56:24 +0800 Message-Id: <20231117125624.16745-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=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 17 Nov 2023 04:56:49 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782816029172258535 X-GMAIL-MSGID: 1782816029172258535 |
Series |
sched/core: fix incorrect cpustat[CPUTIME_FORCEIDLE] update
|
|
Commit Message
cruzzhao
Nov. 17, 2023, 12:56 p.m. UTC
In function __account_forceidle_time(), task_group_account_field()
is called to update kernel_cpustat.cpustat[CPUTIME_FORCEIDLE].
However, p may be not running on current cpu, so update cpustat with
this_cpu_add() is incorrect.
To fix this problem, we get the cpu of p first, and then add delta
to kcpustat_cpu(cpu).cpustat[CPUTIME_FORCEIDLE].
Fixes: 1fcf54deb767 ("sched/core: add forced idle accounting for cgroups")
Signed-off-by: Cruz Zhao <CruzZhao@linux.alibaba.com>
---
kernel/sched/cputime.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
Comments
Hi Cruz, kernel test robot noticed the following build errors: [auto build test ERROR on tip/sched/core] [also build test ERROR on linus/master v6.7-rc1 next-20231117] [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/Cruz-Zhao/sched-core-fix-incorrect-cpustat-CPUTIME_FORCEIDLE-update/20231117-205845 base: tip/sched/core patch link: https://lore.kernel.org/r/20231117125624.16745-1-CruzZhao%40linux.alibaba.com patch subject: [PATCH] sched/core: fix incorrect cpustat[CPUTIME_FORCEIDLE] update config: x86_64-buildonly-randconfig-004-20231118 (https://download.01.org/0day-ci/archive/20231118/202311180359.AFGF0rnk-lkp@intel.com/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231118/202311180359.AFGF0rnk-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202311180359.AFGF0rnk-lkp@intel.com/ All errors (new ones prefixed by >>): In file included from kernel/sched/build_policy.c:52: kernel/sched/cputime.c: In function '__account_forceidle_time': >> kernel/sched/cputime.c:247:41: error: 'index' undeclared (first use in this function) 247 | cgroup_account_cputime_field(p, index, tmp); | ^~~~~ kernel/sched/cputime.c:247:41: note: each undeclared identifier is reported only once for each function it appears in >> kernel/sched/cputime.c:247:48: error: 'tmp' undeclared (first use in this function); did you mean 'tms'? 247 | cgroup_account_cputime_field(p, index, tmp); | ^~~ | tms vim +/index +247 kernel/sched/cputime.c 232 233 234 #ifdef CONFIG_SCHED_CORE 235 /* 236 * Account for forceidle time due to core scheduling. 237 * 238 * REQUIRES: schedstat is enabled. 239 */ 240 void __account_forceidle_time(struct task_struct *p, u64 delta) 241 { 242 unsigned int cpu = task_cpu(p); 243 244 __schedstat_add(p->stats.core_forceidle_sum, delta); 245 246 kcpustat_cpu(cpu).cpustat[CPUTIME_FORCEIDLE] += delta; > 247 cgroup_account_cputime_field(p, index, tmp); 248 } 249 #endif 250
diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c index af7952f12e6c..6f18fdc4a0dc 100644 --- a/kernel/sched/cputime.c +++ b/kernel/sched/cputime.c @@ -239,9 +239,12 @@ void account_idle_time(u64 cputime) */ void __account_forceidle_time(struct task_struct *p, u64 delta) { + unsigned int cpu = task_cpu(p); + __schedstat_add(p->stats.core_forceidle_sum, delta); - task_group_account_field(p, CPUTIME_FORCEIDLE, delta); + kcpustat_cpu(cpu).cpustat[CPUTIME_FORCEIDLE] += delta; + cgroup_account_cputime_field(p, index, tmp); } #endif