Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1407420pxb; Thu, 4 Mar 2021 10:28:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJwgfJYS9+oEspqTLGgFvCIUe4MNrZqimSVux5u8ZIKGDWrOZ3ehfzYinoJFc/k15l4+riF5 X-Received: by 2002:aa7:c550:: with SMTP id s16mr5934088edr.98.1614882537182; Thu, 04 Mar 2021 10:28:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614882537; cv=none; d=google.com; s=arc-20160816; b=F3tWdWIAzy/xGoq3kDVRceFZyz7PL4PlZiyymWIQa2XNNdiceHwdqGvFDtxmPzaHCM U09e0X4kLlBDZtxri3F3hjuWxG5YmuyKkKVP0FHdy78lLMU62pTgvsswTLhU0UklUQ8s +uHHLyG0BN/C6gHyEbFenCJpeqLBORBR6qsZQFVzjjdcUKTgNFWvjOTNaXCYBxRtUJ6A BcvnDNnnzOulLyWYTpdFIoiFFgXlc7Qn57/SvOhjz/SBnZ05uvsRixLW3Enoz0hN7iBH LZBsHYxti0JXkIJVFJ30joksoGcnZac0xi0oUyxiE4qsZTMMrGGJFnPMbKBpjO6xT1Kf GaAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=vyiaA+k3XPe+8kMO6+43EheBAUS/QKtks3rfyUaArhs=; b=W/OZXz/GtZD7fmc79xnDjpgMmq5SFOqLCRp2bUMm+WiVAvVnpLo/X3TDzi/WI8/rgA 1y9oR+oZRaaSVaVPki9n0xPXMerzHic96HGMZ0my3CKKRNl7+ijyGanxZG00FS7Rxf3p +H5VpmOxMInjpB3JVW+31qJrAf6N5WunYOYV9cIEva0Wtb/Xzvf/Z6HSYb7Xl2QKfWHS l/YM2JuFT6jH3ZtDPfihRGxpyH6U3QWic1pMEmLCoJ3Jpt2pLiVcs/V3/R8LCtCGMtMZ rZfCkSRzTW9tZjqtNVc7GYr/5LjakjUN7IEyn8dV24JxgZqgJ4Xgd3KIb1cNIXx7Efrv Ov8A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jg13si18428605ejc.669.2021.03.04.10.28.32; Thu, 04 Mar 2021 10:28:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236530AbhCDQjQ (ORCPT + 99 others); Thu, 4 Mar 2021 11:39:16 -0500 Received: from mail.kernel.org ([198.145.29.99]:58308 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236490AbhCDQiw (ORCPT ); Thu, 4 Mar 2021 11:38:52 -0500 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8535664F52; Thu, 4 Mar 2021 16:38:11 +0000 (UTC) Date: Thu, 4 Mar 2021 11:38:09 -0500 From: Steven Rostedt To: "Yordan Karadzhov (VMware)" Cc: linux-kernel@vger.kernel.org, tglx@linutronix.de, peterz@infradead.org Subject: Re: [RFC PATCH 1/5] tracing: Define new ftrace event "func_repeats" Message-ID: <20210304113809.5c2ccceb@gandalf.local.home> In-Reply-To: <20210304090141.207309-2-y.karadz@gmail.com> References: <20210304090141.207309-1-y.karadz@gmail.com> <20210304090141.207309-2-y.karadz@gmail.com> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 4 Mar 2021 11:01:37 +0200 "Yordan Karadzhov (VMware)" wrote: Thanks Yordan for doing this! I have some comments below. > diff --git a/kernel/trace/trace_entries.h b/kernel/trace/trace_entries.h > index 4547ac59da61..8007f9b6417f 100644 > --- a/kernel/trace/trace_entries.h > +++ b/kernel/trace/trace_entries.h > @@ -338,3 +338,19 @@ FTRACE_ENTRY(hwlat, hwlat_entry, > __entry->nmi_total_ts, > __entry->nmi_count) > ); > + > +FTRACE_ENTRY(func_repeats, func_repeats_entry, > + > + TRACE_FUNC_REPEATS, > + > + F_STRUCT( > + __field( unsigned long, ip ) > + __field( unsigned long, pip ) > + __field( unsigned long, count ) > + ), > + > + F_printk(" %ps <-%ps\t(repeats:%lu)", > + (void *)__entry->ip, > + (void *)__entry->pip, > + __entry->count) After playing with this a little, I realized that we should also store the last timestamp as well. I think that would be interesting information. <...>-37 [004] ...1 2022.303820: gc_worker <-process_one_work <...>-37 [004] ...1 2022.303820: ___might_sleep <-gc_worker <...>-37 [004] ...1 2022.303831: ___might_sleep <-gc_worker (repeats: 127) <...>-37 [004] ...1 2022.303831: queue_delayed_work_on <-process_one_work The above shows that __might_sleep() was called 128 times, but what I don't get from the above, is when that last call was made. You'll see that the timestamp for the repeat output is the same as the next function shown (queue_delayed_work_on()). But the timestamp for the last call to __might_sleep() is lost, and the repeat event ends up being written when it is detected that there are no more repeats. If we had: <...>-37 [004] ...1 2022.303820: gc_worker <-process_one_work <...>-37 [004] ...1 2022.303820: ___might_sleep <-gc_worker <...>-37 [004] ...1 2022.303831: ___might_sleep <-gc_worker (last ts: 2022.303828 repeats: 127) <...>-37 [004] ...1 2022.303831: queue_delayed_work_on <-process_one_work We would know the last time __might_sleep was called. That is, not only should we save the ip and pip in the trace_func_repeats structure, but we should also be storing the last time stamp of the last function event that repeated. Otherwise the above looks like the last __might_sleep called above happened when the queue_delayed_work_on happened, where that may not be the case. -- Steve