Skip to contentSkip to conversation

mm: remove __krealloc

PATCH Applied Florian Westphal 3 participants 5 messages Dec 12, 2019 – Dec 13, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm: remove __krealloc

Since 5.5-rc1 the last user of this function is gone, so remove the functionality.

See commit
2ad9d7747c10 ("netfilter: conntrack: free extension area immediately") for details.

---
 include/linux/slab.h                    |  1 -
 mm/slab_common.c                        | 22 ----------------------
 scripts/coccinelle/free/devm_free.cocci |  4 ----
 3 files changed, 27 deletions(-)
include/linux/slab.h +0 -1
index 877a95c6a2d2..03a389358562 100644
@@ -184,7 +184,6 @@ void memcg_deactivate_kmem_caches(struct mem_cgroup *, struct mem_cgroup *);
 /*
  * Common kmalloc functions provided by all allocators
  */
-void * __must_check __krealloc(const void *, size_t, gfp_t);
 void * __must_check krealloc(const void *, size_t, gfp_t);
 void kfree(const void *);
 void kzfree(const void *);
mm/slab_common.c +0 -22
index f0ab6d4ceb4c..87e8923cf0b6 100644
@@ -1675,28 +1675,6 @@ static __always_inline void *__do_krealloc(const void *p, size_t new_size,
 	return ret;
 }
 
-/**
- * __krealloc - like krealloc() but don't free @p.
- * @p: object to reallocate memory for.
- * @new_size: how many bytes of memory are required.
- * @flags: the type of memory to allocate.
- *
- * This function is like krealloc() except it never frees the originally
- * allocated buffer. Use this if you don't want to free the buffer immediately
- * like, for example, with RCU.
- *
- * Return: pointer to the allocated memory or %NULL in case of error
- */
-void *__krealloc(const void *p, size_t new_size, gfp_t flags)
-{
-	if (unlikely(!new_size))
-		return ZERO_SIZE_PTR;
-
-	return __do_krealloc(p, new_size, flags);
-
-}
-EXPORT_SYMBOL(__krealloc);
-
 /**
  * krealloc - reallocate memory. The contents will remain unchanged.
  * @p: object to reallocate memory for.
scripts/coccinelle/free/devm_free.cocci +0 -4
index 441799b5359b..66aaf68889a5 100644
@@ -94,8 +94,6 @@ position p;
  kfree@p(x)
 |
  kzfree@p(x)
-|
- __krealloc@p(x, ...)
 |
  krealloc@p(x, ...)
 |
@@ -120,8 +118,6 @@ position p != safe.p;
 |
 * kzfree@p(x)
 |
-* __krealloc@p(x, ...)
-|
 * krealloc@p(x, ...)
 |
 * free_pages@p(x, ...)
Signature · 1 line
2.23.0
#1 lore raw
Quoted 8 lines · Florian Westphal

Since 5.5-rc1 the last user of this function is gone, so remove the functionality.

See commit
2ad9d7747c10 ("netfilter: conntrack: free extension area immediately") for details.

So this also means that we can fold __do_krealloc() into krealloc()?

#2 lore raw
Quoted 5 lines · David Rientjes
Quoted 3 lines · Florian Westphal

Since 5.5-rc1 the last user of this function is gone, so remove the functionality.

Quoted 7 lines
Quoted 5 lines

See commit
2ad9d7747c10 ("netfilter: conntrack: free extension area immediately") for details.

So this also means that we can fold __do_krealloc() into krealloc()?

I would leave that to compiler but if you prefer this I can respin.

reviewer Acked-by
#3 lore raw
Quoted 7 lines · Florian Westphal
Quoted 7 lines
Quoted 7 lines

Since 5.5-rc1 the last user of this function is gone, so remove the functionality.

See commit
2ad9d7747c10 ("netfilter: conntrack: free extension area immediately") for details.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

So this also means that we can fold __do_krealloc() into krealloc()?

I would leave that to compiler but if you prefer this I can respin.

Sure, no problem.

Reviewed-by on v1 1/1
#4 lore raw
In reply to Florian Westphal
Quoted 74 lines · Florian Westphal

Since 5.5-rc1 the last user of this function is gone, so remove the functionality.

See commit
2ad9d7747c10 ("netfilter: conntrack: free extension area immediately") for details.

---
 include/linux/slab.h                    |  1 -
 mm/slab_common.c                        | 22 ----------------------
 scripts/coccinelle/free/devm_free.cocci |  4 ----
 3 files changed, 27 deletions(-)
include/linux/slab.h +0 -1
index 877a95c6a2d2..03a389358562 100644
@@ -184,7 +184,6 @@ void memcg_deactivate_kmem_caches(struct mem_cgroup *, struct mem_cgroup *);
 /*
  * Common kmalloc functions provided by all allocators
  */
-void * __must_check __krealloc(const void *, size_t, gfp_t);
 void * __must_check krealloc(const void *, size_t, gfp_t);
 void kfree(const void *);
 void kzfree(const void *);
mm/slab_common.c +0 -22
index f0ab6d4ceb4c..87e8923cf0b6 100644
@@ -1675,28 +1675,6 @@ static __always_inline void *__do_krealloc(const void *p, size_t new_size,
 	return ret;
 }
 
-/**
- * __krealloc - like krealloc() but don't free @p.
- * @p: object to reallocate memory for.
- * @new_size: how many bytes of memory are required.
- * @flags: the type of memory to allocate.
- *
- * This function is like krealloc() except it never frees the originally
- * allocated buffer. Use this if you don't want to free the buffer immediately
- * like, for example, with RCU.
- *
- * Return: pointer to the allocated memory or %NULL in case of error
- */
-void *__krealloc(const void *p, size_t new_size, gfp_t flags)
-{
-	if (unlikely(!new_size))
-		return ZERO_SIZE_PTR;
-
-	return __do_krealloc(p, new_size, flags);
-
-}
-EXPORT_SYMBOL(__krealloc);
-
 /**
  * krealloc - reallocate memory. The contents will remain unchanged.
  * @p: object to reallocate memory for.
scripts/coccinelle/free/devm_free.cocci +0 -2
index 441799b5359b..66aaf68889a5 100644
@@ -94,8 +94,6 @@ position p;
  kfree@p(x)
 |
  kzfree@p(x)
-|
- __krealloc@p(x, ...)
 |
  krealloc@p(x, ...)
 |

scripts/coccinelle/free/devm_free.cocci position p != safe.p; · line 123

Quoted 8 lines
scripts/coccinelle/free/devm_free.cocci +0 -2
@@ -120,8 +118,6 @@ position p != safe.p;
 |
 * kzfree@p(x)
 |
-* __krealloc@p(x, ...)
-|
 * krealloc@p(x, ...)
 |
 * free_pages@p(x, ...)

IMHO, __do_krealloc() changes can go into a separate patch.

Signature · 3 lines
Thanks,

David / dhildenb