[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1429128287.7039.145.camel@j-VirtualBox>
Date: Wed, 15 Apr 2015 13:04:47 -0700
From: Jason Low <jason.low2@...com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Frederic Weisbecker <fweisbec@...il.com>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Ingo Molnar <mingo@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>,
linux-kernel@...r.kernel.org,
"Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Oleg Nesterov <oleg@...hat.com>,
Mike Galbraith <umgwanakikbuti@...il.com>,
Mel Gorman <mgorman@...e.de>,
Steven Rostedt <rostedt@...dmis.org>,
Preeti U Murthy <preeti@...ux.vnet.ibm.com>,
hideaki.kimura@...com, Aswin Chandramouleeswaran <aswin@...com>,
Scott J Norton <scott.norton@...com>, jason.low2@...com
Subject: Re: [PATCH 2/3] sched, timer: Use atomics for thread_group_cputimer
to improve scalability
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists