[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <d4cf37a60703212159u54fe7fdehf052c1cc788b9b94@mail.gmail.com>
Date: Wed, 21 Mar 2007 21:59:33 -0700
From: "Wink Saville" <wink@...ille.com>
To: linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/7] Initial implementation of the trec driver and include files
On 3/21/07, Johannes Weiner <hannes-kernel@...urebad.de> wrote:
> Hi,
>
> On Wed, Mar 21, 2007 at 09:49:12AM -0700, Wink Saville wrote:
> > >>Please don't use camel-case - in general.
> > >>
> > Would p_next, p_cur and p_end be OK?
>
> I think it's generally disliked. Quoting Documentation/CodingStyle:
>
> ``Encoding the type of a function into the name (so-called Hungarian
> notation) is brain damaged - the compiler knows the types anyway and can
> check those, and it only confuses the programmer. No wonder MicroSoft
> makes buggy programs.''
>
I'll change it to; next, cur, end (when in rome do as the romans)
>
> You can implement a sysctl-setting to enable/disable the whole system
> (which then would be runtime changeable).
Generally the way I've used this in the kernel is sprinkle them liberally
where I'm trying to track down a bug or understand how some code works
and then disable some of them using ZREC's but then reenable as
necessary. Finally, I remove them all usually by reverting to the original
code.
In userland I have a more sophisticated version which combines TREC's
and printf's in one macro with a "debug variable" defined as a
set of bits controlling the enable/disable sets of these. For example:
DPRP1(1 << 2, "This is a DPR with parameter=%d", xyz);
#define DPRP1(__bits, __format, __param, ...) \
do { \
if (((__bits) << 16) & dbg_variable) \
printf((__format), __param...); \
if ((__bits) & dbg_variable) \
TREC1((__param)); \
} while (0)
The above divides "dbg_variable" into 2 16 bit fields, the upper 16
bits control if the printf is enabled and the lower 16 bits controls if
the TREC1 is enabled. What I envision happening would possibly
to expose the "dbg_variable" via procfs where it could "easily" be
modified from userland.
Anyway, for my immediate needs I just needed the TREC's so I could
understand the inner workings of the kernel better and assist in debugging.
I've submitted it as a patch incase anyone might be interested.
Actually, are you interested in using them?
In anycase thanks for the feed back.
Wink
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists