From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756290AbdKCRFQ (ORCPT ); Fri, 3 Nov 2017 13:05:16 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:56242 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756247AbdKCRFK (ORCPT ); Fri, 3 Nov 2017 13:05:10 -0400 From: Chris Metcalf To: Steven Rostedt , Ingo Molnar , Peter Zijlstra , Andrew Morton , Rik van Riel , Tejun Heo , Frederic Weisbecker , Thomas Gleixner , "Paul E. McKenney" , Christoph Lameter , Viresh Kumar , Catalin Marinas , Will Deacon , Andy Lutomirski , Michal Hocko , linux-kernel@vger.kernel.org Cc: Chris Metcalf Subject: [PATCH v16 05/13] Add try_stop_full_tick() API for NO_HZ_FULL Date: Fri, 3 Nov 2017 13:04:44 -0400 Message-Id: <1509728692-10460-6-git-send-email-cmetcalf@mellanox.com> X-Mailer: git-send-email 2.1.2 In-Reply-To: <1509728692-10460-1-git-send-email-cmetcalf@mellanox.com> References: <1509728692-10460-1-git-send-email-cmetcalf@mellanox.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This API checks to see if the scheduler tick can be stopped, and if so, stops it and returns 0; otherwise it returns an error. This is intended for use with task isolation, where we will want to be able to stop the tick synchronously when returning to userspace. Signed-off-by: Chris Metcalf --- include/linux/tick.h | 1 + kernel/time/tick-sched.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/include/linux/tick.h b/include/linux/tick.h index fe01e68bf520..078ff2464b00 100644 --- a/include/linux/tick.h +++ b/include/linux/tick.h @@ -234,6 +234,7 @@ static inline void tick_dep_clear_signal(struct signal_struct *signal, extern void tick_nohz_full_kick_cpu(int cpu); extern void __tick_nohz_task_switch(void); +extern int try_stop_full_tick(void); #else static inline int housekeeping_any_cpu(void) { diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index c7a899c5ce64..c026145eba2f 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -861,6 +861,24 @@ static void tick_nohz_full_update_tick(struct tick_sched *ts) #endif } +#ifdef CONFIG_TASK_ISOLATION +int try_stop_full_tick(void) +{ + int cpu = smp_processor_id(); + struct tick_sched *ts = this_cpu_ptr(&tick_cpu_sched); + + /* For an unstable clock, we should return a permanent error code. */ + if (atomic_read(&tick_dep_mask) & TICK_DEP_MASK_CLOCK_UNSTABLE) + return -EINVAL; + + if (!can_stop_full_tick(cpu, ts)) + return -EAGAIN; + + tick_nohz_stop_sched_tick(ts, ktime_get(), cpu); + return 0; +} +#endif + static bool can_stop_idle_tick(int cpu, struct tick_sched *ts) { /* -- 2.1.2