From patchwork Tue Apr 18 11:11:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 9685837 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 285BF602C2 for ; Tue, 18 Apr 2017 16:44:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1AC5928497 for ; Tue, 18 Apr 2017 16:44:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0FD342849A; Tue, 18 Apr 2017 16:44:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=2.0 tests=BAYES_00, DATE_IN_PAST_03_06, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9343228497 for ; Tue, 18 Apr 2017 16:44:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753231AbdDRQop (ORCPT ); Tue, 18 Apr 2017 12:44:45 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:52305 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752358AbdDRQol (ORCPT ); Tue, 18 Apr 2017 12:44:41 -0400 Received: from localhost ([127.0.0.1] helo=[127.0.1.1]) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1d0WDo-0008Ck-Qm; Tue, 18 Apr 2017 18:43:22 +0200 Message-Id: <20170418111400.936735984@linutronix.de> User-Agent: quilt/0.63-1 Date: Tue, 18 Apr 2017 13:11:09 +0200 From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , John Stultz , Eric Dumazet , Anna-Maria Gleixner , "Rafael J. Wysocki" , linux-pm@vger.kernel.org, Arjan van de Ven , "Paul E. McKenney" , Frederic Weisbecker , Rik van Riel , Richard Cochran Subject: [patch V2 07/10] tick/sched: Split out jiffies update helper function References: <20170418111102.490432548@linutronix.de> MIME-Version: 1.0 Content-Disposition: inline; filename=tick-sched_Split-out-jiffies-update-helper.patch Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The logic to get the time of the last jiffies update will be needed by the timer pull model as well. Move the code into a global funtion in anticipation of the new caller. No functional change. Signed-off-by: Richard Cochran Signed-off-by: Anna-Maria Gleixner Signed-off-by: Thomas Gleixner --- kernel/time/tick-internal.h | 1 + kernel/time/tick-sched.c | 27 ++++++++++++++++++++------- 2 files changed, 21 insertions(+), 7 deletions(-) --- a/kernel/time/tick-internal.h +++ b/kernel/time/tick-internal.h @@ -151,6 +151,7 @@ static inline void tick_nohz_init(void) #ifdef CONFIG_NO_HZ_COMMON extern unsigned long tick_nohz_active; +extern u64 get_jiffies_update(unsigned long *basej); #else #define tick_nohz_active (0) #endif --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -112,6 +112,24 @@ static ktime_t tick_init_jiffy_update(vo return period; } +#ifdef CONFIG_NO_HZ_COMMON +/* + * Read jiffies and the time when jiffies were updated last + */ +u64 get_jiffies_update(unsigned long *basej) +{ + unsigned long seq, basejiff; + u64 basemono; + + do { + seq = read_seqbegin(&jiffies_lock); + basemono = last_jiffies_update; + basejiff = jiffies; + } while (read_seqretry(&jiffies_lock, seq)); + *basej = basejiff; + return basemono; +} +#endif static void tick_sched_do_timer(ktime_t now) { @@ -667,15 +685,10 @@ static ktime_t tick_nohz_stop_sched_tick { struct clock_event_device *dev = __this_cpu_read(tick_cpu_device.evtdev); u64 basemono, next_tick, next_local, next_global, next_rcu, delta, expires; - unsigned long seq, basejiff; + unsigned long basejiff; ktime_t tick; - /* Read jiffies and the time when jiffies were updated last */ - do { - seq = read_seqbegin(&jiffies_lock); - basemono = last_jiffies_update; - basejiff = jiffies; - } while (read_seqretry(&jiffies_lock, seq)); + basemono = get_jiffies_update(&basejiff); ts->last_jiffies = basejiff; if (rcu_needs_cpu(basemono, &next_rcu) ||