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

[Xen-devel] [PATCH v2 02/11] tmem: cleanup: drop typedef pfp_t



Using 'struct page_info' directly instead of 'pfp_t' to make code more
straightforward and readable.

Signed-off-by: Bob Liu <bob.liu@xxxxxxxxxx>
---
 xen/common/tmem.c          |   14 +++++++-------
 xen/common/tmem_xen.c      |   22 +++++++++++-----------
 xen/include/xen/tmem_xen.h |   17 ++++++++---------
 3 files changed, 26 insertions(+), 27 deletions(-)

diff --git a/xen/common/tmem.c b/xen/common/tmem.c
index 215722b..4a278f2 100644
--- a/xen/common/tmem.c
+++ b/xen/common/tmem.c
@@ -232,7 +232,7 @@ struct tmem_page_descriptor {
     bool_t eviction_attempted;  /* CHANGE TO lifetimes? (settable) */
     struct list_head pcd_siblings;
     union {
-        pfp_t *pfp;  /* page frame pointer */
+        struct page_info *pfp;  /* page frame pointer */
         char *cdata; /* compressed data */
         struct tmem_page_content_descriptor *pcd; /* page dedup */
     };
@@ -248,7 +248,7 @@ typedef struct tmem_page_descriptor pgp_t;
 
 struct tmem_page_content_descriptor {
     union {
-        pfp_t *pfp;  /* page frame pointer */
+        struct page_info *pfp;  /* page frame pointer */
         char *cdata; /* if compression_enabled */
         char *tze; /* if !compression_enabled, trailing zeroes eliminated */
     };
@@ -341,9 +341,9 @@ static NOINLINE void tmem_free(void *p, size_t size, pool_t 
*pool)
         tmh_free_subpage_thispool(pool,p,size);
 }
 
-static NOINLINE pfp_t *tmem_page_alloc(pool_t *pool)
+static NOINLINE struct page_info *tmem_page_alloc(pool_t *pool)
 {
-    pfp_t *pfp = NULL;
+    struct page_info *pfp = NULL;
 
     if ( pool != NULL && is_persistent(pool) )
         pfp = tmh_alloc_page_thispool(pool);
@@ -356,7 +356,7 @@ static NOINLINE pfp_t *tmem_page_alloc(pool_t *pool)
     return pfp;
 }
 
-static NOINLINE void tmem_page_free(pool_t *pool, pfp_t *pfp)
+static NOINLINE void tmem_page_free(pool_t *pool, struct page_info *pfp)
 {
     ASSERT(pfp);
     if ( pool == NULL || !is_persistent(pool) )
@@ -397,7 +397,7 @@ static NOINLINE int pcd_copy_to_client(tmem_cli_mfn_t cmfn, 
pgp_t *pgp)
 static NOINLINE void pcd_disassociate(pgp_t *pgp, pool_t *pool, bool_t 
have_pcd_rwlock)
 {
     pcd_t *pcd = pgp->pcd;
-    pfp_t *pfp = pgp->pcd->pfp;
+    struct page_info *pfp = pgp->pcd->pfp;
     uint16_t firstbyte = pgp->firstbyte;
     char *pcd_tze = pgp->pcd->tze;
     pagesize_t pcd_size = pcd->size;
@@ -2873,7 +2873,7 @@ EXPORT void tmem_freeze_all(unsigned char key)
 
 EXPORT void *tmem_relinquish_pages(unsigned int order, unsigned int memflags)
 {
-    pfp_t *pfp;
+    struct page_info *pfp;
     unsigned long evicts_per_relinq = 0;
     int max_evictions = 10;
 
diff --git a/xen/common/tmem_xen.c b/xen/common/tmem_xen.c
index 4725558..cbcdb1a 100644
--- a/xen/common/tmem_xen.c
+++ b/xen/common/tmem_xen.c
@@ -56,13 +56,13 @@ void tmh_copy_page(char *to, char*from)
 
 #if defined(CONFIG_ARM)
 static inline void *cli_get_page(tmem_cli_mfn_t cmfn, unsigned long *pcli_mfn,
-                                 pfp_t **pcli_pfp, bool_t cli_write)
+                                 struct page_info **pcli_pfp, bool_t cli_write)
 {
     ASSERT(0);
     return NULL;
 }
 
-static inline void cli_put_page(void *cli_va, pfp_t *cli_pfp,
+static inline void cli_put_page(void *cli_va, struct page_info *cli_pfp,
                                 unsigned long cli_mfn, bool_t mark_dirty)
 {
     ASSERT(0);
@@ -71,7 +71,7 @@ static inline void cli_put_page(void *cli_va, pfp_t *cli_pfp,
 #include <asm/p2m.h>
 
 static inline void *cli_get_page(tmem_cli_mfn_t cmfn, unsigned long *pcli_mfn,
-                                 pfp_t **pcli_pfp, bool_t cli_write)
+                                 struct page_info **pcli_pfp, bool_t cli_write)
 {
     p2m_type_t t;
     struct page_info *page;
@@ -95,7 +95,7 @@ static inline void *cli_get_page(tmem_cli_mfn_t cmfn, 
unsigned long *pcli_mfn,
     return map_domain_page(*pcli_mfn);
 }
 
-static inline void cli_put_page(void *cli_va, pfp_t *cli_pfp,
+static inline void cli_put_page(void *cli_va, struct page_info *cli_pfp,
                                 unsigned long cli_mfn, bool_t mark_dirty)
 {
     if ( mark_dirty )
@@ -109,13 +109,13 @@ static inline void cli_put_page(void *cli_va, pfp_t 
*cli_pfp,
 }
 #endif
 
-EXPORT int tmh_copy_from_client(pfp_t *pfp,
+EXPORT int tmh_copy_from_client(struct page_info *pfp,
     tmem_cli_mfn_t cmfn, pagesize_t tmem_offset,
     pagesize_t pfn_offset, pagesize_t len, tmem_cli_va_param_t clibuf)
 {
     unsigned long tmem_mfn, cli_mfn = 0;
     char *tmem_va, *cli_va = NULL;
-    pfp_t *cli_pfp = NULL;
+    struct page_info *cli_pfp = NULL;
     int rc = 1;
 
     if ( tmem_offset > PAGE_SIZE || pfn_offset > PAGE_SIZE || len > PAGE_SIZE )
@@ -165,7 +165,7 @@ EXPORT int tmh_compress_from_client(tmem_cli_mfn_t cmfn,
     unsigned char *dmem = this_cpu(dstmem);
     unsigned char *wmem = this_cpu(workmem);
     char *scratch = this_cpu(scratch_page);
-    pfp_t *cli_pfp = NULL;
+    struct page_info *cli_pfp = NULL;
     unsigned long cli_mfn = 0;
     void *cli_va = NULL;
 
@@ -190,13 +190,13 @@ EXPORT int tmh_compress_from_client(tmem_cli_mfn_t cmfn,
     return 1;
 }
 
-EXPORT int tmh_copy_to_client(tmem_cli_mfn_t cmfn, pfp_t *pfp,
+EXPORT int tmh_copy_to_client(tmem_cli_mfn_t cmfn, struct page_info *pfp,
     pagesize_t tmem_offset, pagesize_t pfn_offset, pagesize_t len,
     tmem_cli_va_param_t clibuf)
 {
     unsigned long tmem_mfn, cli_mfn = 0;
     char *tmem_va, *cli_va = NULL;
-    pfp_t *cli_pfp = NULL;
+    struct page_info *cli_pfp = NULL;
     int rc = 1;
 
     if ( tmem_offset > PAGE_SIZE || pfn_offset > PAGE_SIZE || len > PAGE_SIZE )
@@ -233,7 +233,7 @@ EXPORT int tmh_decompress_to_client(tmem_cli_mfn_t cmfn, 
void *tmem_va,
                                     size_t size, tmem_cli_va_param_t clibuf)
 {
     unsigned long cli_mfn = 0;
-    pfp_t *cli_pfp = NULL;
+    struct page_info *cli_pfp = NULL;
     void *cli_va = NULL;
     char *scratch = this_cpu(scratch_page);
     size_t out_len = PAGE_SIZE;
@@ -263,7 +263,7 @@ EXPORT int tmh_copy_tze_to_client(tmem_cli_mfn_t cmfn, void 
*tmem_va,
 {
     void *cli_va;
     unsigned long cli_mfn;
-    pfp_t *cli_pfp = NULL;
+    struct page_info *cli_pfp = NULL;
 
     ASSERT(!(len & (sizeof(uint64_t)-1)));
     ASSERT(len <= PAGE_SIZE);
diff --git a/xen/include/xen/tmem_xen.h b/xen/include/xen/tmem_xen.h
index ad1ddd5..f05d0f5 100644
--- a/xen/include/xen/tmem_xen.h
+++ b/xen/include/xen/tmem_xen.h
@@ -277,7 +277,6 @@ static inline void tmh_free_infra(void *p)
 struct client;
 typedef domid_t cli_id_t;
 typedef struct domain tmh_cli_ptr_t;
-typedef struct page_info pfp_t;
 
 extern tmh_client_t *tmh_client_init(cli_id_t);
 extern void tmh_client_destroy(tmh_client_t *);
@@ -337,14 +336,14 @@ static inline bool_t tmh_current_is_privileged(void)
     return !xsm_tmem_control(XSM_PRIV);
 }
 
-static inline uint8_t tmh_get_first_byte(pfp_t *pfp)
+static inline uint8_t tmh_get_first_byte(struct page_info *pfp)
 {
     void *p = __map_domain_page(pfp);
 
     return (uint8_t)(*(char *)p);
 }
 
-static inline int tmh_page_cmp(pfp_t *pfp1, pfp_t *pfp2)
+static inline int tmh_page_cmp(struct page_info *pfp1, struct page_info *pfp2)
 {
     const uint64_t *p1 = (uint64_t *)__map_domain_page(pfp1);
     const uint64_t *p2 = (uint64_t *)__map_domain_page(pfp2);
@@ -382,14 +381,14 @@ static inline int tmh_pcd_cmp(void *va1, pagesize_t len1, 
void *va2, pagesize_t
     return 1;
 }
 
-static inline int tmh_tze_pfp_cmp(pfp_t *pfp1, pagesize_t pfp_len, void *tva, 
pagesize_t tze_len)
+static inline int tmh_tze_pfp_cmp(struct page_info *pfp1, pagesize_t pfp_len, 
void *tva, pagesize_t tze_len)
 {
     const uint64_t *p1 = (uint64_t *)__map_domain_page(pfp1);
     const uint64_t *p2;
     pagesize_t i;
 
     if ( tze_len == PAGE_SIZE )
-       p2 = (uint64_t *)__map_domain_page((pfp_t *)tva);
+       p2 = (uint64_t *)__map_domain_page((struct page_info *)tva);
     else
        p2 = (uint64_t *)tva;
     ASSERT(pfp_len <= PAGE_SIZE);
@@ -411,7 +410,7 @@ static inline int tmh_tze_pfp_cmp(pfp_t *pfp1, pagesize_t 
pfp_len, void *tva, pa
 
 /* return the size of the data in the pfp, ignoring trailing zeroes and
  * rounded up to the nearest multiple of 8 */
-static inline pagesize_t tmh_tze_pfp_scan(pfp_t *pfp)
+static inline pagesize_t tmh_tze_pfp_scan(struct page_info *pfp)
 {
     const uint64_t *p = (uint64_t *)__map_domain_page(pfp);
     pagesize_t bytecount = PAGE_SIZE;
@@ -422,7 +421,7 @@ static inline pagesize_t tmh_tze_pfp_scan(pfp_t *pfp)
     return bytecount;
 }
 
-static inline void tmh_tze_copy_from_pfp(void *tva, pfp_t *pfp, pagesize_t len)
+static inline void tmh_tze_copy_from_pfp(void *tva, struct page_info *pfp, 
pagesize_t len)
 {
     uint64_t *p1 = (uint64_t *)tva;
     const uint64_t *p2 = (uint64_t *)__map_domain_page(pfp);
@@ -496,10 +495,10 @@ int tmh_decompress_to_client(tmem_cli_mfn_t, void *, 
size_t,
 int tmh_compress_from_client(tmem_cli_mfn_t, void **, size_t *,
                             tmem_cli_va_param_t);
 
-int tmh_copy_from_client(pfp_t *, tmem_cli_mfn_t, pagesize_t tmem_offset,
+int tmh_copy_from_client(struct page_info *, tmem_cli_mfn_t, pagesize_t 
tmem_offset,
     pagesize_t pfn_offset, pagesize_t len, tmem_cli_va_param_t);
 
-int tmh_copy_to_client(tmem_cli_mfn_t, pfp_t *, pagesize_t tmem_offset,
+int tmh_copy_to_client(tmem_cli_mfn_t, struct page_info *, pagesize_t 
tmem_offset,
     pagesize_t pfn_offset, pagesize_t len, tmem_cli_va_param_t);
 
 extern int tmh_copy_tze_to_client(tmem_cli_mfn_t cmfn, void *tmem_va, 
pagesize_t len);
-- 
1.7.10.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

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