Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp5053995iob; Mon, 9 May 2022 07:45:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzMnFsgoJeBudGuG/5U8EU39K9RW9h/B0H87ZUWEmN/XB1GbL/4MLyeS9FOxp3MnqQnDjlf X-Received: by 2002:a17:903:22ca:b0:15e:cf4e:79d6 with SMTP id y10-20020a17090322ca00b0015ecf4e79d6mr16988577plg.59.1652107511318; Mon, 09 May 2022 07:45:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652107511; cv=none; d=google.com; s=arc-20160816; b=Gz4qS3/cvSPZWhWaJah0qCKvVyBKeN1yZoKVYsPGhW0RcM4VdeUTJq1Phyv6CGAvmG 9/h/uYj77ZPeR/neQoyWSYAsVOaKD/dGWTle4CKoQ3B67h42JxUjPBAwU34w260bWv5B D+lfZyx6xDt6fsv2SIrBG/8BfQlU0gNXEdxUZWG+XCQ+GbRs1DuVq9w++8vffQExE1cu yszUlx0f0MTCB9jC1Y3WDJzA2mFwZx7b1w3MfnyGse35/qYXH3pbyJwr1Nepf5NTwZB+ +kbSli3B9LX6SFh98T6uE1n8Nt0iqEItF40eK1/Qe3JslIKbzUmaAmF75xrE2bAhhDrz JDGQ== 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; bh=sRnfXSYNJUJ/uzGK+o/C3GsRxzWY0vhCFoq9VkXagiQ=; b=x6UOiO6jnOqbRt349Nwc1aKRf482PqNc6qlkNc3KfY3TXXEFtvarQptfhm+BzCL5Nl kUDxNqS6iXWH49PdLkaOAIaHFwLHkPAEjg7OKXbVHnEnovu3cMcbaNAzj73eKD8rLrWO C1MXeQapQOfWpQ08LBaeutXiXlr1K5XCT8mUPpQXBdjudCTQ7Od2yowcV9ZWCr0xXRRv 8VLSqFu7wF8BrRCW0o4f+0N7OMqbkfZRPnEoCg2BeVny3HPeME9thF/W7Zr0RPM8lopC keme++RJCM4bZ4Rf1pt5sIRlyFruV4cCvreLddAqesvxJ08v79zKL+xRg4VQmSZYpxKM U16Q== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id w5-20020a170902e88500b0015e9605ae8bsi13238741plg.123.2022.05.09.07.45.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 07:45:11 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 349912BEFBF; Mon, 9 May 2022 07:44:13 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237616AbiEIOr5 (ORCPT + 99 others); Mon, 9 May 2022 10:47:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237572AbiEIOru (ORCPT ); Mon, 9 May 2022 10:47:50 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BA989219346; Mon, 9 May 2022 07:43:56 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 95490153B; Mon, 9 May 2022 07:43:56 -0700 (PDT) Received: from e121896.arm.com (unknown [10.57.4.213]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 435393F73D; Mon, 9 May 2022 07:43:54 -0700 (PDT) From: James Clark To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, broonie@kernel.org Cc: german.gomez@arm.com, James Clark , John Garry , Will Deacon , Mathieu Poirier , Leo Yan , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-doc@vger.kernel.org Subject: [PATCH v1 6/6] perf tools: arm64: Add support for VG register Date: Mon, 9 May 2022 15:42:54 +0100 Message-Id: <20220509144257.1623063-7-james.clark@arm.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20220509144257.1623063-1-james.clark@arm.com> References: <20220509144257.1623063-1-james.clark@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Add the name of the VG register so it can be used in --user-regs The event will fail to open if the register is requested but not available so only add it to the mask if the kernel supports sve and also if it supports that specific register. Signed-off-by: James Clark --- tools/perf/arch/arm64/util/perf_regs.c | 34 ++++++++++++++++++++++++++ tools/perf/util/perf_regs.c | 2 ++ 2 files changed, 36 insertions(+) diff --git a/tools/perf/arch/arm64/util/perf_regs.c b/tools/perf/arch/arm64/util/perf_regs.c index 476b037eea1c..c0a921512a90 100644 --- a/tools/perf/arch/arm64/util/perf_regs.c +++ b/tools/perf/arch/arm64/util/perf_regs.c @@ -2,9 +2,11 @@ #include #include #include +#include #include #include +#include "../../../perf-sys.h" #include "../../../util/debug.h" #include "../../../util/event.h" #include "../../../util/perf_regs.h" @@ -43,6 +45,7 @@ const struct sample_reg sample_reg_masks[] = { SMPL_REG(lr, PERF_REG_ARM64_LR), SMPL_REG(sp, PERF_REG_ARM64_SP), SMPL_REG(pc, PERF_REG_ARM64_PC), + SMPL_REG(vg, PERF_REG_ARM64_VG), SMPL_REG_END }; @@ -131,3 +134,34 @@ int arch_sdt_arg_parse_op(char *old_op, char **new_op) return SDT_ARG_VALID; } + +uint64_t arch__user_reg_mask(void) +{ + struct perf_event_attr attr = { + .type = PERF_TYPE_HARDWARE, + .config = PERF_COUNT_HW_CPU_CYCLES, + .sample_type = PERF_SAMPLE_REGS_USER, + .disabled = 1, + .exclude_kernel = 1, + .sample_period = 1, + .sample_regs_user = PERF_REGS_MASK + }; + int fd; + + if (getauxval(AT_HWCAP) & HWCAP_SVE) + attr.sample_regs_user |= SMPL_REG_MASK(PERF_REG_ARM64_VG); + + /* + * Check if the pmu supports perf extended regs, before + * returning the register mask to sample. + */ + if (attr.sample_regs_user != PERF_REGS_MASK) { + event_attr_init(&attr); + fd = sys_perf_event_open(&attr, 0, -1, -1, 0); + if (fd != -1) { + close(fd); + return attr.sample_regs_user; + } + } + return PERF_REGS_MASK; +} diff --git a/tools/perf/util/perf_regs.c b/tools/perf/util/perf_regs.c index a982e40ee5a9..872dd3d38782 100644 --- a/tools/perf/util/perf_regs.c +++ b/tools/perf/util/perf_regs.c @@ -103,6 +103,8 @@ static const char *__perf_reg_name_arm64(int id) return "lr"; case PERF_REG_ARM64_PC: return "pc"; + case PERF_REG_ARM64_VG: + return "vg"; default: return NULL; } -- 2.28.0