lkml.org 
[lkml]   [2008]   [Nov]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/2] ring-buffer: replace most bug ons with warn on and disable buffer

* Steven Rostedt <rostedt@goodmis.org> 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


\
 
 \ /
  Last update: 2008-11-11 10:13    [W:0.039 / U:0.040 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site