[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH] grant-table: use page flag interfaces when copying a grant page



Use SetPage{Foreign,Reserved} instead of bit-bashing directly. Add an
accessor for the foreign page destructor.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
---
 drivers/xen/grant-table.c  |    5 ++---
 include/linux/page-flags.h |    4 +++-
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
index 7079787..76fe621 100644
--- a/drivers/xen/grant-table.c
+++ b/drivers/xen/grant-table.c
@@ -556,10 +556,9 @@ int gnttab_copy_grant_page(grant_ref_t ref, struct page 
**pagep)
        }
 
        new_page->mapping = page->mapping;
-       new_page->index = page->index;
-       set_bit(PG_foreign, &new_page->flags);
+       SetPageForeign(new_page, _PageForeignDestructor(page));
        if (PageReserved(page))
-               set_bit(PG_reserved, &new_page->flags);
+               SetPageReserved(new_page);
        *pagep = new_page;
 
        SetPageForeign(page, gnttab_page_free);
diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index 86325f9..b03950e 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -287,8 +287,10 @@ CLEARPAGEFLAG(Foreign, foreign)
        BUG_ON((dtor) == (void (*)(struct page *, unsigned int))0);     \
        (_page)->index = (long)(dtor);                                  \
 } while (0)
+#define _PageForeignDestructor(_page) \
+       ((void (*)(struct page *, unsigned int))(_page)->index)
 #define PageForeignDestructor(_page, order)    \
-       ((void (*)(struct page *, unsigned int))(_page)->index)(_page, order)
+       _PageForeignDestructor(_page)(_page, order)
 #else
 PAGEFLAG_FALSE(Foreign)
 #endif
-- 
1.5.6.5


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.