From owner-svn-src-projects@FreeBSD.ORG Sun Sep 9 19:34:27 2012 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 2678A106566B; Sun, 9 Sep 2012 19:34:27 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com [209.85.217.182]) by mx1.freebsd.org (Postfix) with ESMTP id 072A98FC08; Sun, 9 Sep 2012 19:34:25 +0000 (UTC) Received: by lbbgg13 with SMTP id gg13so1193317lbb.13 for ; Sun, 09 Sep 2012 12:34:24 -0700 (PDT) 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 :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=R64Aj2IEzpaY48Qkcz64j7LFBd74CGkUF4rIsQ5gkm8=; b=DQENqEezc4JTDkdStov28N4OmLdTdyh9U7u7AMghoOtZZok/Uk6aNj7UWKFvKNIz9v WcL5VfolxJxuOdjeqACo+aZ9dr11Nb1hxPWbwzI2rbh6QvXkWmbaVV2osGrH2+NgFUFo YRvV8QdaXmu9bzGc//E7oierc4oMOZBuxVu8quRV6oRYtokK4p0c7MOIRPmZpyiSJiH1 F2d6UHWqWeALNWxrdvKiqex1bYabA7UctQkrm9+V0rtrdU/lmnnNK60c8AK9N9Gw5ubS U3LM8wr+BPkUAGJREJo7JEzyZUoG9scrJd8T91PJ0xWnlpUpu5prUL2YsmY7PoFuIayo ltIw== MIME-Version: 1.0 Received: by 10.152.48.70 with SMTP id j6mr858878lan.57.1347219264766; Sun, 09 Sep 2012 12:34:24 -0700 (PDT) Sender: asmrookie@gmail.com Received: by 10.112.102.39 with HTTP; Sun, 9 Sep 2012 12:34:24 -0700 (PDT) In-Reply-To: <504CEAE0.704@FreeBSD.org> References: <201207301350.q6UDobCI099069@svn.freebsd.org> <201207301732.33474.jhb@freebsd.org> <504CEAE0.704@FreeBSD.org> Date: Sun, 9 Sep 2012 20:34:24 +0100 X-Google-Sender-Auth: _mQY3cublmA8Elsbx_Usw9a-wgo Message-ID: From: Attilio Rao To: John Baldwin Content-Type: text/plain; charset=UTF-8 Cc: Konstantin Belousov , Davide Italiano , src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: Re: svn commit: r238907 - projects/calloutng/sys/kern X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: attilio@FreeBSD.org List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Sep 2012 19:34:27 -0000 On Sun, Sep 9, 2012 at 8:15 PM, John Baldwin wrote: > On 9/9/12 11:03 AM, Attilio Rao wrote: >> On 8/2/12, Attilio Rao wrote: >>> On 7/30/12, John Baldwin wrote: >> >> [ trimm ] >> >>>> --- //depot/projects/smpng/sys/kern/subr_turnstile.c 2012-06-04 >>>> 18:27:32.000000000 0000 >>>> +++ //depot/user/jhb/lock/kern/subr_turnstile.c 2012-06-05 >>>> 00:27:57.000000000 0000 >>>> @@ -684,6 +684,7 @@ >>>> if (owner) >>>> MPASS(owner->td_proc->p_magic == P_MAGIC); >>>> MPASS(queue == TS_SHARED_QUEUE || queue == TS_EXCLUSIVE_QUEUE); >>>> + KASSERT(!TD_IS_IDLETHREAD(td), ("idle threads cannot block on locks")); >>>> >>>> /* >>>> * If the lock does not already have a turnstile, use this thread's >>> >>> I'm wondering if we should also use similar checks in places doing >>> adaptive spinning (including the TD_NO_SLEEPING check). Likely yes. >> >> So what do you think about this? > > This is isn't really good enough then. An idle thread should not > acquire any lock that isn't a spin lock. Instead, you would be > better off removing the assert I added above and adding an assert to > mtx_lock(), rw_{rw}lock(), sx_{sx}lock(), lockmgr(), rm_{rw}lock() and > all the try variants of those. On a second thought, maybe this is not too bad, confining it in the hard version of functions eventually. Also, I think the checks may be good to go only on locking acquisition operations, not all of them. However, I would leave the check on sleepqueues as it also protects idlethreads from sleep(9). As a side node, also, I would change the output of the sleepqueues panic to also print the wmesg, as Kostik pointed out. Attilio -- Peace can only be achieved by understanding - A. Einstein