Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3583649pxb; Mon, 24 Jan 2022 12:49:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJyzEdPeagvKe7u2ETNwpXpa2o5gKKzzVmLnolgm9wNdm8bPeYA02zUFr5r4D0WDfHmzkrPQ X-Received: by 2002:a17:902:f243:b0:14b:1f32:e923 with SMTP id j3-20020a170902f24300b0014b1f32e923mr10359973plc.121.1643057342472; Mon, 24 Jan 2022 12:49:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643057342; cv=none; d=google.com; s=arc-20160816; b=0D2LkcsAqlQdTyFMfnTdVqmvDLlAQ+1Ms8uD5JI77F05CuTa0+0V3iKFg0+8SEfeu3 qFZxSjDSO7QTk68+SSQOQwzH8IpGU07dIPGAqvtZzPyCiSm+b1XI7/A3d8SiGPcjg9zB lEWbpbmhOe8oRXu30/X7dp4msD4xAb3Gd6hfBe8yz64TAj5+RQQaDbCY1opWJzE+uu7n zwC928ewSDRAxoMdcCcw+w6YgS5F5H89vpke1rt3my6O520uQ4sv+gWKwi00aiDOXL4N qXflkMTNTly+9oYbY+zwH2cUqNDIMPeEmbiLPNqRKjegP/KNT+hXHQPysE3kSoMUOhnI yMyA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=f7u7491J19HMjkCqPoWo5Q4mldI+jvB/B6mZvS6xBrk=; b=V6Z00Oco23UTh7Ihz5bWWq4a1UiJ9lEkSpYrh3126MjJ6lYQn8rET3YUTOIEyjaP+m QhVlUAGBfXD8n3rXr+vXAmeNEXGHosciG4ipTg5/oh09Iq6KFQ2id9oLEuU/K7DtQ1jg YxB9sjv4joJR9rnRVe5q6ijQpZ1N8qAwkYGJ23fjmr4Ig2VArIRXbnh+HRxbM36OjQdN 6aODjHXenssWF6LXFMuLevF8lJS2ultrxQVztttVNTG0X9Gi+BVkHlxxdKdoPI2nBueK T0ZAOb6/bOH5NU9a2EcUNc1oMYzz9EScHp/f+5ln0F1mtrTmoHmN68Ri5lHIJZqPVujc 6Slw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UMd2EqTe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d11si8042437pgw.533.2022.01.24.12.48.39; Mon, 24 Jan 2022 12:49:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UMd2EqTe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352458AbiAXUDc (ORCPT + 99 others); Mon, 24 Jan 2022 15:03:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350507AbiAXTZA (ORCPT ); Mon, 24 Jan 2022 14:25:00 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 149B2C08C5CE; Mon, 24 Jan 2022 11:11:44 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C6D26B8121A; Mon, 24 Jan 2022 19:11:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CEE6EC340E5; Mon, 24 Jan 2022 19:11:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643051501; bh=8aW4a3keyYk8sRa/ZJU3iMDDx20CQs9LRAQ6w3cZQFE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UMd2EqTehv6efDu9aCIRuxbaEYcqRWQfKucFwP2Iv4vC76/dyBDNmWgCRBM/r69k7 ZqOWoCs7+lWM6gwNb6axWpK3SyWgd9nragGjj//5c4rvyJuvQSNsSCvN+YD1Abl2WU reQRow8VTpcwR3MCulih99BTlJXXn4pELTHqdO6w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andrey Ryabinin , "Peter Zijlstra (Intel)" , Daniel Jordan , Tejun Heo Subject: [PATCH 4.14 150/186] cputime, cpuacct: Include guest time in user time in cpuacct.stat Date: Mon, 24 Jan 2022 19:43:45 +0100 Message-Id: <20220124183941.930879858@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183937.101330125@linuxfoundation.org> References: <20220124183937.101330125@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrey Ryabinin commit 9731698ecb9c851f353ce2496292ff9fcea39dff upstream. 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 Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Daniel Jordan Acked-by: Tejun Heo Cc: Link: https://lore.kernel.org/r/20211115164607.23784-1-arbn@yandex-team.com Signed-off-by: Greg Kroah-Hartman --- kernel/sched/cputime.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/kernel/sched/cputime.c +++ b/kernel/sched/cputime.c @@ -150,10 +150,10 @@ void account_guest_time(struct task_stru /* 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; } }