[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20220908000206.41237-1-kuniyu@amazon.com>
Date: Wed, 7 Sep 2022 17:02:06 -0700
From: Kuniyuki Iwashima <kuniyu@...zon.com>
To: <eric.dumazet@...il.com>
CC: <davem@...emloft.net>, <edumazet@...gle.com>, <kuba@...nel.org>,
<kuni1840@...il.com>, <kuniyu@...zon.com>,
<netdev@...r.kernel.org>, <pabeni@...hat.com>
Subject: Re: [PATCH v5 net-next 6/6] tcp: Introduce optional per-netns ehash.
From: Eric Dumazet <eric.dumazet@...il.com>
Date: Wed, 7 Sep 2022 16:45:17 -0700
> On 9/6/22 17:55, Kuniyuki Iwashima wrote:
> > The more sockets we have in the hash table, the longer we spend looking
> > up the socket. While running a number of small workloads on the same
> > host, they penalise each other and cause performance degradation.
> >
> >
> > +
> > +struct inet_hashinfo *inet_pernet_hashinfo_alloc(struct inet_hashinfo *hashinfo,
> > + unsigned int ehash_entries)
> > +{
> > + struct inet_hashinfo *new_hashinfo;
> > + int i;
> > +
> > + new_hashinfo = kmalloc(sizeof(*new_hashinfo), GFP_KERNEL);
>
> You probably could use kmemdup(hashinfo, sizeof(*hashinfo), GFP_KERNEL);
Exactly, I'll use it and remove the manual copy.
Thank you!
> > + if (!new_hashinfo)
> > + goto err;
> > +
> > + new_hashinfo->ehash = kvmalloc_array(ehash_entries,
> > + sizeof(struct inet_ehash_bucket),
> > + GFP_KERNEL_ACCOUNT);
> > + if (!new_hashinfo->ehash)
> > + goto free_hashinfo;
> > +
> > + new_hashinfo->ehash_mask = ehash_entries - 1;
> > +
> > + if (inet_ehash_locks_alloc(new_hashinfo))
> > + goto free_ehash;
> > +
> > + for (i = 0; i < ehash_entries; i++)
> > + INIT_HLIST_NULLS_HEAD(&new_hashinfo->ehash[i].chain, i);
> > +
> > + new_hashinfo->bind_bucket_cachep = hashinfo->bind_bucket_cachep;
> > + new_hashinfo->bhash = hashinfo->bhash;
> > + new_hashinfo->bind2_bucket_cachep = hashinfo->bind2_bucket_cachep;
> > + new_hashinfo->bhash2 = hashinfo->bhash2;
> > + new_hashinfo->bhash_size = hashinfo->bhash_size;
> > +
> > + new_hashinfo->lhash2_mask = hashinfo->lhash2_mask;
> > + new_hashinfo->lhash2 = hashinfo->lhash2;
>
>
> This would avoid copying all these @hashinfo fields.
Powered by blists - more mailing lists