Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1480689pxb; Thu, 4 Mar 2021 12:26:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJyCmP/CqwMgGooBPQ011wCxI9+/iRW0FZUcwGg8eWVDPIc1cK+Szeq+g9d6aOw0nvgJoLDP X-Received: by 2002:a05:6402:1d92:: with SMTP id dk18mr6349542edb.161.1614889575642; Thu, 04 Mar 2021 12:26:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614889575; cv=none; d=google.com; s=arc-20160816; b=a8NWXAWXDtoxDHqeF7nZQTj0O6gqaMv7+8tuvbeDTePfuzTFOBt3pAnJ5qxgqkbU7r AZCgGyeTzUAig0Ds043mJ6RiTsxBqXNwN7C8gxhmIZifzMuM8T3LZYjXEipXs4ojeBMH 5liBGn263GzbKvn8wRZqcNR5kdVMxpPvVDbS85hODBeI5cvPuXqNLJ4McUrwWIRV7Gil l41qxvjkdDlA/iC6bHjja5+pIJV36ntXPfz8XAATC/oR//ArMkcDaQLaag+HCAKJ6LU7 BW+Bos0wmhNbibovmkKxtDvpvgQ+kHuQJLoXAY0lr+dO5wd/lxvcnSUZI13x8r4ARHMj AOtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=n1odR/9HIGhwlY9C1AyzEeD9zVtoOxcaXyC3jT9R5QA=; b=XBncsfBJaaAzTPyp0sLsaXL7zPrMOHFgM/6oc+h2tHq071XLW4lLTfPB1t3KKsLq4c LijqHGidwRlFIbizXz8tWtbX7vaO33JZiC/7SCEZCzSFEObLNUxGplBngcu+vZxrBdpI 9YYFuxZ99bbMnPm31gYGmdclQxUW7TuWb7KMIO2P7jGrY7JMVAn0jgyHz2YABi3sz9cp x4yspvYqbNUYs6NGMQo08c27d6VbJJv03dzQQ5ZlLYSy79ill9kgJo/U4cKtazaCTUhm R5jWM3f3rV5omt8r6M4yKmKHBHqrvRE2O4Al3DTfDa7DDLn+LUGnbn63CAV0SzhuM7zn 2RNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=mhn55k0D; 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=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id fx21si173274ejb.91.2021.03.04.12.25.52; Thu, 04 Mar 2021 12:26:15 -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=@suse.com header.s=susede1 header.b=mhn55k0D; 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=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1447414AbhCBU6I (ORCPT + 99 others); Tue, 2 Mar 2021 15:58:08 -0500 Received: from mx2.suse.de ([195.135.220.15]:50864 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1580523AbhCBSEY (ORCPT ); Tue, 2 Mar 2021 13:04:24 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1614707013; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=n1odR/9HIGhwlY9C1AyzEeD9zVtoOxcaXyC3jT9R5QA=; b=mhn55k0DONsD3wIp8Y4XJ+X3wOcLKsU59xYYRmNFqFD+QjAosw1o2FIWwtx5jlg+NpN1V2 ouNrtZEnOxpvriwCNjlJy7wqODo8p4hk0mPHctHPbURfVHoNkPcwQjIEI/MOqW3MjEvirA 0NUxQFMzmWUtvo7yPaIJ1/xeVtbPxME= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id B3B66AD87; Tue, 2 Mar 2021 17:43:33 +0000 (UTC) Date: Tue, 2 Mar 2021 18:43:23 +0100 From: Michal =?iso-8859-1?Q?Koutn=FD?= To: Muchun Song Cc: 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, mingo@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] sched/cpuacct: Fix charge cpuacct.usage_sys incorrently. Message-ID: References: <20200420070453.76815-1-songmuchun@bytedance.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="dFxZORNm+VieO2OP" Content-Disposition: inline In-Reply-To: <20200420070453.76815-1-songmuchun@bytedance.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --dFxZORNm+VieO2OP Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hello. (Sorry for necroposting, found this upstream reference only now.) On Mon, Apr 20, 2020 at 03:04:53PM +0800, Muchun Song wrote: > /* Time spent by the tasks of the CPU accounting group executing in ... */ > @@ -339,7 +340,7 @@ void cpuacct_charge(struct task_struct *tsk, u64 cputime) > { > struct cpuacct *ca; > int index = CPUACCT_STAT_SYSTEM; > - struct pt_regs *regs = task_pt_regs(tsk); > + struct pt_regs *regs = get_irq_regs() ? : task_pt_regs(tsk); I've read the discussion in [1] but I don't think this approach is correct either (and I don't know what is better :-/). I only have a qualitative proof: host:~ # uname -r 5.10.16-1-default host:~ # systemd-run -p CPUAccounting=yes sh -c 'time sh -c "i=0 ; while [ \"\$i\" -lt 10000 ] ; do i=\$((\$i+1)) ; cat /proc/slabinfo >/dev/null ; done" ; sleep inf' Running as unit: run-r101b9f53efcb4d2a9bfb65feb6f120ca.service host:~ # cat /sys/fs/cgroup/cpuacct/system.slice/run-r101b9f53efcb4d2a9bfb65feb6f120ca.service/cpuacct.usage{,_user,_sys} 16138535165 14332580468 1805954697 (See that sys/user ~ 0.1) host:~ # journalctl -u run-r101b9f53efcb4d2a9bfb65feb6f120ca.service -- Logs begin at Tue 2021-03-02 18:06:41 CET, end at Tue 2021-03-02 18:27:45 CET. -- Mar 02 18:27:29 host systemd[1]: Started /usr/bin/sh -c time sh -c "i=0 ; while [ \"\$i\" -lt 10000 ] ; do i=\$((\$i+1)) ; cat /proc/slabinfo >/dev/null ; done" ; sleep inf. Mar 02 18:27:45 host sh[19117]: real 0m15.543s Mar 02 18:27:45 host sh[19117]: user 0m10.752s Mar 02 18:27:45 host sh[19117]: sys 0m5.379s (See that sys/user ~ 0.5) host:~ # cat /sys/fs/cgroup/cpuacct/system.slice/run-r101b9f53efcb4d2a9bfb65feb6f120ca.service/cpuacct.stat user 415 system 1209 (See that sys/user ~ 3.0 :-o) The expectation is that significant amount of the loop is spent in kernel (dumping slabinfo). I can't tell which of the ratios fits the reality best but the cpuacct.usage_sys still seems too low. Michal [1] https://lore.kernel.org/lkml/20200416141833.50663-1-songmuchun@bytedance.com/ --dFxZORNm+VieO2OP Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEEoQaUCWq8F2Id1tNia1+riC5qSgFAmA+eTUACgkQia1+riC5 qShN+Q//e89E9MA7Ku6PURFKldbhEMpFwuI48vsYuDg1b7OwMtWqk0kpOfhSjjKD N0nP0aMALG1fl9oISUDBzth4CGOzmo28LIlao/f0LGLC+ThJyM48oCEFP44C3VUt hJv4UqEIVHTW7DCuH+lLhU/Tbvwn5TJZoSYdQDwHWsfVlPpO7Ov3mwqlqQlAsr/s nXW+uaz3rjWq8n1L/Q0RK1jbChCLHftF0YG7EBP/5SC0CjN7vnyIIZQQMat8K8qi cbnum0nW4yInY/XBQsUTU13Htk1DB5/c/fqpQurkcp32b8VYMWoV4FrhEhcHSrgD 9XWAA/mvRvzjWIHItgtzQcmBQTz1Kkh+4kjDwHT5Xsl12HCxhPXslkoS4lHIKafu pN3THfUofKeyvRENqcmttDxzWJ74iVSYgs3zmz6nmhpfs2k5HwKF2UEiUeUMLwUd IMdb0rDVD5QhH7JoJ+j8MZQB5nrwrrESdwzV3NCptmxUnyZxarra4fxEM1Cds0Cj wbZlu6KYSrNlwcIG77P03nsTOKWFHKq/CDITvHvCQK1hJYilmW+MPC2DFcLfciRq cFvcn24Mcg6BRBrTvbr5rnhc4mB+MF48K2MckXr+2mk98g1u2JlTYQ2XYj4IgQwq egBnSR90ckz9QD/FSGxJ3ob1CDdmY9DAixP21GbSVKBy6Brfa6A= =xqAD -----END PGP SIGNATURE----- --dFxZORNm+VieO2OP--