From owner-freebsd-net@FreeBSD.ORG Thu Jul 17 00:19:26 2014 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D54A114C for ; Thu, 17 Jul 2014 00:19:26 +0000 (UTC) Received: from mail-pa0-x233.google.com (mail-pa0-x233.google.com [IPv6:2607:f8b0:400e:c03::233]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A50152463 for ; Thu, 17 Jul 2014 00:19:26 +0000 (UTC) Received: by mail-pa0-f51.google.com with SMTP id ey11so2228542pad.38 for ; Wed, 16 Jul 2014 17:19:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=jQQlCAqmwh91Y5tmLJVQzgJrsm4wAFQHzbM2GX7p91M=; b=PAQxcnKv8Okv4WqT/nVOAmEDBbdYSnqa4gsBxaWdtHVRmvTk3gEzh6DzPKfajcUhXv Nja0TawI8iI1Dufm+khpDwvQ1PaBp1OqibiXQfR/NO96Get+7ZPPmVYIFA6cynb6P0zA uehmwd/215Se/0veJ74cGeR/wHwrGLzExTcZA1Q/F8TGN2fftrJExo00wdL7N6Kxao4I ib5SVv4p8XrRqibroL9n0K19bhgkN7y76wG7xlLqfc+cu3qF33iUKaIFnNJGTA0uWs6+ c5bQzTa0hPhCe0fhBKMwRJ6DaeBf9yGT9DoLfXP7OjGSMsBzyLuDY9xQ+HE0FclgADJO StlA== X-Received: by 10.69.17.230 with SMTP id gh6mr33475962pbd.0.1405556366173; Wed, 16 Jul 2014 17:19:26 -0700 (PDT) Received: from [10.192.166.0] (stargate.chelsio.com. [67.207.112.58]) by mx.google.com with ESMTPSA id nd10sm561921pbc.51.2014.07.16.17.19.25 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 16 Jul 2014 17:19:25 -0700 (PDT) Sender: Navdeep Parhar Message-ID: <53C7168C.3050702@FreeBSD.org> Date: Wed, 16 Jul 2014 17:19:24 -0700 From: Navdeep Parhar User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: Luigi Rizzo Subject: Re: change netmap global lock to sx? References: <5385249D.9050501@FreeBSD.org> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: "freebsd-net@freebsd.org" X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Jul 2014 00:19:27 -0000 On 05/27/14 17:32, Luigi Rizzo wrote: >=20 >=20 >=20 > On Wed, May 28, 2014 at 1:49 AM, Navdeep Parhar wrote: >=20 > I'd like to change the netmap global lock from a mutex into a sleep= able > shared/exclusive lock. This will allow a driver's nm_register hook= > (which is called with the global lock held) to sleep if it has to. = I've > casually used pkt-gen after this conversion (patch attached) and th= e > witness hasn't complained about it. >=20 >=20 > =E2=80=8Bno objections, let me give this a try on stable/10 > stable/9 to make sure we can use the same code there as well Any updates? I'm considering what to have in cxgbe(4) in time for 10.1 and this needs to be sorted out before cxgbe's netmap support gets MFC'd to any stable branch. Regards, Navdeep >=20 > cheers > luigi > =E2=80=8B >=20 > Thoughts? >=20 > Regards, > Navdeep >=20 >=20 > diff -r 0300d80260f4 sys/dev/netmap/netmap_kern.h > --- a/sys/dev/netmap/netmap_kern.h Fri May 23 19:00:56 2014 -0= 700 > +++ b/sys/dev/netmap/netmap_kern.h Sat May 24 12:49:15 2014 -0= 700 > @@ -43,13 +43,13 @@ > #define unlikely(x) __builtin_expect((long)!!(x), 0L) >=20 > #define NM_LOCK_T struct mtx > -#define NMG_LOCK_T struct mtx > -#define NMG_LOCK_INIT() mtx_init(&netmap_global_lock, \ > - "netmap global lock", NULL, MTX_DEF= ) > -#define NMG_LOCK_DESTROY() mtx_destroy(&netmap_global_lock) > -#define NMG_LOCK() mtx_lock(&netmap_global_lock) > -#define NMG_UNLOCK() mtx_unlock(&netmap_global_lock) > -#define NMG_LOCK_ASSERT() mtx_assert(&netmap_global_lock, > MA_OWNED) > +#define NMG_LOCK_T struct sx > +#define NMG_LOCK_INIT() sx_init(&netmap_global_lock, \ > + "netmap global lock") > +#define NMG_LOCK_DESTROY() sx_destroy(&netmap_global_lock) > +#define NMG_LOCK() sx_xlock(&netmap_global_lock) > +#define NMG_UNLOCK() sx_xunlock(&netmap_global_lock) > +#define NMG_LOCK_ASSERT() sx_assert(&netmap_global_lock, > SA_XLOCKED) >=20 > #define NM_SELINFO_T struct selinfo > #define MBUF_LEN(m) ((m)->m_pkthdr.len) >=20 >=20