From owner-svn-src-head@FreeBSD.ORG Sun Nov 2 17:07:23 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 8225C971; Sun, 2 Nov 2014 17:07:23 +0000 (UTC) Received: from mail-wi0-x231.google.com (mail-wi0-x231.google.com [IPv6:2a00:1450:400c:c05::231]) (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 C1BA1AF1; Sun, 2 Nov 2014 17:07:22 +0000 (UTC) Received: by mail-wi0-f177.google.com with SMTP id ex7so4682207wid.4 for ; Sun, 02 Nov 2014 09:07:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:reply-to:sender:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=0fGAldwBgByOwkSKFuNpg8zgIy20Ki7k9ieme/5kmhM=; b=pKBf5K1gGMZsRiXzrA694NO9hk5IV4XHzA7uzVV5d4GYJm6EF91zClS6aJio6kmOJQ 3U/fJODyErMztMnRy1yTlMxKNCrSC5+8nuApDFkS8rzVHZEF6tOXS4Dykrrh0B0cthCJ f3ch76MvLx156gNWuDYOkqfUR+iHwHakIqPtpxBhoS4wbdQA5e9bLG1ulRdvDEvSzNqL pEuxo6s5qE3rHXeRUNtb1wzB7qYd3SaCT7zz53+2rFc+e+DoZJY4gxrSrMoy1Lj6sZ0F z4DkI7mP2RYpGHFx9KPSvn9mC332BPCNFQYHGlt8eFElyOIoVOzntm3KuNQuY+q5TIyZ /VFg== MIME-Version: 1.0 X-Received: by 10.194.185.229 with SMTP id ff5mr2077891wjc.122.1414948040956; Sun, 02 Nov 2014 09:07:20 -0800 (PST) Reply-To: attilio@FreeBSD.org Sender: asmrookie@gmail.com Received: by 10.217.69.73 with HTTP; Sun, 2 Nov 2014 09:07:20 -0800 (PST) In-Reply-To: <20141102165916.GY53947@kib.kiev.ua> References: <201411021310.sA2DAWmD003298@svn.freebsd.org> <20141102163728.GX53947@kib.kiev.ua> <20141102165916.GY53947@kib.kiev.ua> Date: Sun, 2 Nov 2014 18:07:20 +0100 X-Google-Sender-Auth: WQwtTCfCtEsenzH1H356ssaeH64 Message-ID: Subject: Re: svn commit: r273966 - in head: share/man/man9 sys/kern sys/sys From: Attilio Rao To: Konstantin Belousov Content-Type: text/plain; charset=UTF-8 Cc: "svn-src-head@freebsd.org" , "svn-src-all@freebsd.org" , "src-committers@freebsd.org" X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Nov 2014 17:07:23 -0000 On Sun, Nov 2, 2014 at 5:59 PM, Konstantin Belousov wrote: > On Sun, Nov 02, 2014 at 05:42:55PM +0100, Attilio Rao wrote: >> On Sun, Nov 2, 2014 at 5:37 PM, Konstantin Belousov wrote: >> > On Sun, Nov 02, 2014 at 04:54:46PM +0100, Attilio Rao wrote: >> >> On Sun, Nov 2, 2014 at 2:10 PM, Konstantin Belousov wrote: >> >> > Author: kib >> >> > Date: Sun Nov 2 13:10:31 2014 >> >> > New Revision: 273966 >> >> > URL: https://svnweb.freebsd.org/changeset/base/273966 >> >> > >> >> > Log: >> >> > Fix two issues with lockmgr(9) LK_CAN_SHARE() test, which determines >> >> > whether the shared request for already shared-locked lock could be >> >> > granted. Both problems result in the exclusive locker starvation. >> >> > >> >> > The concurrent exclusive request is indicated by either >> >> > LK_EXCLUSIVE_WAITERS or LK_EXCLUSIVE_SPINNERS flags. The reverse >> >> > condition, i.e. no exclusive waiters, must check that both flags are >> >> > cleared. >> >> > >> >> > Add a flag LK_NODDLKTREAT for shared lock request to indicate that >> >> > current thread guarantees that it does not own the lock in shared >> >> > mode. This turns back the exclusive lock starvation avoidance code; >> >> > see man page update for detailed description. >> >> > >> >> > Use LK_NODDLKTREAT when doing lookup(9). >> >> >> >> The right way to implement this (selectively disabling writer >> >> starvation avoidance) must be on a lock-basis. >> >> So you need a new flag to pass to lockinit(). This is to support it "globaly". >> > Any vnode (except some very special) does participate in lookup. >> > So the proposed new flag has to be passed to every lockmgr init call. >> > Disabling exclusive starvation support for all vnode lock calls is >> > also wrong. >> > >> >> Then, you can pass it on a lockmgr() instance basis (like FreeBSD also >> >> passes, for example, LK_NOWITNESS). >> >> You can use it during lookup() calls. Maybe you will need to propagate >> >> it via the vn_lock() interface. >> > Well, if you indeed looked at the patch, you would note that this is >> > exactly what is done. The flag is passed only to vn_lock() calls >> > which are coming from lookup (VOP_LOOKUP as well). >> > >> > The flag use is safe since deadlock prevention by td_lk_slocks only >> > matters when the same lock was previously taken by the same thread >> > which does recursive shared request [*]. td_lk_slocks is the poor and >> > very indiscriminative way to express this, but might be unavoidable >> > since shared owners are not recorded. >> >> If you have a better way to fix this into a "rich and discriminative" >> way I'm all ears. > It is easy and cheap to record the set of the owned lockmgr locks for > current thread. I do not believe that we have a situation where more > than 3 locks are held in one time. To give it some slack, we can record > 8 locks shared-owned and do the check for recursion in LK_CAN_SHARE(). > If the thread-locks table overflows, we could either panic() or fall > back to indiscriminative deadlock avoidance (i.e. relying on the sole > td_lk_slocks value). I don't think it is going to be cheap (and certainly it is not viable for things like sx locks and rwlocks). Checking for the owner chain anytime you acquire the lock is certainly not I would call cheap. Attilio -- Peace can only be achieved by understanding - A. Einstein