From: Ido Schimmel <idosch@nvidia.com>
To: Yizhou Zhao <zhaoyz24@mails.tsinghua.edu.cn>
Cc: Jakub Kicinski <kuba@kernel.org>,
dsahern@kernel.org, davem@davemloft.net, edumazet@google.com,
pabeni@redhat.com, horms@kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, yangyx22@mails.tsinghua.edu.cn,
wangao@seu.edu.cn, fengxw06@126.com, qli01@tsinghua.edu.cn,
xuke@tsinghua.edu.cn, stable@vger.kernel.org
Subject: Re: [PATCH net] nexthop: account nexthop allocations to memcg
Date: Sun, 2 Aug 2026 17:07:18 +0300 [thread overview]
Message-ID: <20260802140718.GA368318@shredder> (raw)
In-Reply-To: <C62F834F-2E10-423F-9A2D-F5454184237B@mails.tsinghua.edu.cn>
On Sat, Aug 01, 2026 at 02:56:29PM +0800, Yizhou Zhao wrote:
> Hi Jakub,
>
> Thank you for both reviews. This is the reply for the first one.
>
> > On Jul 30, 2026, at 08:38, Jakub Kicinski <kuba@kernel.org> wrote:
> >
> > This is an AI-generated review of your patch. The human sending this
> > email has considered the AI review valid, or at least plausible.
> > ---
> > --- Patch [1]: [PATCH net] nexthop: account nexthop allocations to memcg ---
> > commit 186a5b6499e65039b5037906ec518baac2833b1d
> > Author: Yizhou Zhao <zhaoyz24@mails.tsinghua.edu.cn>
> >
> > nexthop: account nexthop allocations to memcg
> >
> > The nexthop creation path allocates struct nexthop, struct nh_info,
> > group storage, resilient bucket tables, transient notifier tables and
> > per-group stats without memcg accounting. As a result, a task with
> > CAP_NET_ADMIN can create nexthops and resilient groups whose kernel
> > memory is not charged to the task's memory cgroup, so memory.max does
> > not constrain this part of the workload.
> >
> >> diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c
> >> index 44fe75004cacb..c8685c5835794 100644
> >> --- a/net/ipv4/nexthop.c
> >> +++ b/net/ipv4/nexthop.c
> > [ ... ]
> >> @@ -2943,7 +2945,7 @@ static struct nexthop *nexthop_create(struct net *net, struct nh_config *cfg,
> >> if (!nh)
> >> return ERR_PTR(-ENOMEM);
> >>
> >> - nhi = kzalloc_obj(*nhi);
> >> + nhi = kzalloc_obj(*nhi, GFP_KERNEL_ACCOUNT);
> >
> > [Severity: High]
> > This is a pre-existing issue, but does this patch miss some per-CPU
> > allocations in the nexthop creation path?
>
> Yes. I confirmed that the original patch misses these allocations.
>
> With only the persistent nexthop objects accounted, IPv4 and IPv6 nexthop
> creation can still allocate nhc_pcpu_rth_output and rt6i_pcpu without memcg
> accounting, so memory.max does not constrain that memory.
>
> We will fix this in the next revision by passing GFP_KERNEL_ACCOUNT through
> fib_nh_init() and fib6_nh_init() for persistent nexthop creation, while
> leaving regular route creation with GFP_KERNEL.
>
> Please let me know if you would prefer a different split.
What is the reason for the split? Why only charge the nexthop when it's
created via the nexthop API (e.g., ip nexthop add ...), but not when
it's implicitly created via the route API (e.g., ip route add ...)?
next prev parent reply other threads:[~2026-08-02 14:07 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-28 6:01 [PATCH net] nexthop: account nexthop allocations to memcg Yizhou Zhao
2026-07-30 0:38 ` Jakub Kicinski
2026-08-01 6:56 ` Yizhou Zhao
2026-08-02 14:07 ` Ido Schimmel [this message]
2026-07-30 0:39 ` Jakub Kicinski
2026-08-01 7:13 ` Yizhou Zhao
2026-08-02 14:28 ` Ido Schimmel
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=20260802140718.GA368318@shredder \
--to=idosch@nvidia.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=fengxw06@126.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=qli01@tsinghua.edu.cn \
--cc=stable@vger.kernel.org \
--cc=wangao@seu.edu.cn \
--cc=xuke@tsinghua.edu.cn \
--cc=yangyx22@mails.tsinghua.edu.cn \
--cc=zhaoyz24@mails.tsinghua.edu.cn \
/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