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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 6D2A2C43602 for ; Thu, 2 Jul 2026 20:58:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F3DD710F5B9; Thu, 2 Jul 2026 20:58:14 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="bj1sgP2k"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id 843BF10F5B8; Thu, 2 Jul 2026 20:58:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1783025893; x=1814561893; h=date:message-id:from:to:cc:subject:in-reply-to: references:mime-version; bh=G2/gDmu4JcaZegDuQwkSPamNJlHrTUeYD7oXbtRFJrM=; b=bj1sgP2kLu7Sl0G2Ebu1X2MtrQsBEH7iaoc3QC0iQBQv2K79B4pX0iBi GrbtO445r+kfKw8CrbxI14sopHGFj0X5COo85IIBd7x9U9QAFZEBisN/v jv5zrGhPdvUy1OuPBi3XPSzVU1bP4/vCsBSMjC7ry12JL5/CfFJ8djkPe 0UnV98tSkZFGR95NiZRiRAwMXKP6O4aKE+bZwWrV7xXiWWaRAUsLGfvUq lk4srMc79LTcyja1oqvtNVoqS/Zs15WT70cOfuzNfwbguc5kwfkqyeum5 VpE4mrxzuzaE14jyCDIZUS8uI6O4eiFs6nrfcddkjTVCp5hOsTRobRtt+ Q==; X-CSE-ConnectionGUID: kxQ51Bu8ROeLbsxyoW0Baw== X-CSE-MsgGUID: wzWywadySKS3qfD1IwRLbg== X-IronPort-AV: E=McAfee;i="6800,10657,11835"; a="83876096" X-IronPort-AV: E=Sophos;i="6.25,144,1779174000"; d="scan'208";a="83876096" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jul 2026 13:58:12 -0700 X-CSE-ConnectionGUID: R6DSk37BTz2vE2vITQoNOg== X-CSE-MsgGUID: hUKDnsR6Se6FGiIsTvWFFA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,144,1779174000"; d="scan'208";a="257292258" Received: from chouchen-mobl.amr.corp.intel.com (HELO adixit-MOBL3.intel.com) ([10.125.25.27]) by orviesa005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jul 2026 13:58:12 -0700 Date: Thu, 02 Jul 2026 13:58:04 -0700 Message-ID: <877bndjehv.wl-ashutosh.dixit@intel.com> From: "Dixit, Ashutosh" To: Rodrigo Vivi Cc: John Hubbard , Matthew Brost , Thomas =?ISO-8859-1?Q?Hellstr=F6m?= , David Airlie , Simona Vetter , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark ,, ,, LKML Subject: Re: [PATCH v2 1/2] perf/core: out-of-line and export perf_allow_cpu/tracepoint() In-Reply-To: References: <20260523013326.129491-1-jhubbard@nvidia.com> <20260523013326.129491-2-jhubbard@nvidia.com> <87fr3dv83t.wl-ashutosh.dixit@intel.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/30.2 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-xe-bounces@lists.freedesktop.org Sender: "Intel-xe" On Thu, 02 Jul 2026 06:25:36 -0700, Rodrigo Vivi wrote: > > On Tue, May 26, 2026 at 08:34:14PM -0700, Dixit, Ashutosh wrote: > > On Fri, 22 May 2026 18:33:25 -0700, John Hubbard wrote: > > > > > > These helpers are static inline in and reach > > > into sysctl_perf_event_paranoid and security_perf_event_open(), > > > neither of which is itself exported. The perf_allow_* trio is > > > therefore asymmetric: built-in callers can use any of the three, but > > > modular code can only call perf_allow_kernel(). > > > > > > Move both bodies into kernel/events/core.c next to perf_allow_kernel() > > > and export them with EXPORT_SYMBOL_GPL, following the shape of > > > commit 5e9629d0ae97 ("drivers/perf: arm_spe: Use perf_allow_kernel() > > > for permissions"). Existing in-tree callers live in built-in arch and > > > tracing code, so the change is invisible to them. > > > > > > Provide !CONFIG_PERF_EVENTS stubs that fall back to perfmon_capable(), > > > so the helpers stay callable when perf is compiled out. > > > > > > Signed-off-by: John Hubbard > > > > Reviewed-by: Ashutosh Dixit > > > > > --- > > > include/linux/perf_event.h | 31 +++++++++++++++---------------- > > > kernel/events/core.c | 18 ++++++++++++++++++ > > Peter, Ingo or any other perf maintainer, ack on this patch and on > propagating this through drm trees? Sorry, Rodrigo, I should have recorded Peter's ack, it is here: https://lore.kernel.org/intel-xe/20260527163014.GI3102624@noisy.programming.kicks-ass.net/ > > > > 2 files changed, 33 insertions(+), 16 deletions(-) > > > > > > diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h > > > index 48d851fbd8ea..5842552294c1 100644 > > > --- a/include/linux/perf_event.h > > > +++ b/include/linux/perf_event.h > > > @@ -1791,22 +1791,8 @@ static inline int perf_is_paranoid(void) > > > } > > > > > > extern int perf_allow_kernel(void); > > > - > > > -static inline int perf_allow_cpu(void) > > > -{ > > > - if (sysctl_perf_event_paranoid > 0 && !perfmon_capable()) > > > - return -EACCES; > > > - > > > - return security_perf_event_open(PERF_SECURITY_CPU); > > > -} > > > - > > > -static inline int perf_allow_tracepoint(void) > > > -{ > > > - if (sysctl_perf_event_paranoid > -1 && !perfmon_capable()) > > > - return -EPERM; > > > - > > > - return security_perf_event_open(PERF_SECURITY_TRACEPOINT); > > > -} > > > +extern int perf_allow_cpu(void); > > > +extern int perf_allow_tracepoint(void); > > > > > > extern int perf_exclude_event(struct perf_event *event, struct pt_regs *regs); > > > > > > @@ -2023,6 +2009,19 @@ perf_event_pause(struct perf_event *event, bool reset) { return 0; } > > > static inline int > > > perf_exclude_event(struct perf_event *event, struct pt_regs *regs) { return 0; } > > > > > > +static inline int perf_allow_kernel(void) > > > +{ > > > + return perfmon_capable() ? 0 : -EACCES; > > > +} > > > +static inline int perf_allow_cpu(void) > > > +{ > > > + return perfmon_capable() ? 0 : -EACCES; > > > +} > > > +static inline int perf_allow_tracepoint(void) > > > +{ > > > + return perfmon_capable() ? 0 : -EPERM; > > > +} > > > + > > > #endif /* !CONFIG_PERF_EVENTS */ > > > > > > #if defined(CONFIG_PERF_EVENTS) && defined(CONFIG_CPU_SUP_INTEL) > > > diff --git a/kernel/events/core.c b/kernel/events/core.c > > > index 7935d5663944..cb13f3ad11a3 100644 > > > --- a/kernel/events/core.c > > > +++ b/kernel/events/core.c > > > @@ -14731,6 +14731,24 @@ int perf_allow_kernel(void) > > > } > > > EXPORT_SYMBOL_GPL(perf_allow_kernel); > > > > > > +int perf_allow_cpu(void) > > > +{ > > > + if (sysctl_perf_event_paranoid > 0 && !perfmon_capable()) > > > + return -EACCES; > > > + > > > + return security_perf_event_open(PERF_SECURITY_CPU); > > > +} > > > +EXPORT_SYMBOL_GPL(perf_allow_cpu); > > > + > > > +int perf_allow_tracepoint(void) > > > +{ > > > + if (sysctl_perf_event_paranoid > -1 && !perfmon_capable()) > > > + return -EPERM; > > > + > > > + return security_perf_event_open(PERF_SECURITY_TRACEPOINT); > > > +} > > > +EXPORT_SYMBOL_GPL(perf_allow_tracepoint); > > > + > > > /* > > > * Inherit an event from parent task to child task. > > > * > > > -- > > > 2.54.0 > > >