Re: [PATCH 2/2] ring-buffer: replace most bug ons with warn on anddisable buffer

From: Ingo Molnar
Date: Tue Nov 11 2008 - 04:09:47 EST



* Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:

> +#define RB_WARN_ON_RET_INT(buffer, cond) \
> + do { \
> + if (unlikely(cond)) { \
> + atomic_inc(&buffer->record_disabled); \
> + WARN_ON(1); \
> return -1; \
> } \

btw., the _RET() methods are rather ugly as they include an implicit
code flow change (a 'return' statement).

Please change it to a more readable form that preserves the code flow,
something like:

if (RB_WARN_ON(buffer, cond))
return -1;

See kernel/lockdep.c about how to do this cleanly: introduce a
_single_ global "oh, we are broken" flag which is increased once and
never decreased again.

In the case of lockdep that's the debug_locks flag. It's used in
various code-flow-preserving forms of debug checks:

...
if (DEBUG_LOCKS_WARN_ON(depth >= 20))
return;
...
if (!debug_locks_off_graph_unlock())
return NULL;
...
if (!debug_locks_off_graph_unlock())
return 0;
...
if (!__raw_spin_is_locked(&lockdep_lock))
return DEBUG_LOCKS_WARN_ON(1);

etc.

Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/