netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: David Miller <davem@davemloft.net>,
	netdev@vger.kernel.org, sthemmin@microsoft.com
Subject: Re: [PATCH] inet: add bound ports statistic
Date: Thu, 01 Mar 2018 09:09:00 -0800	[thread overview]
Message-ID: <1519924140.11375.1.camel@gmail.com> (raw)
In-Reply-To: <20180301081613.3b52cd83@xeon-e3>

On Thu, 2018-03-01 at 08:16 -0800, Stephen Hemminger wrote:
> 
> I went through a several possible alternatives.
>    1. Add a counter in the hash bucket head (like listen already has).
>       But not namespace aware
>    2. Add a percpu counter in network namespace (new struct tcp_netns)
>       Logical and adds place to move tcp open sockets as well.
>       But more expensive and several places in code don't have easy
>       access to namespace.

__this_cpu_inc() should not be very expensive.

We always have access to socket namespace when inserting/deleting a
bind entry.

Since we take the spinlock at that times, inserting
__this_cpu_inc(sock_net(sk)->ipv4.bind_counter) would add few
instructions.

>    3. Counting entries in userspace; defeats the purpose of -s flag.
> 
> Agree it is not an urgent statistic, it is just it got broken; willing to
> just drop it.

Not counting the fact that it has really no purpose.

> 
> What about adding cond_resched between buckets like other places do?

This still is dirtying at least 1MB of memory and performs ~64K atomic
operations.
Waste of cpu caches and memory bus.

If we consider converting the whole /proc/net/socketstat to provide a
netns view only, we might use a percpu structure holding all TCP socket
counters, to make sure no more than one cache line per cpu is used
while folding all the cpus counters.

      reply	other threads:[~2018-03-01 17:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-01  2:01 [PATCH] inet: add bound ports statistic Stephen Hemminger
2018-03-01  2:28 ` Eric Dumazet
2018-03-01  3:32   ` David Miller
2018-03-01  4:28     ` Eric Dumazet
2018-03-01 16:16       ` Stephen Hemminger
2018-03-01 17:09         ` Eric Dumazet [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1519924140.11375.1.camel@gmail.com \
    --to=eric.dumazet@gmail.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.org \
    --cc=sthemmin@microsoft.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).