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


Groups > linux.kernel > #1200203 > unrolled thread

[PATCH v2 5/8] xen/tmem: Use page_to_gfn rather than pfn_to_gfn

Started byJulien Grall <julien.grall@citrix.com>
First post2015-08-04 20:20 +0200
Last post2015-08-05 12:10 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v2 5/8] xen/tmem: Use page_to_gfn rather than pfn_to_gfn Julien Grall <julien.grall@citrix.com> - 2015-08-04 20:20 +0200
    Re: [PATCH v2 5/8] xen/tmem: Use page_to_gfn rather than  pfn_to_gfn Stefano Stabellini <stefano.stabellini@eu.citrix.com> - 2015-08-05 12:10 +0200

#1200203 — [PATCH v2 5/8] xen/tmem: Use page_to_gfn rather than pfn_to_gfn

FromJulien Grall <julien.grall@citrix.com>
Date2015-08-04 20:20 +0200
Subject[PATCH v2 5/8] xen/tmem: Use page_to_gfn rather than pfn_to_gfn
Message-ID<pTOYF-1uV-1@gated-at.bofh.it>
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 page_to_gfn.

Signed-off-by: Julien Grall <julien.grall@citrix.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: David Vrabel <david.vrabel@citrix.com>
---
 drivers/xen/tmem.c | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)

diff --git a/drivers/xen/tmem.c b/drivers/xen/tmem.c
index 28c97ff..e0c8dc7 100644
--- a/drivers/xen/tmem.c
+++ b/drivers/xen/tmem.c
@@ -129,21 +129,17 @@ static int xen_tmem_new_pool(struct tmem_pool_uuid uuid,
 /* xen generic tmem ops */
 
 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,
-		gmfn, 0, 0, 0);
+			   page_to_gfn(page), 0, 0, 0);
 }
 
 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,
-		gmfn, 0, 0, 0);
+			   page_to_gfn(page), 0, 0, 0);
 }
 
 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,
 {
 	u32 ind = (u32) index;
 	struct tmem_oid oid = *(struct tmem_oid *)&key;
-	unsigned long pfn = page_to_pfn(page);
 
 	if (pool < 0)
 		return;
 	if (ind != index)
 		return;
 	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,
@@ -287,7 +282,6 @@ static int tmem_frontswap_store(unsigned type, pgoff_t offset,
 {
 	u64 ind64 = (u64)offset;
 	u32 ind = (u32)offset;
-	unsigned long pfn = page_to_pfn(page);
 	int pool = tmem_frontswap_poolid;
 	int ret;
 
@@ -296,7 +290,7 @@ static int tmem_frontswap_store(unsigned type, pgoff_t offset,
 	if (ind64 != ind)
 		return -1;
 	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 */
 	if (ret == 1)
 		return 0;
@@ -313,7 +307,6 @@ static int tmem_frontswap_load(unsigned type, pgoff_t offset,
 {
 	u64 ind64 = (u64)offset;
 	u32 ind = (u32)offset;
-	unsigned long pfn = page_to_pfn(page);
 	int pool = tmem_frontswap_poolid;
 	int ret;
 
@@ -321,7 +314,7 @@ static int tmem_frontswap_load(unsigned type, pgoff_t offset,
 		return -1;
 	if (ind64 != ind)
 		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 */
 	if (ret == 1)
 		return 0;
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1200618 — Re: [PATCH v2 5/8] xen/tmem: Use page_to_gfn rather than pfn_to_gfn

FromStefano Stabellini <stefano.stabellini@eu.citrix.com>
Date2015-08-05 12:10 +0200
SubjectRe: [PATCH v2 5/8] xen/tmem: Use page_to_gfn rather than pfn_to_gfn
Message-ID<pU3O2-6x4-23@gated-at.bofh.it>
In reply to#1200203
On Tue, 4 Aug 2015, Julien Grall wrote:
> 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 page_to_gfn.
> 
> Signed-off-by: Julien Grall <julien.grall@citrix.com>
> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
> Cc: David Vrabel <david.vrabel@citrix.com>

Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>


>  drivers/xen/tmem.c | 21 +++++++--------------
>  1 file changed, 7 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/xen/tmem.c b/drivers/xen/tmem.c
> index 28c97ff..e0c8dc7 100644
> --- a/drivers/xen/tmem.c
> +++ b/drivers/xen/tmem.c
> @@ -129,21 +129,17 @@ static int xen_tmem_new_pool(struct tmem_pool_uuid uuid,
>  /* xen generic tmem ops */
>  
>  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,
> -		gmfn, 0, 0, 0);
> +			   page_to_gfn(page), 0, 0, 0);
>  }
>  
>  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,
> -		gmfn, 0, 0, 0);
> +			   page_to_gfn(page), 0, 0, 0);
>  }
>  
>  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,
>  {
>  	u32 ind = (u32) index;
>  	struct tmem_oid oid = *(struct tmem_oid *)&key;
> -	unsigned long pfn = page_to_pfn(page);
>  
>  	if (pool < 0)
>  		return;
>  	if (ind != index)
>  		return;
>  	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,
> @@ -287,7 +282,6 @@ static int tmem_frontswap_store(unsigned type, pgoff_t offset,
>  {
>  	u64 ind64 = (u64)offset;
>  	u32 ind = (u32)offset;
> -	unsigned long pfn = page_to_pfn(page);
>  	int pool = tmem_frontswap_poolid;
>  	int ret;
>  
> @@ -296,7 +290,7 @@ static int tmem_frontswap_store(unsigned type, pgoff_t offset,
>  	if (ind64 != ind)
>  		return -1;
>  	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 */
>  	if (ret == 1)
>  		return 0;
> @@ -313,7 +307,6 @@ static int tmem_frontswap_load(unsigned type, pgoff_t offset,
>  {
>  	u64 ind64 = (u64)offset;
>  	u32 ind = (u32)offset;
> -	unsigned long pfn = page_to_pfn(page);
>  	int pool = tmem_frontswap_poolid;
>  	int ret;
>  
> @@ -321,7 +314,7 @@ static int tmem_frontswap_load(unsigned type, pgoff_t offset,
>  		return -1;
>  	if (ind64 != ind)
>  		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 */
>  	if (ret == 1)
>  		return 0;
> -- 
> 2.1.4
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web