netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Olaf Hering <olh@suse.de>
To: "David S. Miller" <davem@davemloft.net>
Cc: Olaf Kirch <okir@suse.de>,
	brugolsky@telemetry-investments.com, netdev@oss.sgi.com
Subject: Re: limited number if iptable rules on 64bit hosts
Date: Thu, 3 Feb 2005 19:59:28 +0100	[thread overview]
Message-ID: <20050203185928.GA22832@suse.de> (raw)
In-Reply-To: <20050203104822.05be3281.davem@davemloft.net>

 On Thu, Feb 03, David S. Miller wrote:

> On Thu, 3 Feb 2005 12:19:39 +0100
> Olaf Kirch <okir@suse.de> wrote:
> 
> > At 3445 rules, tmp.size is 524272 (why does it want that much memory? I
> > would expect the only data that's per-CPU is the packet and byte
> > counters).
> 
> The rule itself is replicated per-cpu as well to keep L2 cache
> accesses local per cpu on SMP systems.

Andy made this change, which helped on a dual box.


diff -u linux-2.6.5/net/ipv4/netfilter/ip_tables.c-o linux-2.6.5/net/ipv4/netfilter/ip_tables.c
--- linux-2.6.5/net/ipv4/netfilter/ip_tables.c-o	2005-02-03 08:06:33.000000000 +0100
+++ linux-2.6.5/net/ipv4/netfilter/ip_tables.c	2005-02-03 13:06:32.163182472 +0100
@@ -29,6 +29,12 @@
 
 #include <linux/netfilter_ipv4/ip_tables.h>
 
+#ifdef CONFIG_HOTPLUG_CPU
+#define NF_NR_CPUS NR_CPUS
+#else
+#define NF_NR_CPUS num_online_cpus() 
+#endif
+
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
 MODULE_DESCRIPTION("IPv4 packet filter");
@@ -860,7 +866,7 @@
 	}
 
 	/* And one copy for every other CPU */
-	for (i = 1; i < NR_CPUS; i++) {
+	for (i = 1; i < NF_NR_CPUS; i++) {
 		memcpy(newinfo->entries + SMP_ALIGN(newinfo->size)*i,
 		       newinfo->entries,
 		       SMP_ALIGN(newinfo->size));
@@ -882,7 +888,7 @@
 		struct ipt_entry *table_base;
 		unsigned int i;
 
-		for (i = 0; i < NR_CPUS; i++) {
+		for (i = 0; i < NF_NR_CPUS; i++) {
 			table_base =
 				(void *)newinfo->entries
 				+ TABLE_OFFSET(newinfo, i);
@@ -929,7 +935,7 @@
 	unsigned int cpu;
 	unsigned int i;
 
-	for (cpu = 0; cpu < NR_CPUS; cpu++) {
+	for (cpu = 0; cpu < NF_NR_CPUS; cpu++) {
 		i = 0;
 		IPT_ENTRY_ITERATE(t->entries + TABLE_OFFSET(t, cpu),
 				  t->size,
@@ -1067,7 +1073,7 @@
 		return -ENOMEM;
 
 	newinfo = vmalloc(sizeof(struct ipt_table_info)
-			  + SMP_ALIGN(tmp.size) * NR_CPUS);
+			  + SMP_ALIGN(tmp.size) * NF_NR_CPUS);
 	if (!newinfo)
 		return -ENOMEM;
 
@@ -1380,7 +1386,7 @@
 		= { 0, 0, 0, { 0 }, { 0 }, { } };
 
 	newinfo = vmalloc(sizeof(struct ipt_table_info)
-			  + SMP_ALIGN(table->table->size) * NR_CPUS);
+			  + SMP_ALIGN(table->table->size) * NF_NR_CPUS);
 	if (!newinfo)
 		return -ENOMEM;
 
diff -u linux-2.6.5/mm/vmalloc.c-o linux-2.6.5/mm/vmalloc.c
--- linux-2.6.5/mm/vmalloc.c-o	2005-02-03 08:06:50.000000000 +0100
+++ linux-2.6.5/mm/vmalloc.c	2005-02-03 13:07:44.162236952 +0100
@@ -310,7 +310,10 @@
 			__free_page(area->pages[i]);
 		}
 
-		kfree(area->pages);
+		if (area->nr_pages * sizeof(struct page *) >= 4*PAGE_SIZE)
+			vfree(area->pages);
+		else
+			kfree(area->pages);
 	}
 
 	kfree(area);
@@ -414,7 +417,11 @@
 	array_size = (nr_pages * sizeof(struct page *));
 
 	area->nr_pages = nr_pages;
-	area->pages = pages = kmalloc(array_size, (gfp_mask & ~__GFP_HIGHMEM));
+
+	if (array_size >= 4*PAGE_SIZE) 
+		area->pages = pages = __vmalloc(array_size, (gfp_mask & ~__GFP_HIGHMEM), PAGE_KERNEL);
+	else
+		area->pages = pages = kmalloc(array_size, (gfp_mask & ~__GFP_HIGHMEM));
 	if (!area->pages) {
 		remove_vm_area(area->addr);
 		kfree(area);

  reply	other threads:[~2005-02-03 18:59 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-02 13:38 limited number if iptable rules on 64bit hosts Olaf Hering
2005-02-02 22:25 ` Olaf Hering
2005-02-02 22:38   ` Bill Rugolsky Jr.
2005-02-02 22:52     ` Olaf Hering
2005-02-03 11:19       ` Olaf Kirch
2005-02-03 18:48         ` David S. Miller
2005-02-03 18:59           ` Olaf Hering [this message]
2005-02-03 19:00             ` David S. Miller
2005-02-03 19:33               ` Bart De Schuymer
2005-02-03 21:35               ` Bill Rugolsky Jr.

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=20050203185928.GA22832@suse.de \
    --to=olh@suse.de \
    --cc=brugolsky@telemetry-investments.com \
    --cc=davem@davemloft.net \
    --cc=netdev@oss.sgi.com \
    --cc=okir@suse.de \
    /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).