Re: [PATCH 2/7] fsnotify: support hashed notification queue

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

 



On Wed 17-02-21 17:42:34, Amir Goldstein wrote:
> On Wed, Feb 17, 2021 at 3:48 PM Jan Kara <jack@xxxxxxx> wrote:
> > > > > +static inline size_t fsnotify_group_size(unsigned int q_hash_bits)
> > > > > +{
> > > > > +     return sizeof(struct fsnotify_group) + (sizeof(struct list_head) << q_hash_bits);
> > > > > +}
> > > > > +
> > > > > +static inline unsigned int fsnotify_event_bucket(struct fsnotify_group *group,
> > > > > +                                              struct fsnotify_event *event)
> > > > > +{
> > > > > +     /* High bits are better for hash */
> > > > > +     return (event->key >> (32 - group->q_hash_bits)) & group->max_bucket;
> > > > > +}
> > > >
> > > > Why not use hash_32() here? IMHO better than just stripping bits...
> > >
> > > See hash_ptr(). There is a reason to use the highest bits.
> >
> > Well, but event->key is just a 32-bit number so I don't follow how high
> > bits used by hash_ptr() matter?
> 
> Of course, you are right.
> But that 32-bit number was already generated using a xor of several
> hash_32() results from hash_ptr() and full_name_hash(), so we do not really
> need to mix it anymore to get better entropy in the higher 7 bits.

True. Just masking it with q_hash_bits is fine as well.

								Honza
-- 
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux