On Sat, Apr 1, 2023 at 12:24 PM Anton Protopopov <aspsk@xxxxxxxxxxxxx> wrote: > > > -static inline u32 htab_map_hash(const void *key, u32 key_len, u32 hashrnd) > > > +static inline u32 htab_map_hash(const struct bpf_htab *htab, const void *key, u32 key_len) > > > { > > > - return jhash(key, key_len, hashrnd); > > > + if (likely(htab->key_size_u32)) > > > + return jhash2(key, htab->key_size_u32, htab->hashrnd); > > > + return jhash(key, key_len, htab->hashrnd); > > > > Could you measure the speed when &3 and /4 is done in the hot path ? > > I would expect the performance to be the same or faster, > > since extra load is gone. > > I don't see any visible difference (I've tested "&3 and /4" and "%4==0 and /4" > variants). I bet compiler generates the same code for these two variants. % is optimized into &. / is optimized into >>. > Do you still prefer division in favor of using htab->key_size_u32? yes, because it's a shift.