linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] page-flags updates
@ 2015-10-02  5:40 Kirill A. Shutemov
  2015-10-02  5:40 ` [PATCH 1/3] page-flags: do not corrupt caller 'page' in PF_NO_TAIL Kirill A. Shutemov
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Kirill A. Shutemov @ 2015-10-02  5:40 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, linux-mm, Kirill A. Shutemov

Few updates based on Andrew's feedback.

Kirill A. Shutemov (3):
  page-flags: do not corrupt caller 'page' in PF_NO_TAIL
  page-flags: add documentation for policies
  page-flags: hide PF_* validation check under separate config option

 include/linux/mmdebug.h    |  6 ++++++
 include/linux/page-flags.h | 30 +++++++++++++++++++++---------
 lib/Kconfig.debug          |  8 ++++++++
 3 files changed, 35 insertions(+), 9 deletions(-)

-- 
2.5.1

--
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>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] page-flags: do not corrupt caller 'page' in PF_NO_TAIL
  2015-10-02  5:40 [PATCH 0/3] page-flags updates Kirill A. Shutemov
@ 2015-10-02  5:40 ` Kirill A. Shutemov
  2015-10-02  5:40 ` [PATCH 2/3] page-flags: add documentation for policies Kirill A. Shutemov
  2015-10-02  5:40 ` [PATCH 3/3] page-flags: hide PF_* validation check under separate config option Kirill A. Shutemov
  2 siblings, 0 replies; 4+ messages in thread
From: Kirill A. Shutemov @ 2015-10-02  5:40 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, linux-mm, Kirill A. Shutemov

Andrew noticed that PF_NO_TAIL() modifies caller's 'page'. This doesn't
trigger any bad results, because all users are inline functions which
doesn't use the variable beyond the point. But still not good.

The patch changes PF_NO_TAIL() to always return head page, regardless
'enforce'. This makes operations of page flags with PF_NO_TAIL more
symmetrical: modifications and checks goes to head page. It gives
better chance to recover in case of bug for non-DEBUG_VM kernel.

DEBUG_VM kernel will still trigger VM_BUG_ON() on modifications to tail
pages.

Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
---
 include/linux/page-flags.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index 2a2391c21558..465ca42af633 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -139,9 +139,7 @@ enum pageflags {
 #define PF_NO_TAIL(page, enforce) ({					\
 		if (enforce)						\
 			VM_BUG_ON_PAGE(PageTail(page), page);		\
-		else							\
-			page = compound_head(page);			\
-		page;})
+		compound_head(page);})
 #define PF_NO_COMPOUND(page, enforce) ({					\
 		if (enforce)						\
 			VM_BUG_ON_PAGE(PageCompound(page), page);	\
-- 
2.5.1

--
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>

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] page-flags: add documentation for policies
  2015-10-02  5:40 [PATCH 0/3] page-flags updates Kirill A. Shutemov
  2015-10-02  5:40 ` [PATCH 1/3] page-flags: do not corrupt caller 'page' in PF_NO_TAIL Kirill A. Shutemov
@ 2015-10-02  5:40 ` Kirill A. Shutemov
  2015-10-02  5:40 ` [PATCH 3/3] page-flags: hide PF_* validation check under separate config option Kirill A. Shutemov
  2 siblings, 0 replies; 4+ messages in thread
From: Kirill A. Shutemov @ 2015-10-02  5:40 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, linux-mm, Kirill A. Shutemov

The patch adds description for page flags policies.

Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
---
 include/linux/page-flags.h | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index 465ca42af633..19e4129f00e5 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -133,7 +133,23 @@ enum pageflags {
 
 #ifndef __GENERATING_BOUNDS_H
 
-/* Page flags policies wrt compound pages */
+/*
+ * Page flags policies wrt compound pages
+ *
+ * PF_ANY:
+ *     the page flag is relevant for small, head and tail pages.
+ *
+ * PF_HEAD:
+ *     for compound page all operations related to the page flag applied to
+ *     head page.
+ *
+ * PF_NO_TAIL:
+ *     modifications of the page flag must be done on small or head pages,
+ *     checks can be done on tail pages too.
+ *
+ * PF_NO_COMPOUND:
+ *     the page flag is not relevant for compound pages.
+ */
 #define PF_ANY(page, enforce)	page
 #define PF_HEAD(page, enforce)	compound_head(page)
 #define PF_NO_TAIL(page, enforce) ({					\
-- 
2.5.1

--
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>

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] page-flags: hide PF_* validation check under separate config option
  2015-10-02  5:40 [PATCH 0/3] page-flags updates Kirill A. Shutemov
  2015-10-02  5:40 ` [PATCH 1/3] page-flags: do not corrupt caller 'page' in PF_NO_TAIL Kirill A. Shutemov
  2015-10-02  5:40 ` [PATCH 2/3] page-flags: add documentation for policies Kirill A. Shutemov
@ 2015-10-02  5:40 ` Kirill A. Shutemov
  2 siblings, 0 replies; 4+ messages in thread
From: Kirill A. Shutemov @ 2015-10-02  5:40 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, linux-mm, Kirill A. Shutemov

VM_BUG_ONs in PF_NO_TAIL() and PF_NO_COMPOUND() add 4+ KiB to
mm/build-in.o for DEBUG_VM kernel.

Let's hide them under new config option -- CONFIG_DEBUG_VM_PGFLAGS.
With the option enabled VM_BUG_ON_PGFLAGS() is equal to VM_BUG_ON_PAGE.

Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
---
 include/linux/mmdebug.h    | 6 ++++++
 include/linux/page-flags.h | 8 +++-----
 lib/Kconfig.debug          | 8 ++++++++
 3 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/include/linux/mmdebug.h b/include/linux/mmdebug.h
index 877ef226f90f..c447d8055e50 100644
--- a/include/linux/mmdebug.h
+++ b/include/linux/mmdebug.h
@@ -55,4 +55,10 @@ void dump_mm(const struct mm_struct *mm);
 #define VIRTUAL_BUG_ON(cond) do { } while (0)
 #endif
 
+#ifdef CONFIG_DEBUG_VM_PGFLAGS
+#define VM_BUG_ON_PGFLAGS(cond, page) VM_BUG_ON_PAGE(cond, page)
+#else
+#define VM_BUG_ON_PGFLAGS(cond, page) BUILD_BUG_ON_INVALID(cond)
+#endif
+
 #endif
diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index 19e4129f00e5..8d6e4e9a98af 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -153,12 +153,10 @@ enum pageflags {
 #define PF_ANY(page, enforce)	page
 #define PF_HEAD(page, enforce)	compound_head(page)
 #define PF_NO_TAIL(page, enforce) ({					\
-		if (enforce)						\
-			VM_BUG_ON_PAGE(PageTail(page), page);		\
+		VM_BUG_ON_PGFLAGS(enforce && PageTail(page), page);	\
 		compound_head(page);})
-#define PF_NO_COMPOUND(page, enforce) ({					\
-		if (enforce)						\
-			VM_BUG_ON_PAGE(PageCompound(page), page);	\
+#define PF_NO_COMPOUND(page, enforce) ({				\
+		VM_BUG_ON_PGFLAGS(enforce && PageCompound(page), page);	\
 		page;})
 
 /*
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index e2894b23efb6..0d12bfa429de 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -570,6 +570,14 @@ config DEBUG_VM_RB
 
 	  If unsure, say N.
 
+config DEBUG_VM_PGFLAGS
+	bool "Debug page-flags operations"
+	depends on DEBUG_VM
+	help
+	  Enables extra validation on page flags operations.
+
+	  If unsure, say N.
+
 config DEBUG_VIRTUAL
 	bool "Debug VM translations"
 	depends on DEBUG_KERNEL && X86
-- 
2.5.1

--
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>

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-10-02  5:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-02  5:40 [PATCH 0/3] page-flags updates Kirill A. Shutemov
2015-10-02  5:40 ` [PATCH 1/3] page-flags: do not corrupt caller 'page' in PF_NO_TAIL Kirill A. Shutemov
2015-10-02  5:40 ` [PATCH 2/3] page-flags: add documentation for policies Kirill A. Shutemov
2015-10-02  5:40 ` [PATCH 3/3] page-flags: hide PF_* validation check under separate config option Kirill A. Shutemov

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).