From patchwork Wed Sep 4 20:41:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colton Lewis X-Patchwork-Id: 1981009 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20230601 header.b=0gIcYf1I; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=linuxppc-dev+bounces-1020-incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WzclF4h9Tz1yg3 for ; Thu, 5 Sep 2024 08:35:37 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4WzclF1MGNz2yGN; Thu, 5 Sep 2024 08:35:37 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip="2607:f8b0:4864:20::d4a" ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1725482551; cv=none; b=Ka63E20TctpfwLABjnfAIUW/lgvmlRJCp0VQyKwg3YcXW3xsqRTt2lOP4xwyhkm0PpmvUraQ4EblRJrEHfTC0GhpYnovMggRxwsViMkaq5X2BGXU++4RfUsyI9O2tjL3H+BVr1zSu3TQ/TiJ8H7GaSkTaPy5VT6fSCc737uM/8g8PCvME5n6l4lMZ7auP/PLqi5FK1PxrBidxUGfZLqmJc4X3Mj+zxPXfPJqbtlY75xqri6EjCymJPRBYaE4HnadlQsTC3KtdkCZUOqrEwbyqO3pKp4LrPoT+ByzPVTiIjt07UIj/aDw6vwzCrGyfJFvBAAz6SsoAiiKUCVoSdJ8HA== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1725482551; c=relaxed/relaxed; bh=da1VGWoVEM0srL8pak+5iYqVi4U1+WdMmmo+Uby7jLQ=; h=DKIM-Signature:Date:In-Reply-To:Mime-Version:References: Message-ID:Subject:From:To:Cc:Content-Type; b=AtWuRqYREc8XI6gFsfkN4ND9EjyyQCiIHo9O+IO2ZJpqFA59uqbE3bavyS1WYpJivT4KwwVIh0GXJMTt04jXfpkJPy02DQNwOSz9BASi2EQVpJ0MIuye6+OPBcD+ihCkgsRUhmeJqpYExrBAfo5P8olTIdZV5N8XaVOH3wC04i4y+ktjZ2mo3oeWHxoKewS1XNI+74CDTKgwDoKeqktIuU8T6WrP4aDoNMsr6/BcFit67UH90bSbvY/UUPT5Re1ZLQFlXRCQA6jvMmzQ2egREewJf0AcnebM0DuPbji+YE/evBwcn+q/I1fcy++onBaEZILSp161N1Smx06v3JkH8w== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=reject dis=none) header.from=google.com; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20230601 header.b=0gIcYf1I; dkim-atps=neutral; spf=pass (client-ip=2607:f8b0:4864:20::d4a; helo=mail-io1-xd4a.google.com; envelope-from=3m8byzgskdgaamjrmljcugqemmejc.amkjglsvnna-bctjgqrq.mxj89q.mpe@flex--coltonlewis.bounces.google.com; receiver=lists.ozlabs.org) smtp.mailfrom=flex--coltonlewis.bounces.google.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20230601 header.b=0gIcYf1I; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=flex--coltonlewis.bounces.google.com (client-ip=2607:f8b0:4864:20::d4a; helo=mail-io1-xd4a.google.com; envelope-from=3m8byzgskdgaamjrmljcugqemmejc.amkjglsvnna-bctjgqrq.mxj89q.mpe@flex--coltonlewis.bounces.google.com; receiver=lists.ozlabs.org) Received: from mail-io1-xd4a.google.com (mail-io1-xd4a.google.com [IPv6:2607:f8b0:4864:20::d4a]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4WzZDk1KZzz2xy0 for ; Thu, 5 Sep 2024 06:42:29 +1000 (AEST) Received: by mail-io1-xd4a.google.com with SMTP id ca18e2360f4ac-82a2109c355so869695839f.2 for ; Wed, 04 Sep 2024 13:42:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1725482547; x=1726087347; darn=lists.ozlabs.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=da1VGWoVEM0srL8pak+5iYqVi4U1+WdMmmo+Uby7jLQ=; b=0gIcYf1I/cO0/EGkjmC8+WPr9t3NVUW4y5Q/dU6VlycmsQ3fCEnFar8UeWx9rqYXGB A/yCA7z6depB+5ohqKTC3BiMpWVxWSXz4p3RTkHBRrwhCj6IbEGKKRbaW/+2Ww72FJHG d9F7x81c1in0k4iAzYUVGUtIMTObJwWz8rZ0ve72c3rxxNVPxFCy0d/ZWev3bYbsTOcr XxaanDGf4a7tKMqWNGapjYAfKMoPDUqp0ajcb3l3A2PR8ON6xC8JzZqqkaqTQaiDjIzD poqO8DXK9e2BxQHSo9NeNlWpAosETZ31oPm6BnyeT/FmadMtExJbmEo0iF2c8Nrf6W4R sgWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725482547; x=1726087347; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=da1VGWoVEM0srL8pak+5iYqVi4U1+WdMmmo+Uby7jLQ=; b=UPwT8GU0MXOzDgJh+JGbYzted6VPK3ynwdkpZoF+oCbEDRviKzHbq8ffoq5wBYDXp7 ycMVbevdTMBUaxzn2DtqwjAViRtM1c8csn4lsngCag7Xh/AjuAFH0nYDsuYDJ0Ro52Uy tOEvd6Pvnolbmsn8EupNO2MT//0OPjuCbdc2UNyEmnkAPMwC56tK7uPWA3Fq2z2nfV3F ytCa3BO2277hdjkdgUwxSAfWpxj5vK4DbiahjJr2zDb60cOyMdqJsSl8bUtOS6sWvHpP jfEONKJ4wLOIrdzZlGjUtrCQjhSmmSfHD62LGDS5oT41QoP63grdg2lnXhDvBzkzwP2r 0fXA== X-Forwarded-Encrypted: i=1; AJvYcCUVKvxlpK/VNVcShnp8oSwc4gB9HV2UbdsO0+j+hTU4QXR85kDPIPN3UBhFQb1KvY6VFQJdS0SdMD0LziY=@lists.ozlabs.org X-Gm-Message-State: AOJu0YySDk7bBDES3MA6bSqTQesd6sEVtHoV4MS2XxT3XwuvXW9BeRt8 r/IoiCnLLVrr40OH8L15RvBtoag1UWFb0oFdKRjMG5AS/ydxr8X+gsyMnsWVAxIJ7GQbZfQsyvp QSy2eS0ey+FW7aL6Wa/2WWQ== X-Google-Smtp-Source: AGHT+IF5VwhfDwFkkz0RNP4hdicHfuNY6pJqQwTSSeUmfbLEP1/IRR0I2ApAClPpKugjZhskT8IDcbh94c8otLZ8KA== X-Received: from coltonlewis-kvm.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:14ce]) (user=coltonlewis job=sendgmr) by 2002:a05:6638:2396:b0:4c0:9a05:44d0 with SMTP id 8926c6da1cb9f-4d017d7b001mr570237173.1.1725482547230; Wed, 04 Sep 2024 13:42:27 -0700 (PDT) Date: Wed, 4 Sep 2024 20:41:29 +0000 In-Reply-To: <20240904204133.1442132-1-coltonlewis@google.com> X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Post: List-Subscribe: , , List-Unsubscribe: Mime-Version: 1.0 References: <20240904204133.1442132-1-coltonlewis@google.com> X-Mailer: git-send-email 2.46.0.469.g59c65b2a67-goog Message-ID: <20240904204133.1442132-2-coltonlewis@google.com> Subject: [PATCH 1/5] arm: perf: Drop unused functions From: Colton Lewis To: kvm@vger.kernel.org Cc: Oliver Upton , Sean Christopherson , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , Will Deacon , Russell King , Catalin Marinas , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Naveen N Rao , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Thomas Gleixner , Borislav Petkov , Dave Hansen , x86@kernel.org, "H . Peter Anvin" , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, Colton Lewis perf_instruction_pointer() and perf_misc_flags() aren't used anywhere in this particular perf implementation. Drop them. Signed-off-by: Colton Lewis Acked-by: Mark Rutland --- arch/arm/include/asm/perf_event.h | 7 ------- arch/arm/kernel/perf_callchain.c | 17 ----------------- 2 files changed, 24 deletions(-) diff --git a/arch/arm/include/asm/perf_event.h b/arch/arm/include/asm/perf_event.h index bdbc1e590891..c08f16f2e243 100644 --- a/arch/arm/include/asm/perf_event.h +++ b/arch/arm/include/asm/perf_event.h @@ -8,13 +8,6 @@ #ifndef __ARM_PERF_EVENT_H__ #define __ARM_PERF_EVENT_H__ -#ifdef CONFIG_PERF_EVENTS -struct pt_regs; -extern unsigned long perf_instruction_pointer(struct pt_regs *regs); -extern unsigned long perf_misc_flags(struct pt_regs *regs); -#define perf_misc_flags(regs) perf_misc_flags(regs) -#endif - #define perf_arch_fetch_caller_regs(regs, __ip) { \ (regs)->ARM_pc = (__ip); \ frame_pointer((regs)) = (unsigned long) __builtin_frame_address(0); \ diff --git a/arch/arm/kernel/perf_callchain.c b/arch/arm/kernel/perf_callchain.c index 1d230ac9d0eb..a2601b1ef318 100644 --- a/arch/arm/kernel/perf_callchain.c +++ b/arch/arm/kernel/perf_callchain.c @@ -96,20 +96,3 @@ perf_callchain_kernel(struct perf_callchain_entry_ctx *entry, struct pt_regs *re arm_get_current_stackframe(regs, &fr); walk_stackframe(&fr, callchain_trace, entry); } - -unsigned long perf_instruction_pointer(struct pt_regs *regs) -{ - return instruction_pointer(regs); -} - -unsigned long perf_misc_flags(struct pt_regs *regs) -{ - int misc = 0; - - if (user_mode(regs)) - misc |= PERF_RECORD_MISC_USER; - else - misc |= PERF_RECORD_MISC_KERNEL; - - return misc; -} From patchwork Wed Sep 4 20:41:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colton Lewis X-Patchwork-Id: 1981011 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20230601 header.b=KWPFJ35y; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=linuxppc-dev+bounces-1022-incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Wzcm42S2vz1yg3 for ; Thu, 5 Sep 2024 08:36:20 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Wzcm41QKZz2yhR; Thu, 5 Sep 2024 08:36:20 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip="2607:f8b0:4864:20::d4a" ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1725482551; cv=none; b=fAR+925JEEeT9GWnCUYM5hvE+BwC68cQ89mCqkRgce6t7hYu7ss5l+kccnxE61GAjZxGS1w4d2xFru7DDtqPW2q4o1VuifxrQySP2a3DtcyVB43lvfuC1z3a3frwIp3hUfkx/LG34Nl7AOdW32s+OKsDJWC/I8MwHXl1rnPXN+se5KKo2rUSmuDJKSHAlTXXcZiBbSlpwupbRjyc8vushYD/xM5+vbHgzD9XvuIXWea1TE91WI0dpurPQ78BOts3JRP2yEKnSMcY6zd0WDozKNwASdRzpTsrM33QuIpOnavf1xfMOZ4wLyXqxmzw69WEW7GWkfHczpxdNArcJdVMCQ== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1725482551; c=relaxed/relaxed; bh=qQqk9Qlo1o8ZnG3JB2VpNOlHMqoqEuVOZxeNHBbD724=; h=DKIM-Signature:Date:In-Reply-To:Mime-Version:References: Message-ID:Subject:From:To:Cc:Content-Type; b=DdZaNtRDDXMyYfS/4IP1gvE7R8Ts0KIzOWEWl9JVXK4xxYLEnoRrQaVgCMn/+0pHbWr0/3B5LXdW+MNUncG+wfXPNIVZrnNbv/M3FJri9Ji3PeHHYxPwZ/XSWjSgpkhbSVLCjt//+FvLLVooIJ97+wXPY06WRZDLqDEDkubDc520LbJNwvOO3fFxxyT90M6V97nkM8bj8VcvIWDL6vR8YK6bCxgV5cu0LOhHICJ+zYzwJQY9mZbDBZbyFhW61JGwiJ7tn5rt3qXx0NbThKVRx0keg/xSpOjKiLmEX78vkuoXCyd4OgQhAFDh+rsptuE0veZCtoT93U/wgRL8N/0++w== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=reject dis=none) header.from=google.com; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20230601 header.b=KWPFJ35y; dkim-atps=neutral; spf=pass (client-ip=2607:f8b0:4864:20::d4a; helo=mail-io1-xd4a.google.com; envelope-from=3nmbyzgskdgebnksnmkdvhrfnnfkd.bnlkhmtwoob-cdukhrsr.nyk9ar.nqf@flex--coltonlewis.bounces.google.com; receiver=lists.ozlabs.org) smtp.mailfrom=flex--coltonlewis.bounces.google.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20230601 header.b=KWPFJ35y; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=flex--coltonlewis.bounces.google.com (client-ip=2607:f8b0:4864:20::d4a; helo=mail-io1-xd4a.google.com; envelope-from=3nmbyzgskdgebnksnmkdvhrfnnfkd.bnlkhmtwoob-cdukhrsr.nyk9ar.nqf@flex--coltonlewis.bounces.google.com; receiver=lists.ozlabs.org) Received: from mail-io1-xd4a.google.com (mail-io1-xd4a.google.com [IPv6:2607:f8b0:4864:20::d4a]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4WzZDk2Wsxz2yQJ for ; Thu, 5 Sep 2024 06:42:30 +1000 (AEST) Received: by mail-io1-xd4a.google.com with SMTP id ca18e2360f4ac-82a55adf8dcso520325539f.2 for ; Wed, 04 Sep 2024 13:42:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1725482548; x=1726087348; darn=lists.ozlabs.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=qQqk9Qlo1o8ZnG3JB2VpNOlHMqoqEuVOZxeNHBbD724=; b=KWPFJ35yJ73NaT5GxdeJUcCLWLwUHZKnINMXto/PgEja/JpwYhFc2Rz3M47fDvKVxp Qr444QWYt/t9Nqr5svmLgU+3qZMLcWmQ9xzBhdVK39/ifaTln8tnIUBfo+P0A2JjuQT/ xvRPaQyMBRe38c43Qzttc+oy1r6GHE8YUce7IluuzhX8SNZGp+wyqtouHJoX2J4fKLnS Ynm+qrNBZ1X6sFy/aX+E/rKp96bFH9+UaABqolhFy7TF49zD7yXdoTpFdSZ6r2C6LDkB P/G2st5F9cklDCFDhqT0rRl3rWEwl+Su+lltqIrABH9ij4WFKBDlikvsAHw1FosM2S9R xygw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725482548; x=1726087348; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=qQqk9Qlo1o8ZnG3JB2VpNOlHMqoqEuVOZxeNHBbD724=; b=g0jnxF5N3TbPVTGB/OykziQWJSLUeiJL9K0A5F/dnljmTlGOhQWy6kOVplOaSwl4he pXwJs5Y0U1osP7/q3YL/FrznbfOYGRvcAnEO8Sxw5NGGM6iyGsh5++XIBq/1VvjbraS9 NZ0A7QvUq3N/DnMTv1x/iAw7Rc7L2VSZxiUv1wrx7L6IGRL09UKCJbL7U2j6aZcyofM5 2Ueb9WLSyReegrgMYJbyjDKHQwdtoFwkvYyQeHBtk0Werpg+88mgNJcgW+ps/zQ0FQr6 oX3zCa9PRaXeEDbhuniKCoz05b205sclOTxQsXB3yOwlgIOo5GvsL7eoITLgdVyWqOhH 3pWQ== X-Forwarded-Encrypted: i=1; AJvYcCWlEEYyDBY+x43Vhz4HSAbv8aH0Djn8CYpFvBEimPz3nT1cSf2A9BDsvudULfaHKFw8Cw2QgtrRxdzXKmA=@lists.ozlabs.org X-Gm-Message-State: AOJu0YzLuqc2jMDtzOm4YVEbJLPX7Kxw7+6RzePn1SZiZDYDqNYDa02B rsE57eeM53PZwHURlhu22D16FYhuU0W7oCcECQoDtdOHInjfe2qlE4BweX2hUAoqT8dJnj1YviL QgcSHavLmiQ0l0PJLD9lGWg== X-Google-Smtp-Source: AGHT+IHPF+sZuedNT/jMh+JCzWvvgTeTbKWh6yVWIbPtF10R4fPBteXez+IZX/IIgxw2NVpdi4FMQd2TV471KaO8wg== X-Received: from coltonlewis-kvm.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:14ce]) (user=coltonlewis job=sendgmr) by 2002:a05:6602:13ce:b0:829:eeca:d4b8 with SMTP id ca18e2360f4ac-82a262ff6f1mr64966839f.4.1725482548414; Wed, 04 Sep 2024 13:42:28 -0700 (PDT) Date: Wed, 4 Sep 2024 20:41:30 +0000 In-Reply-To: <20240904204133.1442132-1-coltonlewis@google.com> X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Post: List-Subscribe: , , List-Unsubscribe: Mime-Version: 1.0 References: <20240904204133.1442132-1-coltonlewis@google.com> X-Mailer: git-send-email 2.46.0.469.g59c65b2a67-goog Message-ID: <20240904204133.1442132-3-coltonlewis@google.com> Subject: [PATCH 2/5] perf: Hoist perf_instruction_pointer() and perf_misc_flags() From: Colton Lewis To: kvm@vger.kernel.org Cc: Oliver Upton , Sean Christopherson , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , Will Deacon , Russell King , Catalin Marinas , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Naveen N Rao , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Thomas Gleixner , Borislav Petkov , Dave Hansen , x86@kernel.org, "H . Peter Anvin" , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, Colton Lewis For clarity, rename the arch-specific definitions of these functions to perf_arch_* to denote they are arch-specifc. Define the generic-named functions in one place where they can call the arch-specific ones as needed. Signed-off-by: Colton Lewis --- arch/arm64/include/asm/perf_event.h | 6 +++--- arch/arm64/kernel/perf_callchain.c | 4 ++-- arch/powerpc/include/asm/perf_event_server.h | 6 +++--- arch/powerpc/perf/core-book3s.c | 4 ++-- arch/s390/include/asm/perf_event.h | 6 +++--- arch/s390/kernel/perf_event.c | 4 ++-- arch/x86/events/core.c | 4 ++-- arch/x86/include/asm/perf_event.h | 10 +++++----- include/linux/perf_event.h | 9 ++++++--- kernel/events/core.c | 10 ++++++++++ 10 files changed, 38 insertions(+), 25 deletions(-) diff --git a/arch/arm64/include/asm/perf_event.h b/arch/arm64/include/asm/perf_event.h index eb7071c9eb34..31a5584ed423 100644 --- a/arch/arm64/include/asm/perf_event.h +++ b/arch/arm64/include/asm/perf_event.h @@ -11,9 +11,9 @@ #ifdef CONFIG_PERF_EVENTS struct pt_regs; -extern unsigned long perf_instruction_pointer(struct pt_regs *regs); -extern unsigned long perf_misc_flags(struct pt_regs *regs); -#define perf_misc_flags(regs) perf_misc_flags(regs) +extern unsigned long perf_arch_instruction_pointer(struct pt_regs *regs); +extern unsigned long perf_arch_misc_flags(struct pt_regs *regs); +#define perf_arch_misc_flags(regs) perf_misc_flags(regs) #define perf_arch_bpf_user_pt_regs(regs) ®s->user_regs #endif diff --git a/arch/arm64/kernel/perf_callchain.c b/arch/arm64/kernel/perf_callchain.c index e8ed5673f481..01a9d08fc009 100644 --- a/arch/arm64/kernel/perf_callchain.c +++ b/arch/arm64/kernel/perf_callchain.c @@ -39,7 +39,7 @@ void perf_callchain_kernel(struct perf_callchain_entry_ctx *entry, arch_stack_walk(callchain_trace, entry, current, regs); } -unsigned long perf_instruction_pointer(struct pt_regs *regs) +unsigned long perf_arch_instruction_pointer(struct pt_regs *regs) { if (perf_guest_state()) return perf_guest_get_ip(); @@ -47,7 +47,7 @@ unsigned long perf_instruction_pointer(struct pt_regs *regs) return instruction_pointer(regs); } -unsigned long perf_misc_flags(struct pt_regs *regs) +unsigned long perf_arch_misc_flags(struct pt_regs *regs) { unsigned int guest_state = perf_guest_state(); int misc = 0; diff --git a/arch/powerpc/include/asm/perf_event_server.h b/arch/powerpc/include/asm/perf_event_server.h index 5995614e9062..41587d3f8446 100644 --- a/arch/powerpc/include/asm/perf_event_server.h +++ b/arch/powerpc/include/asm/perf_event_server.h @@ -102,8 +102,8 @@ struct power_pmu { int __init register_power_pmu(struct power_pmu *pmu); struct pt_regs; -extern unsigned long perf_misc_flags(struct pt_regs *regs); -extern unsigned long perf_instruction_pointer(struct pt_regs *regs); +extern unsigned long perf_arch_misc_flags(struct pt_regs *regs); +extern unsigned long perf_arch_instruction_pointer(struct pt_regs *regs); extern unsigned long int read_bhrb(int n); /* @@ -111,7 +111,7 @@ extern unsigned long int read_bhrb(int n); * if we have hardware PMU support. */ #ifdef CONFIG_PPC_PERF_CTRS -#define perf_misc_flags(regs) perf_misc_flags(regs) +#define perf_arch_misc_flags(regs) perf_misc_flags(regs) #endif /* diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c index 42867469752d..dc01aa604cc1 100644 --- a/arch/powerpc/perf/core-book3s.c +++ b/arch/powerpc/perf/core-book3s.c @@ -2332,7 +2332,7 @@ static void record_and_restart(struct perf_event *event, unsigned long val, * Called from generic code to get the misc flags (i.e. processor mode) * for an event_id. */ -unsigned long perf_misc_flags(struct pt_regs *regs) +unsigned long perf_arch_misc_flags(struct pt_regs *regs) { u32 flags = perf_get_misc_flags(regs); @@ -2346,7 +2346,7 @@ unsigned long perf_misc_flags(struct pt_regs *regs) * Called from generic code to get the instruction pointer * for an event_id. */ -unsigned long perf_instruction_pointer(struct pt_regs *regs) +unsigned long perf_arch_instruction_pointer(struct pt_regs *regs) { unsigned long siar = mfspr(SPRN_SIAR); diff --git a/arch/s390/include/asm/perf_event.h b/arch/s390/include/asm/perf_event.h index 9917e2717b2b..f2d83289ec7a 100644 --- a/arch/s390/include/asm/perf_event.h +++ b/arch/s390/include/asm/perf_event.h @@ -37,9 +37,9 @@ extern ssize_t cpumf_events_sysfs_show(struct device *dev, /* Perf callbacks */ struct pt_regs; -extern unsigned long perf_instruction_pointer(struct pt_regs *regs); -extern unsigned long perf_misc_flags(struct pt_regs *regs); -#define perf_misc_flags(regs) perf_misc_flags(regs) +extern unsigned long perf_arch_instruction_pointer(struct pt_regs *regs); +extern unsigned long perf_arch_misc_flags(struct pt_regs *regs); +#define perf_arch_misc_flags(regs) perf_misc_flags(regs) #define perf_arch_bpf_user_pt_regs(regs) ®s->user_regs /* Perf pt_regs extension for sample-data-entry indicators */ diff --git a/arch/s390/kernel/perf_event.c b/arch/s390/kernel/perf_event.c index 5fff629b1a89..f9000ab49f4a 100644 --- a/arch/s390/kernel/perf_event.c +++ b/arch/s390/kernel/perf_event.c @@ -57,7 +57,7 @@ static unsigned long instruction_pointer_guest(struct pt_regs *regs) return sie_block(regs)->gpsw.addr; } -unsigned long perf_instruction_pointer(struct pt_regs *regs) +unsigned long perf_arch_instruction_pointer(struct pt_regs *regs) { return is_in_guest(regs) ? instruction_pointer_guest(regs) : instruction_pointer(regs); @@ -84,7 +84,7 @@ static unsigned long perf_misc_flags_sf(struct pt_regs *regs) return flags; } -unsigned long perf_misc_flags(struct pt_regs *regs) +unsigned long perf_arch_misc_flags(struct pt_regs *regs) { /* Check if the cpum_sf PMU has created the pt_regs structure. * In this case, perf misc flags can be easily extracted. Otherwise, diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c index be01823b1bb4..760ad067527c 100644 --- a/arch/x86/events/core.c +++ b/arch/x86/events/core.c @@ -2940,7 +2940,7 @@ static unsigned long code_segment_base(struct pt_regs *regs) return 0; } -unsigned long perf_instruction_pointer(struct pt_regs *regs) +unsigned long perf_arch_instruction_pointer(struct pt_regs *regs) { if (perf_guest_state()) return perf_guest_get_ip(); @@ -2948,7 +2948,7 @@ unsigned long perf_instruction_pointer(struct pt_regs *regs) return regs->ip + code_segment_base(regs); } -unsigned long perf_misc_flags(struct pt_regs *regs) +unsigned long perf_arch_misc_flags(struct pt_regs *regs) { unsigned int guest_state = perf_guest_state(); int misc = 0; diff --git a/arch/x86/include/asm/perf_event.h b/arch/x86/include/asm/perf_event.h index 91b73571412f..feb87bf3d2e9 100644 --- a/arch/x86/include/asm/perf_event.h +++ b/arch/x86/include/asm/perf_event.h @@ -536,15 +536,15 @@ struct x86_perf_regs { u64 *xmm_regs; }; -extern unsigned long perf_instruction_pointer(struct pt_regs *regs); -extern unsigned long perf_misc_flags(struct pt_regs *regs); -#define perf_misc_flags(regs) perf_misc_flags(regs) +extern unsigned long perf_arch_instruction_pointer(struct pt_regs *regs); +extern unsigned long perf_arch_misc_flags(struct pt_regs *regs); +#define perf_arch_misc_flags(regs) perf_arch_misc_flags(regs) #include /* - * We abuse bit 3 from flags to pass exact information, see perf_misc_flags - * and the comment with PERF_EFLAGS_EXACT. + * We abuse bit 3 from flags to pass exact information, see + * perf_arch_misc_flags() and the comment with PERF_EFLAGS_EXACT. */ #define perf_arch_fetch_caller_regs(regs, __ip) { \ (regs)->ip = (__ip); \ diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index 1a8942277dda..d061e327ad54 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h @@ -1633,10 +1633,13 @@ extern void perf_tp_event(u16 event_type, u64 count, void *record, struct task_struct *task); extern void perf_bp_event(struct perf_event *event, void *data); -#ifndef perf_misc_flags -# define perf_misc_flags(regs) \ +extern unsigned long perf_misc_flags(struct pt_regs *regs); +extern unsigned long perf_instruction_pointer(struct pt_regs *regs); + +#ifndef perf_arch_misc_flags +# define perf_arch_misc_flags(regs) \ (user_mode(regs) ? PERF_RECORD_MISC_USER : PERF_RECORD_MISC_KERNEL) -# define perf_instruction_pointer(regs) instruction_pointer(regs) +# define perf_arch_instruction_pointer(regs) instruction_pointer(regs) #endif #ifndef perf_arch_bpf_user_pt_regs # define perf_arch_bpf_user_pt_regs(regs) regs diff --git a/kernel/events/core.c b/kernel/events/core.c index c973e3c11e03..4384f6c49930 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -6915,6 +6915,16 @@ void perf_unregister_guest_info_callbacks(struct perf_guest_info_callbacks *cbs) EXPORT_SYMBOL_GPL(perf_unregister_guest_info_callbacks); #endif +unsigned long perf_misc_flags(unsigned long pt_regs *regs) +{ + return perf_arch_misc_flags(regs); +} + +unsigned long perf_instruction_pointer(unsigned long pt_regs *regs) +{ + return perf_arch_instruction_pointer(regs); +} + static void perf_output_sample_regs(struct perf_output_handle *handle, struct pt_regs *regs, u64 mask) From patchwork Wed Sep 4 20:41:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colton Lewis X-Patchwork-Id: 1981017 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20230601 header.b=bK3AwCgS; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=linuxppc-dev+bounces-1024-incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WzcmX037Pz1yg3 for ; Thu, 5 Sep 2024 08:36:43 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4WzcmW4fRwz2xCj; Thu, 5 Sep 2024 08:36:43 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip="2607:f8b0:4864:20::b4a" ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1725482553; cv=none; b=HoA0plkifxO0GOW4ZR3r0pHwq0JfbEt817SZkTUVm8vktCRvYwl+KkjeYGJAcb01ReIDUZQNcypIHsDz7qorkb1fyIxCT7gQ54tQd/pyeOdFIOP7e0MxTxHE3RR/LgZYaAGBPJlcr8F8FS6wSIGS824EH+RIB+k8nLk+O48HibX8z7B3k2QWjVX79+QEoSHfVH3jkh49u1MXgqqo1X9v2rNzPxbpscC+/xUTZoJfvEA/yXjMtbq2FuWxCP+m6oPmAr/Vcb7mTpgrbxim5iHK2mmh5aGkVlhTkwFZdxZzwIaeRpVX8NZnWB5gcoRkBL2sRCkOBBgYScV0WY0+xAhctg== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1725482553; c=relaxed/relaxed; bh=yF63B/qB2C2mWkkN7Sev/IpM9OI4DaouC6axCITdljM=; h=DKIM-Signature:Date:In-Reply-To:Mime-Version:References: Message-ID:Subject:From:To:Cc:Content-Type; b=LDhpauJdxsHt6S5tQvDmpW8c5nJU26lUq/54evp6GMIvkEyLJx7rmlt7knVRymob2WxjmHJQQ3WEcro5OAYozIQh1sZDW2zxsvPLCNBmZmrjwPRFU48sRvHxk9d0GNW9qKeZ++Bpo8UzKxoRyX8CM0VFRBHycIhTqLP7745bDX6kEDjVk8B+HLItCtwQh3uI3gAAu6FPyWdkXig1p4qpYaT8I1LRFDH7GCUn8SnCGyveVYVSu7Jto8pi6QZWuvt8glfXMvs7Rsg7N7qILZ4IEriblneR5vjKBiOViImhE4WoNBlJUdqhULKZG0DH+RcFveGAOlHamgXS9oeZUyEYOw== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=reject dis=none) header.from=google.com; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20230601 header.b=bK3AwCgS; dkim-atps=neutral; spf=pass (client-ip=2607:f8b0:4864:20::b4a; helo=mail-yb1-xb4a.google.com; envelope-from=3ncbyzgskdgicoltonlewisgoogle.comlinuxppc-devlists.ozlabs.org@flex--coltonlewis.bounces.google.com; receiver=lists.ozlabs.org) smtp.mailfrom=flex--coltonlewis.bounces.google.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20230601 header.b=bK3AwCgS; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=flex--coltonlewis.bounces.google.com (client-ip=2607:f8b0:4864:20::b4a; helo=mail-yb1-xb4a.google.com; envelope-from=3ncbyzgskdgicoltonlewisgoogle.comlinuxppc-devlists.ozlabs.org@flex--coltonlewis.bounces.google.com; receiver=lists.ozlabs.org) Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4WzZDm5YFKz2y6G for ; Thu, 5 Sep 2024 06:42:32 +1000 (AEST) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-e1a74f824f9so163915276.1 for ; Wed, 04 Sep 2024 13:42:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1725482549; x=1726087349; darn=lists.ozlabs.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=yF63B/qB2C2mWkkN7Sev/IpM9OI4DaouC6axCITdljM=; b=bK3AwCgSVd0unqz6bnppuhSzs9ir7EUwELyIEknhq1aUvzjzeWbbuEKGwsel/Nj41k vpjXF8+rSgfW36wVyGZPokjhlAxvjWqfp/78BMRu9ASjOdLzJckEg1KYXnPLkserJk4c vtmup7VrENchc/LmlMEqjqIZ7hHbALdmjuL5SM2cqahCNG0kuTlXJzrcKgLzsRtMEDsV y+YYAB8QC5rZsqLCBsOPevG1xVT46uhacRxhpbHSSGSdlt/t0XhfV+k++j+3mE4X/ueA aN+seJwyUisyDUUW3AnAMeb/fnHVE5kU9oKpU7XL+qaG1uUkxID3C+rOH8SoDCUgdbnt bHEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725482549; x=1726087349; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=yF63B/qB2C2mWkkN7Sev/IpM9OI4DaouC6axCITdljM=; b=tXSjfHA1pjQyZTLYr5D+LRivfevYbbULPP+1kUX+SQsUx6F3zF36KOPD8XowKPB8Sw M9u5ltpmzwOsaxAiAsI811F7kPljMzBqH01O5bV5KFXxue1SuXLU+KyjXoR65xGvvjLR 388mdAF5RQ8otRu8DHcgBxbdgA9+8fVqhel7MfwjVj577alIVxN1kTDu8VF8v3lcsI20 TXx4ukKIwhWXC0Wd7dFDSzUCEZjpq4wmy+3wWjF/nW36ts7ZkrUO5D0kQeUaTg3gwkxb mCxlEOfZAEcnsK0h5J5T4eWXd8TfK58oRGdHvQSFWj+M5/uhYctQcDDwFRNI2oCxiPKd oC0g== X-Forwarded-Encrypted: i=1; AJvYcCXw5revb4kuCuDrhYIAKn+GeGahriuqelox6gHcFxBbseL7lh+utTzudMoKK1PMDDoSqp09SjRBu3lqPg4=@lists.ozlabs.org X-Gm-Message-State: AOJu0YwVvYbYeaLt80xmhxI9z/dhPUbHL3+AZpQleYtl3S4ukgRK6xsR AW2CKYwyQbUxRyz0CfvHrWXKjW2OmsqsBtx0B8fBhDsOfcWZ/OL0Gxgg6MOHg/m9qVZ/p8kFqnr lUsCkWvNhWu4v51odYXcugw== X-Google-Smtp-Source: AGHT+IHnCAVHhUCP2jsg9QIrX/diUprCN0SQ2aen+GiK4qTsvqjsoiEZxfc39AEm13a4QPmtILTk2j9/pAbTWP98xg== X-Received: from coltonlewis-kvm.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:14ce]) (user=coltonlewis job=sendgmr) by 2002:a25:b612:0:b0:e0e:499f:3d9b with SMTP id 3f1490d57ef6-e1a79fb4d7bmr28585276.1.1725482549203; Wed, 04 Sep 2024 13:42:29 -0700 (PDT) Date: Wed, 4 Sep 2024 20:41:31 +0000 In-Reply-To: <20240904204133.1442132-1-coltonlewis@google.com> X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Post: List-Subscribe: , , List-Unsubscribe: Mime-Version: 1.0 References: <20240904204133.1442132-1-coltonlewis@google.com> X-Mailer: git-send-email 2.46.0.469.g59c65b2a67-goog Message-ID: <20240904204133.1442132-4-coltonlewis@google.com> Subject: [PATCH 3/5] powerpc: perf: Use perf_arch_instruction_pointer() From: Colton Lewis To: kvm@vger.kernel.org Cc: Oliver Upton , Sean Christopherson , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , Will Deacon , Russell King , Catalin Marinas , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Naveen N Rao , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Thomas Gleixner , Borislav Petkov , Dave Hansen , x86@kernel.org, "H . Peter Anvin" , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, Colton Lewis Make sure powerpc uses the arch-specific function now that those have been reorganized. Signed-off-by: Colton Lewis --- arch/powerpc/perf/callchain.c | 2 +- arch/powerpc/perf/callchain_32.c | 2 +- arch/powerpc/perf/callchain_64.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/perf/callchain.c b/arch/powerpc/perf/callchain.c index 6b4434dd0ff3..26aa26482c9a 100644 --- a/arch/powerpc/perf/callchain.c +++ b/arch/powerpc/perf/callchain.c @@ -51,7 +51,7 @@ perf_callchain_kernel(struct perf_callchain_entry_ctx *entry, struct pt_regs *re lr = regs->link; sp = regs->gpr[1]; - perf_callchain_store(entry, perf_instruction_pointer(regs)); + perf_callchain_store(entry, perf_arch_instruction_pointer(regs)); if (!validate_sp(sp, current)) return; diff --git a/arch/powerpc/perf/callchain_32.c b/arch/powerpc/perf/callchain_32.c index ea8cfe3806dc..ddcc2d8aa64a 100644 --- a/arch/powerpc/perf/callchain_32.c +++ b/arch/powerpc/perf/callchain_32.c @@ -139,7 +139,7 @@ void perf_callchain_user_32(struct perf_callchain_entry_ctx *entry, long level = 0; unsigned int __user *fp, *uregs; - next_ip = perf_instruction_pointer(regs); + next_ip = perf_arch_instruction_pointer(regs); lr = regs->link; sp = regs->gpr[1]; perf_callchain_store(entry, next_ip); diff --git a/arch/powerpc/perf/callchain_64.c b/arch/powerpc/perf/callchain_64.c index 488e8a21a11e..115d1c105e8a 100644 --- a/arch/powerpc/perf/callchain_64.c +++ b/arch/powerpc/perf/callchain_64.c @@ -74,7 +74,7 @@ void perf_callchain_user_64(struct perf_callchain_entry_ctx *entry, struct signal_frame_64 __user *sigframe; unsigned long __user *fp, *uregs; - next_ip = perf_instruction_pointer(regs); + next_ip = perf_arch_instruction_pointer(regs); lr = regs->link; sp = regs->gpr[1]; perf_callchain_store(entry, next_ip); From patchwork Wed Sep 4 20:41:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colton Lewis X-Patchwork-Id: 1981016 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20230601 header.b=LsxfWjjf; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=linuxppc-dev+bounces-1023-incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WzcmN1Hl6z1yg3 for ; Thu, 5 Sep 2024 08:36:36 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4WzcmM6fqxz2yn9; Thu, 5 Sep 2024 08:36:35 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip="2607:f8b0:4864:20::b4a" ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1725482552; cv=none; b=NDFwKLhlF49XguDz+0HkP+A/50zz3dVAhkiB9zs12KicB4f36IxQo+kt7PQRJ96FGJ6Zk0VdK4TTqrQko5ltcl5QWmUcnyeNeUieP/+6L/9/AY/BudRIFZ8kClwYJFzbt4DVeX1el8vWzKB0iLbqemXKJ6Cafu/CUS8RopQC01r6i9YXKuTTmfwF4kkgjz7Pj1DO7Xx+Rq7oMJTEcmtEd22JfPNEF3JcIaIrkMNY6SpcKHhQ1+a9AOnld/28/UgJnnaTswbVT4jvhzvVUrfQkTWnFKEDPZvrRm/wRA4M1tCEc6fyyD0e44PwBHQvPiECOfX6snam3lO0a9j4tZ47qA== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1725482552; c=relaxed/relaxed; bh=i72PSOIXWhCeY4HgM9YgFlmZggdii21Cl4McUfu+68c=; h=DKIM-Signature:Date:In-Reply-To:Mime-Version:References: Message-ID:Subject:From:To:Cc:Content-Type; b=dAIsmLOphS09pPJf5kUtJ4qO05SaLRkVZLtKv6fGwDPLT8VCgTbkzShsNNRaLTbQJJ7RGHebQoQZUcRDBk6vPbmBtRoZTwtELWC9wVGdJVprGu34UJ139eJ8mCzmM/4h8AHbWfABs8zrwnx0lChOvkbyLm1rZTHMmx7wXjqwfJ2+vKPv7tV5wp6MsyYOK7YU6mlAgmCciZezRu4iARdrM60NezCBar/chcX/AKqgY+7EYzYo/wRmwCIufUKKSR5YvmVquGd26jtN8qR2KQGk5zjaJ3LzdKABD9PaaKwVgKHbPnUO2uShv5WK1ifkxNNRxjNv1ORxQTAhjWMGK8JWxQ== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=reject dis=none) header.from=google.com; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20230601 header.b=LsxfWjjf; dkim-atps=neutral; spf=pass (client-ip=2607:f8b0:4864:20::b4a; helo=mail-yb1-xb4a.google.com; envelope-from=3nsbyzgskdgmdpmupomfxjthpphmf.dpnmjovyqqd-efwmjtut.pambct.psh@flex--coltonlewis.bounces.google.com; receiver=lists.ozlabs.org) smtp.mailfrom=flex--coltonlewis.bounces.google.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20230601 header.b=LsxfWjjf; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=flex--coltonlewis.bounces.google.com (client-ip=2607:f8b0:4864:20::b4a; helo=mail-yb1-xb4a.google.com; envelope-from=3nsbyzgskdgmdpmupomfxjthpphmf.dpnmjovyqqd-efwmjtut.pambct.psh@flex--coltonlewis.bounces.google.com; receiver=lists.ozlabs.org) Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4WzZDm5WMDz2xy0 for ; Thu, 5 Sep 2024 06:42:32 +1000 (AEST) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-e1a892d8438so184255276.3 for ; Wed, 04 Sep 2024 13:42:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1725482550; x=1726087350; darn=lists.ozlabs.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=i72PSOIXWhCeY4HgM9YgFlmZggdii21Cl4McUfu+68c=; b=LsxfWjjfNa+1LJxZ/rAoonXtwYe5Jyp2nLTL2vzkJrgEvuf6shkqwyifOE3YKn+zNl JPn+w0V1g4pNi9XTJ7hQygtGwhgAOsY/HBuaWwJkgso9nO47VNNnIGDtUlDQFLh/5xqy TsStGAW5uXFxZcUy9VHa9FVTgsSI0cReGCWtlT0rjQvRlaAiixg/xv1KDv8K7q2S64Aq O7PXmYKS5Uzb193lbTKnUwlRE4hTK3gSQdtfh7OWwsnlhSElvfTiF8a9xaGhyrxoXb1a KNAc50LjjpG21V0Km5HaD/uDHQQgmhrslKW6CTa83B+wK55ZfLFMgMviWmM8jC2uw99I gAeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725482550; x=1726087350; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=i72PSOIXWhCeY4HgM9YgFlmZggdii21Cl4McUfu+68c=; b=ehTEOymNg00ECqOukyk+EY3Y2y/QlUSGQh2JPkAd3zIaRjzPminO+6MbTL4gfAxiRY pisQ15hI4eGztqnh2hiQoAEqpS6WK7xxByafBOPyY9X9hZSM8zgMZokD7T5M9f2r7tDO VjG80+pBh+DMLX4CRa0FpRF82r/ykUX6A2ywWc9a65GjQWikPO7N4T4m0YgteUtftB8u li+LppPLJCDf4qbHa+OE89i+I//V/p2FPgjjoJnWCXROPP3Pz60HBvEx913ZzQQ2CaVm j5CFKKpAqyHOMl79eLZnGNvQzUJuc1EOlpKlWtXTPbBzdc7MoGP8mEYZeAKAeNDb8AXY znqg== X-Forwarded-Encrypted: i=1; AJvYcCVT2wEuj0ch4DPv3bIrULEYgApxeVIgI78g/pujUIoL54S/xtMmKiBNVqwvKBCTagXmp0zMWumKY3gHvEg=@lists.ozlabs.org X-Gm-Message-State: AOJu0YxlixDNwkv9aDpvNyhWXep4g8zFoSVOrY6kEQoeTynjAWdsyIzf EdY4IUzjwG1fMSq1T+xcekYBzimMpZJj0JKueblRaOgncLVzd0Gu8zWOHwaqVZEPCSDFlHOuZwt NnCbnd/ougx+w9Y86ZOhbgg== X-Google-Smtp-Source: AGHT+IFmR24uVrOJthtOJz6K2WVb+jtHXjG+hacdDNR8Ql4EFrmp0GPrZ3zw2M5BxgYPY6TLAf+W8lj+BLe1iw09KQ== X-Received: from coltonlewis-kvm.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:14ce]) (user=coltonlewis job=sendgmr) by 2002:a25:361a:0:b0:e0e:445b:606 with SMTP id 3f1490d57ef6-e1d0e58575emr4988276.0.1725482550264; Wed, 04 Sep 2024 13:42:30 -0700 (PDT) Date: Wed, 4 Sep 2024 20:41:32 +0000 In-Reply-To: <20240904204133.1442132-1-coltonlewis@google.com> X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Post: List-Subscribe: , , List-Unsubscribe: Mime-Version: 1.0 References: <20240904204133.1442132-1-coltonlewis@google.com> X-Mailer: git-send-email 2.46.0.469.g59c65b2a67-goog Message-ID: <20240904204133.1442132-5-coltonlewis@google.com> Subject: [PATCH 4/5] x86: perf: Refactor misc flag assignments From: Colton Lewis To: kvm@vger.kernel.org Cc: Oliver Upton , Sean Christopherson , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , Will Deacon , Russell King , Catalin Marinas , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Naveen N Rao , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Thomas Gleixner , Borislav Petkov , Dave Hansen , x86@kernel.org, "H . Peter Anvin" , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, Colton Lewis Break the assignment logic for misc flags into their own respective functions to reduce the complexity of the nested logic. Signed-off-by: Colton Lewis --- arch/x86/events/core.c | 31 +++++++++++++++++++++++-------- arch/x86/include/asm/perf_event.h | 2 ++ 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c index 760ad067527c..87457e5d7f65 100644 --- a/arch/x86/events/core.c +++ b/arch/x86/events/core.c @@ -2948,16 +2948,34 @@ unsigned long perf_arch_instruction_pointer(struct pt_regs *regs) return regs->ip + code_segment_base(regs); } +static unsigned long common_misc_flags(struct pt_regs *regs) +{ + if (regs->flags & PERF_EFLAGS_EXACT) + return PERF_RECORD_MISC_EXACT_IP; + + return 0; +} + +unsigned long perf_arch_guest_misc_flags(struct pt_regs *regs) +{ + unsigned long guest_state = perf_guest_state(); + unsigned long flags = common_misc_flags(); + + if (guest_state & PERF_GUEST_USER) + flags |= PERF_RECORD_MISC_GUEST_USER; + else if (guest_state & PERF_GUEST_ACTIVE) + flags |= PERF_RECORD_MISC_GUEST_KERNEL; + + return flags; +} + unsigned long perf_arch_misc_flags(struct pt_regs *regs) { unsigned int guest_state = perf_guest_state(); - int misc = 0; + unsigned long misc = common_misc_flags(); if (guest_state) { - if (guest_state & PERF_GUEST_USER) - misc |= PERF_RECORD_MISC_GUEST_USER; - else - misc |= PERF_RECORD_MISC_GUEST_KERNEL; + misc |= perf_arch_guest_misc_flags(regs); } else { if (user_mode(regs)) misc |= PERF_RECORD_MISC_USER; @@ -2965,9 +2983,6 @@ unsigned long perf_arch_misc_flags(struct pt_regs *regs) misc |= PERF_RECORD_MISC_KERNEL; } - if (regs->flags & PERF_EFLAGS_EXACT) - misc |= PERF_RECORD_MISC_EXACT_IP; - return misc; } diff --git a/arch/x86/include/asm/perf_event.h b/arch/x86/include/asm/perf_event.h index feb87bf3d2e9..d95f902acc52 100644 --- a/arch/x86/include/asm/perf_event.h +++ b/arch/x86/include/asm/perf_event.h @@ -538,7 +538,9 @@ struct x86_perf_regs { extern unsigned long perf_arch_instruction_pointer(struct pt_regs *regs); extern unsigned long perf_arch_misc_flags(struct pt_regs *regs); +extern unsigned long perf_arch_guest_misc_flags(struct pt_regs *regs); #define perf_arch_misc_flags(regs) perf_arch_misc_flags(regs) +#define perf_arch_guest_misc_flags(regs) perf_arch_guest_misc_flags(regs) #include From patchwork Wed Sep 4 20:41:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colton Lewis X-Patchwork-Id: 1981018 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20230601 header.b=NMrxw7eV; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=linuxppc-dev+bounces-1025-incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Wzcmq01NHz1yg3 for ; Thu, 5 Sep 2024 08:36:58 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Wzcmp5JB9z2yl1; Thu, 5 Sep 2024 08:36:58 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip="2607:f8b0:4864:20::d49" ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1725482554; cv=none; b=HS6Hq3zsPyINNNriLxplUCvJPNNcLvyt9gp8zfWedmFS0I+eZZa/bbWQI3cmprBX2MLvamJXQjiBfUqXH48Sy7zEuYFKSsx3S4/rYe1fQARPnVo/hGdr4U2JueAFPAv8COlhUcddfoBTFE7eQYKjyVT3iWvGaNA0kETtSMXmcr389SMayI7TbagHHdu6oWn+mieBAV/vxvbV1vedxScIjTw1561PITTPa+0zV/ONC0Kxyf49mcgq47MbCQ45da+wojxh8HISALaHdqBddRoJubo06XRiHT+5gsKiFWMi0redtC7gRO0TvBO6SCg7+3qEWRKy8Jew1QnxvJg56FG3ew== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1725482554; c=relaxed/relaxed; bh=ZQ6pbNS+V/v0w7+0Yvg7TstZGOzD6SJqSq8ykXuoLos=; h=DKIM-Signature:Date:In-Reply-To:Mime-Version:References: Message-ID:Subject:From:To:Cc:Content-Type; b=H2iOmLpxycs5SSGyUnSTVxYx3RepCfwr9m4Ofj6CgkTw475dcYni/7mpOcNGqwDj8BcTAoG0Lu4+96f7KylAMjgwF0xMtnBFA6Miay+fa2k7Ii8FiEyR4Cw+ArBlvNrS5FnU8v0rt44Aas+vrwGZxMY08jJXVnA6PWPa9bAOU9DYkHTu5wyIe9rv6BDfWkKFcvXtZviEwaBYshaIu8ZmXRVxpkUvCAEcJiqakBvxsY9RmUfrmQmyb2BtgK11VWu1/tMPpZcEzuWfIum77xO88zrZDDcQsqXtfNZ4fz1HqLMh5K3w3YHQyRSwBbX9jKkeIfI6sMBx4xPO39yryEyK4A== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=reject dis=none) header.from=google.com; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20230601 header.b=NMrxw7eV; dkim-atps=neutral; spf=pass (client-ip=2607:f8b0:4864:20::d49; helo=mail-io1-xd49.google.com; envelope-from=3n8byzgskdgqeqnvqpngykuiqqing.eqonkpwzrre-fgxnkuvu.qbncdu.qti@flex--coltonlewis.bounces.google.com; receiver=lists.ozlabs.org) smtp.mailfrom=flex--coltonlewis.bounces.google.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20230601 header.b=NMrxw7eV; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=flex--coltonlewis.bounces.google.com (client-ip=2607:f8b0:4864:20::d49; helo=mail-io1-xd49.google.com; envelope-from=3n8byzgskdgqeqnvqpngykuiqqing.eqonkpwzrre-fgxnkuvu.qbncdu.qti@flex--coltonlewis.bounces.google.com; receiver=lists.ozlabs.org) Received: from mail-io1-xd49.google.com (mail-io1-xd49.google.com [IPv6:2607:f8b0:4864:20::d49]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4WzZDp2bvwz2xy0 for ; Thu, 5 Sep 2024 06:42:34 +1000 (AEST) Received: by mail-io1-xd49.google.com with SMTP id ca18e2360f4ac-82a36f1515cso696314439f.2 for ; Wed, 04 Sep 2024 13:42:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1725482551; x=1726087351; darn=lists.ozlabs.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=ZQ6pbNS+V/v0w7+0Yvg7TstZGOzD6SJqSq8ykXuoLos=; b=NMrxw7eVkkiaGHUGQS+29l5AmICfmTbkmbxkXaoOpjT8yvkGmf5TULQNDQ8cFL2cyC 3DbbeN3UooeYHnasNDQMQLMs3rSgkcPQl8Tma/LBJs9Kc+prwSV9v0hotIG1P+MONCqK Zg69g38MDmSSnaJX9ZLZfdHlHNdgakJpOBKF9fjzRIJOTAmcOR4P5p0GkBb2sI3O6+Q3 RdKFwReIT6YHZgkHJ4tiNRFfGV66cOHOqFA9+FutadZKT7eU+5Ry2kk1xj6UgMUdpY6K wkPXLiv1ZFdJnq5kYhFGXYdPSsvR/fH8rAze3Eu8maAQ5oHtuQqEPUgIgVFnT1UlCcUi tb6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725482551; x=1726087351; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ZQ6pbNS+V/v0w7+0Yvg7TstZGOzD6SJqSq8ykXuoLos=; b=q8+wTfzL6EQYv7CAjPRABssiDxkX5sw+a17px5pM4UBxgMKD7bJyHY/mpZwsWv+O4i ove72amQJYunCfAKbLetUkTJ3XWBOTSqinKJKPT0tuCmQajui8hc879f0owHjXqQZLQB DVBiYCyoIRPKAu1Kh6E8fCuFaHVc926MGuEB6541zlIMu4dszideEZy9/89mUBzEWOvb as/q/pvASkUSXfOyvxwU9GFRCcbcUF9IsIv1T8TiX6gT/A15rPWkLiR9lVdX+leXqPPJ csk04nGm/pMgOExCtOuVImBaaqUyvVhLzB65LE8BNAlDPK5cEa8+0UMX1kwiBGWKOuhH YitQ== X-Forwarded-Encrypted: i=1; AJvYcCXnfbKL5KXQ9scnd1fIhZwrj4adnxUXFv24DfIP3S0X4IGUX6rpmPrFsCgTzMT/xuNWkRhEYAVCQLRM4RE=@lists.ozlabs.org X-Gm-Message-State: AOJu0YxoNK8vTkMdGlvcPKQKSiluFDf6oHilNmGh2kCSQ365g7Fpwgtm hAh1GJwTbgHQfGNxqut8qPy/flsqTL0VMC7TpO63Ic+7Xid81s+8EJikuZmoR/js2j7gigV21Hy nTbLYdDnQd5hH9efPHg8DQQ== X-Google-Smtp-Source: AGHT+IH9EBCT8+ykT+OpvYVmgAL1GejG/P9BrG7iuA2P0w+bQDK+bVWQxO99M8Ql2oemuKA/7xEPoMWRBeRAyi1Jng== X-Received: from coltonlewis-kvm.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:14ce]) (user=coltonlewis job=sendgmr) by 2002:a05:6638:40a3:b0:4b9:ad96:2adc with SMTP id 8926c6da1cb9f-4d017e9afc4mr1111520173.4.1725482551325; Wed, 04 Sep 2024 13:42:31 -0700 (PDT) Date: Wed, 4 Sep 2024 20:41:33 +0000 In-Reply-To: <20240904204133.1442132-1-coltonlewis@google.com> X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Post: List-Subscribe: , , List-Unsubscribe: Mime-Version: 1.0 References: <20240904204133.1442132-1-coltonlewis@google.com> X-Mailer: git-send-email 2.46.0.469.g59c65b2a67-goog Message-ID: <20240904204133.1442132-6-coltonlewis@google.com> Subject: [PATCH 5/5] perf: Correct perf sampling with guest VMs From: Colton Lewis To: kvm@vger.kernel.org Cc: Oliver Upton , Sean Christopherson , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , Will Deacon , Russell King , Catalin Marinas , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Naveen N Rao , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Thomas Gleixner , Borislav Petkov , Dave Hansen , x86@kernel.org, "H . Peter Anvin" , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, Colton Lewis Previously any PMU overflow interrupt that fired while a VCPU was loaded was recorded as a guest event whether it truly was or not. This resulted in nonsense perf recordings that did not honor perf_event_attr.exclude_guest and recorded guest IPs where it should have recorded host IPs. Reorganize that plumbing to record perf events correctly even when VCPUs are loaded. Signed-off-by: Colton Lewis --- arch/arm64/include/asm/perf_event.h | 4 ---- arch/arm64/kernel/perf_callchain.c | 28 ---------------------------- arch/x86/events/core.c | 16 ++++------------ include/linux/perf_event.h | 21 +++++++++++++++++++-- kernel/events/core.c | 21 +++++++++++++++++---- 5 files changed, 40 insertions(+), 50 deletions(-) diff --git a/arch/arm64/include/asm/perf_event.h b/arch/arm64/include/asm/perf_event.h index 31a5584ed423..ee45b4e77347 100644 --- a/arch/arm64/include/asm/perf_event.h +++ b/arch/arm64/include/asm/perf_event.h @@ -10,10 +10,6 @@ #include #ifdef CONFIG_PERF_EVENTS -struct pt_regs; -extern unsigned long perf_arch_instruction_pointer(struct pt_regs *regs); -extern unsigned long perf_arch_misc_flags(struct pt_regs *regs); -#define perf_arch_misc_flags(regs) perf_misc_flags(regs) #define perf_arch_bpf_user_pt_regs(regs) ®s->user_regs #endif diff --git a/arch/arm64/kernel/perf_callchain.c b/arch/arm64/kernel/perf_callchain.c index 01a9d08fc009..9b7f26b128b5 100644 --- a/arch/arm64/kernel/perf_callchain.c +++ b/arch/arm64/kernel/perf_callchain.c @@ -38,31 +38,3 @@ void perf_callchain_kernel(struct perf_callchain_entry_ctx *entry, arch_stack_walk(callchain_trace, entry, current, regs); } - -unsigned long perf_arch_instruction_pointer(struct pt_regs *regs) -{ - if (perf_guest_state()) - return perf_guest_get_ip(); - - return instruction_pointer(regs); -} - -unsigned long perf_arch_misc_flags(struct pt_regs *regs) -{ - unsigned int guest_state = perf_guest_state(); - int misc = 0; - - if (guest_state) { - if (guest_state & PERF_GUEST_USER) - misc |= PERF_RECORD_MISC_GUEST_USER; - else - misc |= PERF_RECORD_MISC_GUEST_KERNEL; - } else { - if (user_mode(regs)) - misc |= PERF_RECORD_MISC_USER; - else - misc |= PERF_RECORD_MISC_KERNEL; - } - - return misc; -} diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c index 87457e5d7f65..2049b70c5af7 100644 --- a/arch/x86/events/core.c +++ b/arch/x86/events/core.c @@ -2942,9 +2942,6 @@ static unsigned long code_segment_base(struct pt_regs *regs) unsigned long perf_arch_instruction_pointer(struct pt_regs *regs) { - if (perf_guest_state()) - return perf_guest_get_ip(); - return regs->ip + code_segment_base(regs); } @@ -2971,17 +2968,12 @@ unsigned long perf_arch_guest_misc_flags(struct pt_regs *regs) unsigned long perf_arch_misc_flags(struct pt_regs *regs) { - unsigned int guest_state = perf_guest_state(); unsigned long misc = common_misc_flags(); - if (guest_state) { - misc |= perf_arch_guest_misc_flags(regs); - } else { - if (user_mode(regs)) - misc |= PERF_RECORD_MISC_USER; - else - misc |= PERF_RECORD_MISC_KERNEL; - } + if (user_mode(regs)) + misc |= PERF_RECORD_MISC_USER; + else + misc |= PERF_RECORD_MISC_KERNEL; return misc; } diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index d061e327ad54..968f3edd95e4 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h @@ -1633,8 +1633,9 @@ extern void perf_tp_event(u16 event_type, u64 count, void *record, struct task_struct *task); extern void perf_bp_event(struct perf_event *event, void *data); -extern unsigned long perf_misc_flags(struct pt_regs *regs); -extern unsigned long perf_instruction_pointer(struct pt_regs *regs); +extern unsigned long perf_misc_flags(struct perf_event *event, struct pt_regs *regs); +extern unsigned long perf_instruction_pointer(struct perf_event *event, + struct pt_regs *regs); #ifndef perf_arch_misc_flags # define perf_arch_misc_flags(regs) \ @@ -1645,6 +1646,22 @@ extern unsigned long perf_instruction_pointer(struct pt_regs *regs); # define perf_arch_bpf_user_pt_regs(regs) regs #endif +#ifndef perf_arch_guest_misc_flags +static inline unsigned long perf_arch_guest_misc_flags(struct pt_regs *regs) +{ + unsigned long guest_state = perf_guest_state(); + + if (guest_state & PERF_GUEST_USER) + return PERF_RECORD_MISC_GUEST_USER; + + if (guest_state & PERF_GUEST_ACTIVE) + return PERF_RECORD_MISC_GUEST_KERNEL; + + return 0; +} +# define perf_arch_guest_misc_flags(regs) perf_arch_guest_misc_flags(regs) +#endif + static inline bool has_branch_stack(struct perf_event *event) { return event->attr.sample_type & PERF_SAMPLE_BRANCH_STACK; diff --git a/kernel/events/core.c b/kernel/events/core.c index 4384f6c49930..e1a66c9c3773 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -6915,13 +6915,26 @@ void perf_unregister_guest_info_callbacks(struct perf_guest_info_callbacks *cbs) EXPORT_SYMBOL_GPL(perf_unregister_guest_info_callbacks); #endif -unsigned long perf_misc_flags(unsigned long pt_regs *regs) +static bool is_guest_event(struct perf_event *event) { + return !event->attr.exclude_guest && perf_guest_state(); +} + +unsigned long perf_misc_flags(struct perf_event *event, + struct pt_regs *regs) +{ + if (is_guest_event(event)) + return perf_arch_guest_misc_flags(regs); + return perf_arch_misc_flags(regs); } -unsigned long perf_instruction_pointer(unsigned long pt_regs *regs) +unsigned long perf_instruction_pointer(struct perf_event *event, + struct pt_regs *regs) { + if (is_guest_event(event)) + return perf_guest_get_ip(); + return perf_arch_instruction_pointer(regs); } @@ -7737,7 +7750,7 @@ void perf_prepare_sample(struct perf_sample_data *data, __perf_event_header__init_id(data, event, filtered_sample_type); if (filtered_sample_type & PERF_SAMPLE_IP) { - data->ip = perf_instruction_pointer(regs); + data->ip = perf_instruction_pointer(event, regs); data->sample_flags |= PERF_SAMPLE_IP; } @@ -7901,7 +7914,7 @@ void perf_prepare_header(struct perf_event_header *header, { header->type = PERF_RECORD_SAMPLE; header->size = perf_sample_data_size(data, event); - header->misc = perf_misc_flags(regs); + header->misc = perf_misc_flags(event, regs); /* * If you're adding more sample types here, you likely need to do