[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YrUFbLJ5uVbWtZbf@ZenIV>
Date: Fri, 24 Jun 2022 01:29:32 +0100
From: Al Viro <viro@...iv.linux.org.uk>
To: Chuck Lever III <chuck.lever@...cle.com>
Cc: Linux NFS Mailing List <linux-nfs@...r.kernel.org>,
netdev <netdev@...r.kernel.org>,
Dave Chinner <david@...morbit.com>,
"tgraf@...g.ch" <tgraf@...g.ch>, Jeff Layton <jlayton@...hat.com>
Subject: Re: [PATCH RFC 28/30] NFSD: Set up an rhashtable for the filecache
On Fri, Jun 24, 2022 at 12:14:53AM +0000, Chuck Lever III wrote:
>
> > On Jun 23, 2022, at 7:51 PM, Chuck Lever III <chuck.lever@...cle.com> wrote:
> >
> >> On Jun 23, 2022, at 6:56 PM, Al Viro <viro@...iv.linux.org.uk> wrote:
> >>
> >> On Wed, Jun 22, 2022 at 10:15:50AM -0400, Chuck Lever wrote:
> >>
> >>> +static u32 nfsd_file_obj_hashfn(const void *data, u32 len, u32 seed)
> >>> +{
> >>> + const struct nfsd_file *nf = data;
> >>> +
> >>> + return jhash2((const u32 *)&nf->nf_inode,
> >>> + sizeof_field(struct nfsd_file, nf_inode) / sizeof(u32),
> >>> + seed);
> >>
> >> Out of curiosity - what are you using to allocate those? Because if
> >> it's a slab, then middle bits of address (i.e. lower bits of
> >> (unsigned long)data / L1_CACHE_BYTES) would better be random enough...
> >
> > 261 static struct nfsd_file *
> > 262 nfsd_file_alloc(struct nfsd_file_lookup_key *key, unsigned int may)
> > 263 {
> > 264 static atomic_t nfsd_file_id;
> > 265 struct nfsd_file *nf;
> > 266
> > 267 nf = kmem_cache_alloc(nfsd_file_slab, GFP_KERNEL);
> >
> > Was wondering about that. pahole says struct nfsd_file is 112
> > bytes on my system.
>
> Oops. nfsd_file_obj_hashfn() is supposed to be generating the
> hash value based on the address stored in the nf_inode field.
> So it's an inode pointer, alloced via kmem_cache_alloc by default.
inode pointers are definitely "divide by L1_CACHE_BYTES and take lower
bits" fodder...
Powered by blists - more mailing lists