Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933101AbbDOTJc (ORCPT ); Wed, 15 Apr 2015 15:09:32 -0400 Received: from g1t5425.austin.hp.com ([15.216.225.55]:45996 "EHLO g1t5425.austin.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756699AbbDOTJZ (ORCPT ); Wed, 15 Apr 2015 15:09:25 -0400 Message-ID: <1429124961.7039.120.camel@j-VirtualBox> Subject: Re: [PATCH 2/3] sched, timer: Use atomics for thread_group_cputimer to improve scalability From: Jason Low To: Preeti U Murthy Cc: Linus Torvalds , Peter Zijlstra , Ingo Molnar , Thomas Gleixner , linux-kernel@vger.kernel.org, "Paul E. McKenney" , Andrew Morton , Oleg Nesterov , Mike Galbraith , Frederic Weisbecker , Mel Gorman , Steven Rostedt , hideaki.kimura@hp.com, Aswin Chandramouleeswaran , Scott J Norton , jason.low2@hp.com Date: Wed, 15 Apr 2015 12:09:21 -0700 In-Reply-To: <552E3F4F.5030004@linux.vnet.ibm.com> References: <1429052986-9420-1-git-send-email-jason.low2@hp.com> <1429052986-9420-3-git-send-email-jason.low2@hp.com> <552E3F4F.5030004@linux.vnet.ibm.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 Content-Length: 1275 Lines: 35 On Wed, 2015-04-15 at 16:07 +0530, Preeti U Murthy wrote: > On 04/15/2015 04:39 AM, Jason Low wrote: > > /* > > @@ -885,11 +890,8 @@ static void check_thread_timers(struct task_struct *tsk, > > static void stop_process_timers(struct signal_struct *sig) > > { > > struct thread_group_cputimer *cputimer = &sig->cputimer; > > - unsigned long flags; > > > > - raw_spin_lock_irqsave(&cputimer->lock, flags); > > - cputimer->running = 0; > > - raw_spin_unlock_irqrestore(&cputimer->lock, flags); > > + WRITE_ONCE(cputimer->running, 0); > > Why do a WRITE_ONCE() here ? Perhaps Peter can confirm/elaborate, but since we're now updating the running field without the lock, we use WRITE_ONCE to guarantee that this doesn't get optimized in any way. This can also serve as "documentation" that we're writing to a shared variable without a lock. > Maybe you should explicitly mention this > through a comment like Steven pointed out about all > WRITE/READ/ACCESS_ONCE() usage. Yeah, we should add a comment here. Thanks, Jason -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/