From: Shakeel Butt <shakeelb@google.com>
To: "Gražvydas Ignotas" <notasas@gmail.com>
Cc: Wei Wang <weiwan@google.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Eric Dumazet <edumazet@google.com>,
netdev <netdev@vger.kernel.org>, Michal Hocko <mhocko@suse.com>,
Roman Gushchin <guro@fb.com>, Linux MM <linux-mm@kvack.org>,
Cgroups <cgroups@vger.kernel.org>
Subject: Re: UDP rx packet loss in a cgroup with a memory limit
Date: Wed, 12 Oct 2022 21:36:34 -0700 [thread overview]
Message-ID: <CALvZod6VaQXrs1x7ff=RRWWP+CgD0hQkTROfZ9XowQ_Zo3SO3Q@mail.gmail.com> (raw)
In-Reply-To: <CANOLnONQaHXOp1z1rNum74N2b=Ub7t5NsGHqPdHUQL4+4YYEQg@mail.gmail.com>
On Wed, Aug 17, 2022 at 1:12 PM Gražvydas Ignotas <notasas@gmail.com> wrote:
>
> On Wed, Aug 17, 2022 at 9:16 PM Wei Wang <weiwan@google.com> wrote:
> >
> > On Wed, Aug 17, 2022 at 10:37 AM Shakeel Butt <shakeelb@google.com> wrote:
> > >
> > > + Eric and netdev
> > >
> > > On Wed, Aug 17, 2022 at 10:13 AM Johannes Weiner <hannes@cmpxchg.org> wrote:
> > > >
> > > > This is most likely a regression caused by this patch:
> > > >
> > > > commit 4b1327be9fe57443295ae86fe0fcf24a18469e9f
> > > > Author: Wei Wang <weiwan@google.com>
> > > > Date: Tue Aug 17 12:40:03 2021 -0700
> > > >
> > > > net-memcg: pass in gfp_t mask to mem_cgroup_charge_skmem()
> > > >
> > > > Add gfp_t mask as an input parameter to mem_cgroup_charge_skmem(),
> > > > to give more control to the networking stack and enable it to change
> > > > memcg charging behavior. In the future, the networking stack may decide
> > > > to avoid oom-kills when fallbacks are more appropriate.
> > > >
> > > > One behavior change in mem_cgroup_charge_skmem() by this patch is to
> > > > avoid force charging by default and let the caller decide when and if
> > > > force charging is needed through the presence or absence of
> > > > __GFP_NOFAIL.
> > > >
> > > > Signed-off-by: Wei Wang <weiwan@google.com>
> > > > Reviewed-by: Shakeel Butt <shakeelb@google.com>
> > > > Signed-off-by: David S. Miller <davem@davemloft.net>
> > > >
> > > > We never used to fail these allocations. Cgroups don't have a
> > > > kswapd-style watermark reclaimer, so the network relied on
> > > > force-charging and leaving reclaim to allocations that can block.
> > > > Now it seems network packets could just fail indefinitely.
> > > >
> > > > The changelog is a bit terse given how drastic the behavior change
> > > > is. Wei, Shakeel, can you fill in why this was changed? Can we revert
> > > > this for the time being?
> > >
> > > Does reverting the patch fix the issue? However I don't think it will.
> > >
> > > Please note that we still have the force charging as before this
> > > patch. Previously when mem_cgroup_charge_skmem() force charges, it
> > > returns false and __sk_mem_raise_allocated takes suppress_allocation
> > > code path. Based on some heuristics, it may allow it or it may
> > > uncharge and return failure.
> >
> > The force charging logic in __sk_mem_raise_allocated only gets
> > considered on tx path for STREAM socket. So it probably does not take
> > effect on UDP path. And, that logic is NOT being altered in the above
> > patch.
> > So specifically for UDP receive path, what happens in
> > __sk_mem_raise_allocated() BEFORE the above patch is:
> > - mem_cgroup_charge_skmem() gets called:
> > - try_charge() with GFP_NOWAIT gets called and failed
> > - try_charge() with __GFP_NOFAIL
> > - return false
> > - goto suppress_allocation:
> > - mem_cgroup_uncharge_skmem() gets called
> > - return 0 (which means failure)
> >
> > AFTER the above patch, what happens in __sk_mem_raise_allocated() is:
> > - mem_cgroup_charge_skmem() gets called:
> > - try_charge() with GFP_NOWAIT gets called and failed
> > - return false
> > - goto suppress_allocation:
> > - We no longer calls mem_cgroup_uncharge_skmem()
> > - return 0
> >
> > So I agree with Shakeel, that this change shouldn't alter the behavior
> > of the above call path in such a situation.
> > But do let us know if reverting this change has any effect on your test.
>
> The problem is still there (the kernel wasn't compiling after revert,
> had to adjust another seemingly unrelated callsite). It's hard to tell
> if it's better or worse since it happens so randomly.
>
Hello everyone, we have a better understanding why the patch pointed
out by Johannes might have exposed this issue. See
https://lore.kernel.org/all/20221013041833.rhifxw4gqwk4ofi2@google.com/.
To summarize, the old code was depending on a subtle interaction of
force-charge and percpu charge caches which this patch removed. The
fix I am proposing is for the network stack to be explicit of its need
(i.e. use GFP_ATOMIC) instead of depending on a subtle behavior.
next prev parent reply other threads:[~2022-10-13 4:36 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CANOLnON11vzvVdyJfW+QJ36siWR4-s=HJ2aRKpRy7CP=aRPoSw@mail.gmail.com>
[not found] ` <CANOLnOPeOi0gxYwd5+ybdv5w=RZEh5JakJPE9xgrSL1cecZHbw@mail.gmail.com>
2022-08-17 17:13 ` Johannes Weiner
2022-08-17 17:37 ` Shakeel Butt
2022-08-17 18:16 ` Wei Wang
2022-08-17 20:12 ` Gražvydas Ignotas
2022-10-13 4:36 ` Shakeel Butt [this message]
2022-10-13 14:22 ` Johannes Weiner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CALvZod6VaQXrs1x7ff=RRWWP+CgD0hQkTROfZ9XowQ_Zo3SO3Q@mail.gmail.com' \
--to=shakeelb@google.com \
--cc=cgroups@vger.kernel.org \
--cc=edumazet@google.com \
--cc=guro@fb.com \
--cc=hannes@cmpxchg.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=netdev@vger.kernel.org \
--cc=notasas@gmail.com \
--cc=weiwan@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox