Re: [PATCH 5/8] perf/amd/ibs: Don't allow freq mode event creation through ->config interface
From: Namhyung Kim
Date: Wed Oct 09 2024 - 02:27:36 EST
On Tue, Oct 08, 2024 at 11:00:37AM +0530, Ravi Bangoria wrote:
> >> Don't allow freq mode event creation through perf_event_attr->config
> >> interface.
> >
> > Sounds reasonable. I agree the freq mode should use the standard
> > interface using attr->sample_freq. But I'm not sure if the behaivor is
> > defined when attr->freq is set and attr->sample_freq is 0. Maybe this
> > should be handled in the generic code.
>
> I also could not find any reason to allow {freq=1, sample_freq=0}, but:
>
> 1) perf_event_open() allows it.
> 2) ioctl(PERF_EVENT_IOC_PERIOD) allows it.
> 3) all generic code explicitly checks for ->sample_freq != 0 wherever
> ->freq == 1.
>
> I will prepare and post a patch to reject such event and see if there
> are any objections.
Hmm.. now I think that the kernel won't treat it as a sampling event and
would ignore the attr.freq value. Setting IOC_PERIOD to 0 would disable
sampling then. Sorry for the noise.
Thanks,
Namhyung