Re: [PATCH] mm/memcg: bail out early when !memcg in mem_cgroup_lruvec

From: Andrew Morton
Date: Mon Nov 30 2020 - 15:20:55 EST


On Mon, 30 Nov 2020 22:44:11 +0300 Dmitry Osipenko <digetx@xxxxxxxxx> wrote:

> > From: Alex Shi <alex.shi@xxxxxxxxxxxxxxxxx>
> > Date: Wed, 25 Nov 2020 14:06:33 +0800
> > Subject: [PATCH v2] mm/memcg: bail out early when !memcg in mem_cgroup_lruvec
> >
> > Sometime, we use NULL memcg in mem_cgroup_lruvec(memcg, pgdat)
> > so we could get out early in the situation to avoid useless checking.
> >
> > Polished as Andrew Morton's suggestion.
> >
> > --- a/include/linux/memcontrol.h
> > +++ b/include/linux/memcontrol.h
> > @@ -610,20 +610,17 @@ mem_cgroup_nodeinfo(struct mem_cgroup *memcg, int nid)
> > static inline struct lruvec *mem_cgroup_lruvec(struct mem_cgroup *memcg,
> > struct pglist_data *pgdat)
> > {
> > - struct mem_cgroup_per_node *mz;
> > struct lruvec *lruvec;
> >
> > - if (mem_cgroup_disabled()) {
> > + if (mem_cgroup_disabled() || !memcg) {
> > lruvec = &pgdat->__lruvec;
> > - goto out;
> > - }
> > + } else {
> > + struct mem_cgroup_per_node *mz;
> >
> > - if (!memcg)
> > - memcg = root_mem_cgroup;
> > + mz = mem_cgroup_nodeinfo(memcg, pgdat->node_id);
> > + lruvec = &mz->lruvec;
> > + }
> >
> > - mz = mem_cgroup_nodeinfo(memcg, pgdat->node_id);
> > - lruvec = &mz->lruvec;
> > -out:
> > /*
> > * Since a node can be onlined after the mem_cgroup was created,
> > * we have to be prepared to initialize lruvec->pgdat here;
> >
>
> Hi,
>
> This patch causes a hard lock on one of my ARM32 devices using today's
> linux-next, please fix.

Thanks.

This is unexpected. I assume you've confirmed that reverting this
change from linux-next fixes things?