From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754677AbbCBWnZ (ORCPT ); Mon, 2 Mar 2015 17:43:25 -0500 Received: from g9t1613g.houston.hp.com ([15.240.0.71]:51103 "EHLO g9t1613g.houston.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751937AbbCBWnY (ORCPT ); Mon, 2 Mar 2015 17:43:24 -0500 Message-ID: <1425336200.5304.84.camel@j-VirtualBox> Subject: Re: [PATCH v2] sched, timer: Use atomics for thread_group_cputimer to improve scalability From: Jason Low To: Linus Torvalds Cc: Oleg Nesterov , Peter Zijlstra , Ingo Molnar , "Paul E. McKenney" , Andrew Morton , Mike Galbraith , Frederic Weisbecker , Rik van Riel , Steven Rostedt , Scott Norton , Aswin Chandramouleeswaran , Linux Kernel Mailing List , jason.low2@hp.com Date: Mon, 02 Mar 2015 14:43:20 -0800 In-Reply-To: References: <1425321731.5304.14.camel@j-VirtualBox> <20150302194033.GA27914@redhat.com> <20150302194356.GB27914@redhat.com> <1425330975.5304.49.camel@j-VirtualBox> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.3-0ubuntu6 Content-Transfer-Encoding: 7bit Mime-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2015-03-02 at 13:44 -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()". > > 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. Yeah, I suppose the extra (smp_mb or smp_wmb) might add more overhead but since this is not a common code path anyway, it would be worth adding it to make things more clear.