From patchwork Thu Sep 5 10:50:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 13792153 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 15C78CD5BA8 for ; Thu, 5 Sep 2024 10:56:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=LVd4bq0YTjw4v+0IMoc3Cm2fVjGVCOS4YTrWYkTu6OE=; b=vPtY8p1P1XQ/M1LCkynz0GHdES WwJRox6Ycl0/hgFptlDSFr5c7vahWh7vo92/dtpXcSNOYTKO1wPAIUZxwVcfmtWzGkzSL3oRv7e8X +2iQ1Nb8MkkBuGwH64u4GducFY9SggZUk/9KPCAmEvxJlfrysbBEnfJOnvE3TfyVnc+6rVK+XsvY6 Ag49n6bDe1KNkrEPmvCxsEyN6llnNm3bYbNu1/YXx7l9IuPAh4NFN979YsD7+rOC0uWVVHflotqv+ giRAunrG61+3qKvhJBHTCESxTKVcVAV+1TmgrsvSsdKHrALf6pC2FKjdalCfChzdR0wPXa6TkQBhK zrhUmoMw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1smA9w-000000082aI-2sfZ; Thu, 05 Sep 2024 10:56:19 +0000 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1smA58-000000081Oc-3g7x for linux-arm-kernel@lists.infradead.org; Thu, 05 Sep 2024 10:51:23 +0000 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-42bbe908380so4960105e9.2 for ; Thu, 05 Sep 2024 03:51:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725533477; x=1726138277; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LVd4bq0YTjw4v+0IMoc3Cm2fVjGVCOS4YTrWYkTu6OE=; b=yOKahyjLU7ca8HrAEoumGxtkp2ZZv4TeFnkW8bvv/Hmm/b1iUuyqygYUEeGsLIVzsE 2Fm3M6Cx5S/F6jON1kO5j4v/yUS2ummqdGglaj/YJUVcki1sQTl6NIK7ilVMJc6qTbgj 5AqJau54TOYgqmQNK/pjltWXbsDMrwOe60AlWt6he3sR9llINe3+sQP761mFbcrstWTy 1FXpBPI1/VYuPrOTjmazISgu7FP1LBk+Gs+y+6ELDQWLFPtEAehy4fGF5yWZkB1gfuq6 QeKo9ypN1D4+4XS1DA8DuQlH4zPsljLRi2qraW3soCG+CHVtRlehVsNWTeCzJW7k+qfd bVGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725533477; x=1726138277; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LVd4bq0YTjw4v+0IMoc3Cm2fVjGVCOS4YTrWYkTu6OE=; b=ZnJOpzboFXgsxq7PJmoeT5ufrOOnENt4ixSFNtAysrIN1SB0y7bxLxvg39FJzPaFnU a5EzGRs6gn8Yg10QxYgNNYYhZ8Ej5JeN0rpwBH04ThclBLAYqWBPLj9mbvB1FaSH3LRk 0pU6VBG21wvRwwPmcmR5uI3ul60xqELE7PX9l9JWjd7yn6UsPseNGwaLi5y9MBV3g83C 5IKQJEPxIOPlP1QdtT8X/6ALEJCJAxhpBEIHEXra0WL4EYS7RkRN787itq07dz4NpkwE Yhkt8ydg18eNCsm9ocv8DINOxzgW22l2zHAuk3E0o2Qi9TqRGlfM+vSHLM10C39r1xCq v45w== X-Forwarded-Encrypted: i=1; AJvYcCWQnK2tC+WOf0Ql83EGjQttDAc4kAmIofBzf+5ItTNclmMEQJ8+Na+sb1eiTZxYF8M/eXS0hDjoYSa04BzNivS6@lists.infradead.org X-Gm-Message-State: AOJu0YwwtLWFD2DFwWgUwUR/TeWF6p/CM/cCu5NhtzMh8XFQli+WkdrC TxZU5Q+UANZ582gjpzxKRkGMFuPIbv1iy+aI3FdcphupU4ww/0O03oW9S07ntA4= X-Google-Smtp-Source: AGHT+IHLKD1lksVjuCFdRAy71VLeSYs/LO7EW6oQprwBpHDtYZTrW3t9QhBgsgUf6sAqeRl0YMfHGA== X-Received: by 2002:a05:600c:3584:b0:42b:afd8:7568 with SMTP id 5b1f17b1804b1-42bdc64e498mr125056915e9.23.1725533477165; Thu, 05 Sep 2024 03:51:17 -0700 (PDT) Received: from localhost.localdomain ([89.47.253.130]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42bb6df0dbcsm231089965e9.17.2024.09.05.03.51.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2024 03:51:16 -0700 (PDT) From: James Clark To: linux-perf-users@vger.kernel.org, gankulkarni@os.amperecomputing.com, coresight@lists.linaro.org, leo.yan@arm.com, scclevenger@os.amperecomputing.com Cc: James Clark , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" , Suzuki K Poulose , Mike Leach , John Garry , Will Deacon , Leo Yan , Ben Gainey , Ruidong Tian , Benjamin Gray , Mathieu Poirier , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 3/8] perf cs-etm: Remove cs_etm__flush() Date: Thu, 5 Sep 2024 11:50:34 +0100 Message-Id: <20240905105043.160225-4-james.clark@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240905105043.160225-1-james.clark@linaro.org> References: <20240905105043.160225-1-james.clark@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240905_035118_923724_DFD3DBF2 X-CRM114-Status: GOOD ( 20.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This is only called on a discontinuity, and it generates a normal sample and then clears the branch buffer. I'm not convinced that any of the subtle differences between cs_etm__flush() and cs_etm__sample() weren't actual bugs or potential sources of them. Replace it with a call to the existing sample function and then a clear of the branch buffer. One obvious difference is that it now generates a range of instructions based on instructions_sample_period, rather than only a single instruction sample. I think this is actually the correct thing to do. Signed-off-by: James Clark --- tools/perf/util/cs-etm.c | 62 ++++------------------------------------ 1 file changed, 5 insertions(+), 57 deletions(-) diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 602e791ff5ba..cdda8403af2b 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -1908,60 +1908,6 @@ static int cs_etm__exception(struct cs_etm_traceid_queue *tidq) return 0; } -static int cs_etm__flush(struct cs_etm_queue *etmq, - struct cs_etm_traceid_queue *tidq) -{ - int err = 0; - struct cs_etm_auxtrace *etm = etmq->etm; - - /* Handle start tracing packet */ - if (tidq->prev_packet->sample_type == CS_ETM_EMPTY) - goto swap_packet; - - if (etmq->etm->synth_opts.last_branch && - etmq->etm->synth_opts.instructions && - tidq->prev_packet->sample_type == CS_ETM_RANGE) { - u64 addr; - - /* Prepare last branches for instruction sample */ - cs_etm__copy_last_branch_rb(etmq, tidq); - - /* - * Generate a last branch event for the branches left in the - * circular buffer at the end of the trace. - * - * Use the address of the end of the last reported execution - * range - */ - addr = cs_etm__last_executed_instr(tidq->prev_packet); - - err = cs_etm__synth_instruction_sample( - etmq, tidq, addr, - tidq->period_instructions); - if (err) - return err; - - tidq->period_instructions = 0; - - } - - if (etm->synth_opts.branches && - tidq->prev_packet->sample_type == CS_ETM_RANGE) { - err = cs_etm__synth_branch_sample(etmq, tidq); - if (err) - return err; - } - -swap_packet: - cs_etm__packet_swap(etm, tidq); - - /* Reset last branches after flush the trace */ - if (etm->synth_opts.last_branch) - cs_etm__reset_last_branch_rb(tidq); - - return err; -} - static int cs_etm__end_block(struct cs_etm_queue *etmq, struct cs_etm_traceid_queue *tidq) { @@ -2457,10 +2403,12 @@ static int cs_etm__process_traceid_queue(struct cs_etm_queue *etmq, break; case CS_ETM_DISCONTINUITY: /* - * Discontinuity in trace, flush - * previous branch stack + * Discontinuity in trace, generate a sample then + * clear the branch stack. */ - cs_etm__flush(etmq, tidq); + cs_etm__sample(etmq, tidq); + if (etmq->etm->synth_opts.last_branch) + cs_etm__reset_last_branch_rb(tidq); break; case CS_ETM_EMPTY: /*