From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756756AbbCEPUj (ORCPT ); Thu, 5 Mar 2015 10:20:39 -0500 Received: from mail-we0-f171.google.com ([74.125.82.171]:39565 "EHLO mail-we0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751824AbbCEPUh (ORCPT ); Thu, 5 Mar 2015 10:20:37 -0500 Date: Thu, 5 Mar 2015 16:20:34 +0100 From: Frederic Weisbecker To: Linus Torvalds Cc: Jason Low , Oleg Nesterov , Peter Zijlstra , Ingo Molnar , "Paul E. McKenney" , Andrew Morton , Mike Galbraith , Rik van Riel , Steven Rostedt , Scott Norton , Aswin Chandramouleeswaran , Linux Kernel Mailing List Subject: Re: [PATCH v2] sched, timer: Use atomics for thread_group_cputimer to improve scalability Message-ID: <20150305152032.GC5074@lerouge> References: <1425321731.5304.14.camel@j-VirtualBox> <20150302194033.GA27914@redhat.com> <20150302194356.GB27914@redhat.com> <1425330975.5304.49.camel@j-VirtualBox> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 02, 2015 at 01:44:04PM -0800, Linus Torvalds wrote: > On Mon, Mar 2, 2015 at 1:16 PM, Jason Low wrote: > > > > In original code, we set cputimer->running first so it is running while > > we call update_gt_cputime(). Now in this patch, we swapped the 2 calls > > such that we set running after calling update_gt_cputime(), so that > > wouldn't be an issue anymore. > > Hmm. If you actually care about ordering, and 'running' should be > written to after the other things, then it might be best if you use > > smp_store_release(&cputimer->running, 1); > > which makes it clear that the store happens *after* what went before it. > > Or at least have a "smp_wmb()" between the atomic64 updates and the > "WRITE_ONCE()". FWIW, perhaps it can be reduced with an smp_mb__before_atomic() on the account_group_*_time() side, paired with smp_wmb() from the thread_group_cputimer() side. Arming cputime->running shouldn't be too frequent while update cputime happens at least every tick... Assuming smp_mb__before_atomic() is more lightweight than smp_load_acquire() of course. > > I guess that since you use cmpxchg in update_gt_cputime, the accesses > end up being ordered anyway, but it might be better to make that thing > very explicit. > > Linus