From owner-freebsd-current@FreeBSD.ORG Wed Sep 8 20:40:11 2010 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 32D4910656E9 for ; Wed, 8 Sep 2010 20:40:11 +0000 (UTC) (envelope-from weongyo.jeong@gmail.com) Received: from mail-fx0-f54.google.com (mail-fx0-f54.google.com [209.85.161.54]) by mx1.freebsd.org (Postfix) with ESMTP id B57DD8FC1D for ; Wed, 8 Sep 2010 20:40:10 +0000 (UTC) Received: by fxm4 with SMTP id 4so518205fxm.13 for ; Wed, 08 Sep 2010 13:40:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:received:from:date:to:subject :message-id:reply-to:mail-followup-to:mime-version:content-type :content-disposition:user-agent:organization:x-operation-sytem; bh=OedPQQ9BXqTI0en65ze8T5IP4KLS6c7TzhI9HuoSICM=; b=QXYEVo5rySfwiuHVL2U9kNRziyy5U6j+7CgmnYV9sLJXxG5cUE1TUhGJoc7cIXA6RN w25yB4rx5eXx/hR6C8XJb8yNDcGIx7MYWBgRCW8v1ih5W679yFld0Kv9U44mvWboK5Gb J8HyzM6Py48t263fRp3t0EoT9bXwJsaA1MMMg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:date:to:subject:message-id:reply-to:mail-followup-to :mime-version:content-type:content-disposition:user-agent :organization:x-operation-sytem; b=GZuOUX+YrnoSzmD4fT+ho1+h7di5mBZEut1gKSt/54lvycl+ZszXZPqu956cquEckO 9LSmV1OsAjv0kH6ysp1BwX8+Gyatv3cK0kCOOeKOfPY8tBv4M8RfSY7rzwK9hfw0F684 GouyPXmsXYPnHPjIXhDmlygRkzA16gTMPtA9c= Received: by 10.223.116.20 with SMTP id k20mr73755faq.97.1283976858638; Wed, 08 Sep 2010 13:14:18 -0700 (PDT) Received: from weongyo ([174.35.1.224]) by mx.google.com with ESMTPS id b36sm306802faq.11.2010.09.08.13.14.16 (version=SSLv3 cipher=RC4-MD5); Wed, 08 Sep 2010 13:14:17 -0700 (PDT) Received: by weongyo (sSMTP sendmail emulation); Wed, 8 Sep 2010 13:14:19 -0700 From: Weongyo Jeong Date: Wed, 8 Sep 2010 13:14:19 -0700 To: current@freebsd.org Message-ID: <20100908201419.GF1328@weongyo> Mail-Followup-To: current@freebsd.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.2.3i Organization: CDNetworks. X-Operation-Sytem: FreeBSD Cc: Subject: about in_multi_mtx @ netinet/in_mcast.c:1095 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Weongyo Jeong List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Sep 2010 20:40:11 -0000 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) @ netinet/in_mcast.c:1095 2nd 0xffffff00014e3850 USB device SX lock (USB device SX lock) @ /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