From patchwork Thu Sep 12 20:51: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: 1984856 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=wO1rPknp; 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-1298-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) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X4V3k42ZCz1y1C for ; Fri, 13 Sep 2024 06:51:46 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4X4V3f1lJsz2yXd; Fri, 13 Sep 2024 06:51:42 +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=1726174302; cv=none; b=X3hg11mKCSBaG4jSUPGuUzs/6fpuY2OU1dmlXz9Vl2foX6zoFAnJJqxJAlZxcsdcAcuJUyNqNMqGaknGwZ7TOJ/x1bhkL0t29zTFkQbEHzWxMsxuidlFVt+1i9dcfzSxdUT35wsgvmjHb7C9LKUZ53C+1O10qsvMlx20/nahBTZurvVmDceDU7wfgaqfggzFugJLjuzjCj2FN1+ICMenOCeB5BHCTlvB6loRYGZsAqz7TKPnBPK9qUQ8aC37R6NZ2AJAMoDIz1qh1mCU5PwysyLjUUbAtZe0EyzusluIea5whWS75F2WrvP56jquBys1aeQnfRNt1Z9L5pGi3qWAhw== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1726174302; c=relaxed/relaxed; bh=qgNa1Xt6FnUSigDEF0LKTlfU3qkapsIsHTMTckjKajA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=SiXmT/OKYyyAOlDyDqqTBhU/zfdpDOvCsPhnrwVQQooBfnbr+Ki8Lw7Jb8OGxaRbMjvWbuRloBAxsK7+vWakWGa9eROkkVXPYhTqbaoc4BZPP6/5mMC2wTnapERfvReO2Z3FjPOe+mS+l7AuMnMOqYAmesXFHL1G1rUeRqnra4tpZ1Kw6CXBKJfMqN/raAlfiWv2j2K5vNl7K1fb2CdvS7GPJwjOOc5dEm11Z2X6JelCTQtOhIua5ECPCQmkvePLZbSeIPhZ+EHVNrKCR2g0/N/2kPKQZyI8UHp9d8SErIxv0hCasJy1OOGWjvwRO+mV+BXbZgvuV1Fu15b1sKmD3w== 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=wO1rPknp; dkim-atps=neutral; spf=pass (client-ip=2607:f8b0:4864:20::d4a; helo=mail-io1-xd4a.google.com; envelope-from=3wvtjzgskdmwu63b653we0ay66y3w.u64305cf77u-vwd30aba.6h3sta.69y@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=wO1rPknp; 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=3wvtjzgskdmwu63b653we0ay66y3w.u64305cf77u-vwd30aba.6h3sta.69y@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 4X4V3d5g9Qz2yVZ for ; Fri, 13 Sep 2024 06:51:41 +1000 (AEST) Received: by mail-io1-xd4a.google.com with SMTP id ca18e2360f4ac-82cf30e0092so23856939f.3 for ; Thu, 12 Sep 2024 13:51:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726174297; x=1726779097; 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=qgNa1Xt6FnUSigDEF0LKTlfU3qkapsIsHTMTckjKajA=; b=wO1rPknpffyVlEYdpX5BB5fy7vO+4XG1RyRPpaXllN/4mJz7hCjEPGAjfjAlgOQUTf kTZBHAaW8/MY0R76FBHpD8FkNz2xEpYYyYNM50W+mdcmUiXlOXCEPx9qCxcrfybDzkrL IzVYR8uOHTGNPWIPvWW7I2St0QWn90DlV+MXoPNILI7ziqB2Fo/plCS6PCFHM42mtGE4 23y4nc0wIwJJrql/w2WUdK+uM+1Wis0/2+x0UDzGw/ydTQSYljf7CeUqrPTGZDHytgO/ APDMbawsLcSNrNEcFexz4eRjvouW4P/W6BXO4/ppyV15aGjIHAqBjjUAaWT2EMFhh5ef vEdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726174297; x=1726779097; 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=qgNa1Xt6FnUSigDEF0LKTlfU3qkapsIsHTMTckjKajA=; b=ER8Bob3OgvsvunMc+4H0Em5VIQNohkGlB2+pmiNlbVTdUeQ5Kniq52bHHF1jsdIgRK +MKI8AqgnVm3M6QTP76RX/6xIJRbqrWqH8I7d90UNe6c4bAjh5e2IuWZ30pzWYdhHtOt Nrf1gjdgdMHXVd+gPBQZ9dRiIh6HOEb/TfLw/JnRL/u0H2qbUiv9844MAy5XO8K6Qm7I ERXcnobVIk4WX7956413wSwzYsO0UT60sOXu1ttT37Ws2V26uWGLBNA7H3dAdJzcblUj BNMN2RzLURYBZ+iQMj1xxJSTJuC+/KSAgBXFpYKdpYC6Pp1oxrUSB/7Ae+uYuHia+oBR OHaA== X-Forwarded-Encrypted: i=1; AJvYcCUjz/a89c6R0TWh6T8BcXgAy399Z7thnG0iQ3pbSTuV0Sk0HLEGOH/6qSdi6rb2xf1SThRewGuVU6qmH30=@lists.ozlabs.org X-Gm-Message-State: AOJu0YwHa0UZgFREKWfWtOqLA/VnIvDgp+LfEozq9tKVMJ4KpiFXt82h Ql0jeWDmFOzyvf1KrCD6Seuh1PnBM9xlFVvWz3W79lQ1+vI5OPelMvXKkxNhavDDgRlRDutEOq2 TUw4sb1fKud9ecYVp5e9Sew== X-Google-Smtp-Source: AGHT+IHFcuQ/5a/hhlw1GFJJYrc3if7U/QuDvmMiMeVXDMjRO3Gjmvd8L1tjO+zUGwBFmEAgEN40MjfIHW+YAT2pgQ== X-Received: from coltonlewis-kvm.c.googlers.com ([fda3:e722:ac3:cc00:11b:3898:ac11:fa18]) (user=coltonlewis job=sendgmr) by 2002:a05:6638:860c:b0:4d2:27c:18f8 with SMTP id 8926c6da1cb9f-4d36e33a768mr13751173.1.1726174297086; Thu, 12 Sep 2024 13:51:37 -0700 (PDT) Date: Thu, 12 Sep 2024 20:51:29 +0000 In-Reply-To: <20240912205133.4171576-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: <20240912205133.4171576-1-coltonlewis@google.com> X-Mailer: git-send-email 2.46.0.662.g92d0881bb0-goog Message-ID: <20240912205133.4171576-2-coltonlewis@google.com> Subject: [PATCH v3 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 For arm's implementation, perf_instruction_pointer() and perf_misc_flags() are equivalent to the generic versions in include/linux/perf_event.h so arch/arm doesn't need to provide its own versions. Drop them here. Signed-off-by: Colton Lewis --- arch/arm/include/asm/perf_event.h | 7 ------- arch/arm/kernel/perf_callchain.c | 17 ----------------- 2 files changed, 24 deletions(-) -- 2.46.0.662.g92d0881bb0-goog 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 Thu Sep 12 20:51: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: 1984857 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=NbnBwwWb; 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-1297-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) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X4V3k46RWz1y2K for ; Fri, 13 Sep 2024 06:51:46 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4X4V3f0v8cz2yVd; Fri, 13 Sep 2024 06:51:42 +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=1726174302; cv=none; b=FkcxUqhowwDWa2KQ3C1CsXeDkVDO6dgfSnzdk3pc7PyETvCEXxfwPB5wib5vUnDTGsuMBs2mNRoRY38QjeW/yej8S1Pn9w2VRSKuC5QkKQGSyfxwCNqFMy6FzvpcQAtS8AKc5rp8xLeF07b1jOOUlqybLD/TWZaUU2FFeVgRGy6Z7w2AVF0xoON/R51+AhMi6lFOIrtiI+xqcErEoipUy6sXgNzUzHt5ctaRVU67xN11JgO0//BMjN3adHecrtt50Rlucd+mRMUthRqHTeKmT3MXg0Q/WuhBdKafp8WlvD1nWLf0U8VTpIB4kHoGjC1AYy6ztAprq9hHWoEpAqibog== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1726174302; c=relaxed/relaxed; bh=bBuBduG209Jab8XMLtuQHzsmOY9s44tUcmK5TPfdVN4=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=bDo+o3ro8IgZwiVjIj0KGdyF/pGohyJsDcL0KvaifeFQxEyc+h66EOqqiAsaCjTIHHnn+spknWcwN0WzFl2Am64wPVB2dyh53mqdi/B0YnLTxE/XyobdM3wTacPy7HPQ2A4mmaS4A6XJXfEQFAq2GcNJRWIrlMXdpKMiaN03p8pYs/oUQE+WZP97/vKH4K2qEEWSpyffolRfzwJhPwiZu0db2DOxRZ5p69xGnnlIcncy4lKjmCxeEwrrTp2Y47RCXjniFu1LXM7vWe8qNVFeVkaR4XttV8Zf85XMqPisQ1X16ccTTlaiK+LAcS5IG5fFxIgI/Mrc3P8/NCVVhTUsHg== 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=NbnBwwWb; dkim-atps=neutral; spf=pass (client-ip=2607:f8b0:4864:20::d49; helo=mail-io1-xd49.google.com; envelope-from=3wltjzgskdm0v74c764xf1bz77z4x.v75416dg88v-wxe41bcb.7i4tub.7az@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=NbnBwwWb; 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=3wltjzgskdm0v74c764xf1bz77z4x.v75416dg88v-wxe41bcb.7i4tub.7az@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 4X4V3d34FDz2yGh for ; Fri, 13 Sep 2024 06:51:39 +1000 (AEST) Received: by mail-io1-xd49.google.com with SMTP id ca18e2360f4ac-82a32368e13so221937439f.0 for ; Thu, 12 Sep 2024 13:51:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726174298; x=1726779098; 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=bBuBduG209Jab8XMLtuQHzsmOY9s44tUcmK5TPfdVN4=; b=NbnBwwWbb+3jc9VHXXORcny2ASXVg2gMYXxfVya2pbtxZABKzqPyrSpJegibJ334ct Bm4TpBRKsxoKPbxVJ8NvreQb53/zfZjwyvo7qzY7msyYrHCrV1DJRaBjdvrmC83iGtDD 1XSqk0A9mEBmkDQ3ENZslrtf3W25cNobsaOaOYZ3+jEEFe71d2PnzoJ9E8BxAu2SSq7O QEi3d5aYDp7pgDnhlnU6r26Xl4yWwLJJOSLAhWzf0IjMWL4Dq0JwaQ2XjLHUVBnniW3B ch8o6jrg942KS2hk7hF29GvACc7xQSj3gVe3fetImFJuuVcKQNmIalUUXFAQp7ArxaT5 3g5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726174298; x=1726779098; 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=bBuBduG209Jab8XMLtuQHzsmOY9s44tUcmK5TPfdVN4=; b=abTI1UeOiBw71vwBBeqdd2NxOrXUfs6EHBB/NZg6xtsBOIoUFPNQO8KBLc/5WSizq6 +Ha6aeLw5Rc7kjoEDU5V18lpJ3saeZNkSf1zyhd4YjDE9myy+YDjwRz1eV+UL47WnsIk ZQ3I3vttqbx38evOHRMR60Q8ZUCM4+0UN9lVWiJ1BRwWR5zglnhP0HOnUZNC2mcGX4ez QcPO8JzjzeETGmFvKf/sRLj/L7jnliHF2Jw0Fnn01RFID9JebEfI9GD9vsKU8M2fWH63 QWCMISSYcOIc9nTiFtMFWLwKFn97u3WIuUmKoRMEffwNuUhBTjDcmaDEr6/jxtUe/Dtb mpGA== X-Forwarded-Encrypted: i=1; AJvYcCWEF3+RVWSiXILv5F6vaurn05A7EtY27ncxoqu/U9roRyo+OrJ/4CfJ2WUeYaArkYVJpAEQ3HHVkvf9g/s=@lists.ozlabs.org X-Gm-Message-State: AOJu0YxuXn+niUblU2x7uAg6CrO5x0nU1Id6N4mUbQk4dIZfEmZ/VwnA hIB4dgLZ+dmpZPYDPHLaKtOYE39zznH4GSDSgcJRvg7FuK12QsSV9WpcqNF8P4POCblUeuI2C1p PgL5/pnRrjHxqqznoV+Ya7Q== X-Google-Smtp-Source: AGHT+IHuyxoF1O+4DvTuzFh/ZZP8349qH8nbD/zqC3/tkxgPNCvBr0r1+e3VqEUG1lpnklg0vGHAk+SStZ+us7ma2A== X-Received: from coltonlewis-kvm.c.googlers.com ([fda3:e722:ac3:cc00:11b:3898:ac11:fa18]) (user=coltonlewis job=sendgmr) by 2002:a05:6602:60c8:b0:82d:581:8867 with SMTP id ca18e2360f4ac-82d1f980157mr5857639f.3.1726174298132; Thu, 12 Sep 2024 13:51:38 -0700 (PDT) Date: Thu, 12 Sep 2024 20:51:30 +0000 In-Reply-To: <20240912205133.4171576-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: <20240912205133.4171576-1-coltonlewis@google.com> X-Mailer: git-send-email 2.46.0.662.g92d0881bb0-goog Message-ID: <20240912205133.4171576-3-coltonlewis@google.com> Subject: [PATCH v3 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 8a6c6bbcd658..eeabbf791a8c 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -6921,6 +6921,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(struct pt_regs *regs) +{ + return perf_arch_misc_flags(regs); +} + +unsigned long perf_instruction_pointer(struct 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 Thu Sep 12 20:51: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: 1984861 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=rlT0T+bU; 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-1301-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 4X4V4530jpz1y1C for ; Fri, 13 Sep 2024 06:52:05 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4X4V3g0l5nz2ydW; Fri, 13 Sep 2024 06:51: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::114a" ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1726174303; cv=none; b=NuUHD83JeU4Zw5na1kGuYiUh04uaoN/DEtxZA0+J5Lx/uZSeMxioyd57fObjJRoyHbqNr/i0u7sumuBogXJ+WuZEtcOxJKO0dGlMUREBPYO7fp/2P0OzNfqJTlcIU1cCB+ZPDNW912kj+cwgHdLeuRTep6icxIA5w4B+6MZvTsiw7BWDSBU6rHWKQMRmjOvl3feEftOJVu+nG5JQ2bDU8wLfU4o18Fy5r3L00rgkybXN/PSZfAAqfXNHiy/uPtf5yVxrpgYWOLjk8+hFNUYi6OMCvsMJG2vyNb2Phq2foDnczqxMTrfmp7U0lX7CVud1NY78t1HO2RzOKe2/BVsWHA== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1726174303; c=relaxed/relaxed; bh=2R8Y3DFBOrXpT6Dp+2pnByuz3JsPwrzU4P/6bkl9CfA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=AAfUflVm1KBvbv7gPNcvDkPZBd5774w1OCNdr5EUeRndtGY1RIUFfETswGOdtdGv6aG86LPpllZlJpYxj/5Dm6K1Is/xEmdyCYmWKBl4FKrVMW1gnc75NxxkJXvi+Fm8yndEPy2v8RuiKzrPv4hVdECUPYZBpwPhmrnCMDTW/hHYW86rOhpCMk9h6diuYuAaaonj2bvlUETDZRXB8sqKsIwgjb/Vymnq2O4n3uTXYag2VOYz5uCTsuMy3wOPyKxbabwGcyKU2EgLQZdbeAH+BOF3V9QlLahCj6fPZnfZ138EqDTwFo7tlY6of7hUp9mi1G5OQhDtJa5JVT60RUo+DQ== 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=rlT0T+bU; dkim-atps=neutral; spf=pass (client-ip=2607:f8b0:4864:20::114a; helo=mail-yw1-x114a.google.com; envelope-from=3w1tjzgskdm4w85d875yg2c08805y.w86527eh99w-xyf52cdc.8j5uvc.8b0@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=rlT0T+bU; 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::114a; helo=mail-yw1-x114a.google.com; envelope-from=3w1tjzgskdm4w85d875yg2c08805y.w86527eh99w-xyf52cdc.8j5uvc.8b0@flex--coltonlewis.bounces.google.com; receiver=lists.ozlabs.org) Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) (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 4X4V3f4QLCz2yYy for ; Fri, 13 Sep 2024 06:51:42 +1000 (AEST) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-6d3aa5a672dso29383627b3.2 for ; Thu, 12 Sep 2024 13:51:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726174299; x=1726779099; 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=2R8Y3DFBOrXpT6Dp+2pnByuz3JsPwrzU4P/6bkl9CfA=; b=rlT0T+bUzPgQtR0OONMzCS6mCt/kHqm5V6mwGGFEG/Whrz54uyX9Ve7iIfVOGPQ8Ef uKdRfpH9v1i0/+LQ8U1rktvgEQlNpqUpjN8rqWEsTmfJ6J9cnU5Tg2l6MNUE4tKW7UKD CxzLnLCX3HxrnGzVRcULls05dbx6/8YwsXbH3VA1/EtHXdCdW4Omqt8xaOf9a577mxwG HXsR4MRSWfVCuKwOUH2fo/Wf5uxLjA1iTCm/AJoNY8j7Y4qm9qJewbYyE25c7QetS2dJ +wtXEi8Ymsc1b+mf8UwzMCWWK6rRVTfBG7KvsZ3tC2ssOJs4tpbi40AhJpc0mQmlfso8 iXqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726174299; x=1726779099; 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=2R8Y3DFBOrXpT6Dp+2pnByuz3JsPwrzU4P/6bkl9CfA=; b=wwl3ZnAcjzIJAI9faD+9YW3hlyDUqa1cslaNC0ROyFIczhobWMIODrX75eIcpWz+qP 92bKywsXVU/xOEC6+lMtbehJvRUaLA9uvLK0bkAWEthATj7+fgFmYrOtimb4WvpbSuJ/ s6XcRgoc1t3x7HW21RkWLmOxtKZTWZhQicL7rYgzhamyXKUI8xA8At7WuY4TlWBwnnPz E+5wuxIPCEmB4rnMGE7L/s0Krh+q0+ZoZ/IUURoseAB2+zyTuzGXFUb/VqbiJ/0ZwPDG LoOwsind8liWJO5GositEZe9/pDzSiRk7WCIGOevTUj0ZdIdrZSUkx7so9LGyPLC3doX OEdQ== X-Forwarded-Encrypted: i=1; AJvYcCW6eamDuAsBHnpXAqj34WNDuFDgdjpXRY1aBBY7Fxl8SPqjK9FaepP2UHHj6TI1h9svqAjnLmdztCQvF8U=@lists.ozlabs.org X-Gm-Message-State: AOJu0YznT+CruTAKuRvkwHi8j5bBQe9gGITczarYQblFRGQ7tmdsC0G0 edqQKfFuSd3AZ86jTwjJ0Ab0JIfwuAIrNJvNKSiCMFsvm+SiQlkJjtEp1P+n7U66b6sLGaB6pGr GYezCKGHYoutfLHGbpygRTA== X-Google-Smtp-Source: AGHT+IFV1m07CCTdDWX2FOgecLasTDjDmm3XH/XZUgTEGDR6/YrsS27OTSnLSt+SciKeVBgsQCat9dX1tnl2/VgIOw== X-Received: from coltonlewis-kvm.c.googlers.com ([fda3:e722:ac3:cc00:11b:3898:ac11:fa18]) (user=coltonlewis job=sendgmr) by 2002:a05:6902:1743:b0:e03:3cfa:1aa7 with SMTP id 3f1490d57ef6-e1d9db9e1b8mr5314276.1.1726174299130; Thu, 12 Sep 2024 13:51:39 -0700 (PDT) Date: Thu, 12 Sep 2024 20:51:31 +0000 In-Reply-To: <20240912205133.4171576-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: <20240912205133.4171576-1-coltonlewis@google.com> X-Mailer: git-send-email 2.46.0.662.g92d0881bb0-goog Message-ID: <20240912205133.4171576-4-coltonlewis@google.com> Subject: [PATCH v3 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 Thu Sep 12 20:51: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: 1984859 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=vMloIj7T; 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-1300-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 4X4V3v2D4Pz1y2K for ; Fri, 13 Sep 2024 06:51:55 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4X4V3f5hPJz2yZS; Fri, 13 Sep 2024 06:51:42 +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=1726174302; cv=none; b=IHvXebEt2AjrsZy8M3sxHpvq8a/COXYdzNmGPpWgkUc7YMMcxBsSTzvPrSkfiq7ad/LRWEG79daKzyQ1Ak8y+i4HD4NlJPN6PfmWc9k4Gig1j9MMYtODNe+dyLscinVLObZ0viJQDjlD3ZN+R0Jc4/qqNbfmk72dFZyaeSA1dTzUMTwOKlqFIwT5JxXDcK3N5PqzNPAcxITtrCi0+dWREsg8I9LNH+CzuXTEPpXIrwTHOMhJNp50dTQ843J+oWo74MuYdw7sw5XOiRJU51IvYnI7lQ+tv3o+RpH65NqPCHygVvgvKgtGYYJnHL9Zz/mvEeLIRGHNZ5V5udWovKjbAQ== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1726174302; c=relaxed/relaxed; bh=3HOlQ/b1Vqnby1HRrJAa+4JPh1tcBF4UxpW0vveqy4M=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=NF075WRT/+QyZKuUiUZZmrPzoV1Qc/OlwfNj1/MDZKZ1XF2WlGqPwhmbEyYS/f2mkkWYl7OKVXuk0F8BGFpyv16haeR65OAuuIshCPWoSITatB9ICyhA4xxPAsQnPYkgUokqor0bzRB8unzYiw/RqHmIMGCJLrUonhLnWYxVQqjoX2R1h8wpfUNw2TCMS9gziVzKg6N4/8GAEzZW22uu7p9B5C3mdBDO3bKyajBAh0t7+H5u4uD9gpL97keuwRYp9ri4LGgn2svbAA6FvxbXOpewYOB3U69EsyWMePJil3nDFrikO5b2mnIAyrG7O5UEQ1PpsU5l/mYO6jj0WErgAA== 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=vMloIj7T; dkim-atps=neutral; spf=pass (client-ip=2607:f8b0:4864:20::d4a; helo=mail-io1-xd4a.google.com; envelope-from=3xftjzgskdm8x96e986zh3d19916z.x97638fiaax-yzg63ded.9k6vwd.9c1@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=vMloIj7T; 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=3xftjzgskdm8x96e986zh3d19916z.x97638fiaax-yzg63ded.9k6vwd.9c1@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 4X4V3f24Xcz2yYK for ; Fri, 13 Sep 2024 06:51:42 +1000 (AEST) Received: by mail-io1-xd4a.google.com with SMTP id ca18e2360f4ac-82aad3fa5edso170087039f.2 for ; Thu, 12 Sep 2024 13:51:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726174300; x=1726779100; 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=3HOlQ/b1Vqnby1HRrJAa+4JPh1tcBF4UxpW0vveqy4M=; b=vMloIj7TdOq/XX3Xy9ytmnC1H6BOVh9yM1sCaduz8JKBsFeW4pHkVlkQ2Z9g8+tG/S ddf5NR328PX5n1SFqogknU3QjrRLM70UDY4FzgyxkkpgtjhRQQS5sON82x4oM09qBtKt LLaEup3yqcckS7g6sLsRfNdamwoeZ5dzX1OtdANM7CYl2IERzvSt4Eyu+f8Rf7h8pJ6b i0JmxbrvX6hMfzT1CUD0p1sVtPXi72AdcG/5uPMBb47S82VV6Tpe6/SAjm698Amhy0us uAUqm2mNkbyD9CDXjXvHW6/jUs/Ec78N+yERWDB0U3G+UMAFWceyAVjc17HvFInTpqdu j99Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726174300; x=1726779100; 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=3HOlQ/b1Vqnby1HRrJAa+4JPh1tcBF4UxpW0vveqy4M=; b=SgCNDtYXleBD1nsl0jMDrqha5e5pR7PEKo1eAO8FpQw5T8CwaJM4WsTQyTv2lqEXIl oC8Ifb/c8IdAQ+H4GdBQ6osfA/fHiH8FBqQ4Kc7g/VIWmmVruna1WWMHj0BWNeXhm9rh JzfUrtu/B/h4cfeNida91KTq2SCRv2C/FQuTeSFQ8qk1NH0IuMUEJW8mMLnndclFpJlY gnClto5Bt2FoVi3bPf5XAy6pnaa+h+NxxwCyueTqbk/MeEXQc3R+Rl0twT+S7PftiJzl JNGVut8J0qPTimQjG6ufR2ZC7FdXJ5U+JqiSauqVn9RXtol8PTdgWiWS+lhqpN3jCZwy azXg== X-Forwarded-Encrypted: i=1; AJvYcCWCDsq9zBFCFXFFxEoBWyot2Z+Ts7WFmbLvk4dHY9iNytzX+iGQ6bvPZQTQvPDlW/D01fEghZgxfZQxVE0=@lists.ozlabs.org X-Gm-Message-State: AOJu0YziLxghFdZUO3dP5nZZLJKmKc7/8cpngzwi/eoKcEDFB5zpbNFo UOYeEqi64n75vrmG/b6JJAJwgcdzZsIyrkX8+N4npzj/k+SHX+zhK8oH+PBS0kcx1HgNqkeH9Kj g9eSRUNWASFmgsXudbLBvcA== X-Google-Smtp-Source: AGHT+IH+tyLe1qQliN4X6ik9ZMj1aIgWQ7X0DXUSN8bntx8eM08UGo31hDfdaqtl4MXbxod/0+xFT0h7PePUGuXbpA== X-Received: from coltonlewis-kvm.c.googlers.com ([fda3:e722:ac3:cc00:11b:3898:ac11:fa18]) (user=coltonlewis job=sendgmr) by 2002:a05:6602:2d86:b0:82c:eb15:1aae with SMTP id ca18e2360f4ac-82d1f8b0c0amr3300039f.1.1726174300197; Thu, 12 Sep 2024 13:51:40 -0700 (PDT) Date: Thu, 12 Sep 2024 20:51:32 +0000 In-Reply-To: <20240912205133.4171576-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: <20240912205133.4171576-1-coltonlewis@google.com> X-Mailer: git-send-email 2.46.0.662.g92d0881bb0-goog Message-ID: <20240912205133.4171576-5-coltonlewis@google.com> Subject: [PATCH v3 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..d51e5d24802b 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(regs); + + 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(regs); 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 Thu Sep 12 20:51: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: 1984865 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=hLmj5Hf3; 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-1302-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 4X4V4J6R5Qz1y1C for ; Fri, 13 Sep 2024 06:52:16 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4X4V3h711wz2yhZ; Fri, 13 Sep 2024 06:51:44 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip="2607:f8b0:4864:20::149" ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1726174304; cv=none; b=jj8YUqvbAIm5TQBJd/UD6v5v18xSW4JQRVVvBNwOPF8k5pI7bGYXZMS4Bauppva2f6fD+CwMlOg8fPr17RQNR4naj/MJoE5kaZS5NkWjcBKo3tK5ER3Zmdu0s2plVCGv7gUQE3wqHffdAIZlSJaUB8H/KBz2wrkgwIu38EALNlwYJzbtTBhMBXGNvZbCuSnfM53nuXtIGT5Vp+FKKms8rdxkrJb09nPk5zctM6rmxJ6s1e6L/y/EhyQhfV7ZuWSXVaUShtqQymwkJgNhA/b13eqqppeHbIrx2q/hDbESXxnZHadi/wgVFasGgrG9MtDDwxpF/L/6SkXzauqCdciMeg== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1726174304; c=relaxed/relaxed; bh=pN3motQEuLoryG8c/qRFsCpEmHTVQN30TnUfjf1L05Y=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=cK6Rt1H8pJx5PRwc/1RZqXq/pxhb8OKg9c7eXzjCFR64jguV+JUS9jVrnwyI3mK1qHhKIPQ9UAiGfQNvVz0ARXfQoPpUmNPKFzH/JDj2edBMFjTAm0rEuMLTwl0Z1lQ0oOZmalDPRErZWWUwOGutM1aVs+6eWYBbwxN0fmrwLjgNOtzDQUQadmHB0Zne6jl3TWgjH55nLqRmkD40+vw4wkbOb7hoIE9JbGsLqgJS3W0mHm74tozFEHGmg5XCI2zdgqeaX3rxAc2OGgtVuCb8IMKSyDsyX1Q5eK3VrpqBnd3POayB74P6BTrphwrE7AsoMu5JFrP0rGNvCoe1OVROmA== 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=hLmj5Hf3; dkim-atps=neutral; spf=pass (client-ip=2607:f8b0:4864:20::149; helo=mail-il1-x149.google.com; envelope-from=3xvtjzgskdnaya7fa970i4e2aa270.ya8749gjbby-z0h74efe.al7wxe.ad2@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=hLmj5Hf3; 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::149; helo=mail-il1-x149.google.com; envelope-from=3xvtjzgskdnaya7fa970i4e2aa270.ya8749gjbby-z0h74efe.al7wxe.ad2@flex--coltonlewis.bounces.google.com; receiver=lists.ozlabs.org) Received: from mail-il1-x149.google.com (mail-il1-x149.google.com [IPv6:2607:f8b0:4864:20::149]) (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 4X4V3h3zRJz2yYy for ; Fri, 13 Sep 2024 06:51:44 +1000 (AEST) Received: by mail-il1-x149.google.com with SMTP id e9e14a558f8ab-39f5605c674so3260145ab.3 for ; Thu, 12 Sep 2024 13:51:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726174301; x=1726779101; 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=pN3motQEuLoryG8c/qRFsCpEmHTVQN30TnUfjf1L05Y=; b=hLmj5Hf3zKI24SGTTzszTNGZ4cFTY4KipWh1w87d6ksWBpDB1x7gqAl6qP6OEVG53k 5aM3+8q/2YujW8UVAjL+k52EiWgPd6NYsFJpS9NDE72Lb6VFRkwSJpWlDqd57oRxxoXL NZ6tKdEBa0uAiQwJcs1HU5NbwJw0vXw7/kzK6F5eNh2pIbS4Ch8+sY7Qgrp+eEx1rkmA b6IrY8XA9tySy9v2CzeI37iIn5H7iq6JXAq5TN49I3hm1/xtmHonjIgeFMQ9GJ2GDIDB smG80YjwPf3+5p7P+Zo18wFvWr/6OUD6k1+rsh2SHkZY6zjMo8yCFYuwMd85qBWT0ZBt asXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726174301; x=1726779101; 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=pN3motQEuLoryG8c/qRFsCpEmHTVQN30TnUfjf1L05Y=; b=RUhrNpcaepBwh0qcpGIenBRVolBh+K+3a6LYuxuvspObd6CukjA/62k4FNop4zwZ+6 Bm/O2HNsCq4ZKX2ShwgHA5nqyaZeYegTK4r4yog3uKe+lyoD2/CzZy3G/V0jDVWmJNf9 eGnTWKiGbL6YgDm8Untr9fiB0a92ryXmwgmvUXDaxbnRqQwyKeVJfFx4xIoHlNfzRh6J b9lhYE040abSRpkglTlX14ik2N5oMVyh2ZWlsu8RTrvh68Wt9epDMnzBvnKa/gIBPKRp Sa/jVkG+9YycreKGyqZ0E94jKFpnjVqIT9gXRBFRXgrzmLPeib4K2/BHAbO/WH+Jd2AK s5ow== X-Forwarded-Encrypted: i=1; AJvYcCWkezIfd0C8ybj0lNdknwHt6J/B95bIsm3y12sKK3dSEb1FLEswCKykv2MRtnZbnzQJ9logok7bCTTtP5g=@lists.ozlabs.org X-Gm-Message-State: AOJu0YwuxjCgAcO4EtuGH7FvXx/4kw5sz2Qv/IFmx4v9XIwZKSd/oWGw iFijNKZsj8kUQHi8B+3098p872iTsTKiQTUZscEBtA+sKutTl6gRj8nwkOTNeWLlcRYUvVeX4ZI ItRd4VQwmijzu6qcCTthWOw== X-Google-Smtp-Source: AGHT+IE5uBnbPCKzOwkMC48JVFthRmj9q9RybjWG1vwJiuOPIIxum8Gar8GGRDZP2nZfvTS3r0HkOT/glreBt/EPvw== X-Received: from coltonlewis-kvm.c.googlers.com ([fda3:e722:ac3:cc00:11b:3898:ac11:fa18]) (user=coltonlewis job=sendgmr) by 2002:a92:cd83:0:b0:397:b509:6441 with SMTP id e9e14a558f8ab-3a08b72994amr15335ab.2.1726174301380; Thu, 12 Sep 2024 13:51:41 -0700 (PDT) Date: Thu, 12 Sep 2024 20:51:33 +0000 In-Reply-To: <20240912205133.4171576-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: <20240912205133.4171576-1-coltonlewis@google.com> X-Mailer: git-send-email 2.46.0.662.g92d0881bb0-goog Message-ID: <20240912205133.4171576-6-coltonlewis@google.com> Subject: [PATCH v3 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. Rework the sampling logic to only record guest samples for events with exclude_guest = 0. This way any host-only events with exclude_guest set will never see unexpected guest samples. The behaviour of events with exclude_guest = 0 is unchanged. Note that events configured to sample both host and guest may still misattribute a PMI that arrived in the host as a guest event depending on KVM arch and vendor behavior. 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 d51e5d24802b..3c5f512d2bcf 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(regs); - 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 eeabbf791a8c..c5e57c024d9a 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -6921,13 +6921,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(struct pt_regs *regs) +static bool should_sample_guest(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 (should_sample_guest(event)) + return perf_arch_guest_misc_flags(regs); + return perf_arch_misc_flags(regs); } -unsigned long perf_instruction_pointer(struct pt_regs *regs) +unsigned long perf_instruction_pointer(struct perf_event *event, + struct pt_regs *regs) { + if (should_sample_guest(event)) + return perf_guest_get_ip(); + return perf_arch_instruction_pointer(regs); } @@ -7743,7 +7756,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; } @@ -7907,7 +7920,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