From owner-svn-src-projects@FreeBSD.ORG Wed Sep 1 19:22:20 2010 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2A9131065693; Wed, 1 Sep 2010 19:22:20 +0000 (UTC) (envelope-from attilio@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 19D938FC1E; Wed, 1 Sep 2010 19:22:20 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o81JMJrX077542; Wed, 1 Sep 2010 19:22:19 GMT (envelope-from attilio@svn.freebsd.org) Received: (from attilio@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o81JMJFh077539; Wed, 1 Sep 2010 19:22:19 GMT (envelope-from attilio@svn.freebsd.org) Message-Id: <201009011922.o81JMJFh077539@svn.freebsd.org> From: Attilio Rao Date: Wed, 1 Sep 2010 19:22:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r212106 - in projects/sv/sys: net netinet X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Sep 2010 19:22:20 -0000 Author: attilio Date: Wed Sep 1 19:22:19 2010 New Revision: 212106 URL: http://svn.freebsd.org/changeset/base/212106 Log: The break lock happens while the system panicked but it is not an useful operation as, at that point, the other CPUs might be already stopped. It is more correct to just skip locking entirely for the interfaces, as long as the asserts won't whine in panicstr != NULL conditions (to be added asap). The 'acquire_lock' and 'release_lock' semantic is just left for the normal RB_DUMP reboot(2) invokation case (reboot -d, for example). Discussed with: emaste, rstone Modified: projects/sv/sys/net/netdump_client.c projects/sv/sys/netinet/netdump.h Modified: projects/sv/sys/net/netdump_client.c ============================================================================== --- projects/sv/sys/net/netdump_client.c Wed Sep 1 18:41:59 2010 (r212105) +++ projects/sv/sys/net/netdump_client.c Wed Sep 1 19:22:19 2010 (r212106) @@ -1153,8 +1153,6 @@ static void netdump_trigger(void *arg, int howto) { struct dumperinfo dumper; - int broke_lock = 0; - uint8_t broken_state[NETDUMP_BROKEN_STATE_BUFFER_SIZE]; void (*old_if_input)(struct ifnet *, struct mbuf *)=NULL; int error; @@ -1188,8 +1186,7 @@ netdump_trigger(void *arg, int howto) savectx(&dumppcb); dumping++; - bzero(broken_state, sizeof(broken_state)); - error = nd_nic->if_netdump->break_lock(nd_nic, &broke_lock, broken_state, sizeof(broken_state)); + error = nd_nic->if_netdump->acquire_lock(nd_nic); if(error) { printf("netdump_trigger: Could not acquire lock on %s\n", nd_nic->if_xname); @@ -1256,50 +1253,6 @@ trig_abort: } /*- - * Public primitives. - */ - -/* this isn't declared in any header file... */ -extern int system_panic; - -int -netdump_break_lock(struct mtx *lock, const char *name, int *broke_lock, - uint8_t *broken_state, u_int index, u_int bstatesz) -{ - /* XXX: Technically this might be bad because it's possible to be called - from within a critical section (such as when the software watchdog - triggers), although it's only a trylock */ - if (!mtx_trylock(lock)) { - if(system_panic) { - /* The lock is already held. Attempting to use the card is - * probably unsafe at this point, but since we're panicking - * anyway, there's nothing to lose. Be horrible and break the - * lock. - */ - critical_enter(); /* No interrupts so that this is less likely - * to mess up - */ - if(bstatesz >= (index + sizeof(*lock))) { - bcopy(lock, broken_state + index, sizeof(*lock)); - } else { - printf("Netdump: cannot save state of lock %s!", name); - } - - _release_lock_quick(lock); - mtx_destroy(lock); - mtx_init(lock, name, MTX_NETWORK_LOCK, - MTX_DEF); - *broke_lock = 1; - critical_exit();/* We can't grab a lock in a critical section */ - mtx_lock(lock); - } else { - return EAGAIN; - } - } - return 0; -} - -/*- * KLD specific code. */ Modified: projects/sv/sys/netinet/netdump.h ============================================================================== --- projects/sv/sys/netinet/netdump.h Wed Sep 1 18:41:59 2010 (r212105) +++ projects/sv/sys/netinet/netdump.h Wed Sep 1 19:22:19 2010 (r212106) @@ -61,19 +61,13 @@ struct netdump_msg { #ifdef _KERNEL -struct mtx; - struct netdump_methods { void (*test_get_lock)(struct ifnet *); - int (*break_lock)(struct ifnet *, int *, uint8_t *, u_int); + void (*acquire_lock)(struct ifnet *); void (*release_lock)(struct ifnet *); int (*poll_locked)(struct ifnet *, enum poll_cmd, int); }; -int netdump_break_lock(struct mtx *lock, const char *name, - int *broke_lock, uint8_t *broken_state, u_int index, - u_int bstatesz); - #endif #endif /* !_NETINET_NETDUMP_H_ */