From patchwork Tue Mar 14 03:13:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yajun Deng X-Patchwork-Id: 69273 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1539651wrd; Mon, 13 Mar 2023 20:26:10 -0700 (PDT) X-Google-Smtp-Source: AK7set82Qs41WyktP40I+MzuEg3e/BGORgxWRXZA+TY6+u4/8Tl+wQkub/F6i2JsChC/TXsIHK5t X-Received: by 2002:a05:6102:b07:b0:3fe:21e2:b6ad with SMTP id b7-20020a0561020b0700b003fe21e2b6admr12011867vst.28.1678764370443; Mon, 13 Mar 2023 20:26:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678764370; cv=none; d=google.com; s=arc-20160816; b=gFhpfvIvgJSsa4SYOAijzH6uxfeSiOISszC9tbrcuy3oyTln4yu1M9ISHF4Vdrk+ck qrSzxU7YYFsD5zFANZlw1Qw6f//WiyxmYmKt9YfLP6uP1fyhdvIounL+ohmBw/6qeb6l HIgnrlVUhhwOti+TSkhe5CEN6+k3qa6vhfXDpjrnPiViY5/kPd3RUwd/RZViDP0Drz3C MuWKHvoVketLTJuJ4XKtOD8MYCJvDkYynDihSX3dORFriCkmMQmuScn3JhcCteBqYQHn 3aCR9Hwlo8TfO/0jBh7ZAmypwLAmybvQcIjFJ7T9dulf37NYWvTL7EgOIk1so+85aEP5 qmyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=xtue6tgmt/ETmVgm+Gz/X49IfXkoIX4RFUArbKPcTC4=; b=MECVBJtkWuy9ruRSdK7s26W1MkY2Y8gBOBiFeRgxHmvXPDRFpF1deJzP2L+g7MOV6O S2h00eISLTSUUC/PIWjDiSifwXdZHPpR7ZH7YG09tbsWY+3Ro3p36EQgb9KiByTAqIz9 jGWouVg39bXm+zoZumua0jBerWCtIebjoCx+pP0C1apErNHxDqqfr3G3tIe2CIeKcNZU 1V48OL/Z7oU/XoMUoEtoWb6G+B/H3U0mJzVsO3RPusgG/ibVkkJfGXMomncgk4NBGIcC Xr+HUA84Jp9lMcBVir0k9zC+Rs0UkUyiQlLq5+Bg03Q5ibE0xAz07fXJATMeGGrINq51 i8YQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=cPQJDMxv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v24-20020ab06598000000b0074a710aae6csi767339uam.75.2023.03.13.20.25.55; Mon, 13 Mar 2023 20:26:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=cPQJDMxv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229787AbjCNDN5 (ORCPT + 99 others); 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 X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760312028341791065?= X-GMAIL-MSGID: =?utf-8?q?1760312028341791065?= 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);