Re: [RESEND PATCH 2/2] perf/x86: improve the event scheduling to avoid unnecessary pmu_stop/start

Peter Zijlstra
2022-03-04T15:39:51Z

On Fri, Mar 04, 2022 at 07:03:51PM +0800, Wen Yang wrote:
> this issue has been there for a long time, we could reproduce it as follows:

What issue? You've not described an issue. So you cannot reference one.

This is still completely unreadable gibberish.

> 1, run a script that periodically collects perf data, eg:
> while true
> do
> perf stat -e cache-misses,cache-misses,cache-misses -c 1 sleep 2
> perf stat -e cache-misses -c 1 sleep 2
> sleep 1
> done
>
> 2, run another one to capture the ipc, eg:
> perf stat -e cycles:d,instructions:d -c 1 -i 1000

<snip line noise>

> the reason is that the nmi watchdog permanently consumes one fp
> (*cycles*). therefore, when the above shell script obtains *cycles*
> again, only one gp can be used, and its weight is 5.
> but other events (like *cache-misses*) have a weight of 4,
> so the counter used by *cycles* will often be taken away, as in
> the raw data above:
> [1]
> n_events = 3
> assign = {33, 1, 32, ...}
> -->
> n_events = 6
> assign = {33, 3, 32, 0, 1, 2, ...}

Again unreadable... what do any of those numbers mean?

>
> so it will cause unnecessary pmu_stop/start and also cause abnormal cpi.

How?!?

> Cloud servers usually continuously monitor the cpi data of some important
> services. This issue affects performance and misleads monitoring.
>
> The current event scheduling algorithm is more than 10 years old:
> commit 1da53e023029 ("perf_events, x86: Improve x86 event scheduling")

irrelevant

> we wish it could be optimized a bit.

I wish for a unicorn ...

> The fields msk_counters and msk_events are added to indicate currently
> used counters and events so that the used ones can be skipped
> in __perf_sched_find_counter and perf_sched_next_event functions to avoid
> unnecessary pmu_stop/start.

Still not sure what your actual problem is, nor what the actual proposal
is.

Why should I attempt to reverse engineer your code without basic
understanding of what you're actually trying to achieve?