Commit a76e3cc3 authored by Julien Grall's avatar Julien Grall

xen/tmem: Use xen_page_to_gfn rather than pfn_to_gfn

All the caller of xen_tmem_{get,put}_page have a struct page * in hand
and call pfn_to_gfn for the only benefits of these 2 functions.

Rather than passing the pfn in parameter, pass directly the page and use
directly xen_page_to_gfn.
Signed-off-by: default avatarJulien Grall <julien.grall@citrix.com>
Reviewed-by: default avatarStefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: default avatarDavid Vrabel <david.vrabel@citrix.com>
parent 0df4f266
...@@ -129,21 +129,17 @@ static int xen_tmem_new_pool(struct tmem_pool_uuid uuid, ...@@ -129,21 +129,17 @@ static int xen_tmem_new_pool(struct tmem_pool_uuid uuid,
/* xen generic tmem ops */ /* xen generic tmem ops */
static int xen_tmem_put_page(u32 pool_id, struct tmem_oid oid, static int xen_tmem_put_page(u32 pool_id, struct tmem_oid oid,
u32 index, unsigned long pfn) u32 index, struct page *page)
{ {
unsigned long gmfn = pfn_to_gfn(pfn);
return xen_tmem_op(TMEM_PUT_PAGE, pool_id, oid, index, return xen_tmem_op(TMEM_PUT_PAGE, pool_id, oid, index,
gmfn, 0, 0, 0); xen_page_to_gfn(page), 0, 0, 0);
} }
static int xen_tmem_get_page(u32 pool_id, struct tmem_oid oid, static int xen_tmem_get_page(u32 pool_id, struct tmem_oid oid,
u32 index, unsigned long pfn) u32 index, struct page *page)
{ {
unsigned long gmfn = pfn_to_gfn(pfn);
return xen_tmem_op(TMEM_GET_PAGE, pool_id, oid, index, return xen_tmem_op(TMEM_GET_PAGE, pool_id, oid, index,
gmfn, 0, 0, 0); xen_page_to_gfn(page), 0, 0, 0);
} }
static int xen_tmem_flush_page(u32 pool_id, struct tmem_oid oid, u32 index) static int xen_tmem_flush_page(u32 pool_id, struct tmem_oid oid, u32 index)
...@@ -173,14 +169,13 @@ static void tmem_cleancache_put_page(int pool, struct cleancache_filekey key, ...@@ -173,14 +169,13 @@ static void tmem_cleancache_put_page(int pool, struct cleancache_filekey key,
{ {
u32 ind = (u32) index; u32 ind = (u32) index;
struct tmem_oid oid = *(struct tmem_oid *)&key; struct tmem_oid oid = *(struct tmem_oid *)&key;
unsigned long pfn = page_to_pfn(page);
if (pool < 0) if (pool < 0)
return; return;
if (ind != index) if (ind != index)
return; return;
mb(); /* ensure page is quiescent; tmem may address it with an alias */ mb(); /* ensure page is quiescent; tmem may address it with an alias */
(void)xen_tmem_put_page((u32)pool, oid, ind, pfn); (void)xen_tmem_put_page((u32)pool, oid, ind, page);
} }
static int tmem_cleancache_get_page(int pool, struct cleancache_filekey key, static int tmem_cleancache_get_page(int pool, struct cleancache_filekey key,
...@@ -188,7 +183,6 @@ static int tmem_cleancache_get_page(int pool, struct cleancache_filekey key, ...@@ -188,7 +183,6 @@ static int tmem_cleancache_get_page(int pool, struct cleancache_filekey key,
{ {
u32 ind = (u32) index; u32 ind = (u32) index;
struct tmem_oid oid = *(struct tmem_oid *)&key; struct tmem_oid oid = *(struct tmem_oid *)&key;
unsigned long pfn = page_to_pfn(page);
int ret; int ret;
/* translate return values to linux semantics */ /* translate return values to linux semantics */
...@@ -196,7 +190,7 @@ static int tmem_cleancache_get_page(int pool, struct cleancache_filekey key, ...@@ -196,7 +190,7 @@ static int tmem_cleancache_get_page(int pool, struct cleancache_filekey key,
return -1; return -1;
if (ind != index) if (ind != index)
return -1; return -1;
ret = xen_tmem_get_page((u32)pool, oid, ind, pfn); ret = xen_tmem_get_page((u32)pool, oid, ind, page);
if (ret == 1) if (ret == 1)
return 0; return 0;
else else
...@@ -287,7 +281,6 @@ static int tmem_frontswap_store(unsigned type, pgoff_t offset, ...@@ -287,7 +281,6 @@ static int tmem_frontswap_store(unsigned type, pgoff_t offset,
{ {
u64 ind64 = (u64)offset; u64 ind64 = (u64)offset;
u32 ind = (u32)offset; u32 ind = (u32)offset;
unsigned long pfn = page_to_pfn(page);
int pool = tmem_frontswap_poolid; int pool = tmem_frontswap_poolid;
int ret; int ret;
...@@ -296,7 +289,7 @@ static int tmem_frontswap_store(unsigned type, pgoff_t offset, ...@@ -296,7 +289,7 @@ static int tmem_frontswap_store(unsigned type, pgoff_t offset,
if (ind64 != ind) if (ind64 != ind)
return -1; return -1;
mb(); /* ensure page is quiescent; tmem may address it with an alias */ mb(); /* ensure page is quiescent; tmem may address it with an alias */
ret = xen_tmem_put_page(pool, oswiz(type, ind), iswiz(ind), pfn); ret = xen_tmem_put_page(pool, oswiz(type, ind), iswiz(ind), page);
/* translate Xen tmem return values to linux semantics */ /* translate Xen tmem return values to linux semantics */
if (ret == 1) if (ret == 1)
return 0; return 0;
...@@ -313,7 +306,6 @@ static int tmem_frontswap_load(unsigned type, pgoff_t offset, ...@@ -313,7 +306,6 @@ static int tmem_frontswap_load(unsigned type, pgoff_t offset,
{ {
u64 ind64 = (u64)offset; u64 ind64 = (u64)offset;
u32 ind = (u32)offset; u32 ind = (u32)offset;
unsigned long pfn = page_to_pfn(page);
int pool = tmem_frontswap_poolid; int pool = tmem_frontswap_poolid;
int ret; int ret;
...@@ -321,7 +313,7 @@ static int tmem_frontswap_load(unsigned type, pgoff_t offset, ...@@ -321,7 +313,7 @@ static int tmem_frontswap_load(unsigned type, pgoff_t offset,
return -1; return -1;
if (ind64 != ind) if (ind64 != ind)
return -1; return -1;
ret = xen_tmem_get_page(pool, oswiz(type, ind), iswiz(ind), pfn); ret = xen_tmem_get_page(pool, oswiz(type, ind), iswiz(ind), page);
/* translate Xen tmem return values to linux semantics */ /* translate Xen tmem return values to linux semantics */
if (ret == 1) if (ret == 1)
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment