Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp5938232rwp; Mon, 17 Jul 2023 11:57:02 -0700 (PDT) X-Google-Smtp-Source: APBJJlFS7DIuoSn3HZ/B0YTafbtZMUlGhliS/3RrdKkUFsEc8/MJjv7S+y76LPi+rnUNR+jUUe1T X-Received: by 2002:a9d:6450:0:b0:6b9:9e4f:5f4c with SMTP id m16-20020a9d6450000000b006b99e4f5f4cmr10062722otl.29.1689620221894; Mon, 17 Jul 2023 11:57:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689620221; cv=none; d=google.com; s=arc-20160816; b=NtYKU2Jv+C0OkgiLOk4ZjnLuSYdtDnBUs6/8utPN9AYGroFUeQSDxVZeS1G4+CHn+A DZAT9ldnwcYkUYA1rcCPlZP/CcPC/BKPGr2miTAIvqo/ooG2Ta6lj/MLo90vwccxAHXH IdMOLZxRTddkE/dJO56bg3wp/opKxdRH9mcFb6RG8DDn66l4ydt/zRIi54Lxnhlt14Fp MKrWi6QyHq5osGPvht5IouQOjJEkd2CMHcyRHpfhpPPeuDXCcfjS8v3kASniHVnje80Y 1TsuaPjJlR4KhZmr4JVD+7lD/56qnCE+grFtOIB+wcji1YrX99/NzqretP2o24UjMN15 x8Hw== 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; bh=I1Ziv0OiCC2v2gxJXh1x4YwVtsSeWgECOiL5V15Njzk=; fh=Bu0L0DMdZQh4/uYsyXeYnmozS6TNbGrpiKsealRyhMM=; b=wcsAVonFCWZBwgsFM16s2HaoDwjrywubk5SUp0M+Xt9TudkHQ2x+Hr5rN7XIJXnI9f OSTLjiPNsrxIgCxvoZa8ZaAp56ARAZBflZzdJbbkqTgYUgZU1mtp9lbYOJSXsXXX+io3 kfzMluQyH+5fTMHYPP6+6PULEFnd5JKoYm14/Sp3WQIsskrwe4MqWIFpHJVhUWsMD2dR 8BwWMn2higTm9bg5T+G9QXO5KI8qJ8Ve7RjvVXYGUcNIwfV4Ys7nN4VHZkIXyUvExlcV dnh5aETlDgPM294HPoujNwEY3g67m/5oTdMPnink4C/zqTBtF2Wbl8UIXp/5/QpFOGZc q20A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=V6uGZlSt; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k17-20020a63ff11000000b005574480a875si142558pgi.898.2023.07.17.11.56.48; Mon, 17 Jul 2023 11:57:01 -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=@kernel.org header.s=k20201202 header.b=V6uGZlSt; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231560AbjGQS26 (ORCPT + 99 others); Mon, 17 Jul 2023 14:28:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232085AbjGQS2R (ORCPT ); Mon, 17 Jul 2023 14:28:17 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 049E5138 for ; Mon, 17 Jul 2023 11:28:17 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8E7F6611E6 for ; Mon, 17 Jul 2023 18:28:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE184C433C7; Mon, 17 Jul 2023 18:28:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689618496; bh=zuvEkykktJjeNi58BabdAm26lxVTmrSjYHv8G+zZ144=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V6uGZlSt6oa3niWcm26Tf+FRjgeRnOcrzH4HYSGaFsuJFKV0gupUKtuBA73MLGMlb moQ9VD2qqSnss5FD+hpJ5c1oW5NUbxH0DBUnxwvDa62z0ulq3oLz6mPTo/4VBWbKPm 5XyDSH3h6YK+Pfv8rSyZvDTfjoaCpKWP4qvN6lfQDfkTB+dZCXLtMuZprX/A5UEAG4 9Ei9rj4afwYBacMQRinO75Sve3m24By2pZH+QS4VwdJT5BKs8eRwGhqns90D9REVst 0/gqvK8DDgx5ZOzGYeAPQ2jHLtiVdJTQ3SgGIuZ/kTRIxAtyN4JFg++OMR1HKtfIzL /iVsLUhS2S/6A== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id A1C0ACE03F1; Mon, 17 Jul 2023 11:28:15 -0700 (PDT) From: "Paul E. McKenney" To: tglx@linutronix.de Cc: linux-kernel@vger.kernel.org, john.stultz@linaro.org, sboyd@kernel.org, corbet@lwn.net, Mark.Rutland@arm.com, maz@kernel.org, kernel-team@meta.com, neeraju@codeaurora.org, ak@linux.intel.com, feng.tang@intel.com, zhengjun.xing@intel.com, daniel.lezcano@linaro.org, "Paul E. McKenney" , Chris Bainbridge Subject: [PATCH clocksource 1/2] clocksource: Handle negative skews in "skew is too large" messages Date: Mon, 17 Jul 2023 11:28:13 -0700 Message-Id: <20230717182814.1099419-1-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 nanosecond-to-millisecond skew computation uses unsigned arithmetic, which produces user-unfriendly large positive numbers for negative skews. Therefore, use signed arithmetic for this computation in order to preserve the negativity. Reported-by: Chris Bainbridge Reported-by: Feng Tang Fixes: dd029269947a ("clocksource: Improve "skew is too large" messages") Reviewed-by: Feng Tang Tested-by: Chris Bainbridge Signed-off-by: Paul E. McKenney --- kernel/time/clocksource.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c index 88cbc1181b23..c108ed8a9804 100644 --- a/kernel/time/clocksource.c +++ b/kernel/time/clocksource.c @@ -473,8 +473,8 @@ static void clocksource_watchdog(struct timer_list *unused) /* Check the deviation from the watchdog clocksource. */ md = cs->uncertainty_margin + watchdog->uncertainty_margin; if (abs(cs_nsec - wd_nsec) > md) { - u64 cs_wd_msec; - u64 wd_msec; + s64 cs_wd_msec; + s64 wd_msec; u32 wd_rem; pr_warn("timekeeping watchdog on CPU%d: Marking clocksource '%s' as unstable because the skew is too large:\n", @@ -483,8 +483,8 @@ static void clocksource_watchdog(struct timer_list *unused) watchdog->name, wd_nsec, wdnow, wdlast, watchdog->mask); pr_warn(" '%s' cs_nsec: %lld cs_now: %llx cs_last: %llx mask: %llx\n", cs->name, cs_nsec, csnow, cslast, cs->mask); - cs_wd_msec = div_u64_rem(cs_nsec - wd_nsec, 1000U * 1000U, &wd_rem); - wd_msec = div_u64_rem(wd_nsec, 1000U * 1000U, &wd_rem); + cs_wd_msec = div_s64_rem(cs_nsec - wd_nsec, 1000 * 1000, &wd_rem); + wd_msec = div_s64_rem(wd_nsec, 1000 * 1000, &wd_rem); pr_warn(" Clocksource '%s' skewed %lld ns (%lld ms) over watchdog '%s' interval of %lld ns (%lld ms)\n", cs->name, cs_nsec - wd_nsec, cs_wd_msec, watchdog->name, wd_nsec, wd_msec); if (curr_clocksource == cs) -- 2.40.1