Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp8016207rwp; Wed, 19 Jul 2023 04:07:12 -0700 (PDT) X-Google-Smtp-Source: APBJJlHwIl/b2eEzTU9hpKmNenvMnNBV9rZ+xt5mMT6Z0AQq1eU54yA6qg5CYn6g3QUpt0WeKLoI X-Received: by 2002:a05:6512:304a:b0:4fb:8cd1:1679 with SMTP id b10-20020a056512304a00b004fb8cd11679mr15007535lfb.44.1689764832263; Wed, 19 Jul 2023 04:07:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689764832; cv=none; d=google.com; s=arc-20160816; b=h8i+lB5Pml+68sQiRtzprcTT5tvrE0FEi+00TtxLvT/WJAO/MuDKjNXbuzYMGxJBg5 /BGzpUU2qSsHzcMwJBS8aI1RrBDSKjscN3DYrkhdDKJxiRzs9pdoksiMOak5XCs9qJ5r xFrYARCGBnSUkFxmJwqXfAWmAoLj9YnJW1+ZBmBj5XRXBAykFw50RzxG5ZgbfDrELeU7 cxS+VDR7quHrNCp9HpeBipgbSv/tsHUIHWEJURrOQPR86L+Z8xKOv5UwaNoBjqiq9GuC /s1PwDxQaozm7lYoFHjQyHqhRaWFytDEze2fhmm8fylvMVEtpQUmLDR2r6BZZEjs5fOO /IHg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=HwLa1r8NK4LNOdiioCyUjenqXKibRzNCjoM0CtyE62U=; fh=6xZxXYcgwBDRlwE0Tg3Ps9BU0Ht3UcLLJSh2v6HK5AM=; b=y4k0AHHZvmIF5i5OAy/9GdoicUPUrVkrdXzI7GM6H3Tv2JhhHyRUOy7WL79gnFDzLC g9WnL8/faRvRGeCOSPWix4ew9Tw4ArFn4UK0/dUIzxbp+40lfX1+L3bIFuDQSSY9XWot QtYGdp70GiQNrMFJxr5fjtCGqXSex/HUJViD9E6a+Re1Czidnkv8TlGQ1GOvdwyW06bd mGd8Gf95MRz/hA3Op0RDnKQaxe+K9UYEZTdfzgUKZrYFB83GGRa2uviGll6JgxpyTmbU d4SXJ6wqF6YrAfWjNXN5Q38mpbt2lJaTV8unbpeXZW8h8EPJH22akjYiTHJF/6N40mTP cKMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=RcmEEWTh; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=KpxnPmkR; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n16-20020aa7d050000000b0051fee9567basi2746366edo.619.2023.07.19.04.06.45; Wed, 19 Jul 2023 04:07:12 -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=@suse.cz header.s=susede2_rsa header.b=RcmEEWTh; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=KpxnPmkR; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230256AbjGSKgw (ORCPT + 99 others); Wed, 19 Jul 2023 06:36:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230252AbjGSKgt (ORCPT ); Wed, 19 Jul 2023 06:36:49 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFEB5123 for ; Wed, 19 Jul 2023 03:36:48 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 8E9DE21AE2; Wed, 19 Jul 2023 10:36:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1689763007; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HwLa1r8NK4LNOdiioCyUjenqXKibRzNCjoM0CtyE62U=; b=RcmEEWThrTaFM1Ox/X3Z6dFqowpt29tRUptv1/eINLpwh8hrewQk9VQvDwZCCV+1dHC9sc 5N06+vPczRQ8Z22dBYvX90V5HaJIIJKFRUxlCaKxCnAJUn1QWLTu7Nmdx9ssQEVHLYCLW+ hUOeUgKWIKwwa+bhysywF0xf1HAXVIc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1689763007; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HwLa1r8NK4LNOdiioCyUjenqXKibRzNCjoM0CtyE62U=; b=KpxnPmkROJndQUIBAGDqRypJCyZIzo8t5DNPXXEwKnK+dk2+qkBbvwBjGmv7skDmk71K8m qBB4IYOHeYY7VyDg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 7AD0D1361C; Wed, 19 Jul 2023 10:36:47 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id epalHL+8t2RORQAAMHmgww (envelope-from ); Wed, 19 Jul 2023 10:36:47 +0000 From: Cyril Hrubis To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , linux-kernel@vger.kernel.org Cc: ltp@lists.linux.it, Cyril Hrubis , Jiri Bohac Subject: [PATCH 1/2] sched/rt: Fix sysctl_sched_rr_timeslice intial value Date: Wed, 19 Jul 2023 12:37:42 +0200 Message-ID: <20230719103743.4775-2-chrubis@suse.cz> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230719103743.4775-1-chrubis@suse.cz> References: <20230719103743.4775-1-chrubis@suse.cz> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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,T_SCC_BODY_TEXT_LINE,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 Thre is 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 prolem 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 Signed-off-by: Cyril Hrubis CC: Jiri Bohac --- 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 00e0e5074115..185d3d749f6b 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, -- 2.41.0