On Tue, Nov 29, 2005 at 01:33:34PM -0800, David S. Miller wrote:
> From: Mike Stroyan <[EMAIL PROTECTED]>
> Date: Tue, 29 Nov 2005 14:23:10 -0700
> 
> >   The tcp_ehash hash table gets too big on systems with really big memory.
> > It is worse on systems with pages larger than 4KB.  It wastes memory that
> > could be better used.  It also makes the netstat command slow because 
> > reading
> > /proc/net/tcp and /proc/net/tcp6 needs to go through the full hash table.
> 
> Nobody should be using /proc/net/tcp{,6} for anything.
> The netlink based socket dumping is what one should use.
> 
> Anyone running a multi-user system should change the file
> protections of /proc/net/tcp{,6} so that normal users cannot
> access those files if they think this is an issue.

  Is there any plan to change netstat to replace its uses of
/proc/net/tcp* ?  Should there be?  I found earlier mail from you noting
that ss uses netlink.  (ss -a takes almost a full second to use AF_NETLINK
with a 16 million entry hash table.  That does compare pretty well to
3.3 seconds using netstat /proc/net/tcp.)

socket(PF_NETLINK, SOCK_RAW, 4)         = 3 <0.000020>
sendmsg(3, {msg_name(12)={sa_family=AF_NETLINK, pid=0, groups=00000000},
msg_iov(1)=[{"[EMAIL PROTECTED]"...,
76}], msg_controllen=0, msg_flags=0}, 0) = 76 <0.959964>
recvmsg(3, {msg_name(12)={sa_family=AF_NETLINK, pid=0, groups=00000000},
msg_iov(1)=[{"[EMAIL PROTECTED]"...,
8192}], msg_controllen=0, msg_flags=0}, 0) = 2288 <0.000036>

> This does not detract from your fix, however :)
> 
> I agree that a connection between PAGE_SHIFT and hash sizing
> is pointless.  Actually, it's more important to have a tie between
> "pointer size" and hash sizing, ie. 64-bit systems should apportion
> twice as much space for TCP hash tables as 32-bit systems.

  The current mechanism with alloc_large_system_hash does scale the
hash table in proportion to the size of struct inet_ehash_bucket.
The numentries calculation is always done in terms of the number of hash
buckets.  The scale parameter is the desired power-of-two ratio between
the bytes of available RAM and the number of hash buckets.  If the size
of a pointer increases it will be reflected in the size of the struct.
That will increase the amount of RAM dedicated to the hash table.

-- 

Mike Stroyan, [EMAIL PROTECTED]
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to