From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 75D76CF9C6F for ; Mon, 23 Sep 2024 08:55:11 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4XBxdn3TwBz2yK7; Mon, 23 Sep 2024 18:55:09 +1000 (AEST) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1727080591; cv=none; b=n2347Y1DmlyGact62r5dNAk2/wpGQ0qt6Eu4H0QeNbCBOVcoSkWhYQ1Q/9tA6Rq+Z6VlCadkFcn19SFBdmvc7F1BV3k+Iwu1S2ovmDIOhw4yVH4tsFtJbocJc6GEd9iH6mvNlY1+fdWLse9IpCQ16GjZMMTgniT3+wnNXwppay+H5KvTAWvzqeegPG39F5PJApxjllOQPNRj1IvKWbuqRHK3w10XTo8hf0y+8btvRVJH7S03VQnms+IqIlnVGlBAeQaBzxNBRA+D9lfhOVrvKh1NT/ndHNgzG6y6m64kEucz8hqH/ZxKu+hCyFplcwb3QWVw/YgeqySgtJLEc03uZg== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1727080591; c=relaxed/relaxed; bh=ZebgRWJ/R8+CfS0Y5IXDHC2bQ2zqs76xP45fSGYgpho=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Pnd5VYqVODedttIGrw2X35nwVeT5KOznxbuZhcGriW/4hayjob9LsW3O11SB1xo5VEsIB+UhxXV1KdzV7ltSi15pS+tak1eM3xliozBahStGT0xP42WZ8pgSbTBydHwRMzXl5DVRrj86QSbqL16wVOl/SDAJpc+CIta8lrKfibbaWGfPd5vIjnqGF8jE9oPQV2aazKBWQu7+fhesDcKXcMkrI/GKvb+BLrheQuPGN0GGLHhfUGDVwAo+ARMHBCYLjBJghXznJGX1IX8KIpUbOLq+QQQom5ZLc4C2eqV84D7O6Qt5arTWjqrwOiQHiMuk6qJOTY3h/pIO6pAlofZvwA== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=XresYnVN; dkim-atps=neutral; spf=pass (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=tmricht@linux.ibm.com; receiver=lists.ozlabs.org) smtp.mailfrom=linux.ibm.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=XresYnVN; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linux.ibm.com (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=tmricht@linux.ibm.com; receiver=lists.ozlabs.org) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4XBxDG3Wt5z2yDM for ; Mon, 23 Sep 2024 18:36:29 +1000 (AEST) Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 48MLtR3D028184; Mon, 23 Sep 2024 08:35:12 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h= message-id:date:mime-version:subject:to:cc:references:from :in-reply-to:content-type:content-transfer-encoding; s=pp1; bh=Z ebgRWJ/R8+CfS0Y5IXDHC2bQ2zqs76xP45fSGYgpho=; b=XresYnVNvfjS8q25n exIowGTcyNfPFLSf3njKFhkmtThO79Rn/l7bbDHY5upOMZ+GXc0ZNJTpfRNx3UhG 44r5rosQUrKJQZ1hak5YCIEaeI7KPk0HLlS/sw+TPodoA37waRXazoYyY/xPXCqq AxB8S1T/7i6fdkKUH4BHHpRz+FX7etse1GGweODWy7XZ3yNn8bpysFkmJOAYLooy Wc93e4uRc3SZhEmMVqGL0HO5CGVAnkQgo8ca9EVWcYW7xQlbHCJf0syievl22SaG RbwQiMqlzD3Lpi9rGRz9qxTMBS7sONGm/gXX9+JNJb82jsDxIBwXYRU7WQ7dGJvQ UXnwg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 41snvathjk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 23 Sep 2024 08:35:11 +0000 (GMT) Received: from m0356517.ppops.net (m0356517.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 48N8ZAoU000989; Mon, 23 Sep 2024 08:35:10 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 41snvathj9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 23 Sep 2024 08:35:10 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 48N7YNhe008712; Mon, 23 Sep 2024 08:35:09 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 41t8v0wjv3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 23 Sep 2024 08:35:09 +0000 Received: from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com [10.20.54.103]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 48N8Z5tI34800204 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 23 Sep 2024 08:35:05 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E8E0220040; Mon, 23 Sep 2024 08:35:04 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 72FBD20043; Mon, 23 Sep 2024 08:35:03 +0000 (GMT) Received: from [9.171.48.71] (unknown [9.171.48.71]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 23 Sep 2024 08:35:03 +0000 (GMT) Message-ID: <24b8e9b5-32b9-4989-b932-67c20b55377c@linux.ibm.com> Date: Mon, 23 Sep 2024 10:35:02 +0200 X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Post: List-Subscribe: , , List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 2/5] perf: Hoist perf_instruction_pointer() and perf_misc_flags() To: Colton Lewis , 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 References: <20240920174740.781614-1-coltonlewis@google.com> <20240920174740.781614-3-coltonlewis@google.com> Content-Language: en-US From: Thomas Richter Organization: IBM In-Reply-To: <20240920174740.781614-3-coltonlewis@google.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: i312l3CDmy59jmZF1hS3jjvQU0cJGfMh X-Proofpoint-GUID: 7QKql6PTDhcYSEWqd73Ox4EIpbAler4w X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-23_05,2024-09-19_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 priorityscore=1501 phishscore=0 clxscore=1011 spamscore=0 mlxscore=0 adultscore=0 impostorscore=0 bulkscore=0 malwarescore=0 suspectscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2408220000 definitions=main-2409230062 On 9/20/24 19:47, Colton Lewis wrote: > 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..af0f46e2373b 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_arch_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..f6c7b611a212 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_arch_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) For the s390 changes: Acked-by: Thomas Richter -- Thomas Richter, Dept 3303, IBM s390 Linux Development, Boeblingen, Germany -- IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Wolfgang Wendt Geschäftsführung: David Faller Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294