From owner-freebsd-current Tue Oct 8 23: 7:36 2002 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B934237B401; Tue, 8 Oct 2002 23:07:34 -0700 (PDT) Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by mx1.FreeBSD.org (Postfix) with ESMTP id 306CD43E6A; Tue, 8 Oct 2002 23:07:33 -0700 (PDT) (envelope-from bde@zeta.org.au) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id QAA12757; Wed, 9 Oct 2002 16:07:29 +1000 Date: Wed, 9 Oct 2002 16:17:32 +1000 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: John Baldwin Cc: "Vladimir B. "@FreeBSD.ORG, , <" "@server.baldwin.cx>, , Maxime Henrion Subject: Re: DDB sysctl function In-Reply-To: Message-ID: <20021009160129.P4010-100000@gamplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=X-UNKNOWN Content-Transfer-Encoding: QUOTED-PRINTABLE Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Tue, 8 Oct 2002, John Baldwin wrote: > On 08-Oct-2002 Vladimir B. " Grebenschikov wrote: > > =F7 Tue, 08.10.2002, =D7 22:25, Maxime Henrion =CE=C1=D0=C9=D3=C1=CC: > >> - I'm not sure if using the context of the init process to do sysctl > >> calls is the right way to go. However, it is not very clear what yo= u > >> should use to do this, at least to me. > > > > kernel_sysctl need thread pointer, it may be used in sysctl handlers. > > Use curthread perhaps. In -current you always have a thread context, > even when idle. Not in ddb you don't. ddb may be invoked at any point, including in the middle of a thread switch. ddb also use any normal lock, since doing so may deadlock or worse. I don't see how ddb can safely use any of the general sysctl code, especially for writing. There are almost no locks for sysctl now, but that will change when Giant is pushed down and/or removed. Reading can work in the same way as db_ps() now, provided the code doesn't go near any locks: when a data struct is invalid, following garbage pointers cause traps if you are unlucky (endless loops if you are unlucky) and ddb's trap handler longjmp()s back to the main loop. Going near locks causes at least the following problems: - deadlock - not releasing locks in the trap handler before longjmp()'ing. The trap handler cannot reasonably know which locks to release if they were aquired by general code. - traps in the middle of aquiring and releasing locks may leave the locks in a half-initialized state, and the trap handler cannot even unreasonably klnow how to fix this. Similarly for any other global data structures that are modified by general code called from ddb. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message