Subject: Re: ddb help command patch
To: Adam Hamsik <haaaad@gmail.com>
From: Bill Stouder-Studenmund <wrstuden@netbsd.org>
List: tech-kern
Date: 06/27/2007 11:21:59
--utPK4TBebyzZxMrE
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Wed, Jun 27, 2007 at 11:03:10AM -0700, Bill Stouder-Studenmund wrote:
> On Tue, Jun 26, 2007 at 05:48:32PM +0200, Adam Hamsik wrote:
> >=20
> > 2) I think about dynamic ddb command/help API which could be used for =
=20
> > registering/unregistering ddb commands. Now all ddb commands are =20
> > stored in static array db_command_table. Problem is that if every =20
> > kernel component want to add some ddb_commands kernel programer have =
=20
> > to add entry to the ddb_command_table. If we use dynamic structure =20
> > like linked list we can add/remove commands in realtime.
>=20
> Sounds good.
>=20
> > Cons:
> > I have to initialize this list when ddb is run.(lot of malloc's for =20
> > every added command 2 one for command structure and second for help=20
> > (not needed))
>=20
> Actually, I think if we are clever about our list creation, we don't have=
=20
> too much of an issue.
>=20
> Make the list a list of tables. So built-in commands are in one static=20
> table, and we have a static command list head. We then have a malloc'd=20
> list of:
>=20
> struct ddb_command_list_entry {
> 	TAILQ_ENTRY(ddb_command_list_entry)
> 				ddbcl_next;
> 	int			ddbcl_count;		/* count of cmds */
> 	struct ddb_command	*ddbcl_commands;
> };

Note: one thing I wasn't clear on. We have one of the above per command=20
table. So all the internal commands would be covered by generating one of=
=20
the above command list entries. When an lkm adds commands (say 5 of them),=
=20
we add only one list entry for the whole table of 5.

The other API changes would be that you register a command table, not an=20
individual command.

> Yes, there will probably be a pad int in there too on LP64.
>=20
> The upshot of this is that everything other than these list entries can b=
e=20
> in text sections. We only need to malloc one of these command list entry=
=20
> structures per table of commands.

Take care,

Bill

--utPK4TBebyzZxMrE
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (NetBSD)

iD8DBQFGgqrGWz+3JHUci9cRAlptAJ4nTsbHqap8mxgW5SaLQhcfVkJpbwCfW55i
knuS1PzmcTAVDtSHAY81BC0=
=oxxM
-----END PGP SIGNATURE-----

--utPK4TBebyzZxMrE--