From: Eric Dumazet <eric.dumazet@gmail.com>
To: Daniel Baluta <dbaluta@ixiacom.com>
Cc: netdev@vger.kernel.org, davem@davemloft.net,
Rohan Chitradurga <rohan@ixiacom.com>
Subject: Re: [PATCH] udp: avoid searching when no ports are available
Date: Fri, 25 Feb 2011 13:06:15 +0100 [thread overview]
Message-ID: <1298635575.2659.65.camel@edumazet-laptop> (raw)
In-Reply-To: <1298633711-11924-1-git-send-email-dbaluta@ixiacom.com>
Le vendredi 25 février 2011 à 13:35 +0200, Daniel Baluta a écrit :
> udp_lib_get_port uses a bitmap to mark used ports.
>
> When no ports are available we spend a lot of time, searching
> for a port while holding hslot lock. Avoid this by checking if
> bitmap is full.
>
>
> Signed-off-by: Rohan Chitradurga <rohan@ixiacom.com>
> Signed-off-by: Daniel Baluta <dbaluta@ixiacom.com>
> ---
> net/ipv4/udp.c | 6 ++++++
> 1 files changed, 6 insertions(+), 0 deletions(-)
>
> diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
> index d37baaa..3e3592d 100644
> --- a/net/ipv4/udp.c
> +++ b/net/ipv4/udp.c
> @@ -225,6 +225,12 @@ int udp_lib_get_port(struct sock *sk, unsigned short snum,
> udp_lib_lport_inuse(net, snum, hslot, bitmap, sk,
> saddr_comp, udptable->log);
>
> + /* avoid searching when no ports are available */
> + if (bitmap_full(bitmap, PORTS_PER_CHAIN)) {
> + spin_unlock_bh(&hslot->lock);
> + break;
> + }
> +
> snum = first;
> /*
> * Iterate on all possible values of snum for this hash.
Really ? I wonder how you got your performance numbers then.
First, PORTS_PER_CHAIN is wrong here, since its value is the max
possible value (256 bits)
#define UDP_HTABLE_SIZE_MIN (CONFIG_BASE_SMALL ? 128 : 256)
#define MAX_UDP_PORTS 65536
#define PORTS_PER_CHAIN (MAX_UDP_PORTS / UDP_HTABLE_SIZE_MIN) -> 256
As soon as your machine (and most current machines have) has enough
memory, UDP hash table size is not 256, but 1024 or 2048
dmesg | grep "UDP hash"
[ 1.735203] UDP hash table entries: 2048 (order: 6, 327680 bytes)
So real bitmap size is 64 or 32 bits.
Your call to bitmap_full() always return false.
I dont like this patch. If you have special UDP needs on a small
machine, just add to kernel boot param "uhash_entries=8192", so that the
bitmap has 8 bits only.
next parent reply other threads:[~2011-02-25 12:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1298633711-11924-1-git-send-email-dbaluta@ixiacom.com>
2011-02-25 12:06 ` Eric Dumazet [this message]
2011-02-25 16:45 ` [PATCH] udp: avoid searching when no ports are available Daniel Baluta
2011-02-25 16:55 ` Eric Dumazet
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=1298635575.2659.65.camel@edumazet-laptop \
--to=eric.dumazet@gmail.com \
--cc=davem@davemloft.net \
--cc=dbaluta@ixiacom.com \
--cc=netdev@vger.kernel.org \
--cc=rohan@ixiacom.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