Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752789AbbH0ExE (ORCPT ); Thu, 27 Aug 2015 00:53:04 -0400 Received: from g2t2353.austin.hp.com ([15.217.128.52]:45521 "EHLO g2t2353.austin.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751421AbbH0ExD (ORCPT ); Thu, 27 Aug 2015 00:53:03 -0400 Message-ID: <1440651179.32300.71.camel@j-VirtualBox> Subject: Re: [PATCH 3/3] timer: Reduce unnecessary sighand lock contention From: Jason Low To: Frederic Weisbecker Cc: Peter Zijlstra , Ingo Molnar , Thomas Gleixner , Oleg Nesterov , "Paul E. McKenney" , linux-kernel@vger.kernel.org, Linus Torvalds , Davidlohr Bueso , Steven Rostedt , Andrew Morton , Rik van Riel , Scott J Norton , jason.low2@hp.com Date: Wed, 26 Aug 2015 21:52:59 -0700 In-Reply-To: <1440631954.32300.26.camel@j-VirtualBox> References: <1440559068-29680-1-git-send-email-jason.low2@hp.com> <1440559068-29680-4-git-send-email-jason.low2@hp.com> <20150826225628.GD11992@lerouge> <1440631954.32300.26.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 Content-Length: 1844 Lines: 62 On Wed, 2015-08-26 at 16:32 -0700, Jason Low wrote: > Perhaps to be safer, we use something like load_acquire() and > store_release() for accessing both the ->running and ->checking_timer > fields? Regarding using barriers, one option could be to pair them between sig->cputime_expires and the sig->cputimer.checking_timer accesses. fastpath_timer_check() { ... if (READ_ONCE(sig->cputimer.running)) struct task_cputime group_sample; sample_cputime_atomic(&group_sample, &sig->cputimer.cputime_atomic); if (task_cputime_expired(&group_sample, &sig->cputime_expires)) { /* * Comments */ mb(); if (!READ_ONCE(sig->cputimer.checking_timer)) return 1; } } } check_process_timers() { ... WRITE_ONCE(sig->cputimer.checking_timer, 0); /* * Comments */ mb(); sig->cputime_expires.prof_exp = expires_to_cputime(prof_expires); sig->cputime_expires.virt_exp = expires_to_cputime(virt_expires); sig->cputime_expires.sched_exp = sched_expires; ... } By the time the cputime_expires fields get updated at the end of check_process_timers(), other threads in the fastpath_timer_check() should observe the value 0 for READ_ONCE(sig->cputimer.checking_timer). In the case where threads in the fastpath don't observe the WRITE_ONCE(checking_timer, 1) early enough, that's fine, since it will just (unnecessarily) go through the slowpath which is what we also do in the current code. -- 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/