lkml.org 
[lkml]   [2015]   [Sep]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 0/2] Fix memcg/memory.high in case kmem accounting is enabled
On Mon, Aug 31, 2015 at 03:22:22PM -0500, Christoph Lameter wrote:
> On Mon, 31 Aug 2015, Vladimir Davydov wrote:
>
> > I totally agree that we should strive to make a kmem user feel roughly
> > the same in memcg as if it were running on a host with equal amount of
> > RAM. There are two ways to achieve that:
> >
> > 1. Make the API functions, i.e. kmalloc and friends, behave inside
> > memcg roughly the same way as they do in the root cgroup.
> > 2. Make the internal memcg functions, i.e. try_charge and friends,
> > behave roughly the same way as alloc_pages.
> >
> > I find way 1 more flexible, because we don't have to blindly follow
> > heuristics used on global memory reclaim and therefore have more
> > opportunities to achieve the same goal.
>
> The heuristics need to integrate well if its in a cgroup or not. In
> general make use of cgroups as transparent as possible to the rest of the
> code.

Half of kmem accounting implementation resides in SLAB/SLUB. We can't
just make use of cgroups there transparent. For the rest of the code
using kmalloc, cgroups are transparent.

Indeed, we can make memcg_charge_slab behave exactly like alloc_pages,
we can even put it to alloc_pages (where it used to be), but why if the
only user of memcg_charge_slab is SLAB/SLUB core?

I think we'd have more space to manoeuvre if we just taught SLAB/SLUB to
use memcg_charge_slab wisely (as it used to until recently), because
memcg charge/reclaim is quite different from global alloc/reclaim:

- it isn't aware of NUMA nodes, so trying to charge w/o __GFP_WAIT
while inspecting nodes, like in case of SLAB, is meaningless

- it isn't aware of high order page allocations, so trying to charge
w/o __GFP_WAIT while trying optimistically to get a high order page,
like in case of SLUB, is meaningless too

- it can always let a high prio allocation go unaccounted, so IMO there
is no point in introducing emergency reserves (__GFP_MEMALLOC
handling)

- it can always charge a GFP_NOWAIT allocation even if it exceeds the
limit, issuing direct reclaim when a GFP_KERNEL allocation comes or
from a task work, because there is no risk of depleting memory
reserves; so it isn't obvious to me whether we really need an aync
thread handling memcg reclaim like kswapd

Thanks,
Vladimir


\
 
 \ /
  Last update: 2015-09-01 11:41    [W:0.055 / U:0.580 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site