From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756200AbcANPbr (ORCPT ); Thu, 14 Jan 2016 10:31:47 -0500 Received: from mail-wm0-f41.google.com ([74.125.82.41]:38008 "EHLO mail-wm0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755599AbcANPZx (ORCPT ); Thu, 14 Jan 2016 10:25:53 -0500 From: Luca Abeni To: linux-kernel@vger.kernel.org Cc: Peter Zijlstra , Ingo Molnar , Juri Lelli , Luca Abeni Subject: [RFC 8/8] Do not reclaim the whole CPU bandwidth Date: Thu, 14 Jan 2016 16:24:53 +0100 Message-Id: <1452785094-3086-9-git-send-email-luca.abeni@unitn.it> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1452785094-3086-1-git-send-email-luca.abeni@unitn.it> References: <1452785094-3086-1-git-send-email-luca.abeni@unitn.it> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Original GRUB tends to reclaim 100% of the CPU time... And this allows a "CPU hog" (i.e., a busy loop) to starve non-deadline tasks. To address this issue, allow the scheduler to reclaim only a specified fraction of CPU time. NOTE: the fraction of CPU time that cannot be reclaimed is currently hardcoded as (1 << 20) / 10 -> 90%, but it must be made configurable! --- kernel/sched/deadline.c | 3 ++- kernel/sched/sched.h | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 712cc6d..57b693b 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -185,6 +185,7 @@ void init_dl_rq(struct dl_rq *dl_rq) #else init_dl_bw(&dl_rq->dl_bw); #endif + dl_rq->unusable_bw = (1 << 20) / 10; // FIXME: allow to set this! } #ifdef CONFIG_SMP @@ -825,7 +826,7 @@ extern bool sched_rt_bandwidth_account(struct rt_rq *rt_rq); u64 grub_reclaim(u64 delta, struct rq *rq, u64 u) { - return (delta * rq->dl.running_bw) >> 20; + return (delta * (rq->dl.unusable_bw + rq->dl.running_bw)) >> 20; } /* diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index d06005b..76df0ff 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -524,6 +524,10 @@ struct dl_rq { * and decreased when a task blocks */ s64 running_bw; + /* This is the amount of utilization that GRUB can not + * reclaim (per runqueue) + */ + s64 unusable_bw; s64 this_bw; }; -- 1.9.1