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

Peter Zijlstra peterz at infradead.org
Mon Jun 12 14:58:05 UTC 2023


On Mon, Jun 12, 2023 at 05:46:47PM +0300, Dan Carpenter wrote:
> On Mon, Jun 12, 2023 at 11:07:39AM +0200, Peter Zijlstra wrote:
> > @@ -224,17 +243,15 @@ static int event_function(void *info)
> >  	int ret = 0;
> >  
> >  	lockdep_assert_irqs_disabled();
> > +	guard(perf_ctx_lock)(cpuctx, task_ctx);
> >  
> > -	perf_ctx_lock(cpuctx, task_ctx);
> >  	/*
> >  	 * Since we do the IPI call without holding ctx->lock things can have
> >  	 * changed, double check we hit the task we set out to hit.
> >  	 */
> >  	if (ctx->task) {
> > -		if (ctx->task != current) {
> > -			ret = -ESRCH;
> > -			goto unlock;
> > -		}
> > +		if (ctx->task != current)
> > +			return -ESRCH;
> >  
> >  		/*
> >  		 * We only use event_function_call() on established contexts,
> > @@ -254,8 +271,6 @@ static int event_function(void *info)
> >  	}
> >  
> >  	efs->func(event, cpuctx, ctx, efs->data);
> > -unlock:
> > -	perf_ctx_unlock(cpuctx, task_ctx);
> >  
> >  	return ret;
> 
> 
> We can change this to a return 0; and get rid of the "ret" variable.

This and the previous one, done!



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