From owner-svn-src-projects@FreeBSD.ORG Mon Jul 30 14:56:36 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 10A2D106564A; Mon, 30 Jul 2012 14:56:36 +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 1BBF58FC08; Mon, 30 Jul 2012 14:56:34 +0000 (UTC) Received: by lbon10 with SMTP id n10so4265433lbo.13 for ; Mon, 30 Jul 2012 07:56:34 -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=7LJeZqXFdjn8mcz+iVJdV17NMkp1d/qPZ1Lu2+xwMAE=; b=jXPqQLryKDIKG4tyrSiPECHZ7iLytxT6GaxYF0GdvvX1EhgYQkgrX0+8CoADFmfgGs tKYHbz7XqoaRBDgE92nSSSjymQoTA578PaFzePFyAW2e5dwH4DYoUcvaonVwqj1c5FUW 1ZOWz4gtUSYQPR6oKKd47Oroe1WWcfQwZY074p+i0+G3du9qvq5NuMrkjALDiEJLwYGJ q7rhO5BEFLLQD7M/HhPCslv8dWdrxq0g/VI5QFlvwfpCH9OEU0sjL4BhmFOIOF2vRCM9 zftaoWUzW3+IQ49LUFlUb+sEVmDebjoVPTc5VjSX9jQffYYob291EenBmQ5kqxxixI+i B1uA== MIME-Version: 1.0 Received: by 10.152.144.163 with SMTP id sn3mr4278281lab.37.1343660194050; Mon, 30 Jul 2012 07:56:34 -0700 (PDT) Sender: asmrookie@gmail.com Received: by 10.112.27.65 with HTTP; Mon, 30 Jul 2012 07:56:34 -0700 (PDT) In-Reply-To: References: <201207301350.q6UDobCI099069@svn.freebsd.org> <20120730143943.GY2676@deviant.kiev.zoral.com.ua> Date: Mon, 30 Jul 2012 15:56:34 +0100 X-Google-Sender-Auth: kTx6SqOb6925C87dqd10vl7bzwU Message-ID: From: Attilio Rao To: Konstantin Belousov Content-Type: text/plain; charset=UTF-8 Cc: Davide Italiano , 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 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: Mon, 30 Jul 2012 14:56:36 -0000 On 7/30/12, 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. > >> 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? More explicitly, I think such combination TDP_NOSLEEPING + TDP_NOBLOCKING (name invented) should be set on entering the interrupt context, not only related to this part of callouts. This would be a very good help for catching buggy situations. Attilio -- Peace can only be achieved by understanding - A. Einstein