From nobody Mon Feb 9 09:06:13 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98896C4167B for ; Fri, 1 Dec 2023 09:27:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378060AbjLAJ1U (ORCPT ); Fri, 1 Dec 2023 04:27:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378024AbjLAJ1E (ORCPT ); Fri, 1 Dec 2023 04:27:04 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E533510F3 for ; Fri, 1 Dec 2023 01:27:10 -0800 (PST) From: Anna-Maria Behnsen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1701422829; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=x5NV8oLmppm4cChtNeoTUNwitHPz66rl4TtkJG1MsVE=; b=ACJG9BLnPweNxaHJJ9w1pbi+SRth6MXk+ue7mImxGjl0rf06m9//BXNESvnefcAi865eVp HYPHH88orIdDbxTxm6maC9Z7zjntcMuoGw+mucvviLDTWAizOZTFZb3cR0lB9l9VR/YNZ2 XThDs7w8kH85z4y9wuHUBDLuV04+NHpj5jZFQwuLoD1AFW0uGzvPXdi0y5cYapX6LTZk+6 sRTA+PR1Tq1vVNVKY5wlJ92DCMEjLBV6bANERRrmFxSDeOraYXvp1AI2n+5WJao2xPnuyI wNBYPxJiugPji/XfpCYlL5YpmVuIMRE2jvgKEs6sgx+JgsjcFf/iMB+WUJNczg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1701422829; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=x5NV8oLmppm4cChtNeoTUNwitHPz66rl4TtkJG1MsVE=; b=lV7jqkG/73jefeFGIVa0cvbImUlcDQjpHBuRgRZzzHojWnwJUlYoDZ+Hr85NjGiyrNZEyE 1qQTNsPXqXlEXZCQ== To: linux-kernel@vger.kernel.org Cc: Peter Zijlstra , John Stultz , Thomas Gleixner , Eric Dumazet , "Rafael J . Wysocki" , Arjan van de Ven , "Paul E . McKenney" , Frederic Weisbecker , Rik van Riel , Steven Rostedt , Sebastian Siewior , Giovanni Gherdovich , Lukasz Luba , "Gautham R . Shenoy" , Srinivas Pandruvada , K Prateek Nayak , Anna-Maria Behnsen Subject: [PATCH v9 05/32] tracing/timers: Add tracepoint for tracking timer base is_idle flag Date: Fri, 1 Dec 2023 10:26:27 +0100 Message-Id: <20231201092654.34614-6-anna-maria@linutronix.de> In-Reply-To: <20231201092654.34614-1-anna-maria@linutronix.de> References: <20231201092654.34614-1-anna-maria@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" When debugging timer code the timer tracepoints are very important. There is no tracepoint when the is_idle flag of the timer base changes. Instead of always adding manually trace_printk(), add tracepoints which can be easily enabled whenever required. Signed-off-by: Anna-Maria Behnsen Reviewed-by: Frederic Weisbecker --- v9: New in v9 --- include/trace/events/timer.h | 20 ++++++++++++++++++++ kernel/time/timer.c | 2 ++ 2 files changed, 22 insertions(+) diff --git a/include/trace/events/timer.h b/include/trace/events/timer.h index 99ada928d445..1ef58a04fc57 100644 --- a/include/trace/events/timer.h +++ b/include/trace/events/timer.h @@ -142,6 +142,26 @@ DEFINE_EVENT(timer_class, timer_cancel, TP_ARGS(timer) ); =20 +TRACE_EVENT(timer_base_idle, + + TP_PROTO(bool is_idle, unsigned int cpu), + + TP_ARGS(is_idle, cpu), + + TP_STRUCT__entry( + __field( bool, is_idle ) + __field( unsigned int, cpu ) + ), + + TP_fast_assign( + __entry->is_idle =3D is_idle; + __entry->cpu =3D cpu; + ), + + TP_printk("is_idle=3D%d cpu=3D%d", + __entry->is_idle, __entry->cpu) +); + #define decode_clockid(type) \ __print_symbolic(type, \ { CLOCK_REALTIME, "CLOCK_REALTIME" }, \ diff --git a/kernel/time/timer.c b/kernel/time/timer.c index a81d793a43d0..46a9b96a3976 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -1964,6 +1964,7 @@ u64 get_next_timer_interrupt(unsigned long basej, u64= basem) if ((expires - basem) > TICK_NSEC) base->is_idle =3D true; } + trace_timer_base_idle(base->is_idle, base->cpu); raw_spin_unlock(&base->lock); =20 return cmp_next_hrtimer_event(basem, expires); @@ -1985,6 +1986,7 @@ void timer_clear_idle(void) * the lock in the exit from idle path. */ base->is_idle =3D false; + trace_timer_base_idle(0, smp_processor_id()); } #endif =20 --=20 2.39.2