about in_multi_mtx _at_ netinet/in_mcast.c:1095

From: Weongyo Jeong <weongyo.jeong_at_gmail.com>
Date: Wed, 8 Sep 2010 13:14:19 -0700
Hello,

I have a question about IN_MULTI_LOCK() because it uses MTX_DEF flag
when it's initialized so I always encounters the following LOR

lock order reversal: (sleepable after non-sleepable)
 1st 0xffffffff80d0b560 in_multi_mtx (in_multi_mtx) _at_ netinet/in_mcast.c:1095
 2nd 0xffffff00014e3850 USB device SX lock (USB device SX lock) _at_ /usr/home/freebsd_usb/sys/modules/usb/usb/../../../dev/usb/usb_request.c:441
KDB: stack backtrace:
db_trace_self_wrapper() at db_trace_self_wrapper+0x2a
_witness_debugger() at _witness_debugger+0x2e
witness_checkorder() at witness_checkorder+0x807
_sx_xlock() at _sx_xlock+0x55
usbd_do_request_flags() at usbd_do_request_flags+0xe5
axe_cmd() at axe_cmd+0xc7
axe_setmulti_locked() at axe_setmulti_locked+0x70
axe_setmulti() at axe_setmulti+0x3e
axe_ioctl() at axe_ioctl+0x132
if_addmulti() at if_addmulti+0x19b
in_joingroup_locked() at in_joingroup_locked+0x1bc
in_joingroup() at in_joingroup+0x52
in_control() at in_control+0x1144
ifioctl() at ifioctl+0x1118
kern_ioctl() at kern_ioctl+0xbe
ioctl() at ioctl+0xfd
syscallenter() at syscallenter+0x1aa
syscall() at syscall+0x4c
Xfast_syscall() at Xfast_syscall+0xe2

when I uses the following code at driver's ioctl routine:

	case SIOCADDMULTI:
	case SIOCDELMULTI:
		axe_setmulti(sc, 0);
		break;

It means that USB driver always should defer SIOCADDMULTI /
SIOCDELMULTI handling to the other process context to avoid LOR.

My question is that is it safe if the multicasting operations for USB
device happens without IN_MULTI_LOCK?  Or is there any race cases if the
task is deferred?

Or is it OK like the following code?

	case SIOCADDMULTI:
	case SIOCDELMULTI:
		IN_MULTI_UNLOCK();
		axe_setmulti(sc, 0);
		IN_MULTI_LOCK();
		break;

regards,
Weongyo Jeong
Received on Wed Sep 08 2010 - 18:40:11 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:07 UTC