Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3685503pxb; Mon, 24 Jan 2022 15:19:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJxrxRf9sTAik08K7U4sDrG15SyzHFB7Wz/5ikDf5twtLNDuynhKHuUdDScowW46ZOQey/SR X-Received: by 2002:a05:6a00:2c3:b0:4c9:ef02:e252 with SMTP id b3-20020a056a0002c300b004c9ef02e252mr4233084pft.64.1643066358354; Mon, 24 Jan 2022 15:19:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643066358; cv=none; d=google.com; s=arc-20160816; b=RB3WQMnhxmjWOYOQoFqOCM0XJvyzFOPX5U5YZzBNPFsyG3oecQ2D3KCpmF4n0bHmpX tcQMEbyB0FtxeDAfoVIXuLFvnf/YMyBmlsojOKJQmyREcd/4NWnDHN229f2zMdhc2apx zFsmTjRh88waqqgvml2nhu01QO2jvjfml7P5uaNgxYLbYIhfLxJEO8BlTkJlyOJSwaY7 8sffYbiQWVCU+NyU6A9+auh2BwTo2y/X9HLfovGPyRFmWXN8ZsYabW8VEPKcRQHPhrWJ c47R4hvs7jEvA6CLsBJOKKk07kQ3zhGprj3mKv9UsdejkM7+b1FDoa0iDInLC7zesVbl VQBQ== 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=ym6W1Qhkk9LN+3/PEx852ZvF/ecvpeQFPmDSKn8uoXc=; b=cKPNtTymubcBgOiGRLPLEUw3cPWdeVL/NFBYbeW3TRh0toQbxlIgXUcNaDKjARaunK wL7x5oZ59EsDRffnU7Dc3Ye2g6Q/SpUEZUfODJ+9eibyCz892gEBNZuqwUNCjdNqHx5x J535nr2SUhphlgXZlxVYBwnTkj7//ufkneb8PQilsW0F9wxnTikZLMaxaivfsJW/+xnh pg3v8sjpIEdbe1ybiqTE2kHf9R2HxUW9AKFdWViwS8XgSXPoQl/te0+n+mlVzqviA2q7 fAm2Kd7s9T7H3Y1Gma9LOWWGp9vCZWP9TGNnXMK3s2giNWb7N3OGVLogX8WTsGLHOxhu k5ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dhKDlYTf; 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 mi11si676171pjb.124.2022.01.24.15.19.06; Mon, 24 Jan 2022 15:19:18 -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=dhKDlYTf; 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 S1846942AbiAXXRb (ORCPT + 99 others); Mon, 24 Jan 2022 18:17:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1582556AbiAXWPa (ORCPT ); Mon, 24 Jan 2022 17:15:30 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 995A8C04A2C0; Mon, 24 Jan 2022 12:44:54 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 3895760B18; Mon, 24 Jan 2022 20:44:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 138E2C340E5; Mon, 24 Jan 2022 20:44:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643057093; bh=LvKt4kNdalNrtHc1yjv9UoZIUONIbwelUZZZPp/IQas=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dhKDlYTfS2eTdLZQM35ajksS5f4hB0/ip/sngBavHU7/slHv/5IsTjueV6XiHmVTu X8iFhJ1UcBYMLAKO3W0qmn3w5tN1Ppu2uGfRDaG+c9vobHqEA8zL+E5GoZUjhj/hat 4zt+cYgLNru+zR8++FHNKbRinn4y+VSa83irGS9w= 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 5.15 682/846] cputime, cpuacct: Include guest time in user time in cpuacct.stat Date: Mon, 24 Jan 2022 19:43:19 +0100 Message-Id: <20220124184124.600154900@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@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 @@ -148,10 +148,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; } }