From: Sasha Levin <sasha.levin@oracle.com>
To: akpm@linux-foundation.org
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
kirill@shutemov.name, Sasha Levin <sasha.levin@oracle.com>
Subject: [RFC 2/2] mm: additional checks to page flag set/clear
Date: Sat, 28 Dec 2013 20:45:04 -0500 [thread overview]
Message-ID: <1388281504-11453-2-git-send-email-sasha.levin@oracle.com> (raw)
In-Reply-To: <1388281504-11453-1-git-send-email-sasha.levin@oracle.com>
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@oracle.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, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2013-12-29 1:45 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-29 1:45 [RFC 1/2] mm: additional page lock debugging Sasha Levin
2013-12-29 1:45 ` Sasha Levin [this message]
2013-12-30 12:12 ` [RFC 2/2] mm: additional checks to page flag set/clear Kirill A. Shutemov
2013-12-30 11:43 ` [RFC 1/2] mm: additional page lock debugging Kirill A. Shutemov
2013-12-30 16:33 ` Sasha Levin
2013-12-30 22:48 ` Kirill A. Shutemov
2013-12-31 3:22 ` Sasha Levin
2013-12-31 16:26 ` Peter Zijlstra
2013-12-31 16:42 ` Sasha Levin
2014-01-06 10:04 ` Peter Zijlstra
2014-02-10 23:19 ` Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1388281504-11453-2-git-send-email-sasha.levin@oracle.com \
--to=sasha.levin@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=kirill@shutemov.name \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).