From owner-freebsd-hackers@FreeBSD.ORG Mon May 27 05:03:14 2013 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 2078EADC for ; Mon, 27 May 2013 05:03:14 +0000 (UTC) (envelope-from oritm@mellanox.com) Received: from eu1sys200aog112.obsmtp.com (eu1sys200aog112.obsmtp.com [207.126.144.133]) by mx1.freebsd.org (Postfix) with ESMTP id 5E248149 for ; Mon, 27 May 2013 05:03:12 +0000 (UTC) Received: from MTLCAS02.mtl.com ([193.47.165.155]) (using TLSv1) by eu1sys200aob112.postini.com ([207.126.147.11]) with SMTP ID DSNKUaLpB3JYaVuE8br66hyowDqPImsY7O9k@postini.com; Mon, 27 May 2013 05:03:13 UTC Received: from MTLDAG01.mtl.com ([10.0.8.75]) by MTLCAS02.mtl.com ([10.0.8.72]) with mapi id 14.03.0123.003; Mon, 27 May 2013 08:00:14 +0300 From: Orit Moskovich To: Konstantin Belousov Subject: RE: preemptive kernel Thread-Topic: preemptive kernel Thread-Index: AQHOWihm0YFG89T8IkWOFRvrz7kZiJkYcsLw Date: Mon, 27 May 2013 05:00:13 +0000 Message-ID: <981733489AB3BD4DB24B48340F53E0A55B0D56E0@MTLDAG01.mtl.com> References: <981733489AB3BD4DB24B48340F53E0A55B0D5590@MTLDAG01.mtl.com> <20130526154752.GT3047@kib.kiev.ua> In-Reply-To: <20130526154752.GT3047@kib.kiev.ua> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.0.13.1] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Cc: "freebsd-hackers@freebsd.org" X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 May 2013 05:03:14 -0000 Just to be more specific - On x86, during a filter routine all interrupts a= re disabled on the cpu currently handling a filter routine or only interrup= ts on the IRQ that generated the interrupt?=20 Is it possible that on a different cpu an interrupt (filter or ithread) of = the same IRQ will run? Should worry about locking data because an ithread c= an preempt the same ithread or they'll run concurrently on different cpus? -----Original Message----- From: Konstantin Belousov [mailto:kostikbel@gmail.com]=20 Sent: Sunday, May 26, 2013 06:48 PM To: Orit Moskovich Cc: freebsd-hackers@freebsd.org Subject: Re: preemptive kernel On Sun, May 26, 2013 at 11:09:03AM +0000, Orit Moskovich wrote: > Can a filter routine preempt another filter routine? And can an interrupt= thread (or a filter routine) preempt another ithread? Filter handler borrows the context from the thread executed at the time of = the interrupt. At least on x86 (i.e. i386 and amd64) interrupt handlers ar= e executed with the interrupts disabled. So the filter cannot interrupt an= other filter. Interrupt threads are executed with the interrupts enabled. So if an interr= upt is delivered to the CPU while the CPU executed the ithread, the filter = 'preempts' the ithread by executing in its context. For the same reason, i= f the interrupt delivered causes a higher-priority thread become ready to r= un, then the new runnable thread could preempt the interrupt thread accordi= ng to the priority, affinity and other factors considered by a scheduler.