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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <YrAeU7yy6jhh+4zd@FVFYT0MHHV2J.usts.net>
Date:   Mon, 20 Jun 2022 15:14:27 +0800
From:   Muchun Song <songmuchun@...edance.com>
To:     Roman Gushchin <roman.gushchin@...ux.dev>
Cc:     hannes@...xchg.org, mhocko@...nel.org, shakeelb@...gle.com,
        akpm@...ux-foundation.org, cgroups@...r.kernel.org,
        linux-mm@...ck.org, linux-kernel@...r.kernel.org,
        duanxiongchun@...edance.com, longman@...hat.com
Subject: Re: [PATCH v5 08/11] mm: memcontrol: introduce memcg_reparent_ops

On Sun, Jun 19, 2022 at 12:47:39PM -0700, Roman Gushchin wrote:
> On Mon, May 30, 2022 at 03:49:16PM +0800, Muchun Song wrote:
> > In the previous patch, we know how to make the lruvec lock safe when LRU
> > pages are reparented. We should do something like following.
> > 
> >     memcg_reparent_objcgs(memcg)
> >         1) lock
> >         // lruvec belongs to memcg and lruvec_parent belongs to parent memcg.
> >         spin_lock(&lruvec->lru_lock);
> >         spin_lock(&lruvec_parent->lru_lock);
> > 
> >         2) relocate from current memcg to its parent
> >         // Move all the pages from the lruvec list to the parent lruvec list.
> > 
> >         3) unlock
> >         spin_unlock(&lruvec_parent->lru_lock);
> >         spin_unlock(&lruvec->lru_lock);
> > 
> > Apart from the page lruvec lock, the deferred split queue lock (THP only)
> > also needs to do something similar. So we extract the necessary three steps
> > in the memcg_reparent_objcgs().
> > 
> >     memcg_reparent_objcgs(memcg)
> >         1) lock
> >         memcg_reparent_ops->lock(memcg, parent);
> > 
> >         2) relocate
> >         memcg_reparent_ops->relocate(memcg, reparent);
> > 
> >         3) unlock
> >         memcg_reparent_ops->unlock(memcg, reparent);
> > 
> > Now there are two different locks (e.g. lruvec lock and deferred split
> > queue lock) need to use this infrastructure. In the next patch, we will
> > use those APIs to make those locks safe when the LRU pages reparented.
> > 
> > Signed-off-by: Muchun Song <songmuchun@...edance.com>
> 
> I've mixed feelings about this: it looks nice, but maybe too nice. I wonder
> if it's better to open-code it. Not very confident, I wonder what others are
> thinking.
>

I also thought about this. Open-code is not simplified than this since
memcg_reparent_ops can be used for 3 locks which simplifies code a lot.
I also want to hear others' thoughts on this.
 
> 1) Because the lock callback is first called for all ops, then relocate, then
> unlock, implicit lock dependencies are created. Now it depends on the order
> of elements in the memcg_reparent_ops array, which isn't very obvious.

Maybe we can add some comments explaining the lock dependency depends on the
element order in array.

> 2) Unlikely there will be a lot of new ops added in the future.
>

Yep. I think so.

Thanks.

> The code looks correct though.
> 
> Thanks!
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ