Re: [PATCH 2/5] mm: remove unlikly NULL from kfree

Pekka Enberg
2009-03-25T07:34:42Z

On Wed, Mar 25, 2009 at 7:19 AM, Steven Rostedt <rostedt@goodmis.org> wrote:
> From: Steven Rostedt <rostedt@goodmis.org>
>
> Impact: clean up
>
> A NULL pointer to kfree is no longer unlikely, as seen by the
> annotated branch profiler:
>
>  correct incorrect  %        Function                  File              Line
>  ------- ---------  -        --------                  ----              ----
>  728571  1315540  64 kfree                          slab.c               3719
>
> This makes sense, since we now encourage developers to just call kfree
> without checking for NULL.

But those are _error handling paths_ (at least supposed to be). I
wonder which call-sites are responsible for this. Can frtrace help us
here?

> ---
>  mm/slab.c |    2 +-
>  mm/slob.c |    2 +-
>  mm/slub.c |    2 +-
>  3 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/mm/slab.c b/mm/slab.c
> index 4d00855..0386c33 100644
> --- a/mm/slab.c
> +++ b/mm/slab.c
> @@ -3716,7 +3716,7 @@ void kfree(const void *objp)
>        struct kmem_cache *c;
>        unsigned long flags;
>
> -       if (unlikely(ZERO_OR_NULL_PTR(objp)))
> +       if (ZERO_OR_NULL_PTR(objp))
>                return;
>        local_irq_save(flags);
>        kfree_debugcheck(objp);
> diff --git a/mm/slob.c b/mm/slob.c
> index 52bc8a2..e077174 100644
> --- a/mm/slob.c
> +++ b/mm/slob.c
> @@ -491,7 +491,7 @@ void kfree(const void *block)
>  {
>        struct slob_page *sp;
>
> -       if (unlikely(ZERO_OR_NULL_PTR(block)))
> +       if (ZERO_OR_NULL_PTR(block))
>                return;
>
>        sp = (struct slob_page *)virt_to_page(block);
> diff --git a/mm/slub.c b/mm/slub.c
> index 0280eee..65dc436 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -2743,7 +2743,7 @@ void kfree(const void *x)
>        struct page *page;
>        void *object = (void *)x;
>
> -       if (unlikely(ZERO_OR_NULL_PTR(x)))
> +       if (ZERO_OR_NULL_PTR(x))
>                return;
>
>        page = virt_to_head_page(x);
> --
> 1.6.2
>
> --
> --
> 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/
>