public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrea Arcangeli <andrea@suse.de>
To: kuznet@ms2.inr.ac.ru
Cc: linux-kernel@vger.kernel.org
Subject: Re: 2.4.7 softirq incorrectness.
Date: Thu, 26 Jul 2001 20:29:39 +0200	[thread overview]
Message-ID: <20010726202939.D22784@athlon.random> (raw)
In-Reply-To: <20010726002357.D32148@athlon.random> <200107261746.VAA31697@ms2.inr.ac.ru>
In-Reply-To: <200107261746.VAA31697@ms2.inr.ac.ru>; from kuznet@ms2.inr.ac.ru on Thu, Jul 26, 2001 at 09:46:52PM +0400

On Thu, Jul 26, 2001 at 09:46:52PM +0400, kuznet@ms2.inr.ac.ru wrote:
> Hello!
> 
> > At that time I checked loopback that runs under the bh so it's ok too.
> 
> Well, it was not alone. I just looked at couple of places, when
> netif_rx was used. One is right, another (looping multicasts) is wrong. :-)
> 
> So, is plain raising softirq and leaving it raised before return
> to normal context not a bug? If so, then no problems.
> The worst, which can happen is that it will work as earlier, right?

Depends what you mean with 'normal context'. If you mean 'userspace
context' then it is a bug, and in 2.4.5 we would been catching that case
in entry.S.

If there are lots of users of netif_rx outside bh or irq context I guess
this is the simpler way is:

--- 2.4.7/net/core/dev.c	Sat Jul 21 00:04:34 2001
+++ 2.4.7aa1/net/core/dev.c	Thu Jul 26 20:05:26 2001
@@ -1217,10 +1217,10 @@
 enqueue:
 			dev_hold(skb->dev);
 			__skb_queue_tail(&queue->input_pkt_queue,skb);
+			local_irq_restore(flags);
 
 			/* Runs from irqs or BH's, no need to wake BH */
-			__cpu_raise_softirq(this_cpu, NET_RX_SOFTIRQ);
-			local_irq_restore(flags);
+			cpu_raise_softirq(this_cpu, NET_RX_SOFTIRQ);
 #ifndef OFFLINE_SAMPLE
 			get_sample_stats(this_cpu);
 #endif
@@ -1529,10 +1529,10 @@
 
 	local_irq_disable();
 	netdev_rx_stat[this_cpu].time_squeeze++;
+	local_irq_enable();
 
 	/* This already runs in BH context, no need to wake up BH's */
-	__cpu_raise_softirq(this_cpu, NET_RX_SOFTIRQ);
-	local_irq_enable();
+	cpu_raise_softirq(this_cpu, NET_RX_SOFTIRQ);
 
 	NET_PROFILE_LEAVE(softnet_process);
 	return;

> And we are allowed to yuild bhs at any point, when we desire. Nice.
> 
> Actually, also I was afraid opposite thing: netif_rx was used to allow
> to restart processing of skb, when we were in wrong context or were afraid
> recursion. And the situation, when it is called with disabled irqs and/or
> raised spinlock_irq (it was valid very recently!), is undetectable.

It should be detectable with this debugging code (untested but trivially
fixable if it doesn't compile):

--- 2.4.7aa1/include/asm-i386/softirq.h.~1~	Wed Jul 25 22:38:08 2001
+++ 2.4.7aa1/include/asm-i386/softirq.h	Thu Jul 26 20:22:28 2001
@@ -25,7 +25,11 @@
 #define local_bh_enable()						\
 do {									\
 	unsigned int *ptr = &local_bh_count(smp_processor_id());	\
+	unsigned long flags;						\
 									\
+	__save_flags(flags);						\
+	if (!(flags & (1 << 9)))					\
+		BUG();							\
 	barrier();							\
 	if (!--*ptr)							\
 		__asm__ __volatile__ (					\

> Actually, I hope such places are absent, networking core does not use
> irq protection at all, except for netif_rx() yet. :-)

I hope too :).

> > after netif_rx.
> 
> But why not to do just local_bh_disable(); netif_rx(); local_bh_enable()?
> Is this not right?

That is certainly right. However it is slower than just doing if
(pending) do_softirq()  after netif_rx().

Andrea

  parent reply	other threads:[~2001-07-26 20:07 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-22 20:44 2.4.7 softirq incorrectness Rusty Russell
2001-07-22 23:34 ` Andrea Arcangeli
2001-07-23  9:06   ` Rusty Russell
2001-07-23 12:05     ` David S. Miller
2001-07-23 14:31       ` Andrea Arcangeli
2001-07-23 14:29     ` Andrea Arcangeli
2001-07-24  9:35       ` Rusty Russell
2001-07-25 19:33         ` Andrea Arcangeli
2001-07-26 20:26           ` Rusty Russell
2001-07-23  9:25   ` Kai Germaschewski
2001-07-23 11:12     ` Jeff Garzik
2001-07-23 14:18     ` Andrea Arcangeli
2001-07-23 22:24   ` Alexey Kuznetsov
2001-07-25 22:23     ` Andrea Arcangeli
2001-07-26 17:46       ` kuznet
2001-07-26 18:03         ` Jeff Garzik
2001-07-26 18:29         ` Andrea Arcangeli [this message]
2001-07-27 16:48           ` kuznet
2001-07-27  0:47         ` Maksim Krasnyanskiy
2001-07-27 15:01           ` Andrea Arcangeli
2001-07-27 18:31           ` Maksim Krasnyanskiy
2001-07-27 18:59             ` kuznet
2001-07-27 19:21             ` Maksim Krasnyanskiy
2001-07-27 19:35               ` kuznet
2001-07-28  0:52               ` [PATCH] [IMPORTANT] " Maksim Krasnyanskiy
2001-07-28 17:41                 ` kuznet
2001-07-28 18:02                   ` Andrea Arcangeli
2001-07-28 19:02                     ` kuznet
2001-07-28 19:32                       ` Andrea Arcangeli
2001-07-28 23:28                         ` Alexey Kuznetsov
2001-07-29 17:07                           ` Linus Torvalds
2001-07-29 17:52                             ` kuznet
2001-07-30 18:50                               ` Ingo Molnar
2001-07-30 22:47                                 ` Nigel Gamble
2001-07-30 22:56                                   ` Christoph Hellwig
2001-07-31 18:08                                 ` kuznet
2001-07-28 17:54                 ` Andrea Arcangeli
2001-07-28 19:17                   ` Andrea Arcangeli
2001-07-30 18:32                 ` Maksim Krasnyanskiy
2001-07-27  9:34         ` David S. Miller
2001-07-27 17:01           ` kuznet

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=20010726202939.D22784@athlon.random \
    --to=andrea@suse.de \
    --cc=kuznet@ms2.inr.ac.ru \
    --cc=linux-kernel@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