From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751645AbbBPUYv (ORCPT ); Mon, 16 Feb 2015 15:24:51 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42151 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751021AbbBPUYu (ORCPT ); Mon, 16 Feb 2015 15:24:50 -0500 Date: Mon, 16 Feb 2015 15:23:49 -0500 From: Rik van Riel To: peterz@infradead.org Cc: lcapitulino@redhat.com, linux-kernel@vger.kernel.org, mtosatti@redhat.com, mingo@kernel.org, fweisbec@redhat.com Subject: [PATCH] sched,rt,nohz: stop scheduler tick if running realtime task Message-ID: <20150216152349.6a8ed824@annuminas.surriel.com> Organization: Red Hat, Inc. MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If the CPU is running a realtime task that does not round-robin with another realtime task of equal priority, there is no point in keeping the scheduler tick going. After all, whenever the scheduler tick runs, the kernel will just decide not to reschedule. Extend sched_can_stop_tick to recognize these situations, and inform the rest of the kernel that the scheduler tick can be stopped. Signed-off-by: Rik van Riel Tested-by: Luiz Capitulino --- kernel/sched/core.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index ade2958a9197..ad985a632c4d 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -745,6 +745,22 @@ static inline bool got_nohz_idle_kick(void) bool sched_can_stop_tick(void) { /* + * FIFO realtime policy runs the highest priority task. Other runnable + * tasks are of a lower priority. The scheduler tick does nothing. + */ + if (current->policy == SCHED_FIFO) + return true; + + /* + * Round-robin realtime tasks time slice with other tasks at the same + * realtime priority. Is this task the only one at this priority? + */ + if (current->policy == SCHED_RR) { + struct sched_rt_entity *rt_se = ¤t->rt; + return rt_se->run_list.prev == rt_se->run_list.next; + } + + /* * More than one running task need preemption. * nr_running update is assumed to be visible * after IPI is sent from wakers.