Skip to contentSkip to conversation

mm: zbud: Remove zbud_map() and zbud_unmap() function

PATCH In review Souptick Joarder 2 participants 3 messages Feb 17, 2018 – Feb 19, 2018 Memory management

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm: zbud: Remove zbud_map() and zbud_unmap() function

zbud_unmap() is empty function and not getting called from anywhere except from zbud_zpool_unmap(). Hence we can remove zbud_unmap().

Similarly, zbud_map() is only returning (void *)(handle) which can be done within zbud_zpool_map(). Hence we can remove zbud_map().

---
 include/linux/zbud.h |  2 --
 mm/zbud.c            | 30 ++----------------------------
 2 files changed, 2 insertions(+), 30 deletions(-)
include/linux/zbud.h +0 -2
index b1eaf6e..565b88c 100644
@@ -16,8 +16,6 @@ int zbud_alloc(struct zbud_pool *pool, size_t size, gfp_t gfp,
 	unsigned long *handle);
 void zbud_free(struct zbud_pool *pool, unsigned long handle);
 int zbud_reclaim_page(struct zbud_pool *pool, unsigned int retries);
-void *zbud_map(struct zbud_pool *pool, unsigned long handle);
-void zbud_unmap(struct zbud_pool *pool, unsigned long handle);
 u64 zbud_get_pool_size(struct zbud_pool *pool);
 
 #endif /* _ZBUD_H_ */
mm/zbud.c +2 -28
index 28458f7..c83c876 100644
@@ -188,11 +188,11 @@ static int zbud_zpool_shrink(void *pool, unsigned int pages,
 static void *zbud_zpool_map(void *pool, unsigned long handle,
 			enum zpool_mapmode mm)
 {
-	return zbud_map(pool, handle);
+	return (void *)(handle);
 }
 static void zbud_zpool_unmap(void *pool, unsigned long handle)
 {
-	zbud_unmap(pool, handle);
+
 }
 
 static u64 zbud_zpool_total_size(void *pool)
@@ -569,32 +569,6 @@ int zbud_reclaim_page(struct zbud_pool *pool, unsigned int retries)
 }
 
 /**
- * zbud_map() - maps the allocation associated with the given handle
- * @pool:	pool in which the allocation resides
- * @handle:	handle associated with the allocation to be mapped
- *
- * While trivial for zbud, the mapping functions for others allocators
- * implementing this allocation API could have more complex information encoded
- * in the handle and could create temporary mappings to make the data
- * accessible to the user.
- *
- * Returns: a pointer to the mapped allocation
- */
-void *zbud_map(struct zbud_pool *pool, unsigned long handle)
-{
-	return (void *)(handle);
-}
-
-/**
- * zbud_unmap() - maps the allocation associated with the given handle
- * @pool:	pool in which the allocation resides
- * @handle:	handle associated with the allocation to be unmapped
- */
-void zbud_unmap(struct zbud_pool *pool, unsigned long handle)
-{
-}
-
-/**
  * zbud_get_pool_size() - gets the zbud pool size in pages
  * @pool:	pool whose size is being queried
  *

--
1.9.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#1 lore raw
Quoted 7 lines · Souptick Joarder

zbud_unmap() is empty function and not getting called from anywhere except from zbud_zpool_unmap(). Hence we can remove zbud_unmap().

Similarly, zbud_map() is only returning (void *)(handle) which can be done within zbud_zpool_map(). Hence we can remove zbud_map().

The comments at the top of zbud.c talk about using zbud_map() and zbud_unmap(), so just removing the functions without changing the doc in the file is not right.

Additionally, the functions will get compiled out, so this change won't actually make any difference in the compiled kernel.

Finally, removing them from the header file makes the zbud API effectively unusable for any code except zpool, so it would be pointless to leave zbud.h in include/linux (which it doesn't necessarily need to be in anyway, but that's a different topic).

I'd prefer to just leave zbud_map/zbud_unmap in the API, so NAK from me.

Quoted 72 lines
---
 include/linux/zbud.h |  2 --
 mm/zbud.c            | 30 ++----------------------------
 2 files changed, 2 insertions(+), 30 deletions(-)
include/linux/zbud.h +0 -2
index b1eaf6e..565b88c 100644
@@ -16,8 +16,6 @@ int zbud_alloc(struct zbud_pool *pool, size_t size, gfp_t gfp,
        unsigned long *handle);
 void zbud_free(struct zbud_pool *pool, unsigned long handle);
 int zbud_reclaim_page(struct zbud_pool *pool, unsigned int retries);
-void *zbud_map(struct zbud_pool *pool, unsigned long handle);
-void zbud_unmap(struct zbud_pool *pool, unsigned long handle);
 u64 zbud_get_pool_size(struct zbud_pool *pool);
 
 #endif /* _ZBUD_H_ */
mm/zbud.c +2 -29
index 28458f7..c83c876 100644
@@ -188,11 +188,11 @@ static int zbud_zpool_shrink(void *pool, unsigned int pages,
 static void *zbud_zpool_map(void *pool, unsigned long handle,
                        enum zpool_mapmode mm)
 {
-       return zbud_map(pool, handle);
+       return (void *)(handle);
 }
 static void zbud_zpool_unmap(void *pool, unsigned long handle)
 {
-       zbud_unmap(pool, handle);
+
 }
 
 static u64 zbud_zpool_total_size(void *pool)
@@ -569,32 +569,6 @@ int zbud_reclaim_page(struct zbud_pool *pool, unsigned int retries)
 }
 
 /**
- * zbud_map() - maps the allocation associated with the given handle
- * @pool:      pool in which the allocation resides
- * @handle:    handle associated with the allocation to be mapped
- *
- * While trivial for zbud, the mapping functions for others allocators
- * implementing this allocation API could have more complex information encoded
- * in the handle and could create temporary mappings to make the data
- * accessible to the user.
- *
- * Returns: a pointer to the mapped allocation
- */
-void *zbud_map(struct zbud_pool *pool, unsigned long handle)
-{
-       return (void *)(handle);
-}
-
-/**
- * zbud_unmap() - maps the allocation associated with the given handle
- * @pool:      pool in which the allocation resides
- * @handle:    handle associated with the allocation to be unmapped
- */
-void zbud_unmap(struct zbud_pool *pool, unsigned long handle)
-{
-}
-
-/**
  * zbud_get_pool_size() - gets the zbud pool size in pages
  * @pool:      pool whose size is being queried
  *
--
Quoted 2 lines

1.9.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#2 lore raw
Quoted 16 lines · Dan Streetman
Quoted 7 lines · Souptick Joarder

zbud_unmap() is empty function and not getting called from anywhere except from zbud_zpool_unmap(). Hence we can remove zbud_unmap().

Similarly, zbud_map() is only returning (void *)(handle) which can be done within zbud_zpool_map(). Hence we can remove zbud_map().

The comments at the top of zbud.c talk about using zbud_map() and zbud_unmap(), so just removing the functions without changing the doc in the file is not right.

Additionally, the functions will get compiled out, so this change won't actually make any difference in the compiled kernel.

Quoted 6 lines

Finally, removing them from the header file makes the zbud API effectively unusable for any code except zpool, so it would be pointless to leave zbud.h in include/linux (which it doesn't necessarily need to be in anyway, but that's a different topic).

I'd prefer to just leave zbud_map/zbud_unmap in the API, so NAK from me.

Thanks for the feedback :)

Quoted 67 lines
Quoted 67 lines
---
 include/linux/zbud.h |  2 --
 mm/zbud.c            | 30 ++----------------------------
 2 files changed, 2 insertions(+), 30 deletions(-)
include/linux/zbud.h +0 -2
index b1eaf6e..565b88c 100644
@@ -16,8 +16,6 @@ int zbud_alloc(struct zbud_pool *pool, size_t size, gfp_t gfp,
        unsigned long *handle);
 void zbud_free(struct zbud_pool *pool, unsigned long handle);
 int zbud_reclaim_page(struct zbud_pool *pool, unsigned int retries);
-void *zbud_map(struct zbud_pool *pool, unsigned long handle);
-void zbud_unmap(struct zbud_pool *pool, unsigned long handle);
 u64 zbud_get_pool_size(struct zbud_pool *pool);
 
 #endif /* _ZBUD_H_ */
mm/zbud.c +2 -26
index 28458f7..c83c876 100644
@@ -188,11 +188,11 @@ static int zbud_zpool_shrink(void *pool, unsigned int pages,
 static void *zbud_zpool_map(void *pool, unsigned long handle,
                        enum zpool_mapmode mm)
 {
-       return zbud_map(pool, handle);
+       return (void *)(handle);
 }
 static void zbud_zpool_unmap(void *pool, unsigned long handle)
 {
-       zbud_unmap(pool, handle);
+
 }
 
 static u64 zbud_zpool_total_size(void *pool)
@@ -569,32 +569,6 @@ int zbud_reclaim_page(struct zbud_pool *pool, unsigned int retries)
 }
 
 /**
- * zbud_map() - maps the allocation associated with the given handle
- * @pool:      pool in which the allocation resides
- * @handle:    handle associated with the allocation to be mapped
- *
- * While trivial for zbud, the mapping functions for others allocators
- * implementing this allocation API could have more complex information encoded
- * in the handle and could create temporary mappings to make the data
- * accessible to the user.
- *
- * Returns: a pointer to the mapped allocation
- */
-void *zbud_map(struct zbud_pool *pool, unsigned long handle)
-{
-       return (void *)(handle);
-}
-
-/**
- * zbud_unmap() - maps the allocation associated with the given handle
- * @pool:      pool in which the allocation resides
- * @handle:    handle associated with the allocation to be unmapped
- */
-void zbud_unmap(struct zbud_pool *pool, unsigned long handle)
-{
-}
Quoted 8 lines
Quoted 8 lines
mm/zbud.c +0 -3
-
-/**
  * zbud_get_pool_size() - gets the zbud pool size in pages
  * @pool:      pool whose size is being queried
  *
--

1.9.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>