From: David Miller <davem@davemloft.net>
To: eric.dumazet@gmail.com
Cc: netdev@vger.kernel.org, jln@google.com
Subject: Re: [PATCH] tcp: handle tcp_net_metrics_init() order-5 memory allocation failures
Date: Fri, 16 Nov 2012 01:39:40 -0500 (EST) [thread overview]
Message-ID: <20121116.013940.813652515905883288.davem@davemloft.net> (raw)
In-Reply-To: <1353022864.10798.6.camel@edumazet-glaptop>
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Thu, 15 Nov 2012 15:41:04 -0800
> From: Eric Dumazet <edumazet@google.com>
>
> order-5 allocations can fail with current kernels, we should
> try to reduce allocation sizes to allow network namespace
> creation.
>
> Reported-by: Julien Tinnes <jln@google.com>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
Indeed, this has to be done better.
But this kind of retry solution results in non-deterministic behavior.
Yes the tcp metrics cache is best effort, but it's size can influence
behavior in a substantial way depending upon the workload.
I would suggest that we instead use different limits, ones which the
page allocator will satisfy for us always with GFP_KERNEL.
1) include linux/mmzone.h
2) Make the two limits based upon PAGE_ALLOC_COSTLY_ORDER.
That is, make the larger table size PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER
and the smaller one PAGE_SIZE << (PAGE_ALLOC_COSTLY_ORDER - 1).
How about something like this?
diff --git a/net/ipv4/tcp_metrics.c b/net/ipv4/tcp_metrics.c
index 53bc584..d4b2d42 100644
--- a/net/ipv4/tcp_metrics.c
+++ b/net/ipv4/tcp_metrics.c
@@ -1,7 +1,6 @@
#include <linux/rcupdate.h>
#include <linux/spinlock.h>
#include <linux/jiffies.h>
-#include <linux/bootmem.h>
#include <linux/module.h>
#include <linux/cache.h>
#include <linux/slab.h>
@@ -9,6 +8,7 @@
#include <linux/tcp.h>
#include <linux/hash.h>
#include <linux/tcp_metrics.h>
+#include <linux/mmzone.h>
#include <net/inet_connection_sock.h>
#include <net/net_namespace.h>
@@ -1025,10 +1025,12 @@ static int __net_init tcp_net_metrics_init(struct net *net)
slots = tcpmhash_entries;
if (!slots) {
- if (totalram_pages >= 128 * 1024)
- slots = 16 * 1024;
- else
- slots = 8 * 1024;
+ int order = PAGE_ALLOC_COSTLY_ORDER;
+
+ if (totalram_pages < 128 * 1024)
+ order--;
+ slots = (PAGE_SIZE << order) /
+ sizeof(struct tcpm_hash_bucket);
}
net->ipv4.tcp_metrics_hash_log = order_base_2(slots);
next prev parent reply other threads:[~2012-11-16 6:39 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-15 23:41 [PATCH] tcp: handle tcp_net_metrics_init() order-5 memory allocation failures Eric Dumazet
2012-11-15 23:55 ` Joe Perches
2012-11-16 0:47 ` Eric Dumazet
2012-11-16 6:39 ` David Miller [this message]
2012-11-16 15:31 ` Eric Dumazet
2012-11-16 18:37 ` David Miller
2012-11-16 18:51 ` Julien Tinnes
2012-11-16 19:08 ` 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=20121116.013940.813652515905883288.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=jln@google.com \
--cc=netdev@vger.kernel.org \
/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