From patchwork Wed Dec 20 15:59:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 181726 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2747971dyi; Wed, 20 Dec 2023 08:10:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IHA2wjDuUn+MpChixV65d9+i779KYLaMS7abHKoTpdDUEN48UXHKb/WF/hgZPfnVK80FwcW X-Received: by 2002:a17:90b:4a85:b0:28b:9246:8076 with SMTP id lp5-20020a17090b4a8500b0028b92468076mr3278891pjb.75.1703088609675; Wed, 20 Dec 2023 08:10:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703088609; cv=none; d=google.com; s=arc-20160816; b=NnKyyfxWXA2NB64rij86ayDS5sKWfW7L4q31fsW2aWiaEorkL860svyO7aQK5o/LT4 nYqEjKgOT1nXn5cubqLyTJOQMNVGkUfQS8b6EA3aZgfem0dCdpbKR5TmT3gmY3Nin9rC 8UYogOZX2gmi8NnG0L6FonsyPULRqZGgxN686DY/gz4D5C9EchCW4YUypAZQYFpAf7r0 ma8sA/DgdxsfzQ0ce2SdoyhU9BhQ00zbd89/QLp71MolEYlHPU2KUjLH7wMnO3ceKpSe cbBTl4cumpHhIoqox1bj3iWWmmpkQtA+ekAdKSF/vWV0GjiPIyaSLRbBwVGnq1b206/q iOtQ== ARC-Message-Signature: i=1; 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=6orTWLX4jF280KMDj0LvfxF+CGeUwBDqDHyIaGq8Sog=; fh=IdquJyaazQ3wXWxdOExnpctJRLX4Jw3HEb/tnyKonzY=; b=F2L1PkhfmCILkQN8MId352tTUbWvX4mT6D2RWf04Y9+KPkJ/OFlYJAYh/2Hv6/0wYp evg4Gs1I6XFiP/TihQ9S/kUjISaT6O+Qi9T8AYnzLOANzul/OGcd3fCZqvh3kI0fvXDQ nf0a/kPzQeOLYd3ivnBjPanQb94d24+/ul8PiI8mZasR73WSyWMOF+1WIyn5X0ZVD7hV /wFX5fptpknJc8z007QrsXU9DJuYdaGg38Cm4nm7OlkGr1XuWNaP91cCGy/sB0kVGC8U IyvNy8jlJRVlybs1BCK1Y4KjNfnimwbgxw2oZNBIGkYmns35EDqaM5QHwQ6ggERIl3Jj Fw9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=X8i5zmYJ; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel+bounces-7232-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7232-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id g6-20020a17090adb0600b0028b9858e087si35409pjv.106.2023.12.20.08.10.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 08:10:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-7232-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=X8i5zmYJ; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel+bounces-7232-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7232-ouuuleilei=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 73DB3B25B5E for ; Wed, 20 Dec 2023 16:02:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C72F64B128; Wed, 20 Dec 2023 15:59:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="X8i5zmYJ"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="FiNT2VbF" X-Original-To: linux-kernel@vger.kernel.org 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 98D0F487BE; Wed, 20 Dec 2023 15:59:12 +0000 (UTC) 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: Wed, 20 Dec 2023 15:59:10 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1703087950; 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=6orTWLX4jF280KMDj0LvfxF+CGeUwBDqDHyIaGq8Sog=; b=X8i5zmYJy5pkvlLtCyEN2A6J0//niCnFy1XpNceCDd7HVTzvLzx+FxuuEn71TGLEggGoSl pMKXoOKJxFKtJGUk/dEnRHl3PelkiZvsWksMRDQzMcMWHtD2ZL6hDDdpM4RZQcgdwh+Tjf jn9jraQ+OFD/5L3KhH2XoHgiet4gDCrkZQFW/945XTo2+CM9NvDuYKMaFJAgj4cD/lClJ9 kSC7/A46tanbCNUhPznPddE20FkIxGh7AxlbZDWY29Ds6efGCijCW7LzbqhG1zkAKdvCnb Xw9rMlqaPFmnGZxQITvQ7OdWqPV2faKSinBEuN1ZcLel1C8x7cv6ydV0uGQ8KQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1703087950; 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=6orTWLX4jF280KMDj0LvfxF+CGeUwBDqDHyIaGq8Sog=; b=FiNT2VbF3Sc2HM2ciTDk1gFM0+DdKH05G0MkvT0MdMWXsggUHzW3/ods6cmgVRsQrJomRB G/1PaXN4FJsi6qCg== From: "tip-bot2 for Anna-Maria Behnsen" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: timers/core] tracing/timers: Add tracepoint for tracking timer base is_idle flag Cc: "Anna-Maria Behnsen" , Thomas Gleixner , Frederic Weisbecker , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20231201092654.34614-6-anna-maria@linutronix.de> References: <20231201092654.34614-6-anna-maria@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <170308795011.398.2295802154247417093.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784071187560015896 X-GMAIL-MSGID: 1785817841968753614 The following commit has been merged into the timers/core branch of tip: Commit-ID: b573c73101d8786446535b2ab28cbc8907bda9a9 Gitweb: https://git.kernel.org/tip/b573c73101d8786446535b2ab28cbc8907bda9a9 Author: Anna-Maria Behnsen AuthorDate: Fri, 01 Dec 2023 10:26:27 +01:00 Committer: Thomas Gleixner CommitterDate: Wed, 20 Dec 2023 16:49:38 +01:00 tracing/timers: Add tracepoint for tracking timer base is_idle flag 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 Signed-off-by: Thomas Gleixner Reviewed-by: Frederic Weisbecker Link: https://lore.kernel.org/r/20231201092654.34614-6-anna-maria@linutronix.de --- include/trace/events/timer.h | 20 ++++++++++++++++++++ kernel/time/timer.c | 14 +++++++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/include/trace/events/timer.h b/include/trace/events/timer.h index 99ada92..1ef58a0 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) ); +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 = is_idle; + __entry->cpu = cpu; + ), + + TP_printk("is_idle=%d cpu=%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 a81d793..ed8d606 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -1950,7 +1950,10 @@ u64 get_next_timer_interrupt(unsigned long basej, u64 basem) if (time_before_eq(nextevt, basej)) { expires = basem; - base->is_idle = false; + if (base->is_idle) { + base->is_idle = false; + trace_timer_base_idle(false, base->cpu); + } } else { if (base->timers_pending) expires = basem + (u64)(nextevt - basej) * TICK_NSEC; @@ -1961,8 +1964,10 @@ u64 get_next_timer_interrupt(unsigned long basej, u64 basem) * logic is only maintained for the BASE_STD base, deferrable * timers may still see large granularity skew (by design). */ - if ((expires - basem) > TICK_NSEC) + if ((expires - basem) > TICK_NSEC && !base->is_idle) { base->is_idle = true; + trace_timer_base_idle(true, base->cpu); + } } raw_spin_unlock(&base->lock); @@ -1984,7 +1989,10 @@ void timer_clear_idle(void) * sending the IPI a few instructions smaller for the cost of taking * the lock in the exit from idle path. */ - base->is_idle = false; + if (base->is_idle) { + base->is_idle = false; + trace_timer_base_idle(false, smp_processor_id()); + } } #endif