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] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 24 Sep 2020 13:29:11 -0700
From:   Roman Gushchin <guro@...com>
To:     Johannes Weiner <hannes@...xchg.org>
CC:     Andrew Morton <akpm@...ux-foundation.org>,
        Shakeel Butt <shakeelb@...gle.com>,
        Michal Hocko <mhocko@...nel.org>,
        <linux-kernel@...r.kernel.org>, <linux-mm@...ck.org>,
        <kernel-team@...com>
Subject: Re: [PATCH v1 2/4] mm: memcontrol/slab: use helpers to access slab
 page's memcg_data

On Thu, Sep 24, 2020 at 03:53:56PM -0400, Johannes Weiner wrote:
> On Tue, Sep 22, 2020 at 01:36:58PM -0700, Roman Gushchin wrote:
> > To gather all direct accesses to struct page's memcg_data field
> > in one place, let's introduce 4 new helper functions to use in
> > the slab accounting code:
> >   struct obj_cgroup **page_obj_cgroups(struct page *page);
> >   struct obj_cgroup **page_obj_cgroups_check(struct page *page);
> >   bool set_page_obj_cgroups(struct page *page, struct obj_cgroup **objcgs);
> >   void clear_page_obj_cgroups(struct page *page);
> > 
> > They are similar to the corresponding API for generic pages, except
> > that the setter can return false, indicating that the value has been
> > already set from a different thread.
> > 
> > Signed-off-by: Roman Gushchin <guro@...com>
> > Reviewed-by: Shakeel Butt <shakeelb@...gle.com>
> > ---
> >  include/linux/memcontrol.h | 80 ++++++++++++++++++++++++++++++++++++++
> >  mm/memcontrol.c            |  4 +-
> >  mm/slab.h                  | 27 ++-----------
> >  3 files changed, 85 insertions(+), 26 deletions(-)
> > 
> > diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
> > index 3313e7c21534..ab3ea3e90583 100644
> > --- a/include/linux/memcontrol.h
> > +++ b/include/linux/memcontrol.h
> > @@ -409,6 +409,86 @@ static inline void clear_page_mem_cgroup(struct page *page)
> >  	page->memcg_data = 0;
> >  }
> >  
> > +#ifdef CONFIG_MEMCG_KMEM
> > +/*
> > + * page_obj_cgroups - get the object cgroups vector associated with a page
> > + * @page: a pointer to the page struct
> > + *
> > + * Returns a pointer to the object cgroups vector associated with the page,
> > + * or NULL. This function assumes that the page is known to have an
> > + * associated object cgroups vector. It's not safe to call this function
> > + * against pages, which might have an associated memory cgroup: e.g.
> > + * kernel stack pages.
> > + */
> > +static inline struct obj_cgroup **page_obj_cgroups(struct page *page)
> > +{
> > +	return (struct obj_cgroup **)(page->memcg_data & ~0x1UL);
> 
> page_mem_cgroup() has a VM_BUG_ON() if the page is in fact a slab
> type. Should this also check that if memcg_data is set, it MUST have
> the lower bit set?

Absolutely, patch 3 does this after the formalization of the bit as a flag.

> 
> In line with page_memcg(), I think page_objcgs() would be nicer.

Ok to me.

Thanks!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ