Received: by 2002:a05:7412:bb8d:b0:d7:7d3a:4fe2 with SMTP id js13csp27246rdb; Mon, 14 Aug 2023 08:32:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFUKs0gUn4ZVDBPfWvRLqthe+rO8uKsI4TuZ3K90Mlfj77FKqPdrpTJtbHjdNZvkyylSU/0 X-Received: by 2002:a05:6e02:12b1:b0:348:f6cb:e585 with SMTP id f17-20020a056e0212b100b00348f6cbe585mr10964124ilr.30.1692027179562; Mon, 14 Aug 2023 08:32:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692027179; cv=none; d=google.com; s=arc-20160816; b=Q3bvOhnWL5fCRJrpYoHRftlQl5n7RQj61vNsjeLq8m07hInH2KYNW0KiaIS8rKIYQC PEWIAtQs9Lot3sbb46Ud4NgyRspeMFhI3Rk/1E0Ij7fMoHVJnye69SoDYQHX9wxd2Bx9 +wV/CT3bu6nrVK7Hxk2WndWxMOCQpFKSlpKfChRrCD4N7JuCdStqhm7Nj8ciA4WpXPEs nHI6x5ELk3aauS4O/TZHQZ8o9+n73QfW29fi4xnqQ8pTeQpi2toab0ZbnFXUsoGb/xVy y3T86MK22HJJCsccx0YPjksZcjQ8W5wU+a2g+Q4Dq8LNV4N5JAMGxz2K2ke0DqXOhVkl Qw7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=YqjiB9b9W31Axoru4v2fACC/gOxJ7s3KyJ0ZqfuVUqA=; fh=ewCTnLrD3KzNr3Cj31i/vUzTH4c+xIppjr35abVBF0A=; b=nWuQlA/aaVecMszFVi5zxClmQjeeDgf759Ru6YddwbycEm9MFpXS6cRc03gdCv8nJt /Ew0+u/B+nls8iSD8A4GqzkoYKK/GgCJrfu6/nOTS38fZ3G6kNlIuKkXKbqZQMVvq/i+ 8d7RyPkgEqDgI1Evkte8xCXOwyolLbRo5+DQFaAK15q0OPFlrwaS0TIonlPEsN8N+/el r/8kMTIsK1nqpBIobFrH9amadbkBUXWoqPO0M6qpnA2O7TrB+tNuzBR075/5P1ecJuj6 ft6ZtURVLoLBGF97+XF4wk3/uL7on5uof0oGqBWcQagUsaqO2iFnvjLJxE7Ba2g26nUH LHRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=QCn9wF87; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=tTSEcl06; 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=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 138-20020a630090000000b005639fa45a28si8635379pga.630.2023.08.14.08.32.47; Mon, 14 Aug 2023 08:32:59 -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=@linutronix.de header.s=2020 header.b=QCn9wF87; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=tTSEcl06; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232823AbjHNPIq (ORCPT + 99 others); Mon, 14 Aug 2023 11:08:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232693AbjHNPIO (ORCPT ); Mon, 14 Aug 2023 11:08:14 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2ED410C8; Mon, 14 Aug 2023 08:08:09 -0700 (PDT) Date: Mon, 14 Aug 2023 15:08:07 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1692025688; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YqjiB9b9W31Axoru4v2fACC/gOxJ7s3KyJ0ZqfuVUqA=; b=QCn9wF87dFadGwJJ5okww0tNYqH4y+VTIN6/bOBGSnDG7N1pDWodly2O4/SJYBFtX7m8sX +XX9T4PzMScE4/ftlXNK3UU17gmaqfIxBGB1AsVGy1aBIOBN/9g/o6ZW+4AfK9x5wZ3k8K fSTGzBhaHoef9esB/0YO80xbtTfTmlCg3FmQgZqCmLXwgbAIDCMI3A2AJZW0/htx+LFyKA LMVlOxbllhNip+DSZMEfc93o1k63yznmBkAMIwxoaSG61XNxydXUL+NB4R14w/DHe7iG07 1K5crwUSKJH+jFHBT5DMACsQRLxthI5qK+OX6mlGuyqu7un1Jj83E00uBD+0Gw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1692025688; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YqjiB9b9W31Axoru4v2fACC/gOxJ7s3KyJ0ZqfuVUqA=; b=tTSEcl06DpfwEY6Po6Q7lmgTxRo5W5y1/zI3p+y3ycwx5rRZcPhMqnc/TJteiPRfNlFuoE 7fMn1+7ti3P1Q0DQ== From: "tip-bot2 for Cyril Hrubis" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] sched/rt: Fix sysctl_sched_rr_timeslice intial value Cc: Cyril Hrubis , "Peter Zijlstra (Intel)" , Petr Vorel , Mel Gorman , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230802151906.25258-2-chrubis@suse.cz> References: <20230802151906.25258-2-chrubis@suse.cz> MIME-Version: 1.0 Message-ID: <169202568796.27769.5144994079483945988.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS 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 The following commit has been merged into the sched/core branch of tip: Commit-ID: c7fcb99877f9f542c918509b2801065adcaf46fa Gitweb: https://git.kernel.org/tip/c7fcb99877f9f542c918509b2801065adcaf46fa Author: Cyril Hrubis AuthorDate: Wed, 02 Aug 2023 17:19:05 +02:00 Committer: Peter Zijlstra CommitterDate: Mon, 14 Aug 2023 17:01:23 +02:00 sched/rt: Fix sysctl_sched_rr_timeslice intial value There is a 10% rounding error in the intial value of the sysctl_sched_rr_timeslice with CONFIG_HZ_300=y. This was found with LTP test sched_rr_get_interval01: sched_rr_get_interval01.c:57: TPASS: sched_rr_get_interval() passed sched_rr_get_interval01.c:64: TPASS: Time quantum 0s 99999990ns sched_rr_get_interval01.c:72: TFAIL: /proc/sys/kernel/sched_rr_timeslice_ms != 100 got 90 sched_rr_get_interval01.c:57: TPASS: sched_rr_get_interval() passed sched_rr_get_interval01.c:64: TPASS: Time quantum 0s 99999990ns sched_rr_get_interval01.c:72: TFAIL: /proc/sys/kernel/sched_rr_timeslice_ms != 100 got 90 What this test does is to compare the return value from the sched_rr_get_interval() and the sched_rr_timeslice_ms sysctl file and fails if they do not match. The problem it found is the intial sysctl file value which was computed as: static int sysctl_sched_rr_timeslice = (MSEC_PER_SEC / HZ) * RR_TIMESLICE; which works fine as long as MSEC_PER_SEC is multiple of HZ, however it introduces 10% rounding error for CONFIG_HZ_300: (MSEC_PER_SEC / HZ) * (100 * HZ / 1000) (1000 / 300) * (100 * 300 / 1000) 3 * 30 = 90 This can be easily fixed by reversing the order of the multiplication and division. After this fix we get: (MSEC_PER_SEC * (100 * HZ / 1000)) / HZ (1000 * (100 * 300 / 1000)) / 300 (1000 * 30) / 300 = 100 Fixes: 975e155ed873 ("sched/rt: Show the 'sched_rr_timeslice' SCHED_RR timeslice tuning knob in milliseconds") Signed-off-by: Cyril Hrubis Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Petr Vorel Acked-by: Mel Gorman Tested-by: Petr Vorel Link: https://lore.kernel.org/r/20230802151906.25258-2-chrubis@suse.cz --- kernel/sched/rt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index 00e0e50..185d3d7 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -25,7 +25,7 @@ unsigned int sysctl_sched_rt_period = 1000000; int sysctl_sched_rt_runtime = 950000; #ifdef CONFIG_SYSCTL -static int sysctl_sched_rr_timeslice = (MSEC_PER_SEC / HZ) * RR_TIMESLICE; +static int sysctl_sched_rr_timeslice = (MSEC_PER_SEC * RR_TIMESLICE) / HZ; static int sched_rt_handler(struct ctl_table *table, int write, void *buffer, size_t *lenp, loff_t *ppos); static int sched_rr_handler(struct ctl_table *table, int write, void *buffer,