From patchwork Wed Sep 11 22:24:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colton Lewis X-Patchwork-Id: 1984242 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=BLL+lwzp; 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-1264-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 4X3wB35kQ2z1y1y for ; Thu, 12 Sep 2024 08:25:15 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4X3wB23p8Vz2xjQ; Thu, 12 Sep 2024 08:25:14 +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=1726093514; cv=none; b=ZA2oYc+bqw0TffzkQu76PIUMRA3Oqh5hmDMITiOiB9Lw34rJP/Vu4k910GuN7wLGXjBpucu0HVFh/MPQqXX2LfRcA50FUJPcY58pfF8F2oIh3BysKl+azcMFPX2lsIslV12gzqFIOvPZEO0SZA7Y6qVKWPmPwdkg2khRPIhQKgy+KhiUW8nE52ni3x4JmwFoGXNMciGDdbRmagVeVoUsBOcjozQWhScUhIxizET4qHWIC2iMF+xD2hoXTLsPnD02Or3GY5PaLbNMVfw3uaRDxkk0345gZDxRsgOVJw4326cL3N6V6u0A+nk+rs2OKSy7WMHQmnqWc/1JwP4kJCGzOA== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1726093514; c=relaxed/relaxed; bh=98KHHfZAU1dotPbU8K3avps0YbHY8rCmN7CSHv68LAQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Teyy+3CSFv+XlzE5fHfSf5jkE7A7sp08gwsp9wLIDcmSVpv6umPBYc3EjYFhA/o3qupbDZWfdWSL2yjb4Y8PBWiYvTNTYmvN40RRG1C9PN+JF/FE51eh2kJdpwQ9Rl6guORWseYehm01LRhLmvCX4NcGWCvN0zLGP3fIBRXn/girwvwe/s1jSQHduVDKVjG+k+BferqE2LPjWRPJwRmBGPbsDjyc0wHb7PpLOQFA0qkiVcxEVj80oFuCqC3erXVWuXmh9ZgFArFG9l1c8BwZ9VfhDDN1WHVSfYkXxqwkRru9EmEMVf0RCUg9pO3dWGJWhPPfQVFfHmelMfg/7i+TRg== 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=BLL+lwzp; dkim-atps=neutral; spf=pass (client-ip=2607:f8b0:4864:20::149; helo=mail-il1-x149.google.com; envelope-from=3xhjizgskdl0frowrqohzlvjrrjoh.frpolqx0ssf-ghyolvwv.r2odev.ruj@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=BLL+lwzp; 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=3xhjizgskdl0frowrqohzlvjrrjoh.frpolqx0ssf-ghyolvwv.r2odev.ruj@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 4X3wB203Lyz2xHw for ; Thu, 12 Sep 2024 08:25:13 +1000 (AEST) Received: by mail-il1-x149.google.com with SMTP id e9e14a558f8ab-3a050af2717so7248235ab.0 for ; Wed, 11 Sep 2024 15:25:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726093510; x=1726698310; 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=98KHHfZAU1dotPbU8K3avps0YbHY8rCmN7CSHv68LAQ=; b=BLL+lwzprbBxc7YptR6qqFL1gT4DEhGATSl0B/z5ypMjnZbkpWu9d404uxmBjfSbSv Xdd+gJNsijOpdKOWhN6Lc00JgDkVR8JEHiSoaR5Q1q5JkZ3c3GcB5MaKCxCD5NZ3uagr ESAWhlbzQyg5NhFQPwu+iEC1Jf/QxqCLBmtOIiU6jVGX1F6wSBJK3YhyzajqKLu//mdK JHrLXCaaxFiAKLzd5HK0N6ipZEHqD5F+tTOl5RaYbdWP5878O9e7sA4L9mFIh0Umnw2n GdUq+ULHzm5iVxnLGGFT6dnqQDNhvRwAfUwMGz+xd2WPuR72MQbEQz35lgcjhF7gNc7O NfsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726093510; x=1726698310; 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=98KHHfZAU1dotPbU8K3avps0YbHY8rCmN7CSHv68LAQ=; b=rzusVW2Y7/aItbna9jHE0kWPLUKPpXc8nvn239ZGDB3WSBYlllGl0MoqMEhBjH99WL ZgqkHlXNMevm6QB82Rv0B3CCxgv89kKxLuXwKunD3MPgkzYn7TcYdGhlyzBGcJlFVoqw qxkcaBNPVf5+og5GwJOLEyIK3s7PEpM5ugNM8zl4o8TU0sDwWDM36WmPKWIyxxRTOaAm UC7cMyheqDrmFPbTxLb1fXlcgGzFi53ifMHedfLV4shwUKCcm8HdIH3iB7aRYLxL8lMr azl+bpwu87SdkNhQfCst9M41yzVqF4VosgE5EXuNFmIiIAfltGxLHcDAn2yw4JyAFXQ7 uMbA== X-Forwarded-Encrypted: i=1; AJvYcCWEGeVOLHNXh0uuo6kNZ3DYL/nTHooe6Svvxataw1Z3U4srw2ZrOpXgaPt95hBgba8u+ABpntmxAtTd27o=@lists.ozlabs.org X-Gm-Message-State: AOJu0Yzne7iT1SlJDdd6qUeUW43OFATjydA/jsvWtlD1QMbJXe0Q6Kr1 6KLxa2kbz06tyUt2ZeDy6zRtKYOMZHtUtjG4VzfQuMm0Ite646koNLyWcr+LsWhp4862LO//t9v 8vS74izXrpfa7FWjs3o4REA== X-Google-Smtp-Source: AGHT+IHezO/FS6DrvjzqydPLEapvMWYoVJd9AX1NthmyW6WKSgM57sEvRhPyRtAfj2mQLXNB4v5VRUm4UvpIqG0BYA== X-Received: from coltonlewis-kvm.c.googlers.com ([fda3:e722:ac3:cc00:11b:3898:ac11:fa18]) (user=coltonlewis job=sendgmr) by 2002:a05:6e02:1c48:b0:39f:549d:e39d with SMTP id e9e14a558f8ab-3a084967570mr302085ab.5.1726093510446; Wed, 11 Sep 2024 15:25:10 -0700 (PDT) Date: Wed, 11 Sep 2024 22:24:28 +0000 In-Reply-To: <20240911222433.3415301-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: <20240911222433.3415301-1-coltonlewis@google.com> X-Mailer: git-send-email 2.46.0.598.g6f2099f65c-goog Message-ID: <20240911222433.3415301-2-coltonlewis@google.com> Subject: [PATCH v2 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.598.g6f2099f65c-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 Wed Sep 11 22:24: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: 1984244 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=S4xQM/+n; 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-1266-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 4X3wB94tC7z1y1y for ; Thu, 12 Sep 2024 08:25:21 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4X3wB259Rgz2xmZ; Thu, 12 Sep 2024 08:25:14 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip="2607:f8b0:4864:20::1149" ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1726093514; cv=none; b=QQ84AGXq7R+wqlm7YjAXaakNgsylTQqkGbt3I8R1mOHH9OUT6ptiI+mvAaBC8qE5L+4FUevx5v1G3B+S8XPdjgxWGQySoCEtedMWfePk2hk80rpZ7s8YOQWsFqhmnDdSLIneXWk9gxtDu+NqZ3/Qpdc1SX8VbLptHmAQNloMKCyctFSDz4NhWJrhSH2t/PzreHFK0Juuijm4XmHrwuqPJg3nCIQ7k/3JyrLkllhKAUkQWTeFQD9Gkdi4WshP1bCfmkY5tupQoEJ/yl08rVrOggnMRxz/zOgOOSttTh1IzAkmyuOlVkgHvjtDTM6P/5uaDy/qryshpH2O4MCta5CXFA== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1726093514; c=relaxed/relaxed; bh=crmhw2mLEZ3+RGHHnhBbhpz6G/wxlsr9F/cDgMbCNx0=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=SzeY3HdCmRGCKyxHJntqX22wMjicN2LZ+rng4gGsjR/uQIRAs8mxJZFUfyrCpCOLjDjTxvPh9M1e2iTQMw2RnQTiUnlYyNfNdQnPmxr3JchgICVNiI5ylvHNxb1Ow3Qnj4Rbbo3vsTl4WYA27LQU2pihdw3xzll+B1Q88kjTn4YQ9ivyYBWJPb1yl74JCcKl8aPLgcsfR5InV2/hEDju2AJOqzAptPBfsk+cYX0I5yTHyt64wZj9OR7q4VmosmZYRweUW4EViJJPCIVVg1X0idQcjZ+SOxDDRUsz66T9AwZAOZw+b1yS2YfiIrOSFUsguia3FD+omuMtT94LatFBkg== 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=S4xQM/+n; dkim-atps=neutral; spf=pass (client-ip=2607:f8b0:4864:20::1149; helo=mail-yw1-x1149.google.com; envelope-from=3xxjizgskdl4gspxsrpi0mwksskpi.gsqpmry1ttg-hizpmwxw.s3pefw.svk@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=S4xQM/+n; 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::1149; helo=mail-yw1-x1149.google.com; envelope-from=3xxjizgskdl4gspxsrpi0mwksskpi.gsqpmry1ttg-hizpmwxw.s3pefw.svk@flex--coltonlewis.bounces.google.com; receiver=lists.ozlabs.org) Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) (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 4X3wB2117dz2xYl for ; Thu, 12 Sep 2024 08:25:13 +1000 (AEST) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-6d4bd76f5a8so17941767b3.0 for ; Wed, 11 Sep 2024 15:25:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726093512; x=1726698312; 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=crmhw2mLEZ3+RGHHnhBbhpz6G/wxlsr9F/cDgMbCNx0=; b=S4xQM/+nNfHf1h46PZ0MsQ59vwLN8jmLu1P7jAxir2zLl3JeReQvV6C6bUOcZI4r5b EeeMyP1Hdanwb+9xahBd20qRvfsZyLrvBdgKuYfjflHPsfZQWEnt8kZ0aIwMxpqnEdFS 4FztmYarv58x70U8Q8Vc66g3qPRgaFMmnXfy5Bla0jpmiJkIyaFXIMeR1OLLKbB+SUO3 spP+Hr4BnfeyoUWwTLNiWDTNIQRD81WXlEyvrzLIBZauI2AM9fVsviHBksEK1fQHVOUw QdOEnBBCIELk78sI8fUahzpWuqeFnvVOoPIryqyS1iL+nJRW6AwElST6R2t9OwhDbihk /saw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726093512; x=1726698312; 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=crmhw2mLEZ3+RGHHnhBbhpz6G/wxlsr9F/cDgMbCNx0=; b=OQkVugy4JAatFHScB2Ji689TwAybB9M9zO2mGvFphtqTYPeX6JQ34EqN2p/DZ2sLvc 0o63vyXx8GMLRnZVxYCpuv99Cr/2PMdVl0Xjr2xSaM4BWeV8u0a/kWDQx4+Enizt8DBX Hs3N3oE77AhDH/ccsP8iR7b2WATf7yMCErnGmoJ8XBqWYpOZ/ZsRuw2H+MkatmV1My+z /oS3uGIQse6J9HE6gUXPnl7eXUPU8Pzw0p83M70iaVtcAv3L1wT1YRY0An6XGubZ19nW BDK7n00T0K5DfZgRRClj/HygciTK5SB7gu9B0733MO1TPXAQ8Yj0e3itMzlFsNxxVyZI VIAw== X-Forwarded-Encrypted: i=1; AJvYcCUVbqus/7Gr3wXVYoX8Vpuyvj2QepY/cphtlNpI8uwRvWlbVYAHp3W5qiaHHD14nrE+H1oxQYnXB4g37bU=@lists.ozlabs.org X-Gm-Message-State: AOJu0YxeaMeGMANbbVQyyKnBtEZUSM/3s2IGeftb7W3U2qaJSX/tTE8+ CfX2bAhVgxQmBg3tWWQtDtrfxmolnwttL4EJDXeRqWV7FaZQvHtMc1tYwWrvE0doS8s4x714SWI NI3FJ+Oz1zvBoRt7idsu+hw== X-Google-Smtp-Source: AGHT+IG/kcNrSc00DiV0Ogd+lp7Te7joIo9TjDes3ay3ZaxS7IQuZ1/VH3N+WObF+/ClPQF8BfSZxNsumtK7iHDYfg== X-Received: from coltonlewis-kvm.c.googlers.com ([fda3:e722:ac3:cc00:11b:3898:ac11:fa18]) (user=coltonlewis job=sendgmr) by 2002:a05:690c:6c8f:b0:6ad:e9c1:fc4f with SMTP id 00721157ae682-6dbb6b8c62bmr380167b3.5.1726093511584; Wed, 11 Sep 2024 15:25:11 -0700 (PDT) Date: Wed, 11 Sep 2024 22:24:29 +0000 In-Reply-To: <20240911222433.3415301-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: <20240911222433.3415301-1-coltonlewis@google.com> X-Mailer: git-send-email 2.46.0.598.g6f2099f65c-goog Message-ID: <20240911222433.3415301-3-coltonlewis@google.com> Subject: [PATCH v2 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 Wed Sep 11 22:24: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: 1984245 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=BCeB9RwR; 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-1267-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 4X3wBQ0GB7z1y1y for ; Thu, 12 Sep 2024 08:25:34 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4X3wB35wJ5z2xYl; Thu, 12 Sep 2024 08:25:15 +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=1726093515; cv=none; b=oXswJ3qZ4WJfkydCNU1ZmqMhQjV8gXYhu22eRzBqZoMowcSHi224F8qfdMQLxJSvXk+AKXhi71OWUlPKTtEm5c46WLcN+aGgvXQzZwFObAr/ZY8GIHEIDvkq/hf26xq5f+OoPbq5zQPuASRrp5NhvBzwsdl0sm1f5Al6qidKsysQ/Y2k4nlIQuyAH8KVaHLpwjJ4t5RHw4NRI6Ohe19WpWiB6x7ckZx1gmwUDGrapQpxV7HNdpqwy8m+1l+prmxezTM7q/+dGiiF3uW7ekNJq8bgvJ0VOkF7dAlzxUhm98o1nvoUeJgxKlfNB5/GvW8/myCW6gjqpgXkDeN5Y1nDJQ== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1726093515; c=relaxed/relaxed; bh=l4XmBjdboaUqTeMgRqbSdf4DSeJIVFEq/lNcpwN1ftE=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=WOhMc38yJpAOCfEx8/M0sGvEdFUGLmTD+KbLi6jp+Pdt8dayv9MXTDCNlCYiPSMaI/JF0wFoo3blOq/oyFt5jAF+vrOhnNR7tEnigmPWzMYJAoCUC9CIOXSsFb7jKRfU26eqI/K7wv8lrh6AlbPtjv5eJB+g3acs8FgXEfiMgP+nAitvpTjG2uVnWe4Z4bwg/qjCMQsOV9Uj8CANXBaCHY6PwaThL9MwlhDnQiErjNb1VOeEkuWDJIIXa/7FoE5aQx3oD9F/h0cGSM+VZXu7ZiBG4Iv58qDWQJ3v6IWeX4PFu4RcBWMjDUh2FJOLlSdlKcVX5+80DvxaYX3EOt+v/g== 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=BCeB9RwR; dkim-atps=neutral; spf=pass (client-ip=2607:f8b0:4864:20::114a; helo=mail-yw1-x114a.google.com; envelope-from=3ybjizgskdl8htqytsqj1nxlttlqj.htrqnsz2uuh-ij0qnxyx.t4qfgx.twl@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=BCeB9RwR; 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=3ybjizgskdl8htqytsqj1nxlttlqj.htrqnsz2uuh-ij0qnxyx.t4qfgx.twl@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 4X3wB32py3z2y69 for ; Thu, 12 Sep 2024 08:25:15 +1000 (AEST) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-6b47ff8a5c4so17001467b3.2 for ; Wed, 11 Sep 2024 15:25:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726093513; x=1726698313; 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=l4XmBjdboaUqTeMgRqbSdf4DSeJIVFEq/lNcpwN1ftE=; b=BCeB9RwRk0NtgISGxIBFTFJFfvfFAuZ6j9UJCDeA+G8DNqGAIesLfS0DUTurJ+SlPn ACNLmUEB0r2BKMWuGphXhe/Y32PAvsGRrmzhwSPa354BLMPkcqEuaQlyPj8Jn2wnMx9I aPT91xH5L5J+H1QhHgoF6jsxhRJJ+E7PiCwDXETSlpzTWfTZZy5MS3Y3NpzW/rZAp7Bx oPWj/68LD6JY/AmEMsTmAZ3WlRHANI8/OBXbpKAVbBHcivdEUYLiUyc5aFFdG0iWeASh IM4BOXdoBAJe9A3DFxtz0DRprWrT6ztGwvL3NTk8XtD0Ttg+mr/nsBUv3z93ORPFbpkH OfgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726093513; x=1726698313; 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=l4XmBjdboaUqTeMgRqbSdf4DSeJIVFEq/lNcpwN1ftE=; b=m8k91SUr2TNpSTfjeER9eL/5NCFGANy1qCkh2FIIOeVJ61XDyeepL3tGULQCwx91/P UWb3g222u05jZJcYBp7TnizHpgM2X0raBG2EjuCQPCUyUihRuSQ+CXr0LSyARPYI78ZG 6JT7sUDOa4l4A3H/vr+uhqocg+NfnUvXaUJAcjEWKQ17iaMb/biUqKpHRRQ/HEPTWf72 mszaVjhlQaS+QL4sUeS+XwcSbmXQWY+iXmGm7AUv/0PwKmtxN0OyCMEK7Ra+91kKwDtm Ah6wxmYysmKsK22q90ISLly9wqMqNZJqOu7iWWqwg3F0Sj6S4VqKPgSHDZKOGXwzAHbD PpDQ== X-Forwarded-Encrypted: i=1; AJvYcCXkBtlOWM7Knu1beHRPP97J5fMKH3ijuOc4+9G0UMqO9kYeX0inCj4J5nCiaPG9AXAZuhEZfIu+atwGISo=@lists.ozlabs.org X-Gm-Message-State: AOJu0Yx8847JMbZMK3ZdDDCUPuTi/k2yCH9ItK+6Cgf2OlheHwgzQ2lC S5DNCXr+rEh5R3VrdJ9ff1FTtFJnVekHxAFwBj28zSBEni/99xS4XBepBaoRKEEpAHnq2AXfN1a 4hwQ6i6iAnf35HY5AcNIoyA== X-Google-Smtp-Source: AGHT+IHahPlfxq0OnDlBxbNh4kFfba2/NbBP9j+SjDxLZau6fx+NZ8cgucf9q6YqSrrkRp98eVZcQ/vy+HEi7ntE2A== X-Received: from coltonlewis-kvm.c.googlers.com ([fda3:e722:ac3:cc00:11b:3898:ac11:fa18]) (user=coltonlewis job=sendgmr) by 2002:a05:690c:6083:b0:6c3:e9e5:e6a with SMTP id 00721157ae682-6dbb6ba1041mr322647b3.8.1726093512763; Wed, 11 Sep 2024 15:25:12 -0700 (PDT) Date: Wed, 11 Sep 2024 22:24:30 +0000 In-Reply-To: <20240911222433.3415301-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: <20240911222433.3415301-1-coltonlewis@google.com> X-Mailer: git-send-email 2.46.0.598.g6f2099f65c-goog Message-ID: <20240911222433.3415301-4-coltonlewis@google.com> Subject: [PATCH v2 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 11 22:24: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: 1984246 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=l6bl6bX8; 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-1268-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 4X3wBX1Mlqz1y1y for ; Thu, 12 Sep 2024 08:25:40 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4X3wB4300jz2y69; Thu, 12 Sep 2024 08:25:16 +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=1726093516; cv=none; b=Atu4/zOgoKbQIoSi229NTeuJJCEAuQ75Tz6fugvoQRmtnO8jvZhbivDrIoAcuZG2oF/yc0/5R2PnmYIKj7iQZE/j8zFzC0dGJdPk4YbkSud60dERPn0G8h+v7ygtbaCkDboHoPsq7Zd5/CGU3uZ3o+A5tTkPxikl0Ggfc0JKldJAvzBqeDABWwrLiz3Vydhv4iwp7QNdvi089qNbcoL8KwoCfZVCSNi+MzitWPX+3HXd3ohT0GrLIgSFHl/k+CNBzFdab0N7Pc6STMPiy2bFk6rrsDSWnRPT3gAxUVTU45qYIdRhOZUH1+hq4gR89+xbp9xVPJBTbek7KcQXl+G4FA== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1726093516; c=relaxed/relaxed; bh=qY7jazBJP8pJhg0f/dQ9sIJIXrzux0tRJtWLf7xpCl4=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=hkt04rJE+Pzph2vTe+uGYVJ6v2vPqvaK7ICJ/x4mcLhB3FGPRy+YrKorZhoKhqL/E5+Q7cWchb3gdnljAayjPylkSIkRWbsbS2KTRYsxpqZdILV3SEXhCBethAMSnGukmejz+/yKkhdNCJRKanw8wloLaZFVgBb9IYrnPfi6QCcgy6iWFugJVp6ZM/ig8Sjy7zU1uK1EvyeHNm7pj/dL9tghwucJYC0QToQs1xLHZWe5M2Ug4QOngt3KIq3MJwQxIG7mZSYvdd0BU195Sh2Cx5hNXxzQMG7on0t0oma7MSlRF7U1b2Z1WYg7sqzDKJicOTc0gAQaw1tO6Z18WVOPYA== 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=l6bl6bX8; dkim-atps=neutral; spf=pass (client-ip=2607:f8b0:4864:20::b4a; helo=mail-yb1-xb4a.google.com; envelope-from=3yrjizgskdmaiurzutrk2oymuumrk.iusrot03vvi-jk1royzy.u5rghy.uxm@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=l6bl6bX8; 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=3yrjizgskdmaiurzutrk2oymuumrk.iusrot03vvi-jk1royzy.u5rghy.uxm@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 4X3wB41DSCz2y8d for ; Thu, 12 Sep 2024 08:25:15 +1000 (AEST) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-e1159fb161fso776491276.1 for ; Wed, 11 Sep 2024 15:25:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726093514; x=1726698314; 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=qY7jazBJP8pJhg0f/dQ9sIJIXrzux0tRJtWLf7xpCl4=; b=l6bl6bX8XfIyLTscgvNNlDzXVT16JnGUJFYuwrCiHxUtKTIp+OcW3gh01IQB10iTES /PVM2NIYxknisxx7ePHsmVZtVsu/CaWzOl9nBA6XWylVwvSkAREbgGn5AonvRMA/gm3Y lk0H+DVPK5HWVfeWXP7nMdOtnmLzuABRINn8yvWsPYC3zW4hm/tAAe/5xmbg5yubiqml n0U9C91P1F+FmHeyknKRLRhVNx4pQ+3Jjisy1k/dq9CfK0iK89Cd5iDGShHXm19RgeuD sIuNxa6eLcP7ZSfCSleOuQLC5SPAkgkgOKZrn+YPo+seipukk838TyatUUVfR/SYV1zf DF1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726093514; x=1726698314; 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=qY7jazBJP8pJhg0f/dQ9sIJIXrzux0tRJtWLf7xpCl4=; b=LySyHZ+X5xozzgXja/OoBWR1z/Xs0vVw8ZmSuMX+AgOcCLVsyTwaLudDpvTM3QfHls ttVQY+9p5Cjdbblh80a4kLvKhnZPUMfkxOspWhStZquHY0jXdH69sO7LrUPFycjhuGGh DnYUv4va4choAPv9WB55yw4x6CVfOkF7In4zKZu1ZX1MhaE7tm51nfWEUTCPMzu7gXJ6 6donDCI7YAybXO08ObAUnihWvm1l19lxwnR7cCgS05st2DNf4ZBm5A8/RB7P8WZ6ahWb EveAjucOXo9WmQsou4lpoSOXiJzyY3EVdrWspo5+tgPIMyncYPxBcyxMtWIBJG72IeUE IbMw== X-Forwarded-Encrypted: i=1; AJvYcCXJncVtujkdeCXFqJFsmvW/sdxpDGKWgNR0HlSGmY1lSODYPi0FuV/3HJyLCNCswFWNlx0nRqqJe0g3rRw=@lists.ozlabs.org X-Gm-Message-State: AOJu0Yzl/8BPBG5wA/sdCXHotZvza+mXEUWR8jM7nofihhPcweNz3PVY G6+jis7OM/kfgRpARVl9m3OCjdkhXMKXglUrGcpHgbSQCg+HSJLCBA4A3WkB48xKahnkH0fG1R6 VsREJaIb9MCFtwh8k9fGTJw== X-Google-Smtp-Source: AGHT+IEJ4qXFa/RnEyqgs+UMl0d9RUxwmlrJg7JrBYtR4wSiyNcS6y1wcbWXE0ormIQyuX+hDspZQAPbFzn+ORG1EA== X-Received: from coltonlewis-kvm.c.googlers.com ([fda3:e722:ac3:cc00:11b:3898:ac11:fa18]) (user=coltonlewis job=sendgmr) by 2002:a05:6902:27c1:b0:e1a:22d5:d9eb with SMTP id 3f1490d57ef6-e1d9db894c5mr1072276.1.1726093513931; Wed, 11 Sep 2024 15:25:13 -0700 (PDT) Date: Wed, 11 Sep 2024 22:24:31 +0000 In-Reply-To: <20240911222433.3415301-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: <20240911222433.3415301-1-coltonlewis@google.com> X-Mailer: git-send-email 2.46.0.598.g6f2099f65c-goog Message-ID: <20240911222433.3415301-5-coltonlewis@google.com> Subject: [PATCH v2 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 Wed Sep 11 22:24: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: 1984247 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=q8tVXwB9; 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-1269-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 4X3wBf1Qfrz1y1y for ; Thu, 12 Sep 2024 08:25:46 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4X3wB547xmz2yF1; Thu, 12 Sep 2024 08:25:17 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip="2607:f8b0:4864:20::1149" ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1726093517; cv=none; b=b48EzrYFsvyATLipGf8jvIHFXlcEi6JUOqwJHBjTrF4JpeALKjPT3fxRVD2Jafzfzp7fgwq7V+QbNeruT3P4fxl3S9wUEDYdfwY2jkffovPfFm/7fTSos+WMXmP6aePyP/MPsn9WFaEmOjKzk+LuiAaQsM9Tapxw8WcCa9SlQLKggYJdfr3hOEw62mir4WBfsEvSZNnt6MxocSpyjc/w5wERyGpJkQLir4Jk36+K2VQQiV9cTMecVHFRyX1xvw8q7wnHX0Z3p4tLEPU1HCr3qgbH25p8yfR7/b13XmHen+jNtHD7pY7UltL2d6KI6VjDqGHRNkkF//RgrlUqwU21XA== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1726093517; c=relaxed/relaxed; bh=anqmPTOCFLWtYH4INX466EMjOxNIdwCN/nyhNcnm/nY=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Fc1APIVIJV1V0Qjr+Z43rSpAv/6ViPx6AHuzj5RQMLbaiJEjfmlPMONX3fNBiiLcxcZUc3ZFQ05RT9QU54jFK3i8DHAk3aBRUpwL3YBR2e1nBOZayi9VsK4veFw2iHfgyXq5M3HYmZrwGrDCPJtRVRKZQe1mtxgdzJ1yMITDLQ1zfGwqE0G/vQ09XgSE/u3gyQwoTHDXYtUOmNPiYuQQoNQq4JDojZBHwEJjenjtOmwwo+rjCDdBq6C7ila/U5woxT+xtjTL5/0pDnxvTt2DcgKACcEde7Ln92uZ0KdLbei42zF8LlyBw/cPxc9Z6GZ27TPIXGhKF5bBgLOkcufcvg== 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=q8tVXwB9; dkim-atps=neutral; spf=pass (client-ip=2607:f8b0:4864:20::1149; helo=mail-yw1-x1149.google.com; envelope-from=3yxjizgskdmikwt1wvtm4q0owwotm.kwutqv25xxk-lm3tq010.w7tij0.wzo@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=q8tVXwB9; 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::1149; helo=mail-yw1-x1149.google.com; envelope-from=3yxjizgskdmikwt1wvtm4q0owwotm.kwutqv25xxk-lm3tq010.w7tij0.wzo@flex--coltonlewis.bounces.google.com; receiver=lists.ozlabs.org) Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) (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 4X3wB50wk8z2y8d for ; Thu, 12 Sep 2024 08:25:17 +1000 (AEST) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-6d5235d1bcaso13568567b3.2 for ; Wed, 11 Sep 2024 15:25:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726093515; x=1726698315; 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=anqmPTOCFLWtYH4INX466EMjOxNIdwCN/nyhNcnm/nY=; b=q8tVXwB9dToXhJ3LxTo+8sOJk7EmPscaYR8dRpA2JZELs+wIJbB+B//XVtEGd1yrm8 Exzir3DFPxP8Zzhy/2IT1K5rP0oOWngNGMmcxdIvepW6IgHiW69m2YFOUE+R6IRuTAZM 5RGWvxpAH1mMf/uE95Fy1rqO7VuqE15PdLnlmAiECu81d4g23wbG6e6ACezMcfY96Aso RuEkhgWY+dbXvLFEH6i4XykO4qdx4DGE8RlKxxzgT0Lk+P4+4PvdXdm+qOWr4WiIef7j fPOLl+EBqKk9M/vF4BZZHnzFCywwO6T9oDZKZ0c0yLtXTBt3RMgQyjFqPn50mKq7rlv9 J+1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726093515; x=1726698315; 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=anqmPTOCFLWtYH4INX466EMjOxNIdwCN/nyhNcnm/nY=; b=MhLwZ3jZRMAv5HSIUTR3MXC+clG4gMZntTa2TVBFeH6zLC8iz0nAO/MZ6akHoS4uDZ 9QaaRtYIsH4ThWPw/R9L6bDRT6b+K90Q8OQlKxFAfchUgTSObCQiuM7AtyzgZB+enKAN N8OCL2v8iXa75J5I5wfaM+d09LrfE3piovKCFzDprInWp2oHtlxxaoGscXJPz2g0Nf/j dnmqzhd79DyFJ8vpRdQOvnPyvFisUCZJYn7qbHPRmB1efjjgbd44QXVCcpmE0rcxl5T7 WkZqAg8cJW8ELGWnD+/hUIR6mgrtiB4Cn9MW6oHZX+zJDdCzmaye1M5EoSy3PhJATwrk nVXQ== X-Forwarded-Encrypted: i=1; AJvYcCWINDtTgB3WHWBcrUjZv/dOCZ0R6AcLOHc4VdYHaOo3URprdoreaXnulynZ/l6nefQt3TK1T3Bq08cdvHs=@lists.ozlabs.org X-Gm-Message-State: AOJu0YyYj8bwoiNmWmGdVJ7O82L82lA0K+7n7RrmiKnb7LRWDXy6fVN/ SyIi6bD+k9FM7kK0c0EUpuyBam0jAtAOpoubS90aGBMeHCEBsxmYWfDIVWFqPrbYma0l8I2oaxj 9LsKWN8T8HM1UEs8JlMYa+w== X-Google-Smtp-Source: AGHT+IG/v34+rc6eLaOGVWlOE43Zx45msmHQv1J2ivFD+GxJdG/Q3VFoefy68ei4cpHyCypXn3PaKYm2Ons1cxS0+w== X-Received: from coltonlewis-kvm.c.googlers.com ([fda3:e722:ac3:cc00:11b:3898:ac11:fa18]) (user=coltonlewis job=sendgmr) by 2002:a25:e812:0:b0:e16:51f9:59da with SMTP id 3f1490d57ef6-e1d9dc1b42emr3306276.6.1726093515114; Wed, 11 Sep 2024 15:25:15 -0700 (PDT) Date: Wed, 11 Sep 2024 22:24:32 +0000 In-Reply-To: <20240911222433.3415301-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: <20240911222433.3415301-1-coltonlewis@google.com> X-Mailer: git-send-email 2.46.0.598.g6f2099f65c-goog Message-ID: <20240911222433.3415301-6-coltonlewis@google.com> Subject: [PATCH v2 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 clear. This way any host-only events with exclude_guest set will never see unexpected guest samples. The behaviour of events with exclude_guest clear is unchanged. 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 | 15 ++++----------- include/linux/perf_event.h | 21 +++++++++++++++++++-- kernel/events/core.c | 21 +++++++++++++++++---- 5 files changed, 40 insertions(+), 49 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..5f119b9516dc 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); } @@ -2974,14 +2971,10 @@ 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