From nobody Thu Nov 10 21:25:00 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4N7ZcD6zc2z4XHxB; Thu, 10 Nov 2022 21:25:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4N7ZcD5tS8z4GFQ; Thu, 10 Nov 2022 21:25:00 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1668115500; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=PmLPf39Yqu5C1/fZd/dU2p/NtRqItVS8j5ab/Db9kvo=; b=gmvv53N5BngsOTtvXryDtsE2W3odOqYf5VF7nYwbeGVaFPhoL+NpWkYoEYsOC/9w/ccwsC 2hT7h95P9isqQXUH5U5vLW+NzyGkwSXStxbpbFVXCZbXkbbJKJ/M9cqPA15crgNY4ntkC1 KiulKamD4xA4ITw8k78BpDtWGozIed7LxD/jhGAEQxEE/d3B7bRHGSK+rSnwN2xZKAxitD TV/vgpO+3CDCnj6VXTzOCnzaDFBbbaIu1ND3b/moyDGpS7UX7YBAwzhB0FO29jNqzSdeJG +vrggx2fckDms7z1H7ZmlPcEcZYliEafHRLnV7S7i+VNsqLdM5Bl5vsUxRd8iA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1668115500; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=PmLPf39Yqu5C1/fZd/dU2p/NtRqItVS8j5ab/Db9kvo=; b=KnhaL4z0GvcAliRFwpLxEMyt3gZ1Zo8KraUX4ubN1N8xvCxMgPxnEVIaVusIVuAXivKzUM G/17vVn3wHZAf58kEtDtBpg3s188j2YwO3cntnAKuBB4ZRLctkKYft6I7hUVUEnMWvwZkg prZaJZ2XempeTwzd6RlC3VOmJbzU0AQ1adWwq794zoLeVOkKOn8upv9lXZV5wnscoFx8Ia Uw+qP9kmxOYInSUyh67RgMFqbZZmJloz34Ar1HbTuKH+anJ4lYcyraPC5Ig2G1VNCUe0Uo BUodHa7gk0tkRH9Y9W3LmzLFILxTLUHu8bAwDyNUZngUGpQA5mCmIiUgy2SqAA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1668115500; a=rsa-sha256; cv=none; b=xzWo6kHEVg2Mru334ni1DadV/ztvXs1Sr9XHU5anDXT4w9CtWL2gwYNgc/5PNSPMMjagRt IkusISgD4/l/igLEugOzfrDfv43SXfqTbhT1ed1O99Z6LRtwieQx9/Kfc9jdldZtIcKxCh JUO28a/kD/gCEvxjY+8pI5Y/i0DzA5amj0KalBTx10qa8YITamaZtGtl22hJhModEBpCYQ A9Z32BB2kIUlqJeJcdEl24o9LQtujPCpwhk22N05f+7UhRzwrQkUKnyhABusBP8YWFkfou jLVNJvNc0ELyoqhnDZO5oUx9QPA5pdnkFH8JnXtjbsR5F6v7CAbgggorrgRJrQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4N7ZcD434FzGpn; Thu, 10 Nov 2022 21:25:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2AALP0Nf085769; Thu, 10 Nov 2022 21:25:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2AALP0mQ085768; Thu, 10 Nov 2022 21:25:00 GMT (envelope-from git) Date: Thu, 10 Nov 2022 21:25:00 GMT Message-Id: <202211102125.2AALP0mQ085768@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: f5858d5551b4 - stable/13 - arm64 hwpmc: Support restricting counters to user or kernel mode. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: f5858d5551b4559c603c2f3dba512c76b7eea3fb Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=f5858d5551b4559c603c2f3dba512c76b7eea3fb commit f5858d5551b4559c603c2f3dba512c76b7eea3fb Author: John Baldwin AuthorDate: 2022-03-11 19:29:45 +0000 Commit: John Baldwin CommitDate: 2022-11-10 21:04:56 +0000 arm64 hwpmc: Support restricting counters to user or kernel mode. Support the "usr" and "os" qualifiers on arm64 events to restrict event counting to either usermode or the kernel, respectively. If neither qualifier is given, events are counted in both. Reviewed by: emaste Sponsored by: University of Cambridge, Google, Inc. Differential Revision: https://reviews.freebsd.org/D34527 (cherry picked from commit 6bb7ba4aa180f667c1b558de1fc364f41bab57ce) --- lib/libpmc/libpmc.c | 17 ++++++++++++----- sys/dev/hwpmc/hwpmc_arm64.c | 17 +++++++++++++++++ 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/lib/libpmc/libpmc.c b/lib/libpmc/libpmc.c index d36648ee6b89..0ccefad5ca7d 100644 --- a/lib/libpmc/libpmc.c +++ b/lib/libpmc/libpmc.c @@ -779,13 +779,20 @@ static struct pmc_event_alias cortex_a57_aliases[] = { static struct pmc_event_alias cortex_a76_aliases[] = { EV_ALIAS(NULL, NULL) }; + static int -arm64_allocate_pmc(enum pmc_event pe, char *ctrspec __unused, - struct pmc_op_pmcallocate *pmc_config __unused) +arm64_allocate_pmc(enum pmc_event pe, char *ctrspec, + struct pmc_op_pmcallocate *pmc_config) { - switch (pe) { - default: - break; + char *p; + + while ((p = strsep(&ctrspec, ",")) != NULL) { + if (KWMATCH(p, "os")) + pmc_config->pm_caps |= PMC_CAP_SYSTEM; + else if (KWMATCH(p, "usr")) + pmc_config->pm_caps |= PMC_CAP_USER; + else + return (-1); } return (0); diff --git a/sys/dev/hwpmc/hwpmc_arm64.c b/sys/dev/hwpmc/hwpmc_arm64.c index 17d383133bf3..80d97070b913 100644 --- a/sys/dev/hwpmc/hwpmc_arm64.c +++ b/sys/dev/hwpmc/hwpmc_arm64.c @@ -187,6 +187,23 @@ arm64_allocate_pmc(int cpu, int ri, struct pmc *pm, if (config > (PMC_EV_ARMV8_LAST - PMC_EV_ARMV8_FIRST)) return (EINVAL); } + + switch (a->pm_caps & (PMC_CAP_SYSTEM | PMC_CAP_USER)) { + case PMC_CAP_SYSTEM: + config |= PMEVTYPER_U; + break; + case PMC_CAP_USER: + config |= PMEVTYPER_P; + break; + default: + /* + * Trace both USER and SYSTEM if none are specified + * (default setting) or if both flags are specified + * (user explicitly requested both qualifiers). + */ + break; + } + pm->pm_md.pm_arm64.pm_arm64_evsel = config; PMCDBG2(MDP, ALL, 2, "arm64-allocate ri=%d -> config=0x%x", ri, config);