Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1331330lqe; Mon, 8 Apr 2024 06:12:04 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVlWIdhGkcE0FSjrQKa+JoO9hZVMRSLmdCDdRKwbwFXzYxDYDfmeQtEZBQKtJfpXtNO4MyuSxNNjPMKT1qbdGPgwNGY18egM3E7CVRQ9A== X-Google-Smtp-Source: AGHT+IGNwXtFWjKB7ebCm1zfJHZHgCjEBzI6ImOYpA7BTlQSTLye7yyc4e8oFV+eAf3dF4TpoT/s X-Received: by 2002:a50:cdc2:0:b0:56c:3dfb:a1f5 with SMTP id h2-20020a50cdc2000000b0056c3dfba1f5mr6899146edj.22.1712581924263; Mon, 08 Apr 2024 06:12:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712581924; cv=pass; d=google.com; s=arc-20160816; b=DTfuoRb8j1p3hMmSrQe1JzsgKcJgb5WSyIfP4LbXuHU4A/KgAFmPZ1fm28ZpilQmkw Q9n61DYy4AjAJGlhz0BUzYPYVENF8yKPMN7avtC24x2eaFhR/0i7wLgguKp3g9to3wSF me78qsFLe5VVdoBALDr5G5F3hfuv602i55Pkbkle849REP1s6H2VTetvBDt6oBL30FfQ vvbm+UFDu+ZNq1yJezQ3UcWygcnH/qB/GwV2Iez5G+oZuqSIVsAvw9dcTCxG5/1Ucl0q iqarxfH9q3uro1zsNkyqmfULU+bItuwPyq+fZLRr6RhFU8vvQFEzuUj/mVC5/IX9BKLh fgBw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:precedence:robot-unsubscribe:robot-id :message-id:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:in-reply-to:cc:subject:to:reply-to:sender :from:dkim-signature:dkim-signature:date; bh=VQ/OGDtp2giMcT/fWcbolb0miqgxlYVyiLtUTykBXr8=; fh=HIrP3i0WQwu8zLnKtb1acHgteo695uCSG6Yk5OndRkw=; b=fI0U9Fxp4BkWRLst0MskojNmlqp8gI+L1T5Kk3VX2fVydb3vYDWKY7piNDB+Q3nvUT yRpPHoUyttXVzN2VUDzHUALdiv6eEFLJzEQy/vylSZwh9PsUObEYmrQ6t0hwY93iFNFl +lcGmBwaVMdV1qoSgu7vIF06eLraouJLG3UbhRTZy+fCPxP06awHMjhe/GcRZd8I2Ax0 MYkZ34yeTgckcPeooHP4edIVeqo20/xwL9S+hLhn132kNm6QTRB6ZJaqbUKAqxHm8s7N B/UmIqn+/EydzwAw7E7HqIslbZ6f+rOKzK20V3tmUIi3JnRlhcgBJldMouCF5K1FB/jw NxKQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=g7CcQfgB; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-135393-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135393-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id y9-20020a056402440900b0056e367afebdsi3245049eda.325.2024.04.08.06.12.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 06:12:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-135393-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=g7CcQfgB; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-135393-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135393-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de 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 056131F22688 for ; Mon, 8 Apr 2024 13:12:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 476637E57C; Mon, 8 Apr 2024 13:10:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="g7CcQfgB"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="HcBogRps" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 AC06F7C086; Mon, 8 Apr 2024 13:10:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712581839; cv=none; b=gYBkNe8njp57lh7kZORnbckIVqmn+XwJuJnR0uBfxV2sqUlA31eb0y6UP0HhoDdyvYSlaFialG8Fkfw8p/auZezlH0XvN5qb5re0CcNsiSrIrqB9qj9456NO9QW0BUnKqHj0obkFZMECoFbsmQpcIHN2kbD3OTU94TeyPJ6wI90= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712581839; c=relaxed/simple; bh=mN5ZU1h56JdUGSuqshA5rsJr+mVDacGc9R/xyT4xlMQ=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=Lef/PhGt//UjSkzqPuVg8TaiLeKQuKbMZw0gJY2qPt21IR0LhvEJw5aL2QeAYLB2WiyRygGdj5GDW/NPSnVIh0QUpTnfBaXzFoQMpFsvuvXZObPo2MldCUoo1nsBOyDhNUUttZaVNT1HuMOtRUR/FJYo3alARyhlUHFVGhL5xIU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=g7CcQfgB; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=HcBogRps; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Date: Mon, 08 Apr 2024 13:10:34 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1712581835; 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=VQ/OGDtp2giMcT/fWcbolb0miqgxlYVyiLtUTykBXr8=; b=g7CcQfgBdFCrxRISrVfF02XDd3FGM5dynAB1KcOxT6KWX6/eQeegYW26g3we2xcFNzs/RN qi1BSMLXT0ZVaaVWIkzuTMPRr7Lokup98VrThLRjTrBa1ITaSP/kTOOxOATmPjAnVlrbAv KlHdUb5yH70ntV0TnaookaZTtsD6ylxkMq/KeOOToRPozdXTNgfKv073bwJWsmxkmMrR7d 4RJG7z9798Pi/X7lisRQRt/CGXmL1OLPm1AmZ0sBRN1yhG/Dwm7A9Xe3tG+OZvKWp/+oYM /lIMR/pv8iAbrzGhl30BpmgaJPSvyLf8zHXBkHc5BrvFMir4m+Mjh6w+RWx8iA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1712581835; 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=VQ/OGDtp2giMcT/fWcbolb0miqgxlYVyiLtUTykBXr8=; b=HcBogRpsTuQrt/qBQ/qYG8QzLzmirExsJCp/6Z1KVD5/IhV9sqd6qxLe9Ilmasoh6gXVgI 9ghlI0g/7drQeMCg== From: "tip-bot2 for Adrian Hunter" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: timers/core] timekeeping: Consolidate timekeeping helpers Cc: Thomas Gleixner , Adrian Hunter , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20240325064023.2997-15-adrian.hunter@intel.com> References: <20240325064023.2997-15-adrian.hunter@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <171258183490.10875.3885868540516414539.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit The following commit has been merged into the timers/core branch of tip: Commit-ID: e84f43e34faf85816587f80594541ec978449d6e Gitweb: https://git.kernel.org/tip/e84f43e34faf85816587f80594541ec978449d6e Author: Adrian Hunter AuthorDate: Mon, 25 Mar 2024 08:40:18 +02:00 Committer: Thomas Gleixner CommitterDate: Mon, 08 Apr 2024 15:03:08 +02:00 timekeeping: Consolidate timekeeping helpers Consolidate timekeeping helpers, making use of timekeeping_cycles_to_ns() in preference to directly using timekeeping_delta_to_ns(). No functional change. Suggested-by: Thomas Gleixner Signed-off-by: Adrian Hunter Signed-off-by: Thomas Gleixner Link: https://lore.kernel.org/r/20240325064023.2997-15-adrian.hunter@intel.com --- kernel/time/timekeeping.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 618328c..1bbfe1f 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -237,7 +237,9 @@ static void timekeeping_check_update(struct timekeeper *tk, u64 offset) } } -static inline u64 timekeeping_debug_get_delta(const struct tk_read_base *tkr) +static inline u64 timekeeping_cycles_to_ns(const struct tk_read_base *tkr, u64 cycles); + +static inline u64 timekeeping_debug_get_ns(const struct tk_read_base *tkr) { struct timekeeper *tk = &tk_core.timekeeper; u64 now, last, mask, max, delta; @@ -266,22 +268,22 @@ static inline u64 timekeeping_debug_get_delta(const struct tk_read_base *tkr) */ if (unlikely((~delta & mask) < (mask >> 3))) { tk->underflow_seen = 1; - delta = 0; + now = last; } /* Cap delta value to the max_cycles values to avoid mult overflows */ if (unlikely(delta > max)) { tk->overflow_seen = 1; - delta = tkr->clock->max_cycles; + now = last + max; } - return delta; + return timekeeping_cycles_to_ns(tkr, now); } #else static inline void timekeeping_check_update(struct timekeeper *tk, u64 offset) { } -static inline u64 timekeeping_debug_get_delta(const struct tk_read_base *tkr) +static inline u64 timekeeping_debug_get_ns(const struct tk_read_base *tkr) { BUG(); } @@ -389,7 +391,7 @@ 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) { if (IS_ENABLED(CONFIG_DEBUG_TIMEKEEPING)) - return timekeeping_delta_to_ns(tkr, timekeeping_debug_get_delta(tkr)); + return timekeeping_debug_get_ns(tkr); return __timekeeping_get_ns(tkr); }