Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84A0DC6FD1F for ; Tue, 14 Mar 2023 03:13:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229698AbjCNDN5 (ORCPT ); Mon, 13 Mar 2023 23:13:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229648AbjCNDNp (ORCPT ); Mon, 13 Mar 2023 23:13:45 -0400 Received: from out-36.mta0.migadu.com (out-36.mta0.migadu.com [IPv6:2001:41d0:1004:224b::24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DC3113DEE for ; Mon, 13 Mar 2023 20:13:41 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1678763618; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=xtue6tgmt/ETmVgm+Gz/X49IfXkoIX4RFUArbKPcTC4=; b=cPQJDMxvCTUTD9I3fo3Yt8sMAIh2mC8D/K5EXTVmwvBA2n87l/xM1e58L3t1p6M23PPsGs pxEW5RCzXvzMG8BG20pbSww2MEh/GLTwvyRaP0gDIaeWbpjLriRZmKvzu+43VVQ2HhpoB8 T/w59ccRqqfm9fWDUXyj535CxTnWTw8= From: Yajun Deng To: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com Cc: linux-kernel@vger.kernel.org, Yajun Deng Subject: [PATCH] sched/rt: Reset sysctl_sched_rr_timeslice when it non-positive Date: Tue, 14 Mar 2023 11:13:23 +0800 Message-Id: <20230314031323.3638994-1-yajun.deng@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When sysctl_sched_rr_timeslice was set a non-positive number, only sched_rr_timeslice was reset to default, This behavior should let users know. So reset sysctl_sched_rr_timeslice at the same time when it non-positive. Signed-off-by: Yajun Deng --- kernel/sched/rt.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index 0a11f44adee5..0723a6297f96 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -3036,9 +3036,12 @@ static int sched_rr_handler(struct ctl_table *table, int write, void *buffer, * Also, writing zero resets the timeslice to default: */ if (!ret && write) { - sched_rr_timeslice = - sysctl_sched_rr_timeslice <= 0 ? RR_TIMESLICE : - msecs_to_jiffies(sysctl_sched_rr_timeslice); + if (sysctl_sched_rr_timeslice > 0) + sched_rr_timeslice = msecs_to_jiffies(sysctl_sched_rr_timeslice); + else { + sched_rr_timeslice = RR_TIMESLICE; + sysctl_sched_rr_timeslice = (MSEC_PER_SEC / HZ) * RR_TIMESLICE; + } } mutex_unlock(&mutex); -- 2.25.1