From: Jason Low <jason.low2@hp.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Ingo Molnar <mingo@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
linux-kernel@vger.kernel.org,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
Andrew Morton <akpm@linux-foundation.org>,
Oleg Nesterov <oleg@redhat.com>,
Mike Galbraith <umgwanakikbuti@gmail.com>,
Mel Gorman <mgorman@suse.de>,
Steven Rostedt <rostedt@goodmis.org>,
Preeti U Murthy <preeti@linux.vnet.ibm.com>,
hideaki.kimura@hp.com, Aswin Chandramouleeswaran <aswin@hp.com>,
Scott J Norton <scott.norton@hp.com>,
jason.low2@hp.com
Subject: Re: [PATCH 2/3] sched, timer: Use atomics for thread_group_cputimer to improve scalability
Date: Wed, 15 Apr 2015 13:04:47 -0700 [thread overview]
Message-ID: <1429128287.7039.145.camel@j-VirtualBox> (raw)
In-Reply-To: <20150415133211.GP23123@twins.programming.kicks-ass.net>
On Wed, 2015-04-15 at 15:32 +0200, Peter Zijlstra wrote:
> On Wed, Apr 15, 2015 at 03:25:36PM +0200, Frederic Weisbecker wrote:
> > On Tue, Apr 14, 2015 at 04:09:45PM -0700, Jason Low wrote:
> > > void thread_group_cputimer(struct task_struct *tsk, struct task_cputime *times)
> > > {
> > > struct thread_group_cputimer *cputimer = &tsk->signal->cputimer;
> > > struct task_cputime sum;
> > >
> > > if (!cputimer->running) {
> > > /*
> > > * The POSIX timer interface allows for absolute time expiry
> > > * values through the TIMER_ABSTIME flag, therefore we have
> > > + * to synchronize the timer to the clock every time we start it.
> > > */
> > > thread_group_cputime(tsk, &sum);
> > > + update_gt_cputime(cputimer, &sum);
> > > + /* Start 'running' after update_gt_cputime() */
> > > + smp_store_release(&cputimer->running, 1);
> >
> > This barrier should be mirrored somewhere but I can't see where in this patch.
> > Maybe in another one in the series. Or maybe there is already a barrier in the
> > existing code that I'm missing. I would expect to see it in account_group_*_time().
> > In any case, there should be comment about what it mirrors.
>
> I think it should be in cputimer_running(), which should use
> smp_load_acquire() to read cputimer->running.
>
> That way you guarantee that everything observing 'running' will indeed
> observe the initialized state.
So I intended the smp_store_release() here to be mainly for
documentation purposes, to say that we would like to set running after
the update.
With patch 3/3, even if running happens to get set earlier, the worst
case scenario is that update_gt_cputime may have to do go through some
retry logic. This isn't much of a performance issue in practice
(especially compared to adding smp_load_acquire() to hot paths), since
we only enter this path when we need to enable the timers.
In that case, I'm wondering if should just convert this back to
WRITE_ONCE(cputimer->running, 1) and avoid adding barriers to the hot
paths?
Thanks,
Jason
next prev parent reply other threads:[~2015-04-15 20:05 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-14 23:09 [PATCH 0/3] sched, timer: Improve scalability of itimers Jason Low
2015-04-14 23:09 ` [PATCH 1/3] sched, timer: Remove usages of ACCESS_ONCE in the scheduler Jason Low
2015-04-14 23:59 ` Steven Rostedt
2015-04-15 2:12 ` Jason Low
2015-04-15 2:40 ` Steven Rostedt
2015-04-15 7:46 ` Ingo Molnar
2015-04-15 18:49 ` Jason Low
2015-04-15 19:16 ` Steven Rostedt
2015-04-16 2:46 ` Jason Low
2015-04-16 16:52 ` Peter Zijlstra
2015-04-16 18:02 ` Ingo Molnar
2015-04-16 18:15 ` Peter Zijlstra
2015-04-16 18:24 ` Ingo Molnar
2015-04-16 19:02 ` Peter Zijlstra
2015-04-16 19:41 ` Paul E. McKenney
2015-04-17 3:25 ` Jason Low
2015-04-17 8:19 ` Ingo Molnar
2015-04-16 21:00 ` Jason Low
2015-04-16 2:29 ` Jason Low
2015-04-16 2:37 ` Steven Rostedt
2015-04-14 23:09 ` [PATCH 2/3] sched, timer: Use atomics for thread_group_cputimer to improve scalability Jason Low
2015-04-15 7:33 ` Ingo Molnar
2015-04-15 7:35 ` Ingo Molnar
2015-04-15 17:14 ` Jason Low
2015-04-15 10:37 ` Preeti U Murthy
2015-04-15 19:09 ` Jason Low
2015-04-15 13:25 ` Frederic Weisbecker
2015-04-15 13:32 ` Peter Zijlstra
2015-04-15 20:04 ` Jason Low [this message]
2015-04-15 14:23 ` Davidlohr Bueso
2015-04-15 21:15 ` Jason Low
2015-04-14 23:09 ` [PATCH 3/3] sched, timer: Use cmpxchg to do updates in update_gt_cputime() Jason Low
2015-04-14 23:53 ` [PATCH 0/3] sched, timer: Improve scalability of itimers Linus Torvalds
2015-04-15 7:24 ` Ingo Molnar
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=1429128287.7039.145.camel@j-VirtualBox \
--to=jason.low2@hp.com \
--cc=akpm@linux-foundation.org \
--cc=aswin@hp.com \
--cc=fweisbec@gmail.com \
--cc=hideaki.kimura@hp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@kernel.org \
--cc=oleg@redhat.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.org \
--cc=preeti@linux.vnet.ibm.com \
--cc=rostedt@goodmis.org \
--cc=scott.norton@hp.com \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=umgwanakikbuti@gmail.com \
/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.