Re: [PATCH v2] X.509: Introduce scope-based x509_certificate allocation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Feb 12, 2024 at 12:57:02PM -0800, Dan Williams wrote:
> Lukas Wunner wrote:
> > On Mon, Feb 12, 2024 at 11:07:06AM -0800, Dan Williams wrote:
> > > Lukas Wunner wrote:
> > > > In x509_cert_parse(), add a hint for the compiler that kzalloc()
> > > > never returns an ERR_PTR().  Otherwise the compiler adds a gratuitous
> > > > IS_ERR() check on return.  Introduce a handy assume() macro for this
> > > > which can be re-used elsewhere in the kernel to provide hints for the
> > > > compiler.
> 
> Might I suggest the following:
> 
> > diff --git a/include/linux/compiler.h b/include/linux/compiler.h
> > index bb1339c..384803e 100644
> > --- a/include/linux/compiler.h
> > +++ b/include/linux/compiler.h
> > @@ -139,6 +139,8 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
> >  } while (0)
> >  #endif
> >  
> > +#define assume(cond) do if(!(cond)) __builtin_unreachable(); while(0)
> 
> s/__builtin_unreachable()/unreachable()/?

I tried that and it didn't work.  The superfluous IS_ERR() check
was not optimized away by gcc.  It seemed to remove the unreachable
portion of the code before using it for optimization of the code.


> Move this to cleanup.h and add extend the DEFINE_FREE() comment about
> its usage:

Yes, spreading the knowledge in this way might make sense.
I'll wait for Peter to weigh in before submitting that though.

Thanks,

Lukas




[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]
  Powered by Linux