Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E3D9C433EF for ; Mon, 15 Nov 2021 16:46:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 27B0B61BB3 for ; Mon, 15 Nov 2021 16:46:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232381AbhKOQsv (ORCPT ); Mon, 15 Nov 2021 11:48:51 -0500 Received: from forwardcorp1o.mail.yandex.net ([95.108.205.193]:48316 "EHLO forwardcorp1o.mail.yandex.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229618AbhKOQsD (ORCPT ); Mon, 15 Nov 2021 11:48:03 -0500 X-Greylist: delayed 4453 seconds by postgrey-1.27 at vger.kernel.org; Mon, 15 Nov 2021 11:47:51 EST Received: from vla1-a78d115f8d22.qloud-c.yandex.net (vla1-a78d115f8d22.qloud-c.yandex.net [IPv6:2a02:6b8:c0d:2906:0:640:a78d:115f]) by forwardcorp1o.mail.yandex.net (Yandex) with ESMTP id B4C6D2E049A; Mon, 15 Nov 2021 19:44:41 +0300 (MSK) Received: from myt6-10e59078d438.qloud-c.yandex.net (myt6-10e59078d438.qloud-c.yandex.net [2a02:6b8:c12:5209:0:640:10e5:9078]) by vla1-a78d115f8d22.qloud-c.yandex.net (mxbackcorp/Yandex) with ESMTP id hOlDRbklxT-ifsuAXrS; Mon, 15 Nov 2021 19:44:41 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.com; s=default; t=1636994681; bh=IrYt5MMKvMGkiv1f4WYXd7ucQOljaPxik4BhGGjfmzQ=; h=Message-Id:Date:Subject:To:From:Cc; b=CWHoIMgtpMlSq2b3O2tN9O/rz0FXjrLJxj8NIqum8Vju46OaQouRWDpfwoECmB+t7 xIJ2Kt4uCyGziCGgtO3iTxOIFLDS4sV1YfTxlaesYT8cnQZpE3LvfHLLCJCO9uFoYQ CV5lgUPqoysVecg/onWn8Fg1KNvNirOF7LTBZrmU= Authentication-Results: vla1-a78d115f8d22.qloud-c.yandex.net; dkim=pass header.i=@yandex-team.com Received: from dellarbn.yandex.net (dynamic-red3.dhcp.yndx.net [2a02:6b8:0:107:3e85:844d:5b1d:60a]) by myt6-10e59078d438.qloud-c.yandex.net (smtpcorp/Yandex) with ESMTPS id 7goUWCU60O-ifwSgdBU; Mon, 15 Nov 2021 19:44:41 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) X-Yandex-Fwd: 2 From: Andrey Ryabinin To: Ingo Molnar , Peter Zijlstra Cc: Andrey Ryabinin , Daniel Jordan , Tejun Heo , stable@vger.kernel.org, Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, Dan Schatzberg Subject: [PATCH v3 1/4] cputime, cpuacct: Include guest time in user time in cpuacct.stat Date: Mon, 15 Nov 2021 19:46:04 +0300 Message-Id: <20211115164607.23784-1-arbn@yandex-team.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org cpuacct.stat in no-root cgroups shows user time without guest time included int it. This doesn't match with user time shown in root cpuacct.stat and /proc//stat. This also affects cgroup2's cpu.stat in the same way. Make account_guest_time() to add user time to cgroup's cpustat to fix this. Fixes: ef12fefabf94 ("cpuacct: add per-cgroup utime/stime statistics") Signed-off-by: Andrey Ryabinin Reviewed-by: Daniel Jordan Acked-by: Tejun Heo Cc: --- kernel/sched/cputime.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c index 872e481d5098..042a6dbce8f3 100644 --- a/kernel/sched/cputime.c +++ b/kernel/sched/cputime.c @@ -148,10 +148,10 @@ void account_guest_time(struct task_struct *p, u64 cputime) /* Add guest time to cpustat. */ if (task_nice(p) > 0) { - cpustat[CPUTIME_NICE] += cputime; + task_group_account_field(p, CPUTIME_NICE, cputime); cpustat[CPUTIME_GUEST_NICE] += cputime; } else { - cpustat[CPUTIME_USER] += cputime; + task_group_account_field(p, CPUTIME_USER, cputime); cpustat[CPUTIME_GUEST] += cputime; } } -- 2.32.0