Re: [PATCH 1/2] mm, slob: Prevent false positive trace upon allocation failure

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

 



Pekka,

I'd like to bring your attention to this patch, and make a little question.


On Tue, Aug 14, 2012 at 11:38 AM, Ezequiel Garcia <elezegarcia@xxxxxxxxx> wrote:
> This patch changes the __kmalloc_node() logic to return NULL
> if alloc_pages() fails to return valid pages.
> This is done to avoid to trace a false positive kmalloc event.
>
> Cc: Pekka Enberg <penberg@xxxxxxxxxx>
> Cc: Christoph Lameter <cl@xxxxxxxxx>
> Cc: Glauber Costa <glommer@xxxxxxxxxxxxx>
> Signed-off-by: Ezequiel Garcia <elezegarcia@xxxxxxxxx>
> ---
>  mm/slob.c |   11 ++++++-----
>  1 files changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/mm/slob.c b/mm/slob.c
> index 45d4ca7..686e98b 100644
> --- a/mm/slob.c
> +++ b/mm/slob.c
> @@ -450,15 +450,16 @@ void *__kmalloc_node(size_t size, gfp_t gfp, int node)
>                                    size, size + align, gfp, node);
>         } else {
>                 unsigned int order = get_order(size);
> +               struct page *page;
>
>                 if (likely(order))
>                         gfp |= __GFP_COMP;
>                 ret = slob_new_pages(gfp, order, node);
> -               if (ret) {
> -                       struct page *page;
> -                       page = virt_to_page(ret);
> -                       page->private = size;
> -               }
> +               if (!ret)
> +                       return NULL;
> +
> +               page = virt_to_page(ret);
> +               page->private = size;
>
>                 trace_kmalloc_node(_RET_IP_, ret,
>                                    size, PAGE_SIZE << order, gfp, node);


As you can see this patch prevents to trace a kmem event if the allocation
fails.

I'm still unsure about tracing or not this ones, and I'm considering tracing
failures, perhaps with return=0 and allocated size=0.

In this case, it would be nice to have SLxB all do the same.
Right now, this is not the case.

You can see how slob::kmem_cache_alloc_node traces independently
of the allocation succeeding.
I have no problem trying a fix for this, but I don't now how to trace
this cases.

Although it is a corner case, I think it's important to define a clear
and consistent
behaviour to make tracing reliable.

Thanks,
Ezequiel.

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


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]