Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp1165793rwo; Wed, 2 Aug 2023 09:37:14 -0700 (PDT) X-Google-Smtp-Source: APBJJlHgQ5lsUVfKJdvcNbAUpC86t2Lm/kLrM04qa4o7Y6fwQZOMW6KkEmo3X3ouUGtSlH0xGw2D X-Received: by 2002:a05:6e02:e0d:b0:346:c04e:ca25 with SMTP id a13-20020a056e020e0d00b00346c04eca25mr14150873ilk.14.1690994234048; Wed, 02 Aug 2023 09:37:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690994234; cv=none; d=google.com; s=arc-20160816; b=fewxIXdP0MgxTz7QvDH+9Z8olDzsy+KQG8IlXrt1S3/nApwyeskHcRyNiKa7U+M8/M 9nQMV9dBzFrKgxa5TNCukzeLw4uGybWlFpegWlc0JKI9B7Im7550jSyg6pRdzX08UqmL kuIo+JGHe5Dlx9fHGNT9oM/vYnVjzssWkIEeJAk5/VScchuVv+St+COsBOyp0pYsKXUi kqeXd5WSGV6zeUjyTd5/bbFobbKH5SBaJ1BGwIUNUZeOcorYdRmNcPgN4njWUDuKRdVX PCxxzTxhMRHu37M6dtfTfRIshQrij7mWGa9F5W0aie6HVZT8Nn9s9bsWkclXwC800xpP zY5g== 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=wlFk5dvM8K/mJr6kxmbHlFDi02aaVykLxV2u1JfHHgA=; fh=2umZATIjmSM4XtqqQAj4GAoN+cHhV1IBHs6yZRwWTto=; b=Jb3Wn5BSBh7FAbgKkGB/SFX0K7UHI5QReT664tgKT0RFRuDjJvDxd3+LVu2ErWUA2R Ow9fQ8ZSkHzWRZPYd+QyCJ1frCUQ+5Mb3dymFKzpC5eQ/VSkGVcOn8em2DTm5jxq5LgN oCXwvZ24Y0a7sVeJsEFFk1RVERwLRF7DA5lENITJgeEDt0xabxA9mgZu4EsC1yxH9PtS LXjnK6LKzF0QMJyUgR4DsriE091zBJJld+Ij5JYae6c39PW4u6U0G+QpuEmTgkXCir1N D32dljoRsn9gbayTCyLerXkJdy0UHw/EAP4/BxNPWR/lesDJAtaE/ZNH49dng+sukMKx nx/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=CZQ5PhLd; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=r13tfUpX; 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 br22-20020a17090b0f1600b0025bb4a1c12esi1426841pjb.148.2023.08.02.09.37.01; Wed, 02 Aug 2023 09:37:13 -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=CZQ5PhLd; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=r13tfUpX; 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 S234573AbjHBPYI (ORCPT + 99 others); Wed, 2 Aug 2023 11:24:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235307AbjHBPXG (ORCPT ); Wed, 2 Aug 2023 11:23:06 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 863C4421E for ; Wed, 2 Aug 2023 08:19:39 -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 6B99721A7E; Wed, 2 Aug 2023 15:18:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1690989491; 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=wlFk5dvM8K/mJr6kxmbHlFDi02aaVykLxV2u1JfHHgA=; b=CZQ5PhLdOHyWQN6tTzJMrLCItZfFSZ/2dVhgUewDh3csulP44eitM4QsDQfxMRKdCDRAnn 6SbZ1rFF0UljI8ioElywV6wEnRA3cXYAYduqXWgu8XyHRwsi/CupP0ekgDyT+adVXt2xgh 59E/5bO0IKssmr0eQcIYq39DmK2uaUc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1690989491; 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=wlFk5dvM8K/mJr6kxmbHlFDi02aaVykLxV2u1JfHHgA=; b=r13tfUpXUfo0p+Ag951rgi/GIczAL7OPNXwvaWelnCluQCukST+8NZQ9h5E7dzpU/y9L6B yCkstgGOhLLDV/Aw== 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 582FB13919; Wed, 2 Aug 2023 15:18:11 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id Vik1FLNzymRiKAAAMHmgww (envelope-from ); Wed, 02 Aug 2023 15:18:11 +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 , Petr Vorel Subject: [PATCH 1/2 RESEND] sched/rt: Fix sysctl_sched_rr_timeslice intial value Date: Wed, 2 Aug 2023 17:19:05 +0200 Message-ID: <20230802151906.25258-2-chrubis@suse.cz> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802151906.25258-1-chrubis@suse.cz> References: <20230802151906.25258-1-chrubis@suse.cz> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_SOFTFAIL,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 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 CC: Jiri Bohac Fixes: 975e155ed873 ("sched/rt: Show the 'sched_rr_timeslice' SCHED_RR timeslice tuning knob in milliseconds") Signed-off-by: Cyril Hrubis Acked-by: Mel Gorman Reviewed-by: Petr Vorel Tested-by: Petr Vorel --- 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