From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932090AbbCBVTg (ORCPT ); Mon, 2 Mar 2015 16:19:36 -0500 Received: from g4t3426.houston.hp.com ([15.201.208.54]:38568 "EHLO g4t3426.houston.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751891AbbCBVTe (ORCPT ); Mon, 2 Mar 2015 16:19:34 -0500 Message-ID: <1425331172.5304.50.camel@j-VirtualBox> Subject: Re: [PATCH v2] sched, timer: Use atomics for thread_group_cputimer to improve scalability From: Jason Low To: Oleg Nesterov Cc: Peter Zijlstra , Ingo Molnar , Linus Torvalds , "Paul E. McKenney" , Andrew Morton , Mike Galbraith , Frederic Weisbecker , Rik van Riel , Steven Rostedt , Scott Norton , Aswin Chandramouleeswaran , linux-kernel@vger.kernel.org Date: Mon, 02 Mar 2015 13:19:32 -0800 In-Reply-To: <20150302194033.GA27914@redhat.com> References: <1425321731.5304.14.camel@j-VirtualBox> <20150302194033.GA27914@redhat.com> 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 20:40 +0100, Oleg Nesterov wrote: > Well, I forgot everything about this code, but let me ask anyway ;) > > On 03/02, Jason Low wrote: > > @@ -222,13 +239,10 @@ void thread_group_cputimer(struct task_struct *tsk, struct task_cputime *times) > > * it. > > */ > > thread_group_cputime(tsk, &sum); > > - raw_spin_lock_irqsave(&cputimer->lock, flags); > > - cputimer->running = 1; > > - update_gt_cputime(&cputimer->cputime, &sum); > > - } else > > - raw_spin_lock_irqsave(&cputimer->lock, flags); > > - *times = cputimer->cputime; > > - raw_spin_unlock_irqrestore(&cputimer->lock, flags); > > + update_gt_cputime(cputimer, &sum); > > + ACCESS_ONCE(cputimer->running) = 1; > > WRITE_ONCE() looks better... Okay, I can update that. > but it is not clear to me why do we need it > at all. Peter suggested it here as we would now be updating the running field without the lock: https://lkml.org/lkml/2015/1/23/641