Date: Wed, 11 Aug 2010 22:11:37 +0300 From: Kostik Belousov <kostikbel@gmail.com> To: Attilio Rao <attilio@freebsd.org> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Jeff Roberson <jeff@freebsd.org>, John Baldwin <jhb@freebsd.org> Subject: Re: svn commit: r211176 - in head/sys: amd64/amd64 i386/i386 Message-ID: <20100811191137.GO2396@deviant.kiev.zoral.com.ua> In-Reply-To: <AANLkTi=qDOGFWnKfH63vRF1Hx-_cc1Z0H71Vm2bMM-ti@mail.gmail.com> References: <201008111051.o7BApRp4028538@svn.freebsd.org> <20100811105739.GJ2396@deviant.kiev.zoral.com.ua> <AANLkTikk3m-=5W7TVV5C-XM4AnwS1LuAi7GGEeP0B9dV@mail.gmail.com> <20100811123430.GK2396@deviant.kiev.zoral.com.ua> <AANLkTikmSTt7jLPMfFeSxyTi00KfvuWCHCL5XBZouf2m@mail.gmail.com> <20100811144646.GL2396@deviant.kiev.zoral.com.ua> <AANLkTimvkEkP_08jNU_YyS%2BeDOcQtFf6xwiE2Xfscd5v@mail.gmail.com> <AANLkTi=qDOGFWnKfH63vRF1Hx-_cc1Z0H71Vm2bMM-ti@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
--Jl+DbTnyraiZ/loT Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Aug 11, 2010 at 07:10:00PM +0200, Attilio Rao wrote: > 2010/8/11 Attilio Rao <attilio@freebsd.org>: > > 2010/8/11 Kostik Belousov <kostikbel@gmail.com>: > >> On Wed, Aug 11, 2010 at 04:29:21PM +0200, Attilio Rao wrote: > >>> 2010/8/11 Kostik Belousov <kostikbel@gmail.com>: > >>> > On Wed, Aug 11, 2010 at 01:21:46PM +0200, Attilio Rao wrote: > >>> >> 2010/8/11 Kostik Belousov <kostikbel@gmail.com>: > >>> >> > 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: > >>> >> >> =9A IPI handlers may run generally with interrupts disabled bec= ause they > >>> >> >> =9A are served via an interrupt gate. > >>> >> >> > >>> >> >> =9A However, that doesn't explicitly prevent preemption and thr= ead > >>> >> >> =9A migration thus scheduler pinning may be necessary in some h= andlers. > >>> >> >> =9A Fix that. > >>> >> > > >>> >> > How the preemption is supposed to happen ? Aside from the explic= it > >>> >> > calls to mi_switch() from e.g. critical_exit(). > >>> >> > >>> >> IIRC it should be hardclock() willing to schedule the softclock().= It > >>> >> 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 > >>> > =9A =9A =9A =9Acpu =3D PCPU_GET(cpuid); > >>> > =9A =9A =9A =9Acpumask =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. >=20 > 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). Let me rephrase the original question: how the code of the kind a =3D b; c =3D d; while executed with interrupts disabled, can be a subject to the kernel preemption ? Well, the code are slightly more involved, because evaluation of the right part of the assignment causes rebasing against non-default segment register on x86oids, but the detail is irrelevant. --Jl+DbTnyraiZ/loT Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (FreeBSD) iEYEARECAAYFAkxi9egACgkQC3+MBN1Mb4j/OQCfYbQR4NJtJkoUByep52q035p6 6pIAnRtSldYHmMhsMTNKG9cyWLNil+fn =zR30 -----END PGP SIGNATURE----- --Jl+DbTnyraiZ/loT--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100811191137.GO2396>