lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-id: <175862707333.1696783.11988392990379659217@noble.neil.brown.name>
Date: Tue, 23 Sep 2025 21:31:13 +1000
From: NeilBrown <neilb@...mail.net>
To: "Menglong Dong" <menglong8.dong@...il.com>
Cc: "Herbert Xu" <herbert@...dor.apana.org.au>, tgraf@...g.ch,
 linux-crypto@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] rhashtable: add likely() to __rht_ptr()

On Tue, 23 Sep 2025, Menglong Dong wrote:
> On Tue, Sep 23, 2025 at 2:36 PM Herbert Xu <herbert@...dor.apana.org.au> wrote:
> >
> > Menglong Dong <menglong8.dong@...il.com> wrote:
> > > In the fast path, the value of "p" in __rht_ptr() should be valid.
> > > Therefore, wrap it with a "likely". The performance increasing is tiny,
> > > but it's still worth to do it.
> > >
> > > Signed-off-by: Menglong Dong <dongml2@...natelecom.cn>
> > > ---
> > > include/linux/rhashtable.h | 5 +++--
> > > 1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > It's not obvious that rht_ptr would be non-NULL.  It depends on the
> > work load.  For example, if you're doing a lookup where most keys
> > are non-existent then it would most likely be NULL.
> 
> Yeah, I see. In my case, the usage of the rhashtable will be:
> add -> lookup, and rht_ptr is alway non-NULL. You are right,
> it can be NULL in other situations, and it's not a good idea to
> use likely() here ;)

Have you measured a performance increase?  How tiny is it?

It might conceivably make sense to have a rhashtable_lookup_likely() and
rhashtable_lookup_unlikely(), but concrete evidence of the benefit would
be needed.

Thanks,
NeilBrown

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ