Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1365176

[PATCH 3/4] page-flags: make page flag helpers accept struct head_page

From "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Newsgroups linux.kernel
Subject [PATCH 3/4] page-flags: make page flag helpers accept struct head_page
Date 2016-03-27 21:50 +0200
Message-ID <rhoRc-4ub-25@gated-at.bofh.it> (permalink)
References <rhoRc-4ub-13@gated-at.bofh.it> <rhoRc-4ub-15@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


This patch makes all generated page flag helpers to accept pointer to
struct head_page as well as struct page.

In case if pointer to struct head_page is passed, we assume that it's
head page and bypass policy constrain checks.

Note, to get get inteface consistent we would need to make non-generated
page flag helper to accept struct head_page as well.

Not-yet-signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
---
 scripts/mkpageflags.sh | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/scripts/mkpageflags.sh b/scripts/mkpageflags.sh
index 29d46bccaea4..272aab4ad1a3 100755
--- a/scripts/mkpageflags.sh
+++ b/scripts/mkpageflags.sh
@@ -6,23 +6,23 @@ fatal() {
 }
 
 any() {
-	echo "(__p)"
+	echo "((struct page *)(__p))"
 }
 
 head() {
-	echo "compound_head(__p)"
+	echo "compound_head((struct page *)(__p))"
 }
 
 no_tail() {
 	local enforce="${1:+VM_BUG_ON_PGFLAGS(PageTail(__p), __p);}"
 
-	echo "({$enforce compound_head(__p);})"
+	echo "({$enforce compound_head((struct page *)(__p));})"
 }
 
 no_compound() {
 	local enforce="${1:+VM_BUG_ON_PGFLAGS(PageCompound(__p), __p);}"
 
-	echo "({$enforce __p;})"
+	echo "({$enforce ((struct page *)(__p));})"
 }
 
 generate_test() {
@@ -34,7 +34,9 @@ generate_test() {
 	cat <<EOF
 #define $uname(__p) ({								\\
 	int ret;								\\
-	if (__builtin_types_compatible_p(typeof(*(__p)), struct page))		\\
+	if (__builtin_types_compatible_p(typeof(*(__p)), struct head_page))	\\
+		ret = $op(PG_$lname, &((struct head_page *)(__p))->page.flags);	\\
+	else if (__builtin_types_compatible_p(typeof(*(__p)), struct page))	\\
 		ret = $op(PG_$lname, &$page->flags);				\\
 	else									\\
 		BUILD_BUG();							\\
@@ -52,7 +54,9 @@ generate_mod() {
 
 	cat <<EOF
 #define $uname(__p) do {							\\
-	if (__builtin_types_compatible_p(typeof(*(__p)), struct page))		\\
+	if (__builtin_types_compatible_p(typeof(*(__p)), struct head_page))	\\
+		$op(PG_$lname, &((struct head_page *)(__p))->page.flags);	\\
+	else if (__builtin_types_compatible_p(typeof(*(__p)), struct page))	\\
 		$op(PG_$lname, &$page->flags);					\\
 	else									\\
 		BUILD_BUG();							\\
-- 
2.8.0.rc3

Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

[PATCH 1/4] page-flags: generate page-flags helpers with script "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2016-03-27 21:50 +0200
  [PATCH 2/4] mm: introduce struct head_page and compound_head_t "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2016-03-27 21:50 +0200
  [PATCH 3/4] page-flags: make page flag helpers accept struct head_page "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2016-03-27 21:50 +0200

csiph-web