[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID:
<PAXPR04MB9185A88FCCBA757077DD521D893CA@PAXPR04MB9185.eurprd04.prod.outlook.com>
Date: Sat, 23 Aug 2025 19:34:16 +0000
From: Shenwei Wang <shenwei.wang@....com>
To: Andrew Lunn <andrew@...n.ch>
CC: Wei Fang <wei.fang@....com>, Andrew Lunn <andrew+netdev@...n.ch>, "David
S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>, Jakub
Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>, Alexei
Starovoitov <ast@...nel.org>, Daniel Borkmann <daniel@...earbox.net>, Jesper
Dangaard Brouer <hawk@...nel.org>, John Fastabend <john.fastabend@...il.com>,
Clark Wang <xiaoning.wang@....com>, Stanislav Fomichev <sdf@...ichev.me>,
"imx@...ts.linux.dev" <imx@...ts.linux.dev>, "netdev@...r.kernel.org"
<netdev@...r.kernel.org>, "linux-kernel@...r.kernel.org"
<linux-kernel@...r.kernel.org>, dl-linux-imx <linux-imx@....com>
Subject: Re: [PATCH v3 net-next 4/5] net: fec: add change_mtu to support
dynamic buffer allocation
> -----Original Message-----
> From: Andrew Lunn <andrew@...n.ch>
> Sent: Saturday, August 23, 2025 2:17 PM
> To: Shenwei Wang <shenwei.wang@....com>
> Cc: Wei Fang <wei.fang@....com>; Andrew Lunn <andrew+netdev@...n.ch>;
> David S. Miller <davem@...emloft.net>; Eric Dumazet
> <edumazet@...gle.com>; Jakub Kicinski <kuba@...nel.org>; Paolo Abeni
> <pabeni@...hat.com>; Alexei Starovoitov <ast@...nel.org>; Daniel Borkmann
> <daniel@...earbox.net>; Jesper Dangaard Brouer <hawk@...nel.org>; John
> Fastabend <john.fastabend@...il.com>; Clark Wang
> <xiaoning.wang@....com>; Stanislav Fomichev <sdf@...ichev.me>;
> imx@...ts.linux.dev; netdev@...r.kernel.org; linux-kernel@...r.kernel.org; dl-
> linux-imx <linux-imx@....com>
> Subject: [EXT] Re: [PATCH v3 net-next 4/5] net: fec: add change_mtu to support
> dynamic buffer allocation
> > +
> > + WRITE_ONCE(ndev->mtu, new_mtu);
> > +
> > + /* Create the pagepool according the new mtu */
> > + if (fec_enet_alloc_buffers(ndev) < 0)
> > + return -ENOMEM;
> > +
>
> This is the wrong order. You need to first allocate the new buffers and then free
> the old ones. If the allocation fails, you still have a working interface using the
> smaller buffers, and the MTU change just returns -ENOMEM. If you free the
> buffers and the allocation of the new buffers fail, you interface is dead, because it
> has no buffers.
>
I've considered that. I was wondering-if there's no available memory, should it still be
treated as a critical issue for the system in this case?
The current API doesn't support allocating memory first and freeing it only upon success.
Supporting such behavior would require a redesign of the buffer management flow.
As an alternative, we could attempt to fall back to allocating buffers of the original size if the
operation fails. However, this still doesn't guarantee success.
Regards,
Shenwei
> Andrew
Powered by blists - more mailing lists