[PATCH v3 26/57] perf: Simplify event_function*()

Peter Zijlstra peterz at infradead.org
Tue Jun 13 07:39:14 UTC 2023


On Mon, Jun 12, 2023 at 10:56:06PM -0700, Namhyung Kim wrote:
> Hi Peter,
> 
> On Mon, Jun 12, 2023 at 2:39 AM Peter Zijlstra <peterz at infradead.org> wrote:
> >
> > Use guards to reduce gotos and simplify control flow.
> >
> > Signed-off-by: Peter Zijlstra (Intel) <peterz at infradead.org>
> > ---
> >  kernel/events/core.c |   39 ++++++++++++++++++++++++++-------------
> >  1 file changed, 26 insertions(+), 13 deletions(-)
> >
> > --- a/kernel/events/core.c
> > +++ b/kernel/events/core.c
> > @@ -214,6 +214,25 @@ struct event_function_struct {
> >         void *data;
> >  };
> >
> > +typedef struct {
> > +       struct perf_cpu_context *cpuctx;
> > +       struct perf_event_context *ctx;
> > +} class_perf_ctx_lock_t;
> > +
> > +static inline void class_perf_ctx_lock_destructor(class_perf_ctx_lock_t *_T)
> > +{
> > +       if (_T->cpuctx)
> > +               perf_ctx_unlock(_T->cpuctx, _T->ctx);
> 
> Shouldn't it be called unconditionally?

In all surviving cases it will be, so yeah, I can remove that condition.



More information about the Linux-security-module-archive mailing list