Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp1804470lqz; Mon, 1 Apr 2024 19:21:33 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW1C7zAqMdrfBN1JGaDz5OTG1vL+LhZrI1KmhiAZvM4mr4vrRa6KqP3wrHBZTpeBeqTjabsSWWQgmHRr9MYoCA9Mh3GgpCpJo76PXHqMA== X-Google-Smtp-Source: AGHT+IELczvRahJFNhmFIQTmHc8n+w95VV2xPcCYRZjgiM86IzlgHqux1ZmduN67XWCt5mwndK6r X-Received: by 2002:a05:622a:246:b0:434:34d4:72c5 with SMTP id c6-20020a05622a024600b0043434d472c5mr716689qtx.23.1712024492929; Mon, 01 Apr 2024 19:21:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712024492; cv=pass; d=google.com; s=arc-20160816; b=G2phdSJc52GM5nLgZEob6+vP3dZQ+3UfqVktYfbe8WTELNYZYRtobcDeitVeDTYI1H HIhQJe0Zn+9XcgVY5elvlAqrFg88Qnsm8oB1Q8fIggNF1Wn9i7uE5Xv5IvsazYWMSij1 zRIYFFO/b+37luYOzer6zB4oH3anxKr5ILYj6C0Iox/pF63SgP6/rh4/KsBovAlo+POS y4cEu9S5cn5HxQQRBYrvmG+V8e/puUSFfUbRz9OPTNVCjiXqPvl/lCrbFWa/o2tpytux l2IkNEQGiz3jFALGZYXBP3xgbAZZzgigunWUY/qMOopZROtgpfsJ8sZULZ7h8DNTviDj bRTA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=K9H+VCbt5kHlKzlZQcAxBnFVs2r/a3xnsusxT6muaDA=; fh=4AyU/x+val9l9ExwDmfmpeW7R8l/NbvEHNqFh2t6BLo=; b=yQbD2OGQ2wTyjNqh9u9lh15A4a4kshiCk78ZZMQDccNT98zUH5aWmIYHkV1JQsia5A 74V/9QNd2W42sVnK9pYxn4qOspn3kj9gyASBZDMH5m892ojO3eRtWof/Ih+85U58pfvG kLy2YNhhNCRZJfYMd/LD7m6rYhVq9KIhGH+yewm1RHw3qFj3QADRZvYYVWbafNuxBAGW un3Lxw29jRmPa55knBYf9uqPpIj6dumZljBt5a0jCzLVEsO5fyz8qTRE4cL6YQIQUJDq BhvgnMpmJDJpl/ZDriYIpzaOMUlB8XUAOqnK0tmqp+KEAuBaOwjfyaYRUqJoqJYxT7qk hc7A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QUCRASCY; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-127287-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-127287-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d10-20020a05622a05ca00b0043149c1ce28si11104423qtb.98.2024.04.01.19.21.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Apr 2024 19:21:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-127287-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QUCRASCY; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-127287-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-127287-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id A44651C23559 for ; Tue, 2 Apr 2024 02:21:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AA9F6F9DA; Tue, 2 Apr 2024 02:21:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="QUCRASCY" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D2E983201; Tue, 2 Apr 2024 02:21:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712024483; cv=none; b=Ve4dmN5wEO71pDwtSdrXm9knkj08hXCAgoguZaigGMiiZMslJF00G/61A2UK00Ew/Yi8B5OJatKWn6NNOcXasbR42a+1B28EynOLAo3VxOQODX/Gn2GLpXk52jshFacSbch9zpU4XEk993YgEES+vR2/qnX2/VcS9e8oSjNLDmg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712024483; c=relaxed/simple; bh=Og/+JDitgrRM0fH/rw9CSzIBupnsDehGZbLbP4VdvLE=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=D3Pk88jk0eZbJUAqOevbVVFv9W4c1JKijjjxfAk8apt7Wly1Qmgzpr7jiL52ZK8iYdeWgIjaEWiYgTighK+V45qUZ1HeA34Xq3mBGZZLOcWWHOzpfoTCcmsyS+FgNawFp8hvu6K+hsEgeBfWiDDFBzpcXEzVk9zPvk10abB4fNI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QUCRASCY; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3E28DC433C7; Tue, 2 Apr 2024 02:21:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712024483; bh=Og/+JDitgrRM0fH/rw9CSzIBupnsDehGZbLbP4VdvLE=; h=From:To:Cc:Subject:Date:From; b=QUCRASCYLY87O5ee0YFs1PTo/XRNpEB7qvuHXvtchmFROQSCUXAadT3/oaaKbiLp6 Yp0jfym/1qh7tTOQ0m/mBHTmW4Rk6sN94/RrWSJfchA+dbLGMOgmIoOTFrJ1oR04FI jlrW9e0IgmUQce6JpU/SuBDTDJ/EWi2OQFFyouCbhARDmdHM8Vs/MgqEdyarurQwMU vWBHDGU8IaCfuCF2IsT63bKZtzNJNpYOkmxz7qEgtBK8y4p8SRkz8IpWBrGjJE+OvD 49pDy+yShsuyhwconPBp9Uu6/z5uzFjhlGg6eOi+E6WpaLGODmTFlqwmRRz+WUkch3 jstNB/lVuQYvA== From: Andrii Nakryiko To: x86@kernel.org, peterz@infradead.org, mingo@redhat.com, tglx@linutronix.de Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org, jolsa@kernel.org, song@kernel.org, kernel-team@meta.com, Andrii Nakryiko Subject: [PATCH v5 0/4] perf/x86/amd: add LBR capture support outside of hardware events Date: Mon, 1 Apr 2024 19:21:14 -0700 Message-ID: <20240402022118.1046049-1-andrii@kernel.org> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add AMD-specific implementation of perf_snapshot_branch_stack static call that allows LBR capture from arbitrary points in the kernel. This is utilized by BPF programs. See patch #3 for all the details. Patches #1 and #2 are preparatory steps to ensure LBR freezing is completely inlined and have no branches, to minimize LBR snapshot contamination. Patch #4 removes an artificial restriction on perf events with LBR enabled. v4->v5: - rebased on top of perf/urgent branch to resolve conflicts with 598c2fafc06f ("perf/x86/amd/lbr: Use freeze based on availability"). Andrii Nakryiko (4): perf/x86/amd: ensure amd_pmu_core_disable_all() is always inlined perf/x86/amd: avoid taking branches before disabling LBR perf/x86/amd: support capturing LBR from software events perf/x86/amd: don't reject non-sampling events with configured LBR arch/x86/events/amd/core.c | 37 +++++++++++++++++++++++++++++++++++- arch/x86/events/amd/lbr.c | 13 +------------ arch/x86/events/perf_event.h | 13 +++++++++++++ 3 files changed, 50 insertions(+), 13 deletions(-) -- 2.43.0