tools: add WARN_ON_ONCE
authorMatthew Wilcox <willy@linux.intel.com>
Wed, 14 Dec 2016 23:07:56 +0000 (15:07 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 15 Dec 2016 00:04:09 +0000 (16:04 -0800)
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/1480369871-5271-37-git-send-email-mawilcox@linuxonhyperv.com
Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
Tested-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Konstantin Khlebnikov <koct9i@gmail.com>
Cc: Ross Zwisler <ross.zwisler@linux.intel.com>
Cc: Matthew Wilcox <mawilcox@microsoft.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
tools/include/asm/bug.h
tools/testing/radix-tree/Makefile
tools/testing/radix-tree/linux/bug.h
tools/testing/radix-tree/linux/types.h

index 9e5f4846967fcf6e098c039c61b455f1a9326b64..beda1a884b50f0465ace7e3f01ca6014e5d3e755 100644 (file)
        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);    \
index f2e07f2fd4b48282a274aae7c667a25116ab4505..3c338dc3b162be900efa93055b4b5d7205eeddcf 100644 (file)
@@ -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 \
index ccbe444977df5dd86770a7bbcc08af352cf5a761..23b8ed52f8c80a0e52a811776049d9d27e24c9ee 100644 (file)
@@ -1 +1 @@
-#define WARN_ON_ONCE(x)                assert(x)
+#include "asm/bug.h"
index faa0b6ff9ca869f7791c23abe4293ad620e236d6..8491d89873bb03005a0a4dde1a8cf531b9a63c25 100644 (file)
@@ -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;