From owner-freebsd-arch@FreeBSD.ORG Tue May 14 11:02:02 2013 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id B86FF908 for ; Tue, 14 May 2013 11:02:02 +0000 (UTC) (envelope-from oritm@mellanox.com) Received: from eu1sys200aog120.obsmtp.com (eu1sys200aog120.obsmtp.com [207.126.144.149]) by mx1.freebsd.org (Postfix) with ESMTP id 17ACF1C0 for ; Tue, 14 May 2013 11:02:00 +0000 (UTC) Received: from MTLCAS01.mtl.com ([193.47.165.155]) (using TLSv1) by eu1sys200aob120.postini.com ([207.126.147.11]) with SMTP ID DSNKUZIZoXMSn5y6A8VTszY3yQ5oyfdSsAWi@postini.com; Tue, 14 May 2013 11:02:01 UTC Received: from MTLDAG01.mtl.com ([10.0.8.75]) by MTLCAS01.mtl.com ([10.0.8.71]) with mapi id 14.03.0123.003; Tue, 14 May 2013 13:04:22 +0300 From: Orit Moskovich To: "freebsd-arch@freebsd.org" Subject: FreeBSD spinlock - compatibility layer Thread-Topic: FreeBSD spinlock - compatibility layer Thread-Index: Ac5QiaSgCms1CiujRJ+uiUawknitKQ== Date: Tue, 14 May 2013 10:04:21 +0000 Message-ID: <981733489AB3BD4DB24B48340F53E0A55B0CFD79@MTLDAG01.mtl.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.0.13.1] MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.14 X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 May 2013 11:02:02 -0000 Hi, I read about the FreeBSD mutex implementation for spinlock in the compatibi= lity layer. I might be wrong, but I noticed a code section that might be problematic: Taken from http://svn.freebsd.org/base/release/9.1.0/sys/ofed/include/linux= /spinlock.h: 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); } But MTX_DEF initializes mutex as a sleep mutex: By default, MTX_DEF mutexes will context switch when they are already held. There is a flag MTX_SPIN Which I think is the right one in this case . I'd appreciate your take on this issue. Thanks, Orit Moskovich