From owner-freebsd-net@freebsd.org Mon Dec 19 11:21:24 2016 Return-Path: Delivered-To: freebsd-net@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3E870C87D35 for ; Mon, 19 Dec 2016 11:21:24 +0000 (UTC) (envelope-from v.maffione@gmail.com) Received: from mail-oi0-x243.google.com (mail-oi0-x243.google.com [IPv6:2607:f8b0:4003:c06::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 0B28E12EC; Mon, 19 Dec 2016 11:21:24 +0000 (UTC) (envelope-from v.maffione@gmail.com) Received: by mail-oi0-x243.google.com with SMTP id u15so19072455oie.3; Mon, 19 Dec 2016 03:21:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=2Ov5t3kLwHYBF4VJIJwWCiItwIZ6YLDoRB9cL7x7GgE=; b=OqVTndpOi5pa3+983k2cUZ1RY9eN7HmManuZ5ei8HdWOs19vS5ERkkdYkLrnssM+Kk 9EIUjejMAQrJ7vc6wu7cyKfCJ/8lYcVp6dP7of9UVS90Ngq2Vi4LAm7911eNq+YFeeXW ghZrlNtqlUasK4C3XGVIa6ugsQAAOhFXa/7syiJfjtDb219FJVTUsVcvwwLUAkbNLWj2 VWUXa3Tox8OidO6z+DC6sH3GA4bNM17M2MxfOyv6czeaku9GGT6m2ydSEaMOtYq+esoW IzReggQdqyu5pceBYbV2zm4/ONgU5SO7ffuxmIT6AmQzEnDNAY/TSNcREyk9acyVRJF0 BgKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=2Ov5t3kLwHYBF4VJIJwWCiItwIZ6YLDoRB9cL7x7GgE=; b=i3Y22Nq1xxJnbji0I5kW51TtjXOwPIadxn989dh7Wu5bkBoEIhpeo6BPb4FRhncBSG 1sBQ0nKWERhdRt1JBtIdROFsgXjBY9rmauBPmT/SnxYdnVZZTEgAli6gL0BoslQ9penF 6LfGC2vDXqDH77ryNcZIXV1peMQ7bBfKywMvvIlx+7idhXtC/JYKouRYdOh/i9AsG8A9 OdZRNfWttnK+SuPKpJ86MBlopGubPDevL+M+a2hDfvbJEtlKmUl6NnVVmR9glUiswaCW EoKinKOVQbqIn/G+yWO5eNk1hwjE2wdg0OCRiZIPUB4gw3Kx3YIqnABWKKDR14VUHLti nuYQ== X-Gm-Message-State: AIkVDXKouxIyMum5/SYZE6d0xTOQVEKqTnTseDhJBscoSXVskwJWTKA+S5zTVVVY5MONd2xMpK2HESrZayfg7A== X-Received: by 10.157.60.244 with SMTP id t49mr5216702otf.178.1482146483325; Mon, 19 Dec 2016 03:21:23 -0800 (PST) MIME-Version: 1.0 Received: by 10.157.45.200 with HTTP; Mon, 19 Dec 2016 03:21:22 -0800 (PST) In-Reply-To: <20161217222812.GA4979@ox> References: <20161217222812.GA4979@ox> From: Vincenzo Maffione Date: Mon, 19 Dec 2016 12:21:22 +0100 Message-ID: Subject: Re: cxgbe's native netmap support broken since r307394 To: Vincenzo Maffione , Luigi Rizzo , "freebsd-net@freebsd.org" , Giuseppe Lettieri , np@freebsd.com Content-Type: text/plain; charset=UTF-8 X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Dec 2016 11:21:24 -0000 Hi Navdeep, Indeed, we have reviewed the code, and we think it is ok to implement nm_os_ifnet_lock() with IFNET_RLOCK(), instead of using IFNET_WLOCK(). Since IFNET_RLOCK() results into sx_slock(), this should fix the issue. On FreeBSD, this locking is needed to protect a flag read by nm_iszombie(). However, on Linux the same lock is also needed to protect the call to the nm_hw_register() callback, so we prefer to have an "unified" locking scheme, i.e. always calling nm_hw_register under the lock. Does this make sense to you? Would it be easy for you to make a quick test by replacing IFNET_WLOCK with IFNET_RLOCK? Thanks, Vincenzo 2016-12-17 23:28 GMT+01:00 Navdeep Parhar : > Luigi, Vincenzo, > > The last major update to netmap (r307394 and followups) broke cxgbe's > native netmap support. The problem is that netmap_hw_reg now holds an > rw_lock around the driver's netmap_on/off routines. It has always been > safe for the driver to sleep during these operations but now it panics > instead. > > Why is IFNET_WLOCK needed here? It seems like a regression to disallow > sleep on the control path. > > Regards, > Navdeep > > begin_synchronized_op with the following non-sleepable locks held: > exclusive rw ifnet_rw (ifnet_rw) r = 0 (0xffffffff8271d680) locked @ > /root/ws/head/sys/dev/netmap/netmap_freebsd.c:95 > stack backtrace: > #0 0xffffffff810837a5 at witness_debugger+0xe5 > #1 0xffffffff81084d88 at witness_warn+0x3b8 > #2 0xffffffff83ef2bcc at begin_synchronized_op+0x6c > #3 0xffffffff83f14beb at cxgbe_netmap_reg+0x5b > #4 0xffffffff809846f1 at netmap_hw_reg+0x81 > #5 0xffffffff809806de at netmap_do_regif+0x19e > #6 0xffffffff8098121d at netmap_ioctl+0x7ad > #7 0xffffffff8098682f at freebsd_netmap_ioctl+0x5f -- Vincenzo Maffione