All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <dada1@cosmosbay.com>
To: "David S. Miller" <davem@davemloft.net>
Cc: laforge@netfilter.org, netfilter-devel@lists.netfilter.org,
	kaber@trash.net
Subject: Re: num_possible_cpus() usage in iptables
Date: Mon, 10 Oct 2005 08:23:27 +0200	[thread overview]
Message-ID: <434A08DF.5090402@cosmosbay.com> (raw)
In-Reply-To: <20051009.204734.30319051.davem@davemloft.net>

David S. Miller a écrit :
> Guys, you can't use this interface like that.
> 
> It's a _COUNT_ of the number of possible processors, not the number of
> the higest PHYSICAL cpu index.
> 
> So you can have cpu's numbered "0" and "2", but num_possible_cpus()
> will return 2.  This is not just theoretical, Ultra60 sparc64 systems
> have this exact physical cpu numbering.   And as a result, when the
> changes went into iptables to use num_possible_cpus() instead of NR_CPUS
> it broke iptables.  It OOPS's when you load the module, in fact.
> 
> So, on such a system, this loop:
> 
> 	/* And one copy for every other CPU */
> 	for (i = 1; i < num_possible_cpus(); i++) {
> 		memcpy(newinfo->entries + SMP_ALIGN(newinfo->size)*i,
> 		       newinfo->entries,
> 		       SMP_ALIGN(newinfo->size));
> 	}
> 
> would initialize the wrong entries.
> 
> We need to fix this.
> 
> 
Hi David

My previous patch ([PATCH 3/3] netfilter : 3 patches to boost ip_tables 
performance) addressed this problem.


http://marc.theaimsgroup.com/?l=linux-netdev&m=112733887410796&w=2

Relevant parts :

-	for (i = 1; i < num_possible_cpus(); i++) {
-		memcpy(newinfo->entries + SMP_ALIGN(newinfo->size)*i,
-		       newinfo->entries,
-		       SMP_ALIGN(newinfo->size));
+	for_each_cpu(i) {
+		if (newinfo->entries[i] && newinfo->entries[i] != entry0)
+			memcpy(newinfo->entries[i], entry0, newinfo->size);


-		for (i = 0; i < num_possible_cpus(); i++) {
-			table_base =
-				(void *)newinfo->entries
-				+ TABLE_OFFSET(newinfo, i);
-
-			table_base->comefrom = 0xdead57ac;
+		for_each_cpu(cpu) {
+			struct ipt_entry *table_base = newinfo->entries[cpu];
+			if (table_base)
+				table_base->comefrom = 0xdead57ac;

But the whole thing was suspended because nobody wants to put a vmalloc_node() 
inside kernel.

Eric

  reply	other threads:[~2005-10-10  6:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-10  3:47 num_possible_cpus() usage in iptables David S. Miller
2005-10-10  6:23 ` Eric Dumazet [this message]
2005-10-11  0:27   ` David S. Miller
2005-10-11 14:35     ` Harald Welte
2005-10-11 20:00       ` David S. Miller
2005-10-10  8:19 ` Harald Welte
2005-10-10  8:52   ` seb

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=434A08DF.5090402@cosmosbay.com \
    --to=dada1@cosmosbay.com \
    --cc=davem@davemloft.net \
    --cc=kaber@trash.net \
    --cc=laforge@netfilter.org \
    --cc=netfilter-devel@lists.netfilter.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.