Re: [PATCH] dev: use name hash for dev_seq_ops
From: Stephen Hemminger <hidden>
Date: 2011-10-21 17:08:10
Also in:
lkml
On Fri, 21 Oct 2011 09:45:10 +0300 Mihai Maruseac [off-list ref] wrote:
quoted hunk ↗ jump to hunk
Instead of using the dev->next chain and trying to resync at each call to dev_seq_start, use the name hash, keeping the bucket and the offset in seq->private field. Tests revealed the following results for ifconfig > /dev/null * 1000 interfaces: * 0.114s without patch * 0.089s with patch * 3000 interfaces: * 0.489s without patch * 0.110s with patch * 5000 interfaces: * 1.363s without patch * 0.250s with patch * 128000 interfaces (other setup): * ~100s without patch * ~30s with patch Signed-off-by: Mihai Maruseac <redacted> --- net/core/dev.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 69 insertions(+), 15 deletions(-)diff --git a/net/core/dev.c b/net/core/dev.c index 70ecb86..6edbcc5 100644 --- a/net/core/dev.c +++ b/net/core/dev.c@@ -4041,6 +4041,60 @@ static int dev_ifconf(struct net *net, char __user *arg) } #ifdef CONFIG_PROC_FS + +#define BUCKET_SPACE (32 - NETDEV_HASHBITS) + +struct dev_iter_state { + struct seq_net_private p; + unsigned int pos; /* bucket << BUCKET_SPACE + offset */ +}; + +#define get_bucket(x) ((x) >> BUCKET_SPACE) +#define get_offset(x) ((x) & ((1 << BUCKET_SPACE) - 1)) +#define set_bucket_offset(b, o) ((b) << BUCKET_SPACE | (o)) + +static inline struct net_device *dev_from_same_bucket(struct seq_file *seq)
Why are all these function marked inline? They are big, hardly hot path and better to not continue the bad practice of inlining too much code.