All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@suse.cz>
To: linux-kernel@vger.kernel.org
Cc: Dave Jones <davej@redhat.com>, Arnd Bergmann <arnd@arndb.de>,
	Thomas Gleixner <tglx@linutronix.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	cpufreq@vger.kernel.org, Alexey Dobriyan <adobriyan@gmail.com>
Subject: Re: [PATCH 3/3] proc: consider NO_HZ when printing idle and iowait times
Date: Fri, 5 Aug 2011 16:23:50 +0200	[thread overview]
Message-ID: <20110805142349.GE12657@tiehlicka.suse.cz> (raw)
In-Reply-To: <9314d03604802205b02524ebda1e534547042dfa.1312544541.git.mhocko@suse.cz>

On Thu 04-08-11 17:20:32, Michal Hocko wrote:
> show_stat handler of the /proc/stat file relies on kstat_cpu(cpu)
> statistics when priting information about idle and iowait times.
> This is OK if we are not using tickless kernel (CONFIG_NO_HZ) because
> counters are updated periodically.
> With NO_HZ things got more tricky because we are not doing idle/iowait
> accounting while we are tickless so the value might get outdated.
> Users of /proc/stat will notice that by unchanged idle/iowait values
> which is then interpreted as 0% idle/iowait time. From the user space
> POV this is an unexpected behavior and a change of the interface.
> 
> Let's fix this by using get_cpu_{idle,iowait}_time_us which accounts the
> total idle/iowait time since boot and it doesn't rely on sampling or any
> other periodic activity. Fall back to the previous behavior if NO_HZ is
> disabled or not configured.

I forgot to mention that this might be racy because we are updating
those per-cpu values without having preemption disabled or any other
locking which would be necessary as governors iterate over all CPUs.
Governors do not have to care about that because they are singletons. 
Introducing locks doesn't look like an option but I was thinking
about adding __get_cpu_{idle,iowait}_time_us which wouldn't call
update_ts_timestat and calculate the result instead.
I can add a patch which does that but I wanted to hear about general
approach first.

-- 
Michal Hocko
SUSE Labs
SUSE LINUX s.r.o.
Lihovarska 1060/12
190 00 Praha 9    
Czech Republic

  parent reply	other threads:[~2011-08-05 14:23 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-25 14:33 Have we changed /proc/stat idle statistics by NOHZ kernel? Michal Hocko
2011-08-01 19:59 ` Andrew Morton
2011-08-02 17:02   ` Michal Hocko
     [not found]     ` <cover.1312544541.git.mhocko@suse.cz>
     [not found]       ` <9314d03604802205b02524ebda1e534547042dfa.1312544541.git.mhocko@suse.cz>
2011-08-05 14:23         ` Michal Hocko [this message]
2011-08-22  9:56           ` [PATCH] nohz: do not update idle/iowait counters from get_cpu_{idle,iowait}_time_us if not asked Michal Hocko
2011-08-22  9:56             ` Michal Hocko
2011-08-17 11:59       ` [PATCH 0/3 RFC] Fix /proc/stat idle/iowait statistics for tickless kernel Michal Hocko
2011-08-23 21:18         ` Andrew Morton
     [not found]       ` <c6c176ace7eca5fffe568865193a1061d181c77c.1312544541.git.mhocko@suse.cz>
2011-08-17 14:02         ` [PATCH 2/3] cputime: clean up cputime_to_usecs and usecs_to_cputime macros Arnd Bergmann

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=20110805142349.GE12657@tiehlicka.suse.cz \
    --to=mhocko@suse.cz \
    --cc=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=cpufreq@vger.kernel.org \
    --cc=davej@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.