All of lore.kernel.org
 help / color / mirror / Atom feed
From: Frederic Weisbecker <fweisbec@gmail.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Oleg Nesterov <oleg@redhat.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Fernando Luis Vazquez Cao <fernando_b1@lab.ntt.co.jp>,
	Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Arjan van de Ven <arjan@linux.intel.com>
Subject: Re: [PATCH 4/5] sched: Refactor iowait accounting
Date: Sat, 19 Oct 2013 18:02:37 +0200	[thread overview]
Message-ID: <20131019160235.GA13534@localhost.localdomain> (raw)
In-Reply-To: <20131019153535.GA2490@laptop.programming.kicks-ass.net>

On Sat, Oct 19, 2013 at 05:35:35PM +0200, Peter Zijlstra wrote:
> On Sat, Oct 19, 2013 at 05:17:20PM +0200, Frederic Weisbecker wrote:
> > +u64 get_cpu_iowait_time_us(int cpu, u64 *last_update_time)
> > +{
> > +	ktime_t iowait, delta = { .tv64 = 0 };
> > +	struct rq *rq = cpu_rq(cpu);
> > +	ktime_t now = ktime_get();
> > +	unsigned int seq;
> > +
> > +	do {
> > +		seq = read_seqbegin(&rq->iowait_lock);
> > +		if (rq->nr_iowait)
> > +			delta = ktime_sub(now, rq->iowait_start);
> > +		iowait = ktime_add(rq->iowait_time, delta);
> > +	} while (read_seqretry(&rq->iowait_lock, seq));
> > +
> > +	if (last_update_time)
> > +		*last_update_time = ktime_to_us(now);
> > +
> > +	return ktime_to_us(iowait);
> > +}
> > +EXPORT_SYMBOL_GPL(get_cpu_iowait_time_us);
> > +
> > +static void cpu_iowait_start(struct rq *rq)
> > +{
> > +	write_seqlock(&rq->iowait_lock);
> > +	if (!rq->nr_iowait++)
> > +		rq->iowait_start = ktime_get();
> > +	write_sequnlock(&rq->iowait_lock);
> > +}
> > +
> > +static void cpu_iowait_end(struct rq *rq)
> > +{
> > +	ktime_t delta;
> > +	write_seqlock(&rq->iowait_lock);
> > +	if (!--rq->nr_iowait) {
> > +		delta = ktime_sub(ktime_get(), rq->iowait_start);
> > +		rq->iowait_time = ktime_add(rq->iowait_time, delta);
> > +	}
> > +	write_sequnlock(&rq->iowait_lock);
> > +}
> 
> Yeah, so using ktime_get() for this is completely insane ;-)

Woops, yeah I clearly overlooked that while moving the code :)
local_clock() should be fine.

> 
> I just had a look at delayacct; wth wrote that crap; that too uses
> gtod.

I can't find where it does that. kernel/delayacct.c doesn't seem to at least.

  reply	other threads:[~2013-10-19 16:02 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-19 15:17 [RFC PATCH 0/5] nohz: Fix racy sleeptime stats v2 Frederic Weisbecker
2013-10-19 15:17 ` [PATCH 1/5] nohz: Convert a few places to use local per cpu accesses Frederic Weisbecker
2013-10-19 15:17 ` [PATCH 2/5] nohz: Only update sleeptime stats locally Frederic Weisbecker
2013-10-19 15:17 ` [PATCH 3/5] timer: Change idle/iowait accounting semantics Frederic Weisbecker
2013-10-20  7:34   ` Andreas Mohr
2013-11-04 16:22     ` Frederic Weisbecker
2013-10-19 15:17 ` [PATCH 4/5] sched: Refactor iowait accounting Frederic Weisbecker
2013-10-19 15:35   ` Peter Zijlstra
2013-10-19 16:02     ` Frederic Weisbecker [this message]
2013-10-19 16:05       ` Peter Zijlstra
2013-10-19 16:20         ` Frederic Weisbecker
2013-10-20 11:10   ` Andreas Mohr
2013-11-04 17:34     ` Frederic Weisbecker
2013-11-04 18:38       ` Andreas Mohr
2013-10-19 15:17 ` [PATCH 5/5] nohz: Synchronize sleep time stats with seqlock Frederic Weisbecker

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=20131019160235.GA13534@localhost.localdomain \
    --to=fweisbec@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=arjan@linux.intel.com \
    --cc=fernando_b1@lab.ntt.co.jp \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=oleg@redhat.com \
    --cc=penguin-kernel@I-love.SAKURA.ne.jp \
    --cc=peterz@infradead.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.