From owner-svn-src-all@FreeBSD.ORG Wed Aug 11 17:10:03 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5B7691065673; Wed, 11 Aug 2010 17:10:03 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: from mail-qy0-f175.google.com (mail-qy0-f175.google.com [209.85.216.175]) by mx1.freebsd.org (Postfix) with ESMTP id 96B678FC20; Wed, 11 Aug 2010 17:10:02 +0000 (UTC) Received: by qyk11 with SMTP id 11so5267305qyk.13 for ; Wed, 11 Aug 2010 10:10:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received :in-reply-to:references:date:x-google-sender-auth:message-id:subject :from:to:cc:content-type:content-transfer-encoding; bh=/0/B3cHGtp1l6u1b0f0RQjG02ztkJkoStbcSXP9AR6E=; b=iR133J7TyGascRVd+rEWCNJgVFo07p6T1FACJ357Teu7DMyv/azMqkHQgBRb/XqZr8 b0hR5ZIviYtWH9EIv5VBzGRoSUFALRkDiwNiebfvj9T6yR4FOnEVVZBVT0V3SQOQ3EQy RqaH2P0jc1gH92azTrNb2OTIEKnrgwOE339QA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=fTTZleHIE5MQacD9Q3VPNrmS1OCpAzyuuIokDuVZ7UpFoIOmCzApzUPihe/2Or/RoY ejTy6TyjhidjIL/Oa1yBDt7B6jtH+VpnLLi3UDI/1fDXUw90qok7XBLZ5LOfFTXN7lKi uhjPr9yErEIU57ahpy/H4FtfuyXo4hIlGnZII= MIME-Version: 1.0 Received: by 10.224.87.139 with SMTP id w11mr10858685qal.358.1281546601115; Wed, 11 Aug 2010 10:10:01 -0700 (PDT) Sender: asmrookie@gmail.com Received: by 10.229.251.6 with HTTP; Wed, 11 Aug 2010 10:10:00 -0700 (PDT) In-Reply-To: References: <201008111051.o7BApRp4028538@svn.freebsd.org> <20100811105739.GJ2396@deviant.kiev.zoral.com.ua> <20100811123430.GK2396@deviant.kiev.zoral.com.ua> <20100811144646.GL2396@deviant.kiev.zoral.com.ua> Date: Wed, 11 Aug 2010 19:10:00 +0200 X-Google-Sender-Auth: rondmOG4NZe9QkwLpgj-ydcEwQ0 Message-ID: From: Attilio Rao To: Kostik Belousov Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Jeff Roberson , John Baldwin Subject: Re: svn commit: r211176 - in head/sys: amd64/amd64 i386/i386 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Aug 2010 17:10:03 -0000 2010/8/11 Attilio Rao : > 2010/8/11 Kostik Belousov : >> On Wed, Aug 11, 2010 at 04:29:21PM +0200, Attilio Rao wrote: >>> 2010/8/11 Kostik Belousov : >>> > On Wed, Aug 11, 2010 at 01:21:46PM +0200, Attilio Rao wrote: >>> >> 2010/8/11 Kostik Belousov : >>> >> > On Wed, Aug 11, 2010 at 10:51:27AM +0000, Attilio Rao wrote: >>> >> >> Author: attilio >>> >> >> Date: Wed Aug 11 10:51:27 2010 >>> >> >> New Revision: 211176 >>> >> >> URL: http://svn.freebsd.org/changeset/base/211176 >>> >> >> >>> >> >> Log: >>> >> >> =C2=A0 IPI handlers may run generally with interrupts disabled be= cause they >>> >> >> =C2=A0 are served via an interrupt gate. >>> >> >> >>> >> >> =C2=A0 However, that doesn't explicitly prevent preemption and th= read >>> >> >> =C2=A0 migration thus scheduler pinning may be necessary in some = handlers. >>> >> >> =C2=A0 Fix that. >>> >> > >>> >> > How the preemption is supposed to happen ? Aside from the explicit >>> >> > calls to mi_switch() from e.g. critical_exit(). >>> >> >>> >> IIRC it should be hardclock() willing to schedule the softclock(). I= t >>> >> is the critical_exit() in the thread_unlock() that may trigger it >>> >> (sorry for not digging more, it was a while back that I hacked this >>> >> part, but I guess you can verify on your own). >>> >> We already have other points within the kernel that take care of >>> >> dealing with preemption/migration like lapic_handle_timer(), for >>> >> example. >>> > >>> > Right, and if the interrupts are indeed disabled, I do not see how >>> > the preemption may be triggered in the fragments like >>> > =C2=A0 =C2=A0 =C2=A0 =C2=A0cpu =3D PCPU_GET(cpuid); >>> > =C2=A0 =C2=A0 =C2=A0 =C2=A0cpumask =3D PCPU_GET(cpumask); >>> >>> I don't recall all the details and I have no time to dig now. However, >>> also spinlock_enter() does disable explicitly preemption via >>> critical_enter() after have disabled the interrupts. >>> Let me CC jhb as he implemented spinlock_enter() and may have a clue >>> about how preemption can happen with interrupts disabled. >> >> spinlock_enter() disables preemption to handle the recursive >> calls to spinlock_enter/leave, I think, to prevent switch on >> leave. > > No. > Please look at how spinlock_enter() is implemented in ia32/amd64 in > order to see how it does handle recursion. And besides we have other patterns running with interrupts disabled taking care of preemption as well (I think I already pointed to one, I think you could find others easilly). Attilio --=20 Peace can only be achieved by understanding - A. Einstein