lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20201117201547.GA156448@carbon.DHCP.thefacebook.com>
Date:   Tue, 17 Nov 2020 12:15:47 -0800
From:   Roman Gushchin <guro@...com>
To:     Shakeel Butt <shakeelb@...gle.com>
CC:     Johannes Weiner <hannes@...xchg.org>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Linux MM <linux-mm@...ck.org>,
        Michal Hocko <mhocko@...nel.org>,
        Christoph Lameter <cl@...ux.com>,
        LKML <linux-kernel@...r.kernel.org>,
        Kernel Team <kernel-team@...com>
Subject: Re: [PATCH 2/2] mm: memcg/slab: pre-allocate obj_cgroups for slab
 caches with SLAB_ACCOUNT

On Tue, Nov 17, 2020 at 09:42:53AM -0800, Shakeel Butt wrote:
> On Thu, Nov 12, 2020 at 4:19 PM Roman Gushchin <guro@...com> wrote:
> >
> [snip]
> >
> > From 8b28d91475d54c552e503e66f169e1e00475c856 Mon Sep 17 00:00:00 2001
> > From: Roman Gushchin <guro@...com>
> > Date: Wed, 16 Sep 2020 15:43:48 -0700
> > Subject: [PATCH v2 2/2] mm: memcg/slab: pre-allocate obj_cgroups for slab
> >  caches with SLAB_ACCOUNT
> >
> > In general it's unknown in advance if a slab page will contain
> > accounted objects or not. In order to avoid memory waste, an
> > obj_cgroup vector is allocated dynamically when a need to account
> > of a new object arises. Such approach is memory efficient, but
> > requires an expensive cmpxchg() to set up the memcg/objcgs pointer,
> > because an allocation can race with a different allocation on another
> > cpu.
> >
> > But in some common cases it's known for sure that a slab page will
> > contain accounted objects: if the page belongs to a slab cache with a
> > SLAB_ACCOUNT flag set. It includes such popular objects like
> > vm_area_struct, anon_vma, task_struct, etc.
> >
> > In such cases we can pre-allocate the objcgs vector and simple assign
> > it to the page without any atomic operations, because at this early
> > stage the page is not visible to anyone else.
> >
> > v2: inline set_page_objcgs() and add some comments, by Johannes
> >
> > Signed-off-by: Roman Gushchin <guro@...com>
> [snip]
> >
> >  static __always_inline void account_slab_page(struct page *page, int order,
> > -                                             struct kmem_cache *s)
> > +                                             struct kmem_cache *s,
> > +                                             gfp_t gfp)
> >  {
> > +       if (memcg_kmem_enabled() && (s->flags & SLAB_ACCOUNT))
> > +               memcg_alloc_page_obj_cgroups(page, s, gfp, true);
> > +
> 
> I was wondering why not add (gfp & __GFP_ACCOUNT) check as well but it
> seems like for that some additional plumbing is required.

Yes, it's doable, but requires passing another argument through the whole stack.

> 
> Anyways:
> 
> Reviewed-by: Shakeel Butt <shakeelb@...gle.com>

Thank you!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ