RE: [EXT] Re: [PATCH v4 1/2] net: page_pool: export page_pool_stats definition

From: Shenwei Wang
Date: Tue Nov 15 2022 - 12:52:48 EST




> -----Original Message-----
> From: Andrew Lunn <andrew@xxxxxxx>
> Sent: Tuesday, November 15, 2022 11:43 AM
> To: Shenwei Wang <shenwei.wang@xxxxxxx>
> Cc: David S. Miller <davem@xxxxxxxxxxxxx>; Eric Dumazet
> <edumazet@xxxxxxxxxx>; Jakub Kicinski <kuba@xxxxxxxxxx>; Paolo Abeni
> <pabeni@xxxxxxxxxx>; Jesper Dangaard Brouer <hawk@xxxxxxxxxx>; Ilias
> Apalodimas <ilias.apalodimas@xxxxxxxxxx>; Alexei Starovoitov
> <ast@xxxxxxxxxx>; Daniel Borkmann <daniel@xxxxxxxxxxxxx>; John Fastabend
> <john.fastabend@xxxxxxxxx>; netdev@xxxxxxxxxxxxxxx; linux-
> kernel@xxxxxxxxxxxxxxx; imx@xxxxxxxxxxxxxxx
> Subject: Re: [EXT] Re: [PATCH v4 1/2] net: page_pool: export page_pool_stats
> definition
>
> Caution: EXT Email
>
> > > I agree the API is broken, but i think there is a better fix.
> > >
> > > There should be a stub of page_pool_get_stats() for when
> > > CONFIG_PAGE_POOL_STATS is disabled.
> > >
> > > Nothing actually dereferences struct page_pool_stats when you have this
> stub.
> > > So it might be enough to simply have
> > >
> > > struct page_pool_stats{
> > > };
> > >
> >
> > As the structure is open when the CONFIG_PAGE_POOL_STATS is enabled,
> > you can not prevent a user to access its members. The empty stub will
> > still have problems in this kind of situations.
>
> The users, i.e. the driver, has no need to access its members. The members can
> change, new ones can be added, and it will not cause a problem, given the way
> this API is defined. Ideally, page_pool_stats would of been an opaque cookie,
> but that is not how it was implemented :-(
>

Okay if the assumption is the user would never access its members.

Regards,
Shenwei

> Andrew