Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/netinet Don't hold kernel lock across call to ip_input()...



details:   https://anonhg.NetBSD.org/src/rev/d450d7a67883
branches:  trunk
changeset: 753505:d450d7a67883
user:      tls <tls%NetBSD.org@localhost>
date:      Wed Mar 31 07:31:15 2010 +0000

description:
Don't hold kernel lock across call to ip_input() -- it blocked *all*
hardware interrupts for the length of time it took for all dequeued
packets to flow up the stack (on multiprocessors only).  Initial testing
shows performance impact is minimal -- since this temporary fix actually
means taking/releasing the kernel lock per-packet, that seems
acceptable.

Holding the kernel lock across the ip_input() call duplicated the
exclusion intended to be provided by the socket locks/softnet lock
(same lock, for INET/INET6 sockets) and could mask serious bugs.  Several
hours' testing didn't turn any up but I'd be surprised if some don't now
appear.

Damon Permezel noticed the problem.  Temporary fix suggested by matt@.

diffstat:

 sys/netinet/ip_input.c |  6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diffs (28 lines):

diff -r 139102796d7f -r d450d7a67883 sys/netinet/ip_input.c
--- a/sys/netinet/ip_input.c    Wed Mar 31 06:40:30 2010 +0000
+++ b/sys/netinet/ip_input.c    Wed Mar 31 07:31:15 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip_input.c,v 1.284 2009/09/16 15:23:05 pooka Exp $     */
+/*     $NetBSD: ip_input.c,v 1.285 2010/03/31 07:31:15 tls Exp $       */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.284 2009/09/16 15:23:05 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.285 2010/03/31 07:31:15 tls Exp $");
 
 #include "opt_inet.h"
 #include "opt_compat_netbsd.h"
@@ -483,7 +483,9 @@
                splx(s);
                if (m == NULL)
                        break;
+               KERNEL_UNLOCK_ONE(NULL);
                ip_input(m);
+               KERNEL_LOCK(1, NULL);
        }
        KERNEL_UNLOCK_ONE(NULL);
        mutex_exit(softnet_lock);



Home | Main Index | Thread Index | Old Index