All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lukas Wunner <lukas@wunner.de>
To: Dan Williams <dan.j.williams@intel.com>
Cc: David Howells <dhowells@redhat.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	"David S. Miller" <davem@davemloft.net>,
	Jonathan Cameron <Jonathan.Cameron@huawei.com>,
	keyrings@vger.kernel.org, linux-crypto@vger.kernel.org,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Ard Biesheuvel <ardb@kernel.org>,
	Jarkko Sakkinen <jarkko@kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Nathan Chancellor <nathan@kernel.org>
Subject: Re: [PATCH v2] X.509: Introduce scope-based x509_certificate allocation
Date: Tue, 13 Feb 2024 06:04:45 +0100	[thread overview]
Message-ID: <20240213050445.GA27995@wunner.de> (raw)
In-Reply-To: <65ca861e14779_5a7f2949e@dwillia2-xfh.jf.intel.com.notmuch>

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

      reply	other threads:[~2024-02-13  5:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-12 11:24 [PATCH v2] X.509: Introduce scope-based x509_certificate allocation Lukas Wunner
2024-02-12 12:19 ` Andy Shevchenko
2024-02-12 16:36   ` Lukas Wunner
2024-02-12 18:10 ` Jarkko Sakkinen
2024-02-12 19:07 ` Dan Williams
2024-02-12 19:20   ` Lukas Wunner
2024-02-12 20:57     ` Dan Williams
2024-02-13  5:04       ` Lukas Wunner [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240213050445.GA27995@wunner.de \
    --to=lukas@wunner.de \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=ardb@kernel.org \
    --cc=dan.j.williams@intel.com \
    --cc=davem@davemloft.net \
    --cc=dhowells@redhat.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=jarkko@kernel.org \
    --cc=keyrings@vger.kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.