linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] slab: drop unneeded NULL-pointer check in kfree auto cleanup
@ 2023-09-12  8:26 Bartosz Golaszewski
  2023-09-12 10:42 ` Peter Zijlstra
  0 siblings, 1 reply; 3+ messages in thread
From: Bartosz Golaszewski @ 2023-09-12  8:26 UTC (permalink / raw)
  To: Christoph Lameter, Pekka Enberg, David Rientjes, Joonsoo Kim,
	Andrew Morton, Vlastimil Babka, Roman Gushchin, Hyeonggon Yoo,
	Peter Zijlstra
  Cc: linux-mm, linux-kernel, Bartosz Golaszewski

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

kfree() already accepts and silently ignores NULL-pointers, there's no
need to check it when running the auto cleanup routine.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 include/linux/slab.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/slab.h b/include/linux/slab.h
index 8228d1276a2f..fb709ed506ba 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -228,7 +228,7 @@ void kfree(const void *objp);
 void kfree_sensitive(const void *objp);
 size_t __ksize(const void *objp);
 
-DEFINE_FREE(kfree, void *, if (_T) kfree(_T))
+DEFINE_FREE(kfree, void *, kfree(_T))
 
 /**
  * ksize - Report actual allocation size of associated object
-- 
2.39.2



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] slab: drop unneeded NULL-pointer check in kfree auto cleanup
  2023-09-12  8:26 [PATCH] slab: drop unneeded NULL-pointer check in kfree auto cleanup Bartosz Golaszewski
@ 2023-09-12 10:42 ` Peter Zijlstra
  2023-09-12 11:26   ` Bartosz Golaszewski
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Zijlstra @ 2023-09-12 10:42 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Christoph Lameter, Pekka Enberg, David Rientjes, Joonsoo Kim,
	Andrew Morton, Vlastimil Babka, Roman Gushchin, Hyeonggon Yoo,
	linux-mm, linux-kernel, Bartosz Golaszewski

On Tue, Sep 12, 2023 at 10:26:43AM +0200, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> 
> kfree() already accepts and silently ignores NULL-pointers, there's no
> need to check it when running the auto cleanup routine.

There is, because now the compiler can't help you anymore. Also see:

  https://lkml.kernel.org/r/169451499208.27769.5856056754166699857.tip-bot2@tip-bot2


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] slab: drop unneeded NULL-pointer check in kfree auto cleanup
  2023-09-12 10:42 ` Peter Zijlstra
@ 2023-09-12 11:26   ` Bartosz Golaszewski
  0 siblings, 0 replies; 3+ messages in thread
From: Bartosz Golaszewski @ 2023-09-12 11:26 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Christoph Lameter, Pekka Enberg, David Rientjes, Joonsoo Kim,
	Andrew Morton, Vlastimil Babka, Roman Gushchin, Hyeonggon Yoo,
	linux-mm, linux-kernel, Bartosz Golaszewski

On Tue, Sep 12, 2023 at 12:43 PM Peter Zijlstra <peterz@infradead.org> wrote:
>
> On Tue, Sep 12, 2023 at 10:26:43AM +0200, Bartosz Golaszewski wrote:
> > From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> >
> > kfree() already accepts and silently ignores NULL-pointers, there's no
> > need to check it when running the auto cleanup routine.
>
> There is, because now the compiler can't help you anymore. Also see:
>
>   https://lkml.kernel.org/r/169451499208.27769.5856056754166699857.tip-bot2@tip-bot2

Makes sense, thanks!

Bart


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-09-12 11:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-12  8:26 [PATCH] slab: drop unneeded NULL-pointer check in kfree auto cleanup Bartosz Golaszewski
2023-09-12 10:42 ` Peter Zijlstra
2023-09-12 11:26   ` Bartosz Golaszewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox