From owner-freebsd-hackers@FreeBSD.ORG Sun Mar 12 14:28:29 2006 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 09EF916A400 for ; Sun, 12 Mar 2006 14:28:29 +0000 (GMT) (envelope-from guomingyan@gmail.com) Received: from xproxy.gmail.com (xproxy.gmail.com [66.249.82.199]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8563643D48 for ; Sun, 12 Mar 2006 14:28:28 +0000 (GMT) (envelope-from guomingyan@gmail.com) Received: by xproxy.gmail.com with SMTP id i27so682177wxd for ; Sun, 12 Mar 2006 06:28:27 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type; b=mP/zYfC6fKueP2ZNrSouOCPs2815w1NVzt1dAiZJ4WJNGqyh3O6QvS6hO35mLClV25GEZdQdKgh4kSdYaMWXNVRbk+n02P76pSep8Qe6wV/eOqaw/PKRQ8Pee4ixEAZQiuiUpkN+pj2/729hy14fsAOgKFAZyNvjnI/2Ljr2xEU= Received: by 10.70.51.10 with SMTP id y10mr5122094wxy; Sun, 12 Mar 2006 06:28:27 -0800 (PST) Received: by 10.70.40.6 with HTTP; Sun, 12 Mar 2006 06:28:27 -0800 (PST) Message-ID: <1fa17f810603120628q386d6811t9a2cab36c9cb7a0b@mail.gmail.com> Date: Sun, 12 Mar 2006 22:28:27 +0800 From: prime To: freebsd-hackers@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: Re:Doubts about PICKUP_GIANT() and mtx_lock(&Giant) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Mar 2006 14:28:29 -0000 Date: Sun, 12 Mar 2006 16:25:07 +0530 > From: "Pranav Peshwe" > Subject: Doubts about PICKUP_GIANT() and mtx_lock(&Giant). > To: freebsd-hackers@freebsd.org > Message-ID: > > Content-Type: text/plain; charset=3DISO-8859-1 > > Hello, > What is effectively the difference between PICKUP/DROP_GIANT an= d > mtx_lock/unlock(&Giant) ? From the macro expansion, i surmise that > PICKUP/DROP_GIANT deals with recursion in Giant locking.Is this correct ? > is > this the only difference ? What will happen if i mix the usage of > PICKUP/DROP_GIANT and mtx_lock/unlock(&Giant) ? > Also,is there any hard and fast rule prescribing which method of taking > the > Giant should be used where in the kernel ? > > TIA. > > Regards, > Pranav > > > -------------------------------------------------------------------------= -- > To argue with a person who has renounced the use of reason is like > administering medicine to the dead. -- Thomas Paine > > In my opinion,DROP_GIANT() guarantees that Giant is *really* dropped even it is recursively held.Sometimes we have to make sure that Giant is not held,and mtx_unlock(&Giant) can't give us such a promise,so you shouldn't use it in such situations. Mix the usage of DROP_GIANT() and mtx_unlock(&Giant) is not a good idea,I think. In fact,if you really do it,even the compiler will reject your source code :-). Regards, MingyanGuo -- Three passions, simple but overwhelmingly strong, have governed my life: the longing for love, the search for knowledge, and unbearable pity for the suffering of mankind. ---------Bertrand Russell