Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2639789lqp; Mon, 25 Mar 2024 05:23:25 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVMZVTT8qyywphcREf3xP5raVkoa44IHbMq8jCRRnQRcHjZ8BsNVspXS4J1WBl51OBDR6Kmc+BhBFdVt36TmsE6yEGGhRaqgtg7/dLJrA== X-Google-Smtp-Source: AGHT+IFkWrItYlUgHboqysw4W3xqmP7/MNHN621rAymIETLqPF43zgRUURdqoziKDbAZxnNweE3u X-Received: by 2002:a17:90b:4001:b0:2a0:1bca:90be with SMTP id ie1-20020a17090b400100b002a01bca90bemr5068205pjb.23.1711369404999; Mon, 25 Mar 2024 05:23:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711369404; cv=pass; d=google.com; s=arc-20160816; b=dwo/UOKqjc5USMgyRR+yzSa3vZzP3YgHoZjpjp1RzKPoDu2wr6rd4i3vlLESAWyYFt lFl6Na0B9D2cLCR+GQjOUQrBdH+Y6Do3PUj2+gZNQCT0VXq7u4cx6sKSvJqHWXKlGSCm ksg3F9mdzW4DobjEx+FE36vkx8Z7sgnYuKthKe7IrUF5CfjSB9kpWGtb4MzqzunjXFCD NNmEGtwLrK9TF9WSd4DhtvUOcVfUkP5sAKZBwKPbHuS0AKWcQjvBCMHJKcyixpnUaeVD VG3c6R0lOFFNXaSQ67yY7EWpInIoeLRJhFr6pGVPVrFbaFG5FZtuJQtZIW0sjx/W/9lR 2IQA== 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=XzuQX/fIv3X89TaOUfN7Rwp70aDPg9Ygvhv1/ThFn1U=; fh=wgq3SFFcpYoLsYNr1Fy+HYH2+WGNJgTNu+AnKLa6P2U=; b=uRNy8t8Xk6T91fw1taK/k3qT8IdvbVn6gh25J+U/0bbenBWX+B8zKRqEyBGHVtviyO bNuNivYzUUSgVFLHSOF9+F007zfPdeEI4fXsoB1bDDWGy3yrdzIu3y1PiSmy390Wj6di S9DMUM4faVzuNz2EnAuXr3KGts7+GFZgOtxnXL8hvnYvdntL4addH8hrQoH1OqjtYHhB HTJhtjAx9qY9/WMd+QfnieXuwBvM182FeKn16ZdPs2V5ErYqgboRshiHRrvE4h+rx08q 7Gf9L660T/IadT7hbIF38oHX8lNBk2OMSh6GCihfysB7TsbfDhnlP+9+L387D8/K0nk8 izyg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=a2v8Ujy0; 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-116601-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116601-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id w12-20020a17090aad4c00b0029c10847ca6si11376886pjv.19.2024.03.25.05.23.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 05:23:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-116601-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=a2v8Ujy0; 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-116601-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116601-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 21AE1286A5D for ; Mon, 25 Mar 2024 12:21:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7897E1586F4; Mon, 25 Mar 2024 08:53:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="a2v8Ujy0" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (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 4E1A815F417; Mon, 25 Mar 2024 06:41:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711348901; cv=none; b=mohslj15zagYyKq+a7CtKUPGPm4L/CZCu8JwrGxx7OH3PJvxECPZh1d5zTNC26o9FqGzoBiczBnDjGbdCAR1jPBxxm8As5G7h74zYH+pJTPlATnCb4ClSt/5/tpSFHMDwNUNaCKyA0SI2sCCGUaNGWyJflta6qY3cCmc87i01Qw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711348901; c=relaxed/simple; bh=zboSVI3HgVZXbpDBNnsTotqgGm69H9hHwUY1hZ67rA8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Xl9tQ5d4Pn+3ewuxKsayb4b5emAOWhNgvKydTwhC5KbikgEWM6rL8Huu+Is6sMgBuoPZybBP+/pHw9uW8vsqWjofrS3VSXIMRewHWVAdmqwMvWH1YcIEcLSK1JMHHvUxLiZUzP0ZcYIDlKb2Zy8YtPaDuTdJFRmgA52RXQZJ+oM= 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=a2v8Ujy0; arc=none smtp.client-ip=192.198.163.9 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=1711348899; x=1742884899; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zboSVI3HgVZXbpDBNnsTotqgGm69H9hHwUY1hZ67rA8=; b=a2v8Ujy0sQ+IDOD9pVB2CMc/Jh0i+4V3YJqsJGXnddv7kTrDgxiRVM+l CnIaUQnNIoYKWi1z11gbB/+zdprGVb7j4PkZnywCdOIitt/tUz8WgbDC5 sh/v+jHy+IyUbD7kYeQgedV2zHCP2uT557QzVDImuQ1YM6lwbHy/i6Rxc Y0cLTVn6Mq1lFxtlY4uDd3Kxc09+tmzCAmFUk4k7CkpimyNdmLJP4Qxk/ vQCHSBDvSLV4mbOGPjtCAWbZ0aEnyj0/56oBmw5cIWCYINWUNDTRNvARo CYAYDQSstyiiHSysQuvOdGcX3JBGjPJysdyU6El041idJ0T6Txmj5D0lN Q==; X-IronPort-AV: E=McAfee;i="6600,9927,11023"; a="17065255" X-IronPort-AV: E=Sophos;i="6.07,152,1708416000"; d="scan'208";a="17065255" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Mar 2024 23:41:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,152,1708416000"; d="scan'208";a="38629609" 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:31 -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 09/19] timekeeping: Move timekeeping helper functions Date: Mon, 25 Mar 2024 08:40:13 +0200 Message-Id: <20240325064023.2997-10-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 Move timekeeping helper functions to prepare for their reuse. Suggested-by: Thomas Gleixner Signed-off-by: Adrian Hunter --- kernel/time/timekeeping.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index b58dffc58a8f..3375f0a6400f 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -381,6 +381,23 @@ static inline u64 timekeeping_delta_to_ns(const struct tk_read_base *tkr, u64 de return nsec; } +static inline u64 timekeeping_cycles_to_ns(const struct tk_read_base *tkr, u64 cycles) +{ + u64 delta; + + /* calculate the delta since the last update_wall_time */ + delta = clocksource_delta(cycles, tkr->cycle_last, tkr->mask); + return timekeeping_delta_to_ns(tkr, delta); +} + +static __always_inline u64 fast_tk_get_delta_ns(struct tk_read_base *tkr) +{ + u64 delta, cycles = tk_clock_read(tkr); + + delta = clocksource_delta(cycles, tkr->cycle_last, tkr->mask); + return timekeeping_delta_to_ns(tkr, delta); +} + static inline u64 timekeeping_get_ns(const struct tk_read_base *tkr) { u64 delta; @@ -389,15 +406,6 @@ static inline u64 timekeeping_get_ns(const struct tk_read_base *tkr) return timekeeping_delta_to_ns(tkr, delta); } -static inline u64 timekeeping_cycles_to_ns(const struct tk_read_base *tkr, u64 cycles) -{ - u64 delta; - - /* calculate the delta since the last update_wall_time */ - delta = clocksource_delta(cycles, tkr->cycle_last, tkr->mask); - return timekeeping_delta_to_ns(tkr, delta); -} - /** * update_fast_timekeeper - Update the fast and NMI safe monotonic timekeeper. * @tkr: Timekeeping readout base from which we take the update @@ -431,14 +439,6 @@ static void update_fast_timekeeper(const struct tk_read_base *tkr, memcpy(base + 1, base, sizeof(*base)); } -static __always_inline u64 fast_tk_get_delta_ns(struct tk_read_base *tkr) -{ - u64 delta, cycles = tk_clock_read(tkr); - - delta = clocksource_delta(cycles, tkr->cycle_last, tkr->mask); - return timekeeping_delta_to_ns(tkr, delta); -} - static __always_inline u64 __ktime_get_fast_ns(struct tk_fast *tkf) { struct tk_read_base *tkr; -- 2.34.1