From: Eric Dumazet <dada1@cosmosbay.com>
To: "Ilpo Järvinen" <ilpo.jarvinen@helsinki.fi>,
"David Miller" <davem@davemloft.net>
Cc: Netdev <netdev@vger.kernel.org>
Subject: Re: net-next/unix: BUG: using smp_processor_id() in preemptible
Date: Sun, 23 Nov 2008 04:32:30 +0100 [thread overview]
Message-ID: <4928CECE.602@cosmosbay.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0811221634370.10534@wrl-59.cs.helsinki.fi>
[-- Attachment #1: Type: text/plain, Size: 1505 bytes --]
Ilpo Järvinen a écrit :
> I got plenty of these from sock_prot_inuse_add:
>
> BUG: using smp_processor_id() in preemptible [00000000] code: rcS/1146
>
> caller is sock_prot_inuse_add+0x24/0x42
> Pid: 1146, comm: rcS Not tainted 2.6.28-rc6-01121-g89a2f15 #76
> Call Trace:
> [<ffffffff80365767>] debug_smp_processor_id+0xd3/0xe8
> [<ffffffff80485a0f>] sock_prot_inuse_add+0x24/0x42
> [<ffffffff80514cdd>] unix_create1+0x161/0x176
> [<ffffffff80514d52>] unix_create+0x60/0x6b
> [<ffffffff80483f66>] __sock_create+0x144/0x1bd
> [<ffffffff80483edb>] ? __sock_create+0xb9/0x1bd
> [<ffffffff8048402d>] sock_create+0x2d/0x2f
> [<ffffffff80484274>] sys_socket+0x29/0x5b
> [<ffffffff8020c10a>] system_call_fastpath+0x16/0x1b
>
>
Thanks Ilpo for this report
I guess the following is necessary.
Once Christopher and Rusty work on percpu variables is finished,
the preempt_enable()/disable() wont be necessary anymore, so
its a temporary workaround anyway.
[PATCH] net: make sock_prot_inuse_add() preempt safe
Ilpo Järvinen reported that commit a8076d8db98de6da61394b2e942320e4612643ac
(net: af_unix should update its inuse counter) was triggering
a warning in smp_processor_id(), being called in a preemptible code.
Fix is to make sock_prot_inuse_add() safe in this regard. This fix
can be reverted when new percpu infrastructure is ready, allowing
a cpu to safely do a increment/decrement on a percpu var.
Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
[-- Attachment #2: prot_inuse.patch --]
[-- Type: text/plain, Size: 822 bytes --]
diff --git a/net/core/sock.c b/net/core/sock.c
index a4e840e..d4f5ad7 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -1942,8 +1942,8 @@ static DECLARE_BITMAP(proto_inuse_idx, PROTO_INUSE_NR);
#ifdef CONFIG_NET_NS
void sock_prot_inuse_add(struct net *net, struct proto *prot, int val)
{
- int cpu = smp_processor_id();
- per_cpu_ptr(net->core.inuse, cpu)->val[prot->inuse_idx] += val;
+ per_cpu_ptr(net->core.inuse, get_cpu())->val[prot->inuse_idx] += val;
+ put_cpu();
}
EXPORT_SYMBOL_GPL(sock_prot_inuse_add);
@@ -1989,7 +1989,9 @@ static DEFINE_PER_CPU(struct prot_inuse, prot_inuse);
void sock_prot_inuse_add(struct net *net, struct proto *prot, int val)
{
+ preempt_disable();
__get_cpu_var(prot_inuse).val[prot->inuse_idx] += val;
+ preempt_enable();
}
EXPORT_SYMBOL_GPL(sock_prot_inuse_add);
next prev parent reply other threads:[~2008-11-23 3:32 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-22 21:04 net-next/unix: BUG: using smp_processor_id() in preemptible Ilpo Järvinen
2008-11-23 3:32 ` Eric Dumazet [this message]
2008-11-23 21:40 ` Ilpo Järvinen
2008-11-24 1:20 ` David Miller
2008-11-24 1:34 ` David Miller
2008-11-24 5:51 ` Eric Dumazet
2008-11-24 8:01 ` Eric Dumazet
2008-11-24 8:09 ` David Miller
2008-11-24 8:41 ` Ilpo Järvinen
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=4928CECE.602@cosmosbay.com \
--to=dada1@cosmosbay.com \
--cc=davem@davemloft.net \
--cc=ilpo.jarvinen@helsinki.fi \
--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 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.