Linux-Fsdevel Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Alexey Dobriyan <adobriyan@gmail.com>
To: Tom Hromatka <tom.hromatka@oracle.com>
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
fweisbec@gmail.com, tglx@linutronix.de, mingo@kernel.org
Subject: Re: [RESEND PATCH 2/2] /proc/stat: Simplify iowait and idle calculations when cpu is offline
Date: Thu, 10 Sep 2020 15:14:48 +0300 [thread overview]
Message-ID: <20200910121448.GA59606@localhost.localdomain> (raw)
In-Reply-To: <20200909144122.77210-3-tom.hromatka@oracle.com>
On Wed, Sep 09, 2020 at 08:41:22AM -0600, Tom Hromatka wrote:
> static u64 get_idle_time(struct kernel_cpustat *kcs, int cpu)
> {
> - u64 idle, idle_usecs = -1ULL;
> + u64 idle, idle_usecs;
>
> - if (cpu_online(cpu))
> - idle_usecs = get_cpu_idle_time_us(cpu, NULL);
> -
> - if (idle_usecs == -1ULL)
> - /* !NO_HZ or cpu offline so we can rely on cpustat.idle */
> - idle = kcs->cpustat[CPUTIME_IDLE];
> - else
> - idle = idle_usecs * NSEC_PER_USEC;
> + idle_usecs = get_cpu_idle_time_us(cpu, NULL);
> + idle = idle_usecs * NSEC_PER_USEC;
>
> return idle;
> }
>
> static u64 get_iowait_time(struct kernel_cpustat *kcs, int cpu)
> {
> - u64 iowait, iowait_usecs = -1ULL;
> -
> - if (cpu_online(cpu))
> - iowait_usecs = get_cpu_iowait_time_us(cpu, NULL);
> + u64 iowait, iowait_usecs;
>
> - if (iowait_usecs == -1ULL)
> - /* !NO_HZ or cpu offline so we can rely on cpustat.iowait */
> - iowait = kcs->cpustat[CPUTIME_IOWAIT];
> - else
> - iowait = iowait_usecs * NSEC_PER_USEC;
> + iowait_usecs = get_cpu_iowait_time_us(cpu, NULL);
> + iowait = iowait_usecs * NSEC_PER_USEC;
You can gc variables in both cases:
return get_cpu_iowait_time_us() * NSEC_PER_USEC;
next prev parent reply other threads:[~2020-09-10 12:16 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-09 14:41 [RESEND PATCH 0/2] iowait and idle fixes in /proc/stat Tom Hromatka
2020-09-09 14:41 ` [RESEND PATCH 1/2] tick-sched: Do not clear the iowait and idle times Tom Hromatka
2020-09-13 21:27 ` Thomas Gleixner
2020-09-09 14:41 ` [RESEND PATCH 2/2] /proc/stat: Simplify iowait and idle calculations when cpu is offline Tom Hromatka
2020-09-10 12:14 ` Alexey Dobriyan [this message]
2020-09-13 21:35 ` Thomas Gleixner
2020-09-14 16:31 ` [RESEND PATCH 0/2] iowait and idle fixes in /proc/stat Tom Hromatka
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=20200910121448.GA59606@localhost.localdomain \
--to=adobriyan@gmail.com \
--cc=fweisbec@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=tglx@linutronix.de \
--cc=tom.hromatka@oracle.com \
--subject='Re: [RESEND PATCH 2/2] /proc/stat: Simplify iowait and idle calculations when cpu is offline' \
/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
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).