Skip to content

Commit

Permalink
tools: add WARN_ON_ONCE
Browse files Browse the repository at this point in the history
Patch series "Radix tree patches for 4.10", v3.

Mostly these are improvements; the only bug fixes in here relate to
multiorder entries (which are unused in the 4.9 tree).

This patch (of 32):

The radix tree uses its own buggy WARN_ON_ONCE.  Replace it with the
definition from asm-generic/bug.h

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Matthew Wilcox <[email protected]>
Tested-by: Kirill A. Shutemov <[email protected]>
Cc: Konstantin Khlebnikov <[email protected]>
Cc: Ross Zwisler <[email protected]>
Cc: Matthew Wilcox <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Matthew Wilcox authored and torvalds committed Dec 15, 2016
1 parent 4b4bb46 commit ebb9a9a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
11 changes: 11 additions & 0 deletions tools/include/asm/bug.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@
unlikely(__ret_warn_on); \
})

#define WARN_ON_ONCE(condition) ({ \
static int __warned; \
int __ret_warn_once = !!(condition); \
\
if (unlikely(__ret_warn_once && !__warned)) { \
__warned = true; \
WARN_ON(1); \
} \
unlikely(__ret_warn_once); \
})

#define WARN_ONCE(condition, format...) ({ \
static int __warned; \
int __ret_warn_once = !!(condition); \
Expand Down
2 changes: 1 addition & 1 deletion tools/testing/radix-tree/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

CFLAGS += -I. -g -O2 -Wall -D_LGPL_SOURCE
CFLAGS += -I. -I../../include -g -O2 -Wall -D_LGPL_SOURCE
LDFLAGS += -lpthread -lurcu
TARGETS = main
OFILES = main.o radix-tree.o linux.o test.o tag_check.o find_next_bit.o \
Expand Down
2 changes: 1 addition & 1 deletion tools/testing/radix-tree/linux/bug.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define WARN_ON_ONCE(x) assert(x)
#include "asm/bug.h"
2 changes: 0 additions & 2 deletions tools/testing/radix-tree/linux/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
#define __rcu
#define __read_mostly

#define BITS_PER_LONG (sizeof(long) * 8)

static inline void INIT_LIST_HEAD(struct list_head *list)
{
list->next = list;
Expand Down

0 comments on commit ebb9a9a

Please sign in to comment.