Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp211150iob; Mon, 2 May 2022 17:20:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzPUcQyc4UIjreSB1F+aQnMh/7LjsVCz6YCnDMg8nwT+7myVKyV6zQk6SyNLSDm610z8ZdK X-Received: by 2002:a05:6a00:b41:b0:50d:35fa:476d with SMTP id p1-20020a056a000b4100b0050d35fa476dmr13527244pfo.33.1651537204388; Mon, 02 May 2022 17:20:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651537204; cv=none; d=google.com; s=arc-20160816; b=V8GrMScY7rghXBRsF/HqO19Kz5tUhoQccPDW+WRVYRVrMrAKPt1O5tIBJ5KnDMitfv 9r19ZUKg0GweUcCuZEqjXSSS0EAuLA8+166kZVgbXymYRqGx9gkKthUqsjK/1SRkV9Hc rhCpemOF1lwLPhTOMoBB7GjzITonQfvK0Ce2ipEqlrTDgWxlfk0Fubttw0E/HtIA1Tjb qPEPlXQ1lAeU2GLi/OZ/4ZhKkUOLAp24/yxrFkk+7UMu0d3Q+jD4yeYJPB4KWmScj9wx jeRe6fDcuj4pY9KiWIANGGY1tQBs2V7KXJkvhR5RjnhCtTLhlbnyHdNe8AFfVeZq0CFN rqxA== 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=f/r4Cr4LIbct+QmoLMEDKJK9N84oHAeuGCRsDKpfLa4=; b=d06gy4sQQs8FrgjxsMUDDPHe72QpHlYCz3NL1k82R/Dim1CTaON1ItfqzzB8vEhheh v8KLv131QmncTWTVWRCD0WbQg0I7osqa3FJcUaoN6pT9YW0gojv/e1bTlMjV0wSfXRbv 3NuQxgo0eQuYYhSl+yvv72ZZPu0BgYZgrYqwVr3eqP2Y/gVXJwNwi7gHuBEA4vsGLmZ+ NK+2jZ83TOrTFmUx24/Bchia/9dR9PYwed5uFwx/1vn8fAtccOcqc3IfYQe/hAmYPgvg KZNHFLUfI+b8aHF9WhPWPqel4eByqBFpmo1Gh+CmMRRruNS2GeBFPr/sAmhuwkWZqFyS DOBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="wmIBmj5/"; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id m9-20020a056a00080900b0050d2215073fsi15720756pfk.201.2022.05.02.17.20.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 May 2022 17:20:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="wmIBmj5/"; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CE858396A4; Mon, 2 May 2022 17:17:08 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385063AbiEBMfR (ORCPT + 99 others); Mon, 2 May 2022 08:35:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385034AbiEBMfG (ORCPT ); Mon, 2 May 2022 08:35:06 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 901D012A94; Mon, 2 May 2022 05:31:37 -0700 (PDT) Date: Mon, 02 May 2022 12:31:34 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1651494696; 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=f/r4Cr4LIbct+QmoLMEDKJK9N84oHAeuGCRsDKpfLa4=; b=wmIBmj5/NmsyAiy4G03UEEKkVhke5koL9VlVEDxlqpZ3kQ0KoSi9IwtrVJ4CxbbSqi9U7z oFv2mzHfCZSmfheNQk4wnl+4nTsikNgTW/zuBV2g91UK4M4gbjjMNAzS7q1r+ZUv/Pfws8 7PMufNmgDCZZGFG4sR6YYZFT8PXBZA0DnZYpTcpT3glwgB2ytGHiFf03SH1Ryg4RT9YTQp m4t0FqDU7jkGqR6Mz/l/UwMR83slg4u3TovEhZZlAj+a9vRDf2C5amyV61yohh/+W812Cv 4pdKY/Il0qXONM2/IM3WnLszoWp2hilBW4mq1aOHagbT3fIweJJ7FsJygGsgYw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1651494696; 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=f/r4Cr4LIbct+QmoLMEDKJK9N84oHAeuGCRsDKpfLa4=; b=7FCP9M6OTc6fnS3HsvhXQicxOOZif520lggPMa8d3BxxCRd7S53G/tEWmkdI2zIiWG1tWh ZEREP3gd81uZ1pCg== From: "tip-bot2 for Maciej W. Rozycki" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: timers/core] time/sched_clock: Round the frequency reported to nearest rather than down Cc: "Maciej W. Rozycki" , Thomas Gleixner , John Stultz , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: References: MIME-Version: 1.0 Message-ID: <165149469466.4207.13955503601048091435.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.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 timers/core branch of tip: Commit-ID: 92067440f1311dfa4d77b57a9da6b3706f5da32e Gitweb: https://git.kernel.org/tip/92067440f1311dfa4d77b57a9da6b3706f5da32e Author: Maciej W. Rozycki AuthorDate: Sun, 24 Apr 2022 12:47:20 +01:00 Committer: Thomas Gleixner CommitterDate: Mon, 02 May 2022 14:29:04 +02:00 time/sched_clock: Round the frequency reported to nearest rather than down The frequency reported for clock sources are rounded down, which gives misleading figures, e.g.: I/O ASIC clock frequency 24999480Hz sched_clock: 32 bits at 24MHz, resolution 40ns, wraps every 85901132779ns MIPS counter frequency 59998512Hz sched_clock: 32 bits at 59MHz, resolution 16ns, wraps every 35792281591ns Rounding to nearest is more adequate: I/O ASIC clock frequency 24999664Hz sched_clock: 32 bits at 25MHz, resolution 40ns, wraps every 85900499947ns MIPS counter frequency 59999728Hz sched_clock: 32 bits at 60MHz, resolution 16ns, wraps every 35791556599ns Signed-off-by: Maciej W. Rozycki Signed-off-by: Thomas Gleixner Acked-by: John Stultz Link: https://lore.kernel.org/r/alpine.DEB.2.21.2204240055590.9383@angie.orcam.me.uk --- kernel/time/sched_clock.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/time/sched_clock.c b/kernel/time/sched_clock.c index b1b9b12..ee07f3a 100644 --- a/kernel/time/sched_clock.c +++ b/kernel/time/sched_clock.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -199,11 +200,11 @@ sched_clock_register(u64 (*read)(void), int bits, unsigned long rate) r = rate; if (r >= 4000000) { - r /= 1000000; + r = DIV_ROUND_CLOSEST(r, 1000000); r_unit = 'M'; } else { if (r >= 1000) { - r /= 1000; + r = DIV_ROUND_CLOSEST(r, 1000); r_unit = 'k'; } else { r_unit = ' ';