From: "Mi, Dapeng" <dapeng1.mi@linux.intel.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Kan Liang <kan.liang@linux.intel.com>,
Andi Kleen <ak@linux.intel.com>,
Eranian Stephane <eranian@google.com>,
linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
Dapeng Mi <dapeng1.mi@intel.com>
Subject: Re: [Patch v4 07/13] perf/x86/intel: Allocate arch-PEBS buffer and initialize PEBS_BASE MSR
Date: Mon, 23 Jun 2025 16:41:34 +0800 [thread overview]
Message-ID: <24cfe3f8-2d3f-442c-8adf-5b7446776147@linux.intel.com> (raw)
In-Reply-To: <20250623072850.GN1613200@noisy.programming.kicks-ass.net>
On 6/23/2025 3:28 PM, Peter Zijlstra wrote:
> On Mon, Jun 23, 2025 at 09:17:23AM +0800, Mi, Dapeng wrote:
>> On 6/21/2025 5:20 PM, Peter Zijlstra wrote:
>>> On Fri, Jun 20, 2025 at 10:39:03AM +0000, Dapeng Mi wrote:
>>>
>>>> diff --git a/arch/x86/events/intel/ds.c b/arch/x86/events/intel/ds.c
>>>> index b6eface4dccd..72b925b8c482 100644
>>>> --- a/arch/x86/events/intel/ds.c
>>>> +++ b/arch/x86/events/intel/ds.c
>>>> @@ -625,13 +625,22 @@ static int alloc_pebs_buffer(int cpu)
>>>> int max, node = cpu_to_node(cpu);
>>>> void *buffer, *insn_buff, *cea;
>>>>
>>>> - if (!x86_pmu.ds_pebs)
>>>> + if (!intel_pmu_has_pebs())
>>>> return 0;
>>>>
>>>> - buffer = dsalloc_pages(bsiz, GFP_KERNEL, cpu);
>>>> + /*
>>>> + * alloc_pebs_buffer() could be called by init_arch_pebs_buf_on_cpu()
>>>> + * which is in atomic context.
>>>> + */
>>>> + buffer = dsalloc_pages(bsiz, preemptible() ? GFP_KERNEL : GFP_ATOMIC, cpu);
>>>> if (unlikely(!buffer))
>>>> return -ENOMEM;
>>> Here we go again.. that is CPU_STARTING context, that has IRQs disabled
>>> and as such no allocation is allowed. Not even GFP_ATOMIC -- this will
>>> break PREEMPT_RT.
>> Thanks. So we could have to follow what current legacy PEBS does and defer
>> the PEBS buffer allocation until creating perf events
>> (x86_reserve_hardware()).
> The normal way to do this kind of thing is allocate in prepare, use in
> starting, and the reverse on down, stop using in dying and free in dead.
>
> Specifically we have the callbacks:
>
> CPUHP_PERF_X86_PREPARE -> x86_pmu.cpu_prepare() / x86_pmu.cpu_dead()
> CPUHP_PERF_X86_STARTING -> x86_pmu.cpu_starting() / x86_pmu.cpu_dying()
>
> to arrange for just such a setup.
Sure. Would do. Thanks.
>
next prev parent reply other threads:[~2025-06-23 8:41 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-20 10:38 [Patch v4 00/13] arch-PEBS enabling for Intel platforms Dapeng Mi
2025-06-20 10:38 ` [Patch v4 01/13] perf/x86/intel: Replace x86_pmu.drain_pebs calling with static call Dapeng Mi
2025-06-20 10:38 ` [Patch v4 02/13] perf/x86/intel: Correct large PEBS flag check Dapeng Mi
2025-06-20 10:38 ` [Patch v4 03/13] perf/x86/intel: Initialize architectural PEBS Dapeng Mi
2025-06-20 10:39 ` [Patch v4 04/13] perf/x86/intel/ds: Factor out PEBS record processing code to functions Dapeng Mi
2025-06-20 10:39 ` [Patch v4 05/13] perf/x86/intel/ds: Factor out PEBS group " Dapeng Mi
2025-06-20 10:39 ` [Patch v4 06/13] perf/x86/intel: Process arch-PEBS records or record fragments Dapeng Mi
2025-06-20 10:39 ` [Patch v4 07/13] perf/x86/intel: Allocate arch-PEBS buffer and initialize PEBS_BASE MSR Dapeng Mi
2025-06-21 9:20 ` Peter Zijlstra
2025-06-23 1:17 ` Mi, Dapeng
2025-06-23 7:28 ` Peter Zijlstra
2025-06-23 8:41 ` Mi, Dapeng [this message]
2025-06-20 10:39 ` [Patch v4 08/13] perf/x86/intel: Update dyn_constranit base on PEBS event precise level Dapeng Mi
2025-06-20 10:39 ` [Patch v4 09/13] perf/x86/intel: Setup PEBS data configuration and enable legacy groups Dapeng Mi
2025-06-21 9:27 ` Peter Zijlstra
2025-06-23 1:20 ` Mi, Dapeng
2025-06-21 9:34 ` Peter Zijlstra
2025-06-23 1:38 ` Mi, Dapeng
2025-06-21 9:36 ` Peter Zijlstra
2025-06-23 1:39 ` Mi, Dapeng
2025-06-21 9:41 ` Peter Zijlstra
2025-06-23 1:55 ` Mi, Dapeng
2025-06-21 9:43 ` Peter Zijlstra
2025-06-23 1:55 ` Mi, Dapeng
2025-06-20 10:39 ` [Patch v4 10/13] perf/x86/intel: Add counter group support for arch-PEBS Dapeng Mi
2025-06-20 10:39 ` [Patch v4 11/13] perf/x86: Support to sample SSP register Dapeng Mi
2025-06-20 10:39 ` [Patch v4 12/13] perf/x86/intel: Support to sample SSP register for arch-PEBS Dapeng Mi
2025-06-20 10:39 ` [Patch v4 13/13] perf tools: x86: Support to show SSP register Dapeng Mi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=24cfe3f8-2d3f-442c-8adf-5b7446776147@linux.intel.com \
--to=dapeng1.mi@linux.intel.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=dapeng1.mi@intel.com \
--cc=eranian@google.com \
--cc=irogers@google.com \
--cc=kan.liang@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).