Date: Wed, 1 Sep 2010 19:22:19 +0000 (UTC) From: Attilio Rao <attilio@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r212106 - in projects/sv/sys: net netinet Message-ID: <201009011922.o81JMJFh077539@svn.freebsd.org>
index | next in thread | raw e-mail
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_ */help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201009011922.o81JMJFh077539>
