[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANn89iJJu2ZEu2X+AdfUKrBVj5N5h2bSDE73fwNcVmOm-JSVwA@mail.gmail.com>
Date: Mon, 27 Jun 2022 21:06:14 +0200
From: Eric Dumazet <edumazet@...gle.com>
To: Kuniyuki Iwashima <kuniyu@...zon.com>
Cc: David Miller <davem@...emloft.net>,
"Eric W. Biederman" <ebiederm@...ssion.com>,
Herbert Xu <herbert@...dor.apana.org.au>,
Jakub Kicinski <kuba@...nel.org>,
Kuniyuki Iwashima <kuni1840@...il.com>,
netdev <netdev@...r.kernel.org>, Paolo Abeni <pabeni@...hat.com>,
Pavel Emelyanov <xemul@...nvz.org>
Subject: Re: [PATCH v2 net] af_unix: Do not call kmemdup() for init_net's
sysctl table.
On Mon, Jun 27, 2022 at 8:59 PM Kuniyuki Iwashima <kuniyu@...zon.com> wrote:
>
> From: Eric Dumazet <edumazet@...gle.com>
> Date: Mon, 27 Jun 2022 20:40:24 +0200
> > On Mon, Jun 27, 2022 at 8:30 PM Kuniyuki Iwashima <kuniyu@...zon.com> wrote:
> > >
> > > From: Jakub Kicinski <kuba@...nel.org>
> > > Date: Mon, 27 Jun 2022 10:58:59 -0700
> > > > On Sun, 26 Jun 2022 11:43:27 -0500 Eric W. Biederman wrote:
> > > > > Kuniyuki Iwashima <kuniyu@...zon.com> writes:
> > > > >
> > > > > > While setting up init_net's sysctl table, we need not duplicate the global
> > > > > > table and can use it directly.
> > > > >
> > > > > Acked-by: "Eric W. Biederman" <ebiederm@...ssion.com>
> > > > >
> > > > > I am not quite certain the savings of a single entry table justivies
> > > > > the complexity. But the looks correct.
> > > >
> > > > Yeah, the commit message is a little sparse. The "why" is not addressed.
> > > > Could you add more details to explain the motivation?
> > >
> > > I was working on a series which converts UDP/TCP hash tables into per-netns
> > > ones like AF_UNIX to speed up looking up sockets. It will consume much
> > > memory on a host with thousands of netns, but it can be waste if we do not
> > > have its protocol family's sockets.
> >
> > For the record, I doubt we will accept such a patch (per net-ns
> > TCP/UDP hash tables)
>
> Is it because it's risky?
Because it will be very expensive. TCP hash tables are quite big.
[ 4.917080] tcp_listen_portaddr_hash hash table entries: 65536
(order: 8, 1048576 bytes, vmalloc)
[ 4.917260] TCP established hash table entries: 524288 (order: 10,
4194304 bytes, vmalloc hugepage)
[ 4.917760] TCP bind hash table entries: 65536 (order: 8, 1048576
bytes, vmalloc)
[ 4.917881] TCP: Hash tables configured (established 524288 bind 65536)
> IIRC, you said we need per netns table for TCP in the future.
Which ones exactly ? I guess you misunderstood.
>
>
> > > So, I'm now working on a follow-up series for AF_UNIX per-netns hash table
> > > so that we can change the size for a child netns by a sysctl knob:
> > >
> > > # sysctl -w net.unix.child_hash_entries=128
> > > # ip net add test # created with the hash table size 128
> > > # ip net exec test sh
> > > # sysctl net.unix.hash_entries # read-only
> > > 128
> > >
> > > (The size for init_net can be changed via a new boot parameter
> > > xhash_entries like uhash_entries/thash_entries.)
> > >
> > > While implementing that, I found that kmemdup() is called for init_net but
> > > TCP/UDP does not (See: ipv4_sysctl_init_net()). Unlike IPv4, AF_UNIX does
> > > not have a huge sysctl table, so it cannot be a problem though, this patch
> > > is for consuming less memory and kind of consistency. The reason I submit
> > > this seperately is that it might be better to have a Fixes tag.
> >
> > I think that af_unix module can be unloaded.
> >
> > Your patch will break the module unload operation.
>
> Thank you!
> I had to take of kfree() in unix_sysctl_unregister().
Powered by blists - more mailing lists