Skip site navigation (1)Skip section navigation (2)
Date:      09 Oct 2002 13:05:22 +0400
From:      "Vladimir B. " Grebenschikov <vova@sw.ru>
To:        Bruce Evans <bde@zeta.org.au>
Cc:        John Baldwin <jhb@FreeBSD.ORG>, Grebenschikov@FreeBSD.ORG, vova@sw.ru, freebsd-current@FreeBSD.ORG, Maxime Henrion <mux@FreeBSD.ORG>
Subject:   Re: DDB sysctl function
Message-ID:  <1034154322.900.3.camel@vbook.express.ru>
In-Reply-To: <20021009160129.P4010-100000@gamplex.bde.org>
References:  <20021009160129.P4010-100000@gamplex.bde.org>

next in thread | previous in thread | raw e-mail | index | archive | help
=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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1034154322.900.3.camel>