From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759767AbbBIL1Y (ORCPT ); Mon, 9 Feb 2015 06:27:24 -0500 Received: from bombadil.infradead.org ([198.137.202.9]:46488 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753551AbbBIL1W (ORCPT ); Mon, 9 Feb 2015 06:27:22 -0500 Date: Mon, 9 Feb 2015 12:27:15 +0100 From: Peter Zijlstra To: Zefan Li Cc: Ingo Molnar , Mike Galbraith , LKML , Stefan Bader Subject: Re: [PATCH] sched, autogroup: Fix failure when writing to cpu.rt_runtime_us Message-ID: <20150209112715.GO24151@twins.programming.kicks-ass.net> References: <54D32AD4.1060003@huawei.com> <20150205142527.GI5029@twins.programming.kicks-ass.net> <54D4194B.2040808@huawei.com> <20150206105840.GJ23123@twins.programming.kicks-ass.net> <54D5B873.5030208@huawei.com> <20150209112237.GR5029@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150209112237.GR5029@twins.programming.kicks-ass.net> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 09, 2015 at 12:22:37PM +0100, Peter Zijlstra wrote: > Indeed, setting runtime=0 for the root group is a very bad thing > regardless of this patch. It would disallow the kernel from creating RT > threads, which it needs for 'correct' operation in a number of cases. > > But lets make that a separate patch. --- Subject: sched,rt: Avoid obvious configuration fail From: Peter Zijlstra Date: Mon Feb 9 12:23:20 CET 2015 Setting the root group's cpu.rt_runtime_us to 0 is a bad thing; it would disallow the kernel creating RT tasks. One can of course still set it to 1, which will (likely) still wreck your kernel, but at least make it clear that setting it to 0 is not good. Collect both sanity checks into the one place while we're there. Suggested-by: Zefan Li Signed-off-by: Peter Zijlstra (Intel) --- kernel/sched/core.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -7742,6 +7742,17 @@ static int tg_set_rt_bandwidth(struct ta { int i, err = 0; + /* + * Disallowing the root group RT runtime is BAD, it would disallow the + * kernel creating (and or operating) RT threads. + */ + if (tg == &root_task_group && rt_runtime == 0) + return -EINVAL; + + /* No period doesn't make any sense. */ + if (rt_period == 0) + return -EINVAL; + mutex_lock(&rt_constraints_mutex); read_lock(&tasklist_lock); err = __rt_schedulable(tg, rt_period, rt_runtime); @@ -7798,9 +7809,6 @@ static int sched_group_set_rt_period(str rt_period = (u64)rt_period_us * NSEC_PER_USEC; rt_runtime = tg->rt_bandwidth.rt_runtime; - if (rt_period == 0) - return -EINVAL; - return tg_set_rt_bandwidth(tg, rt_period, rt_runtime); }