Re: question: why use vzalloc() and vzfree() in mem_cgroup_alloc()and mem_cgroup_free()

From: Chris Snook
Date: Wed Dec 14 2011 - 20:04:27 EST


On Dec 14, 12:12 pm, Laurent Chavey <chavey@xxxxxxxxxx> wrote:
> context:
>
> While testing patches from Glauber Costa, "adding support
> for tcp memory allocation in kmem cgroup", we hit a
> BUG_ON(in_interrupt()) in vfree(). The code path in question
> is taken because the izeof(struct mem_cgroup) is
>
> >= PAGE_SIZE in the call to mem_cgroup_free(),

Still, or again? A cursory search turns up this patch:

https://lkml.org/lkml/2010/9/27/147

but I don't have handy any further information about how it fared.

> Since socket may get free in an interrupt context,
> the combination of vzalloc(), vfree() should not be used
> when accounting for socket mem (unless the code is modified).

Agreed, but why does socket freeing cause struct mem_cgroup to be
freed? I think I'm missing something about the kmem cgroup
implementation.

> question:
>
> Is there reasons why vzalloc() is used in mem_cgroup_alloc() ?
>     . are we seeing mem fragmentations to level that fail
>       kzalloc() or kmalloc().
>     . do we have empirical data that shows the allocation failure
>       rate for kmalloc(), kzalloc() per alloc size (num pages)

Laziness? Last I checked, OpenAFS still called vmalloc() in the
pageout path, which is a no-no of similar magnitude, because handling
the failure properly is difficult to code and even more difficult to
test, and nobody is seeing machines deadlock often enough to justify
the development effort.

If we're having significant failures in allocating two consecutive
pages, we'll probably have other problems too, but there are
conditions where being able to vzalloc that could save you. I suspect
they're less common than conditions where vzalloc in interrupt context
would burn you, but I have no empirical data to support that.

-- Chris
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/