From owner-freebsd-current Wed Oct 9 2: 5:41 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 BF07837B401; Wed, 9 Oct 2002 02:05:39 -0700 (PDT) Received: from vbook.express.ru (asplinux.ru [195.133.213.194]) by mx1.FreeBSD.org (Postfix) with ESMTP id B35D543E4A; Wed, 9 Oct 2002 02:05:35 -0700 (PDT) (envelope-from vova@express.ru) Received: from vova by vbook.express.ru with local (Exim 3.36 #1) id 17zCmR-0000Ga-00; Wed, 09 Oct 2002 13:05:23 +0400 Subject: Re: DDB sysctl function From: "Vladimir B. " Grebenschikov To: Bruce Evans Cc: John Baldwin , Grebenschikov@FreeBSD.ORG, vova@sw.ru, freebsd-current@FreeBSD.ORG, Maxime Henrion In-Reply-To: <20021009160129.P4010-100000@gamplex.bde.org> References: <20021009160129.P4010-100000@gamplex.bde.org> Content-Type: text/plain; charset=KOI8-R Content-Transfer-Encoding: quoted-printable X-Mailer: Ximian Evolution 1.0.7 Date: 09 Oct 2002 13:05:22 +0400 Message-Id: <1034154322.900.3.camel@vbook.express.ru> Mime-Version: 1.0 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 =F7 Wed, 09.10.2002, =D7 10:17, Bruce Evans =CE=C1=D0=C9=D3=C1=CC: > On Tue, 8 Oct 2002, John Baldwin wrote: >=20 > > 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 = you > > >> 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. >=20 > 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 As minimal, It will deadlocked if you call sysctl when drop to DDB from another sysctl handler. > - 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. Yes, you are right but for me code is still usable in many cases. Code is for development, not for any production use. And one, as developer, can look at backtrace before use it. > Bruce =20 --=20 Vladimir B. Grebenschikov vova@sw.ru, SWsoft, Inc. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message