mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yang Jihong <yangjihong1@huawei.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Namhyung Kim <namhyung@kernel.org>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	linux-perf-users <linux-perf-users@vger.kernel.org>,
	Yang Jihong <yangjihong1@huawei.com>,
	Jiri Olsa <jolsa@kernel.org>
Subject: Re: [PATCH RESEND v4] perf/core: Fix reentry problem in perf_output_read_group
Date: Mon, 5 Sep 2022 09:33:43 +0800	[thread overview]
Message-ID: <5aec1311-6fa9-b7f9-bbef-e58a6ab6eb73@huawei.com> (raw)
In-Reply-To: <0ed8a3fe-f2f3-ed47-413a-b53b6fd9ac8f@huawei.com>

Hello,

On 2022/9/5 9:25, Yang Jihong wrote:
> On Fri, Sep 02, 2022 at 04:29:18PM +0800, Yang Jihong wrote:
>  > perf_output_read_group may respond to IPI request of other cores and
>  > invoke __perf_install_in_context function. As a result, hwc 
> configuration is modified.
>  > causing inconsistency and unexpected consequences.
>  >
>  > Interrupts are not disabled when perf_output_read_group reads PMU 
> counter.
>  > In this case, IPI request may be received from other cores.
>  > As a result, PMU configuration is modified and an error occurs when
>  > reading PMU counter:
>  >
>  >                    CPU0                                         CPU1
>  > __se_sys_perf_event_open
>  > perf_install_in_context
>  > perf_output_read_group smp_call_function_single
>  >   for_each_sibling_event(sub, leader) { generic_exec_single
>  >     if ((sub != event) && remote_function
>  >         (sub->state == PERF_EVENT_STATE_ACTIVE))                    |
>  > <enter IPI handler: __perf_install_in_context>   <----RAISE IPI-----+
>  > __perf_install_in_context
>  >   ctx_resched
>  >     event_sched_out
>  >       armpmu_del
>  >         ...
>  >         hwc->idx = -1; // event->hwc.idx is set to -1 ...
>  > <exit IPI>
>  >             sub->pmu->read(sub);
>  >               armpmu_read
>  >                 armv8pmu_read_counter
>  >                   armv8pmu_read_hw_counter
>  >                     int idx = event->hw.idx; // idx = -1
>  >                     u64 val = armv8pmu_read_evcntr(idx);
>  >                       u32 counter = ARMV8_IDX_TO_COUNTER(idx); // 
> invalid counter = 30
>  >                       read_pmevcntrn(counter) // undefined instruction
>  >
>  > Signed-off-by: Yang Jihong <yangjihong1@huawei.com>
>  > ---
> 
> Right; thanks for reminding me. I had hoped you'd pick up and test the 
> extra assertion some, but I'll just do that on top.
> .
OK, if you want me to do assertion testing on any scenarios,
please send me the patch.

Thanks,
Yang

       reply	other threads:[~2022-09-05  1:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <0ed8a3fe-f2f3-ed47-413a-b53b6fd9ac8f@huawei.com>
2022-09-05  1:33 ` Yang Jihong [this message]
2022-09-02  8:29 Yang Jihong
2022-09-02 12:01 ` Peter Zijlstra

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=5aec1311-6fa9-b7f9-bbef-e58a6ab6eb73@huawei.com \
    --to=yangjihong1@huawei.com \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=rostedt@goodmis.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

all inboxes | Powered by JetHome®