From: "Lihua (lihua, ran)" <hucool.lihua@huawei.com>
To: Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Juri Lelli <juri.lelli@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Steven Rostedt <rostedt@goodmis.org>,
Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
Daniel Bristot de Oliveira <bristot@redhat.com>,
"open list:SCHEDULER" <linux-kernel@vger.kernel.org>,
<frederic@kernel.org>
Subject: Re: [Question] Reading /proc/stat has a time backward issue
Date: Mon, 8 Aug 2022 20:23:46 +0800 [thread overview]
Message-ID: <7b2586c0-c380-c856-7d63-b7bff6f3a640@huawei.com> (raw)
In-Reply-To: <1f1f625a-148d-0398-f840-1f9b4e964189@huawei.com>
ping...
Your suggestions are valuable, I don't have a good way to fix this.
thanks all.
在 2022/8/4 15:44, Lihua (lihua, ran) 写道:
> ping...
>
> Any good suggestions?
>
> thanks all.
>
> 在 2022/7/27 12:02, Lihua (lihua, ran) 写道:
>> Hi all,
>>
>> I found a problem that the statistical time goes backward, the value read first is 319, and the value read again is 318. As follows:
>> first:
>> cat /proc/stat | grep cpu1
>> cpu1 319 0 496 41665 0 0 0 0 0 0
>> then:
>> cat /proc/stat | grep cpu1
>> cpu1 318 0 497 41674 0 0 0 0 0 0
>>
>> Time goes back, which is counterintuitive.
>>
>> After debug this, I found that the problem is caused by the implementation of kcpustat_cpu_fetch_vtime. As follows:
>>
>> CPU0 CPU1
>> First:
>> show_stat():
>> ->kcpustat_cpu_fetch()
>> ->kcpustat_cpu_fetch_vtime()
>> ->cpustat[CPUTIME_USER] = kcpustat_cpu(cpu) + vtime->utime + delta; rq->curr is in user mod
>> ---> When CPU1 rq->curr running on userspace, need add utime and delta
>> ---> rq->curr->vtime->utime is less than 1 tick
>> Then:
>> show_stat():
>> ->kcpustat_cpu_fetch()
>> ->kcpustat_cpu_fetch_vtime()
>> ->cpustat[CPUTIME_USER] = kcpustat_cpu(cpu); rq->curr is in kernel mod
>> ---> When CPU1 rq->curr running on kernel space, just got kcpustat
>>
>> Because the values of utime、 stime and delta are temporarily written to cpustat. Therefore, there are two problems read from /proc/stat:
>> 1. There may be a regression phenomenon;
>> 2. When there are many tasks, the statistics are not accurate enough when utime and stime do not exceed one TICK.
>> The time goes back is counterintuitive, and I want to discuss whether there is a good solution without compromising performance.
>>
>> Thanks a lot.
next prev parent reply other threads:[~2022-08-08 12:23 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-27 4:02 [Question] Reading /proc/stat has a time backward issue Lihua (lihua, ran)
2022-08-04 7:44 ` Lihua (lihua, ran)
2022-08-08 12:23 ` Lihua (lihua, ran) [this message]
2022-08-11 12:49 ` Frederic Weisbecker
2022-08-13 18:58 ` Li Hua
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7b2586c0-c380-c856-7d63-b7bff6f3a640@huawei.com \
--to=hucool.lihua@huawei.com \
--cc=bristot@redhat.com \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=frederic@kernel.org \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=vincent.guittot@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).