From patchwork Fri Aug 4 15:52:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Bristot de Oliveira X-Patchwork-Id: 131259 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:44a:b0:3f2:4152:657d with SMTP id ez10csp388250vqb; Fri, 4 Aug 2023 09:44:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHz8WkShPs6jucjwID7R+C4dVTHGbw0dSknn5DpoPIcVHBOMlG12EdytLAUKHxduQubWtC7 X-Received: by 2002:a17:907:2cd4:b0:970:c9f:2db6 with SMTP id hg20-20020a1709072cd400b009700c9f2db6mr1785814ejc.63.1691167484562; Fri, 04 Aug 2023 09:44:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691167484; cv=none; d=google.com; s=arc-20160816; b=pEvS5uvXMDd7VpoB5ZQra+Y1flOzdlCiJ7VDvKdE3/hOkAfvYdZuF7eBXrh8eu5+fQ NS24jQEBEgPaQx3H8B+RwD3f4zX2m2cBhuhmPjKNDV4FuouDYLA+mRilEpb81iQSHXi5 aryoBDFH//6o7YjclPjeseIwlOzSD6xDhOb17dAI56pHn7beiEiB2IA+DB/qlVHU6YfD 4ST87jE6QEJK96hIRdgg5lr5AWSixEaJnO/l4O4E74vRK2UlN+YoU4y1wPtEEdUfEQCG 7pN4huk+q19TcbfE8zBFFPKaJ8ViLC6nJfkTXVuNLDnnmlieC46EmLaskOsSS/3CFxTb AZAw== 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:date:subject:cc:to:from :dkim-signature; bh=ZRsp6C/oYlkEjeuKhBsipWUtWySA1vZ1FP3yaCcIilg=; fh=xOK/STtxvfdsFFx6oPoqk87WRzpPeY52tFJxVRRfZkU=; b=NTcaa0EuKt1vtWs0PvkL1mcjnHmCKVOHskv7fV7GX0ScxD15P5Iq48pn0bqPmTQwIC jpngZ70T5KTYLkGBe/TXhQu03UTEnocnBkeHVe/C59AXPklvUpszPvgebfCWIeBEUzt2 2hjuAwHVjTEOBHLAcbOiHCi9Puh2j4bDIeixdKzaftP+Hnq6BWeJ0UnLOeAYf/Rv/yL+ /N2o4nSaGTbkXkZBoY/3aEDN2FSX775wGvsNAtF641RConjKfs3uykXb2r8C1Pj4G8au 4qT08yUjoucBzIAhQNVl5K19IMAH69KdReHkqCFQ7nX/bLcuscL52dWXnNyJgYliRPEc K5Nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hQPFGtNz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d17-20020a170906041100b00992ac6d8893si1905379eja.792.2023.08.04.09.44.20; Fri, 04 Aug 2023 09:44:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hQPFGtNz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232237AbjHDPwg (ORCPT + 99 others); Fri, 4 Aug 2023 11:52:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232221AbjHDPwd (ORCPT ); Fri, 4 Aug 2023 11:52:33 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4944B49CB; Fri, 4 Aug 2023 08:52:32 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 82D806209C; Fri, 4 Aug 2023 15:52:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 51B18C433CA; Fri, 4 Aug 2023 15:52:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691164351; bh=gTe7K81Fy/E2vjahMI33+dObPnl+nUbydfjT/SnxZuM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hQPFGtNzLnGg3aIvjUJA9gtmk2KqFUP4NGM9a9jSuQ9oWvRODlTupdKxJBokpou5K Nq4GyugvHYYwZmKbEMOSStikAyXJXWpcpjRQtkZuzPDV/DEl+d8eGW2Am9+jejQs0S uDXpEOoqWhpHpFfbpTuRMEfKeSYcWOuG7ZqX1B4ETlA+tci47Se9U1XlyFchU681s7 XWxsJhhfdkivGCPPBKM9UKJWyuCVSbLdcoiFCXlYtByjhzWpO/Ku5pjToCsyoZ/ZCr U+q+42fwMZcXqhwnHC2Vrl0FNj1ITdqHVzUiHKLIfFId9dJKPrhpRMWjEjRc8N2veA JODSip/inIsXA== From: Daniel Bristot de Oliveira To: linux-kernel@vger.kernel.org, linux-trace-devel@vger.kernel.org, Steven Rostedt Cc: William White , Daniel Bristot de Oliveira , Masami Hiramatsu Subject: [PATCH 3/3] rtla/timerlat_aa: Fix previous IRQ delay for IRQs that happens after thread sample Date: Fri, 4 Aug 2023 17:52:13 +0200 Message-Id: X-Mailer: git-send-email 2.38.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773317636538644986 X-GMAIL-MSGID: 1773317636538644986 timerlat auto-analysis takes note of all IRQs, before or after the execution of the timerlat thread. Because we cannot go backward in the trace (we will fix it when moving to trace-cmd lib?), timerlat aa take note of the last IRQ execution in the waiting for the IRQ state, and then print it if it is executed after the expected timer IRQ starting time. After the thread sample, the timerlat starts recording the next IRQs as "previous" irq for the next occurrence. However, if an IRQ happens after the thread measurement but before the tracing stops, it is classified as a previous IRQ. That is not wrong, as it can be "previous" for the subsequent activation. What is wrong is considering it as a potential source for the last activation. Ignore the IRQ interference that happens after the IRQ starting time for now. A future improvement for timerlat can be either keeping a list of previous IRQ execution or using the trace-cmd library. Still, it requires further investigation - it is a new feature. Fixes: 27e348b221f6 ("rtla/timerlat: Add auto-analysis core") Signed-off-by: Daniel Bristot de Oliveira --- tools/tracing/rtla/src/timerlat_aa.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tools/tracing/rtla/src/timerlat_aa.c b/tools/tracing/rtla/src/timerlat_aa.c index baf1efda0581..7093fd5333be 100644 --- a/tools/tracing/rtla/src/timerlat_aa.c +++ b/tools/tracing/rtla/src/timerlat_aa.c @@ -545,7 +545,7 @@ static int timerlat_aa_kworker_start_handler(struct trace_seq *s, struct tep_rec static void timerlat_thread_analysis(struct timerlat_aa_data *taa_data, int cpu, int irq_thresh, int thread_thresh) { - unsigned long long exp_irq_ts; + long long exp_irq_ts; int total; int irq; @@ -562,12 +562,15 @@ static void timerlat_thread_analysis(struct timerlat_aa_data *taa_data, int cpu, /* * Expected IRQ arrival time using the trace clock as the base. + * + * TODO: Add a list of previous IRQ, and then run the list backwards. */ exp_irq_ts = taa_data->timer_irq_start_time - taa_data->timer_irq_start_delay; - - if (exp_irq_ts < taa_data->prev_irq_timstamp + taa_data->prev_irq_duration) - printf(" Previous IRQ interference: \t\t up to %9.2f us\n", - ns_to_usf(taa_data->prev_irq_duration)); + if (exp_irq_ts < taa_data->prev_irq_timstamp + taa_data->prev_irq_duration) { + if (taa_data->prev_irq_timstamp < taa_data->timer_irq_start_time) + printf(" Previous IRQ interference: \t\t up to %9.2f us\n", + ns_to_usf(taa_data->prev_irq_duration)); + } /* * The delay that the IRQ suffered before starting.