Re: [PATCH] perf/core: fix perf_event_mux_interval_ms when set zero

From: Namhyung Kim
Date: Tue Jun 14 2022 - 18:08:40 EST


Hello,

On Tue, Jun 14, 2022 at 3:38 AM Yajun Deng <yajun.deng@xxxxxxxxx> wrote:
>
> The perf_event_mux_interval_ms is set to zero or one by default.

I see that __perf_mux_hrtimer_init() sets it to PERF_CPU_HRTIMER
if it's less than 1.

Thanks,
Namhyung


> It can't change back when someone changes it from zero to another
> value.
>
> Make perf_event_mux_interval_ms to PERF_CPU_HRTIMER when set zero.
>
> Fixes: 62b856397927 ("perf: Add sysfs entry to adjust multiplexing interval per PMU")
> Signed-off-by: Yajun Deng <yajun.deng@xxxxxxxxx>
> ---
> kernel/events/core.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index 61ad10862c21..73c8c7462bbf 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -10954,9 +10954,12 @@ perf_event_mux_interval_ms_store(struct device *dev,
> if (ret)
> return ret;
>
> - if (timer < 1)
> + if (timer < 0)
> return -EINVAL;
>
> + if (timer < 1)
> + timer = PERF_CPU_HRTIMER;
> +
> /* same value, noting to do */
> if (timer == pmu->hrtimer_interval_ms)
> return count;
> --
> 2.25.1
>