From patchwork Sat Jun 4 04:28:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 12869561 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 CABB8C433EF for ; Sat, 4 Jun 2022 04:30:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=e/lhCx/91g8NK5iigPOWOf8MFOCPligt7TWx/yHB71g=; b=AryIh6Bb9Lznu0 yEC/FewJJqZmwdTPAOf371P2iKopPdFIzfKpm1y0T/l38T9RXnnpjdwjZkNBocj8NOgQTsFzHuGLy KniB2Cwas/uwgemQhmrje1GcGH1BQe1J2ZP96C/89tPsM4GciEsL7FvRmfzLhiWwYkLXO1CUvJYNM eUA6KLr5vjEboz9s6skGu+9Taid1g+a9TLNBUMAtYTnFUN+HiJRvcWPzFWiM30DF0liMoCUisSaJF 7LwCe7zbCJqdsCSmSaYQABgHxvB0/GZdgNgB/q/RwY0GbgY3tvLd36S9Fch8Ye66Ed1vbuZFicD6j DHyEVbNGDmYL3ZcvvPzQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nxLPi-00AE2b-6i; Sat, 04 Jun 2022 04:29:26 +0000 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nxLPO-00ADwb-6a for linux-arm-kernel@lists.infradead.org; Sat, 04 Jun 2022 04:29:07 +0000 Received: by mail-pj1-x1034.google.com with SMTP id l20-20020a17090a409400b001dd2a9d555bso8528643pjg.0 for ; Fri, 03 Jun 2022 21:29:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9Itr786U0bNQsTn9HxoMNJVLfUK0SwX/2+UygpwWJQU=; b=HRrqkSj5jFDX3oMdC1b9v6uPAqX/It6MRcEmj5Xxq9SmXB740LQdQ0XK56Rip58K2N iyVPOXcR4/24EcInYwZz6mOBPcEyuUfcofWoYnyqNVDsMWiIbjOHIYOFglDE9C8Vk4lp n/Br/AdLC8qZp9sQLK4oio+rHwYCvXa+QG81PjO7mVeq6WlUzkKitg0M2ZIWjBkbVzm6 MMYTJkAXvaU3hKMX5oKllQHiDzyxILYIMnedbAI/49PKj3HIzJdbBYmRFQ/Nmjf17i9Q 4pqdfmL1YmcR/z9ZEIs6ncfC3OR/gLid8xbqcOAeUD7FGEwXOI2JqCWCUGRvpko9kBC9 xuPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9Itr786U0bNQsTn9HxoMNJVLfUK0SwX/2+UygpwWJQU=; b=nRRhGG+qqd4Zj5ceuIxsQJ6PTPtYTqut5DfDfzk/iYajVd5KtBMTm7S6Vy6/MVnu96 P9w4zroNXNS8eZ+2/57S+S95JarZrW2R74h0lY0hJe3r79JT614RPzeq3zfbMbSA7n8/ FRhM5oe/Z1wQ7Ofqxjpq9h9a0GV/rIut/gemOSFX+1bpmjQJJ1SYidERM4hPP3hGEr3P PoJQFVMO5CFkbHqNViuZiTxtFezwsfWM6CdaKkuksqyPX/B5IbbZBKB/9LHH+AzWP1f+ Px7dbTLBF+CI//TBFpjGvh1F26Z7Yb6wszRfcJOxia80W8XhVJ0W/E4Pnb0NDX0OF+aq Q0Ag== X-Gm-Message-State: AOAM53130VsCrjUBSyGNcOLJY6tWcieWguy8DPRlVT2WhPMz6Dain1kA D2D4EHxfwRu4hEU7J2XX9fRmmA== X-Google-Smtp-Source: ABdhPJwcVD8GDGMqWVcKhZsnjvsdvpCLQ7ZPeHk9MVEH18VB3jqs5x0IRE/k2dPvQfmz6M3PqL0egw== X-Received: by 2002:a17:902:b683:b0:163:4ef2:3c40 with SMTP id c3-20020a170902b68300b001634ef23c40mr12758423pls.123.1654316945603; Fri, 03 Jun 2022 21:29:05 -0700 (PDT) Received: from leo-build-box.lan (ec2-54-67-95-58.us-west-1.compute.amazonaws.com. [54.67.95.58]) by smtp.gmail.com with ESMTPSA id w24-20020a1709027b9800b00163d4c3ffabsm6152916pll.304.2022.06.03.21.29.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jun 2022 21:29:05 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Peter Zijlstra , Ingo Molnar , Mark Rutland , Jiri Olsa , Namhyung Kim , Ian Rogers , John Garry , Will Deacon , James Clark , German Gomez , Ali Saidi , Joe Mario , Adam Li , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Leo Yan Subject: [PATCH v5 04/17] perf arm-spe: Don't set data source if it's not a memory operation Date: Sat, 4 Jun 2022 12:28:07 +0800 Message-Id: <20220604042820.2270916-5-leo.yan@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220604042820.2270916-1-leo.yan@linaro.org> References: <20220604042820.2270916-1-leo.yan@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220603_212906_285689_4D461C3B X-CRM114-Status: GOOD ( 19.44 ) 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 Except memory load and store operations, Arm SPE records also can support other operation types, bug when set the data source field the current code assumes a record is a either load operation or store operation, this leads to wrongly synthesize memory samples. This patch strictly checks the record operation type, it only sets data source only for the operation types ARM_SPE_LD and ARM_SPE_ST, otherwise, returns zero for data source. Therefore, we can synthesize memory samples only when data source is a non-zero value, the function arm_spe__is_memory_event() is useless and removed. Fixes: e55ed3423c1b ("perf arm-spe: Synthesize memory event") Signed-off-by: Leo Yan Reviewed-by: Ali Saidi Tested-by: Ali Saidi Reviewed-by: German Gomez --- tools/perf/util/arm-spe.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c index 1a80151baed9..d040406f3314 100644 --- a/tools/perf/util/arm-spe.c +++ b/tools/perf/util/arm-spe.c @@ -387,26 +387,16 @@ static int arm_spe__synth_instruction_sample(struct arm_spe_queue *speq, return arm_spe_deliver_synth_event(spe, speq, event, &sample); } -#define SPE_MEM_TYPE (ARM_SPE_L1D_ACCESS | ARM_SPE_L1D_MISS | \ - ARM_SPE_LLC_ACCESS | ARM_SPE_LLC_MISS | \ - ARM_SPE_REMOTE_ACCESS) - -static bool arm_spe__is_memory_event(enum arm_spe_sample_type type) -{ - if (type & SPE_MEM_TYPE) - return true; - - return false; -} - static u64 arm_spe__synth_data_source(const struct arm_spe_record *record) { union perf_mem_data_src data_src = { 0 }; if (record->op == ARM_SPE_LD) data_src.mem_op = PERF_MEM_OP_LOAD; - else + else if (record->op == ARM_SPE_ST) data_src.mem_op = PERF_MEM_OP_STORE; + else + return 0; if (record->type & (ARM_SPE_LLC_ACCESS | ARM_SPE_LLC_MISS)) { data_src.mem_lvl = PERF_MEM_LVL_L3; @@ -510,7 +500,11 @@ static int arm_spe_sample(struct arm_spe_queue *speq) return err; } - if (spe->sample_memory && arm_spe__is_memory_event(record->type)) { + /* + * When data_src is zero it means the record is not a memory operation, + * skip to synthesize memory sample for this case. + */ + if (spe->sample_memory && data_src) { err = arm_spe__synth_mem_sample(speq, spe->memory_id, data_src); if (err) return err;