[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1388281504-11453-2-git-send-email-sasha.levin@oracle.com>
Date: Sat, 28 Dec 2013 20:45:04 -0500
From: Sasha Levin <sasha.levin@...cle.com>
To: akpm@...ux-foundation.org
Cc: linux-mm@...ck.org, linux-kernel@...r.kernel.org,
kirill@...temov.name, Sasha Levin <sasha.levin@...cle.com>
Subject: [RFC 2/2] mm: additional checks to page flag set/clear
Check if the flag is already set before setting it, and vice versa
for clearing.
Obviously setting or clearing a flag twice isn't a problem on it's
own, but it implies that there's an issue where some piece of code
assumed an opposite state of the flag.
Signed-off-by: Sasha Levin <sasha.levin@...cle.com>
---
include/linux/page-flags.h | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index d1fe1a7..36b0bef 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -130,6 +130,12 @@ enum pageflags {
#ifndef __GENERATING_BOUNDS_H
+#ifdef CONFIG_DEBUG_VM_PAGE_FLAGS
+#define VM_ASSERT_FLAG(assert, page) VM_BUG_ON_PAGE(assert, page)
+#else
+#define VM_ASSERT_FLAG(assert, page) do { } while (0)
+#endif
+
/*
* Macros to create function definitions for page flags
*/
@@ -139,11 +145,13 @@ static inline int Page##uname(const struct page *page) \
#define SETPAGEFLAG(uname, lname) \
static inline void SetPage##uname(struct page *page) \
- { set_bit(PG_##lname, &page->flags); }
+ { VM_ASSERT_FLAG(Page##uname(page), page); \
+ set_bit(PG_##lname, &page->flags); }
#define CLEARPAGEFLAG(uname, lname) \
static inline void ClearPage##uname(struct page *page) \
- { clear_bit(PG_##lname, &page->flags); }
+ { VM_ASSERT_FLAG(!Page##uname(page), page); \
+ clear_bit(PG_##lname, &page->flags); }
#define __SETPAGEFLAG(uname, lname) \
static inline void __SetPage##uname(struct page *page) \
--
1.8.3.2
--
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