From owner-svn-src-projects@FreeBSD.ORG Mon Jul 30 20:58:38 2012 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4E1F7106564A; Mon, 30 Jul 2012 20:58:38 +0000 (UTC) (envelope-from davide.italiano@gmail.com) Received: from mail-vb0-f54.google.com (mail-vb0-f54.google.com [209.85.212.54]) by mx1.freebsd.org (Postfix) with ESMTP id C58008FC12; Mon, 30 Jul 2012 20:58:37 +0000 (UTC) Received: by vbmv11 with SMTP id v11so6194531vbm.13 for ; Mon, 30 Jul 2012 13:58:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=kbEjvIP6i8ujieEP4F9kYKulD1wvytn4sEspV0oegSA=; b=FvpxmoUXJHDsPEgomvT/Nu+btz1F4T7APgGuEnll8YjFya4nOajLvfX40J1npvPiG7 ko22I7kZdBw88sfypMJIx1/nF2yMeup+rFnid+tkLyUq9Oc+hLIV18H+YgxRYCGSI7D1 J17LBZZ1kebocZ1GelrQ7cIB9ICGayMe6+duHvdMKOQ35b0p+EQ0Oi9B/IrXxghFQsOF qQ17jJPcUcZUPEdNheX5AYy85AplfVxgIHf+DllVSPE5BXBWX5HxrY/cYR6wbC7KZJ6A 32rAfszTwmABtFdXebeam05dVYkv9x/2o59N2pDIFXsLgRMeMXPdpOWtZICVsQD1aIK8 BEWQ== MIME-Version: 1.0 Received: by 10.52.71.79 with SMTP id s15mr10855020vdu.86.1343681917311; Mon, 30 Jul 2012 13:58:37 -0700 (PDT) Sender: davide.italiano@gmail.com Received: by 10.58.196.170 with HTTP; Mon, 30 Jul 2012 13:58:37 -0700 (PDT) In-Reply-To: References: <201207301350.q6UDobCI099069@svn.freebsd.org> <20120730143943.GY2676@deviant.kiev.zoral.com.ua> <20120730145912.GZ2676@deviant.kiev.zoral.com.ua> Date: Mon, 30 Jul 2012 22:58:37 +0200 X-Google-Sender-Auth: abZtTBscVUNNs8dlApuuEY2kGEI Message-ID: From: Davide Italiano To: attilio@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 Cc: Konstantin Belousov , svn-src-projects@freebsd.org, src-committers@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 List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Jul 2012 20:58:38 -0000 On Mon, Jul 30, 2012 at 10:48 PM, Attilio Rao wrote: > On Mon, Jul 30, 2012 at 3:59 PM, Konstantin Belousov > wrote: >> On Mon, Jul 30, 2012 at 03:51:22PM +0100, Attilio Rao wrote: >>> On 7/30/12, Konstantin Belousov wrote: >>> > On Mon, Jul 30, 2012 at 03:24:26PM +0100, Attilio Rao wrote: >>> >> On 7/30/12, Davide Italiano wrote: >>> >> > On Mon, Jul 30, 2012 at 4:02 PM, Attilio Rao >>> >> > wrote: >>> >> > Thanks for the comment, Attilio. >>> >> > Yes, it's exactly what you thought. If direct flag is equal to one >>> >> > you're sure you're processing a callout which runs directly from >>> >> > hardware interrupt context. In this case, the running thread cannot >>> >> > sleep and it's likely you have TDP_NOSLEEPING flags set, failing the >>> >> > KASSERT() in THREAD_NO_SLEEPING() and leading to panic if kernel is >>> >> > compiled with INVARIANTS. >>> >> > In case you're running from SWI context (direct equals to zero) code >>> >> > remains the same as before. >>> >> > I think what I'm doing works due the assumption thread running never >>> >> > sleeps. Do you suggest some other way to handle this? >>> >> >>> >> Possibly the quicker way to do this is to have a way to deal with the >>> >> TDP_NOSLEEPING flag in recursed way, thus implement the same logic as >>> >> VFS_LOCK_GIANT() does, for example. >>> >> You will need to change the few callers of THREAD_NO_SLEEPING(), but >>> >> the patch should be no longer than 10/15 lines. >>> > >>> > There are already curthread_pflags_set/restore KPI designed exactly to >>> > handle >>> > nested private thread flags. >>> >>> Yes, however I would use curthread_pflags* KPI within >>> THREAD_NO_SLEEPING() as this name is much more explicit. >>> >> Sure, hiding it in THREAD_NO_SLEEPING (THREAD_NO_SLEEP_ENTER/LEAVE ?) >> is the way to use curthread_pflags_set there. >> >> As a second though, on the other hand, is it safe to modify td_flags >> from the interrupt context at all ? Probably yes if interrupt handler >> always leave td_pflags in the same state on leave as it was on entry, >> but couldn't too smart compiler cause inconsistent view of td_pflags >> inside the handler ? > > Can you think of any? Because I cannot think of a case where a nested > interrupt can messup with already compiled code, unless it leaks a > cleanup. > > I was more worried about the compiler reordering operations before > locking could really see it, but I think in this case the functions > call to sleepqueue (at least) works as a sequence point so we are > safe. > >> >>> > Also, I wonder, should you assert somehow that direct dispatch cannot block >>> > as well ? >>> >>> Yes, it would be optimal, but I don't think we have a flag for that >>> right now, do we? >> >> I am not aware of such flag, this might be a good reason to introduce it, >> if issue about td_pflags is just a product of my imagination. > > I think you should be good to go. Do you plan to work on such a patch? I may work on that as final part of my GSoC work considering I've an interest in this. Though, I could need some guidance and help in review. Can you provide these? > > Thanks, > Attilio > > > -- > Peace can only be achieved by understanding - A. Einstein Thanks, Davide