From owner-freebsd-hackers@FreeBSD.ORG Fri Oct 6 13:45:42 2006 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8662B16A614; Fri, 6 Oct 2006 13:45:42 +0000 (UTC) (envelope-from stas@FreeBSD.org) Received: from com1.ht-systems.ru (com1.ht-systems.ru [83.97.104.204]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7F0F043D5F; Fri, 6 Oct 2006 13:45:28 +0000 (GMT) (envelope-from stas@FreeBSD.org) Received: from [80.250.160.136] (helo=fonon.realnet) by com1.ht-systems.ru with esmtpa (Exim 4.62) (envelope-from ) id 1GVpzm-0006ts-GB; Fri, 06 Oct 2006 17:44:10 +0400 Received: from localhost (localhost [127.0.0.1]) by fonon.realnet (Postfix) with SMTP id CD6BD11F43; Fri, 6 Oct 2006 17:45:06 +0400 (MSD) Date: Fri, 6 Oct 2006 17:45:04 +0400 From: Stanislav Sedov To: David Xu Message-Id: <20061006174504.c4af61ba.stas@FreeBSD.org> In-Reply-To: <200610050829.36266.davidxu@freebsd.org> References: <20061004214040.GA6878@porthos.spock.org> <200610050829.36266.davidxu@freebsd.org> Organization: The FreeBSD Project X-Mailer: carrier-pigeon Mime-Version: 1.0 Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg="PGP-SHA1"; boundary="Signature=_Fri__6_Oct_2006_17_45_04_+0400_DMoL4sCT_Cq6bkCI" X-Spam-Flag: SKIP X-Spam-Yversion: Spamooborona 1.6.0 Cc: freebsd-hackers@freebsd.org, Jonathan Chen Subject: Re: running code on all CPUs X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Oct 2006 13:45:42 -0000 --Signature=_Fri__6_Oct_2006_17_45_04_+0400_DMoL4sCT_Cq6bkCI Content-Type: text/plain; charset=KOI8-R Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, 5 Oct 2006 08:29:36 +0800 David Xu wrote: > On Thursday 05 October 2006 05:40, Jonathan Chen wrote: > > Hello, > > > > I'm currently writing kernel code to use MCA (machine check architect= ure) > > in order to detect things like ECC errors. As part of this, I need t= o run > > code on all CPUs periodically to check some status registers. Where = is the > > best place to do this? It doesn't seem that I can use regular kernel > > threads since I can't specify a CPU binding with that interface. I'v= e > > thought about hooking a function call to either the beginning of > > idle_proc() or somewhere in mi_switch(), but neither solution seems o= ptimal > > since there are no guarantees when idle_proc() is ran and mi_switch()= seems > > like a really bad idea from a performance standpoint. Suggestions? > > > > Also, are there any locking pitfalls or other issues I should be awar= e of > > when writing code to run in either idle_proc() or mi_switch()? > > > > -Jon > > AFAIK, you can use scheduler API, the sched_bind() moves current thread= to > a specific CPU, hope this helps. > You can find examples e.g. in hwpmc driver. Just grep by sched_bin. -- Stanislav Sedov [[=F2=CF=D3=D3=C9=D1, = =ED=CF=D3=CB=D7=C1]] PGP id: 0xEB269581 http://people.freebsd.org/~stas/stas.key.asc --Signature=_Fri__6_Oct_2006_17_45_04_+0400_DMoL4sCT_Cq6bkCI Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (FreeBSD) iD8DBQFFJl3gK/VZk+smlYERAg+SAJ9oqUZGZuFziMyTZ7UsefRj7K5EngCeONWt oqNO3izXovUBpWlPA3xLThY= =EfRp -----END PGP SIGNATURE----- --Signature=_Fri__6_Oct_2006_17_45_04_+0400_DMoL4sCT_Cq6bkCI--