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: <CAMZfGtVAf6aZQs+1mh_KDx53DtpavYb_KpTbhoZL0kfpsCeXsA@mail.gmail.com>
Date:   Fri, 6 Nov 2020 00:01:12 +0800
From:   Muchun Song <songmuchun@...edance.com>
To:     Johannes Weiner <hannes@...xchg.org>
Cc:     Andrew Morton <akpm@...ux-foundation.org>,
        Shakeel Butt <shakeelb@...gle.com>,
        Roman Gushchin <guro@...com>, Michal Hocko <mhocko@...e.com>,
        Yafang Shao <laoar.shao@...il.com>,
        Chris Down <chris@...isdown.name>, Tejun Heo <tj@...nel.org>,
        LKML <linux-kernel@...r.kernel.org>
Subject: Re: [External] Re: [PATCH] mm: memcontrol: fix missing wakeup polling thread

On Thu, Nov 5, 2020 at 11:52 PM Johannes Weiner <hannes@...xchg.org> wrote:
>
> On Wed, Nov 04, 2020 at 08:55:58PM +0800, Muchun Song wrote:
> > When wen poll the memory.swap.events, we can miss being waked up when the
> > swap event occurs. Because we didn't notify.
> >
> > Fixes: f3a53a3a1e5b ("mm, memcontrol: implement memory.swap.events")
> > Signed-off-by: Muchun Song <songmuchun@...edance.com>
>
> Good catch!
>
> > ---
> >  include/linux/memcontrol.h | 18 ++++++++++++++++--
> >  1 file changed, 16 insertions(+), 2 deletions(-)
> >
> > diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
> > index 0f4dd7829fb2..2456cb737329 100644
> > --- a/include/linux/memcontrol.h
> > +++ b/include/linux/memcontrol.h
> > @@ -1071,15 +1071,29 @@ static inline void count_memcg_event_mm(struct mm_struct *mm,
> >       rcu_read_unlock();
> >  }
> >
> > +static inline bool is_swap_memory_event(enum memcg_memory_event event)
> > +{
> > +     return event == MEMCG_SWAP_HIGH || event == MEMCG_SWAP_MAX ||
> > +            event == MEMCG_SWAP_FAIL;
> > +}
>
> Please inline this, it's not really worth the indirection.
>
> >  static inline void memcg_memory_event(struct mem_cgroup *memcg,
> >                                     enum memcg_memory_event event)
> >  {
> > +     bool swap_event = is_swap_memory_event(event);
> > +     struct cgroup_file *cfile;
> > +
> >       atomic_long_inc(&memcg->memory_events_local[event]);
> > -     cgroup_file_notify(&memcg->events_local_file);
> > +     if (swap_event) {
> > +             cfile = &memcg->swap_events_file;
> > +     } else {
> > +             cfile = &memcg->events_file;
> > +             cgroup_file_notify(&memcg->events_local_file);
> > +     }
> >
> >       do {
> >               atomic_long_inc(&memcg->memory_events[event]);
> > -             cgroup_file_notify(&memcg->events_file);
> > +             cgroup_file_notify(cfile);
>
> This loop is a walk up the hierarchy and memcg keeps changing, so you
> cannot cache cfile up front.
>
>                 if (swap_event)
>                         cgroup_file_notify(&memcg->swap_events_file);
>                 else
>                         cgroup_file_notify(&memcg->events_file);

Oh, Yeah, Thanks for reminding me.

-- 
Yours,
Muchun

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ