Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2664003lqp; Mon, 25 Mar 2024 06:06:54 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVXkvZcWiu7bqvb3fUJV1Cs3lIq4Mcv1tyVm4yS1kzCe5/N8oPjT82ZwDcDDJIAI160wPTST23LZxiAKd6GeTiRjJwgXUzyMddX4uSAOQ== X-Google-Smtp-Source: AGHT+IEZduo0+4dVWPAl3i4Xsbjo9UGFTfqHzPXLrJGOYvcTwwTv9dMLKcdRJGsc0KVGM1khI/oJ X-Received: by 2002:a17:906:a2c9:b0:a46:a81a:330f with SMTP id by9-20020a170906a2c900b00a46a81a330fmr4085005ejb.5.1711372013775; Mon, 25 Mar 2024 06:06:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711372013; cv=pass; d=google.com; s=arc-20160816; b=DLA1TDla2ZU2qdyhUr1APPZZxpZCkgxK8OlGdY1GYI3NJ2B7fQ1dNUDYcqhn0kqRXZ v7w/mV4kkI4hwJeuDoNIdKHW2xBduYZQUSmuhLPMEdYmadX60XpPb1G6V0pbJ832xzb0 eBU2y3w78P/MxwvMhcmE+fsV1H3AkvWn1kpVG9unpqunBo+kPPqXApNqqMX7WactoBtL U44CZo+0bHV5zCJ88nChaBROfhr++4e5bE8Dw+QZzMcz+7otClaDdlwvvg2p+Wb9C38m isivSXPokFn/b2a4fI/lL/IRpG1St/7GmE7Z7sDRMFbHParlvLeJfHhfFrDujypt92X9 y2kQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:organization:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=RdPwuAtp3J8wKIQEY0+pBalQBgnbtgj21l5N6xHb2oo=; fh=wgq3SFFcpYoLsYNr1Fy+HYH2+WGNJgTNu+AnKLa6P2U=; b=L3rr8HUV45vIzCVDmiqpuTlEtQPBd1y8rFX6rzfJDKKUKt+O7cmMh0VUZOslQQniVC 9jTGD8LatFgYf/te8b33bhNApwOFbDIvFP1nlk/QdKM22EgI9wRDIENeRQ6DO1pOSSIG 8iselXczMF666tjxZvQR7u0YeY8j0heZsAThh8zSK6MlMEGADhbMwXlZgFFoAYmCsmLq BB57RZxXUsald1VG+T+UMSzfj/ZeL/d8IiABgeFYXnVgtqAMXerj4GwB6AETq4Lzbdso /ezveAA/GXHIG6SmA1/KawY4NSZZkHnsLvOuyDQ8f+97szCXG2+5ljsjOFg+JRS57h0o gSTQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=kacXCTsG; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-116577-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116577-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id qk13-20020a1709077f8d00b00a4652a15dedsi2445511ejc.603.2024.03.25.06.06.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 06:06:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-116577-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=kacXCTsG; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-116577-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116577-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 76C8A1F3B128 for ; Mon, 25 Mar 2024 13:06:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AC25B13D2BD; Mon, 25 Mar 2024 08:53:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="kacXCTsG" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 039391607A9; Mon, 25 Mar 2024 06:42:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711348936; cv=none; b=CpvxMsFVcak5N43K6gx2TmQR4bH6gI/iIvBn+1G95YxuHuYohDbJ2B/qQFU1dWUALwDrGpirdSyZSk3cS03bLZQmKZdYS0pBPqb//drjkg/EW/cGmJCuu3x7y1X61GxKj+RrDGju5OFhZI+yfzzYFYuvF/r3ntsd79Njp1zEu2c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711348936; c=relaxed/simple; bh=16GQ0vc+mvjtkGYNmUSKlWdfc5Q8uWzvZ2NpVFo2g5s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=p08Nnba5CYMaatFqWY9C/1uT9n0CaBGu1cK5AOuM/TZI/LqP/9eE6+zEJBaX3Hj6vRcMDCHB/zXLUUV9N4BQy16z0orK2IC9jh8qMgWsTkRbClMGFgdIjGRgnFFPg+IRUOAhKGUFOuIi7b2FyEhLHWcUP93cSTsU+qLpgRLe1qk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=kacXCTsG; arc=none smtp.client-ip=192.198.163.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1711348935; x=1742884935; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=16GQ0vc+mvjtkGYNmUSKlWdfc5Q8uWzvZ2NpVFo2g5s=; b=kacXCTsGv4OpHRPuTJrcg6HgzlpoQXPEGWjLDeYr8GcjKPFx1yYrrZGp n/cSY714LqlZGpKjqYkRp+MIMZNv0vPBqeoSi/L2K8Pc1qYpn1lWbBqeb sB43kHwjXHxWLITOHq5h5jykb0Ccd+UrWY2hizkMFj1ifyGHemoEF21bX etXVgkQJiybwSp6UyvjhQpdokIwWnl/TlGTqD48DD70+vO6NblqwZF9ne GlBR7wmfmLMSMSTiSWV/T/XFqpAgrDno+UVHGUlvFpbgWUP8iJVxfj+Bt VPtq/cm2ee/NcqBhAnVJmAEEnFHFCeOSPEAi7yvRexcfOxwX74jWBFHgY A==; X-IronPort-AV: E=McAfee;i="6600,9927,11023"; a="6191502" X-IronPort-AV: E=Sophos;i="6.07,152,1708416000"; d="scan'208";a="6191502" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Mar 2024 23:42:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,152,1708416000"; d="scan'208";a="38629669" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO ahunter-VirtualBox.home\044ger.corp.intel.com) ([10.251.211.155]) by fmviesa002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Mar 2024 23:41:58 -0700 From: Adrian Hunter To: Thomas Gleixner Cc: Michael Ellerman , Nicholas Piggin , Christophe Leroy , "Aneesh Kumar K.V" , "Naveen N. Rao" , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Andy Lutomirski , Vincenzo Frascino , John Stultz , Stephen Boyd , Peter Zijlstra , Randy Dunlap , Bjorn Helgaas , Arnd Bergmann , Anna-Maria Behnsen , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org Subject: [PATCH V2 13/19] timekeeping: Refactor timekeeping helpers Date: Mon, 25 Mar 2024 08:40:17 +0200 Message-Id: <20240325064023.2997-14-adrian.hunter@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240325064023.2997-1-adrian.hunter@intel.com> References: <20240325064023.2997-1-adrian.hunter@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Content-Transfer-Encoding: 8bit Simplify use of timekeeping sanity checking, in preparation for consolidating timekeeping helpers. This works towards eliminating timekeeping_delta_to_ns() in favour of timekeeping_cycles_to_ns(). Suggested-by: Thomas Gleixner Signed-off-by: Adrian Hunter --- kernel/time/timekeeping.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index f81d675291e0..618328cd4bc4 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -237,7 +237,7 @@ static void timekeeping_check_update(struct timekeeper *tk, u64 offset) } } -static inline u64 timekeeping_get_delta(const struct tk_read_base *tkr) +static inline u64 timekeeping_debug_get_delta(const struct tk_read_base *tkr) { struct timekeeper *tk = &tk_core.timekeeper; u64 now, last, mask, max, delta; @@ -281,17 +281,9 @@ static inline u64 timekeeping_get_delta(const struct tk_read_base *tkr) static inline void timekeeping_check_update(struct timekeeper *tk, u64 offset) { } -static inline u64 timekeeping_get_delta(const struct tk_read_base *tkr) +static inline u64 timekeeping_debug_get_delta(const struct tk_read_base *tkr) { - u64 cycle_now, delta; - - /* read clocksource */ - cycle_now = tk_clock_read(tkr); - - /* calculate the delta since the last update_wall_time */ - delta = clocksource_delta(cycle_now, tkr->cycle_last, tkr->mask); - - return delta; + BUG(); } #endif @@ -396,10 +388,10 @@ static __always_inline u64 __timekeeping_get_ns(const struct tk_read_base *tkr) static inline u64 timekeeping_get_ns(const struct tk_read_base *tkr) { - u64 delta; + if (IS_ENABLED(CONFIG_DEBUG_TIMEKEEPING)) + return timekeeping_delta_to_ns(tkr, timekeeping_debug_get_delta(tkr)); - delta = timekeeping_get_delta(tkr); - return timekeeping_delta_to_ns(tkr, delta); + return __timekeeping_get_ns(tkr); } /** -- 2.34.1