From owner-freebsd-infiniband@freebsd.org Fri Mar 3 16:34:29 2017 Return-Path: Delivered-To: freebsd-infiniband@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 6B439CF6992 for ; Fri, 3 Mar 2017 16:34:29 +0000 (UTC) (envelope-from vijju.singh@gmail.com) Received: from mail-lf0-x233.google.com (mail-lf0-x233.google.com [IPv6:2a00:1450:4010:c07::233]) (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 E90CF1C85 for ; Fri, 3 Mar 2017 16:34:28 +0000 (UTC) (envelope-from vijju.singh@gmail.com) Received: by mail-lf0-x233.google.com with SMTP id j90so12935528lfk.2 for ; Fri, 03 Mar 2017 08:34:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=WGQNoJs1OfpILoqam2+YHrrVsPwV+Ditm7mxoHqsfHE=; b=GOIsWk1XabH4mdDRyli6/3drk6zIy6XRZteUjM5JLUD+/hsnkRyEO2GYadIeINWXNC 4opxuIze649kDwzExXKSd936ilniYHG1odGAzEZ+wvSe2U+3yvwO0wxXOwqrAr0IFZjJ Lit1wMYkDFuxdje5Uh2v/cTg86b4hUtMXF8mbU/sOyYUW5zTO20CutWs49+kKI+rH3o8 kFjVTLI6qqXVI9zKlg94ye93uBvJWxLL5yFATx1Fjf96+FYu8GXwaCsPESjdeF4fdfF1 3psKpue7F4gf32TN44aXn4WeWmXKx2o3VHOosxWvzIBaby2pEzxayOerJ6HwUUVpmA4w aoBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=WGQNoJs1OfpILoqam2+YHrrVsPwV+Ditm7mxoHqsfHE=; b=DaNdQ4M65XrxhW8tt2rj6db9MwlGG1yHACCKCJvKi08USrypuaJ9nfyN2W3tqBzVWN 2mXbZy7BbVPSwnaxC7/Y+z5F3/j2tnYg7CrX3VpHr+Jd5seMZBIkGV40fHw5FoLG7Cdv 6YUeXL3T0vDdsWvkDxC68uazz9naMFzpZLoEjxpIqYw5bmTQSJwaPZpKtrWT5bG6dqCe upfzTr3KuxBpyJ0otkVdyYzcAAfHAEBlowSA0MLGLlkK3nZoK+9hVKFKOCfc3R3V4z+4 xdYmOsCFRy+JcxkDcXg6+zhzLJWGYCOyQbp1J4Lp0wvOTwAD3VYDymYvPERw76M8o8xB p12w== X-Gm-Message-State: AMke39nmtmbSv2attOvtUz/L/7CcKiicGSi3CsZRvm0lKecvNrksB+c/Vo1ePCdhx2GCoWk85vnmmDeiyV/XSg== X-Received: by 10.46.80.11 with SMTP id e11mr1377017ljb.116.1488558866681; Fri, 03 Mar 2017 08:34:26 -0800 (PST) MIME-Version: 1.0 Received: by 10.25.67.9 with HTTP; Fri, 3 Mar 2017 08:34:26 -0800 (PST) From: Vijay Singh Date: Fri, 3 Mar 2017 08:34:26 -0800 Message-ID: Subject: OFED spinlocks To: "freebsd-infiniband@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: freebsd-infiniband@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Infiniband on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Mar 2017 16:34:29 -0000 I am looking at sys/ofed/include/linux/spinlock.h in 10.3: static inline void spin_lock_init(spinlock_t *lock) { memset(&lock->m, 0, sizeof(lock->m)); mtx_init(&lock->m, "lnxspin", NULL, MTX_DEF | MTX_NOWITNESS); } #define DEFINE_SPINLOCK(lock) \ spinlock_t lock; \ MTX_SYSINIT(lock, &(lock).m, "lnxspin", MTX_DEF) If this a spin lock, why do we use MTX_DEF? What am I missing. -vijay From owner-freebsd-infiniband@freebsd.org Fri Mar 3 16:38:08 2017 Return-Path: Delivered-To: freebsd-infiniband@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 B8D55CF69F5 for ; Fri, 3 Mar 2017 16:38:08 +0000 (UTC) (envelope-from hps@selasky.org) Received: from mail.turbocat.net (turbocat.net [IPv6:2a01:4f8:c17:6c4b::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 84D3E1D1B for ; Fri, 3 Mar 2017 16:38:08 +0000 (UTC) (envelope-from hps@selasky.org) Received: from hps2016.home.selasky.org (unknown [62.141.129.119]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.turbocat.net (Postfix) with ESMTPSA id 4B07A1FE025; Fri, 3 Mar 2017 17:37:41 +0100 (CET) Subject: Re: OFED spinlocks To: Vijay Singh , "freebsd-infiniband@freebsd.org" References: From: Hans Petter Selasky Message-ID: <5c38ad75-b6f1-41af-8d24-95dc3bd81a36@selasky.org> Date: Fri, 3 Mar 2017 17:37:19 +0100 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-infiniband@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Infiniband on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Mar 2017 16:38:08 -0000 On 03/03/17 17:34, Vijay Singh wrote: > I am looking at sys/ofed/include/linux/spinlock.h in 10.3: > > static inline void > spin_lock_init(spinlock_t *lock) > { > > memset(&lock->m, 0, sizeof(lock->m)); > mtx_init(&lock->m, "lnxspin", NULL, MTX_DEF | MTX_NOWITNESS); > } > > #define DEFINE_SPINLOCK(lock) \ > spinlock_t lock; \ > MTX_SYSINIT(lock, &(lock).m, "lnxspin", MTX_DEF) > > If this a spin lock, why do we use MTX_DEF? What am I missing. Hi, OFED lifts everything with spinlocks in Linux to the FreeBSD mutex domain. This has been done, because several other kernel APIs in FreeBSD are implemented using mutexes and cannot be used when real spinlocks are locked. This is done throughout OFED/LinuxKPI and it should not affect any applications. --HPS