mbox series

[net-next,0/4] net/mlx5: Memory optimizations

Message ID 20211130150705.19863-1-shayd@nvidia.com (mailing list archive)
Headers show
Series net/mlx5: Memory optimizations | expand

Message

Shay Drori Nov. 30, 2021, 3:07 p.m. UTC
This series provides knobs which will enable users to
minimize memory consumption of mlx5 Functions (PF/VF/SF).
mlx5 exposes two new generic devlink resources for EQ size
configuration and uses devlink generic param max_macs.

Patches summary:
 - Patch-1 Provides I/O EQ size resource which enables to save
   up to 128KB.
 - Patch-2 Provides event EQ size resource which enables to save up to
   512KB.
 - Patch-3 Clarify max_macs param.
 - Patch-4 Provides max_macs param which enables to save up to 70KB

In total, this series can save up to 700KB per Function.

Shay Drory (4):
  net/mlx5: Let user configure io_eq_size resource
  net/mlx5: Let user configure event_eq_size resource
  devlink: Clarifies max_macs generic devlink param
  net/mlx5: Let user configure max_macs generic param

 .../networking/devlink/devlink-params.rst     |  6 +-
 .../networking/devlink/devlink-resource.rst   |  4 +
 Documentation/networking/devlink/mlx5.rst     |  4 +
 .../net/ethernet/mellanox/mlx5/core/Makefile  |  2 +-
 .../net/ethernet/mellanox/mlx5/core/devlink.c | 67 ++++++++++++++++
 .../net/ethernet/mellanox/mlx5/core/devlink.h | 12 +++
 .../ethernet/mellanox/mlx5/core/devlink_res.c | 79 +++++++++++++++++++
 drivers/net/ethernet/mellanox/mlx5/core/eq.c  |  5 +-
 .../net/ethernet/mellanox/mlx5/core/main.c    | 21 +++++
 include/linux/mlx5/driver.h                   |  4 -
 include/linux/mlx5/eq.h                       |  1 -
 include/linux/mlx5/mlx5_ifc.h                 |  2 +-
 include/net/devlink.h                         |  2 +
 13 files changed, 198 insertions(+), 11 deletions(-)
 create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/devlink_res.c

Comments

Jakub Kicinski Nov. 30, 2021, 7:39 p.m. UTC | #1
On Tue, 30 Nov 2021 17:07:02 +0200 Shay Drory wrote:
>  - Patch-1 Provides I/O EQ size resource which enables to save
>    up to 128KB.
>  - Patch-2 Provides event EQ size resource which enables to save up to
>    512KB.

Why is something allocated in host memory a device resource? 
Shay Drori Dec. 1, 2021, 8:22 a.m. UTC | #2
On 11/30/2021 21:39, Jakub Kicinski wrote:
> On Tue, 30 Nov 2021 17:07:02 +0200 Shay Drory wrote:
>>   - Patch-1 Provides I/O EQ size resource which enables to save
>>     up to 128KB.
>>   - Patch-2 Provides event EQ size resource which enables to save up to
>>     512KB.
> Why is something allocated in host memory a device resource? 
Jakub Kicinski Dec. 2, 2021, 5:31 p.m. UTC | #3
On Wed, 1 Dec 2021 10:22:17 +0200 Shay Drory wrote:
> On 11/30/2021 21:39, Jakub Kicinski wrote:
> > On Tue, 30 Nov 2021 17:07:02 +0200 Shay Drory wrote:  
> >>   - Patch-1 Provides I/O EQ size resource which enables to save
> >>     up to 128KB.
> >>   - Patch-2 Provides event EQ size resource which enables to save up to
> >>     512KB.  
> > Why is something allocated in host memory a device resource? 
Saeed Mahameed Dec. 2, 2021, 6:55 p.m. UTC | #4
On Thu, 2021-12-02 at 09:31 -0800, Jakub Kicinski wrote:
> On Wed, 1 Dec 2021 10:22:17 +0200 Shay Drory wrote:
> > On 11/30/2021 21:39, Jakub Kicinski wrote:
> > > On Tue, 30 Nov 2021 17:07:02 +0200 Shay Drory wrote:  
> > > >   - Patch-1 Provides I/O EQ size resource which enables to save
> > > >     up to 128KB.
> > > >   - Patch-2 Provides event EQ size resource which enables to
> > > > save up to
> > > >     512KB.  
> > > Why is something allocated in host memory a device resource? 
Jakub Kicinski Dec. 3, 2021, 1:28 a.m. UTC | #5
On Thu, 2 Dec 2021 18:55:37 +0000 Saeed Mahameed wrote:
> On Thu, 2021-12-02 at 09:31 -0800, Jakub Kicinski wrote:
> > On Wed, 1 Dec 2021 10:22:17 +0200 Shay Drory wrote:  
> > > EQ resides in the host memory. It is RO for host driver, RW by
> > > device.
> > > When interrupt is generated EQ entry is placed by device and read
> > > by driver.
> > > It indicates about what event occurred such as CQE, async and more.  
> > 
> > I understand that. My point was the resource which is being consumed
> > here is _host_ memory. Is there precedent for configuring host memory
> > consumption via devlink resource?
> 
> it's a device resource size nonetheless, devlink resource API makes
> total sense.

I disagree. Devlink resources were originally written to partition
finite device resources. You're just sizing a queue here.

> > I'd even question whether this belongs in devlink in the first place.
> > It is not global device config in any way. If devlink represents the
> > entire device it's rather strange to have a case where main instance
> > limits a size of some resource by VFs and other endpoints can still
> > choose whatever they want.
> 
> This resource is per function instance, we have devlink instance per
> function, e.g. in the VM, there is a VF devlink instance the VM user
> can use to control own VF resources. in the PF/Hypervisor, the only
> devlink representation of the VF will be devlink port function (used
> for other purposes)
> 
> for example:
> 
> A tenant can fine-tune a resource size tailored to their needs via the
> VF's own devlink instance.

Yeah, because it's a device resource. Tenant can consume their host
DRAM in any way they find suitable.

> An admin can only control or restrict a max size of a resource for a
> given port function ( the devlink instance that represents the VF in
> the hypervisor). (note: this patchset is not about that)
> 
> > > So far no feedback by other vendors.
> > > The resources are implemented in generic way, if other vendors
> > > would
> > > like to implement them.  
> > 
> > Well, I was hoping you'd look around, but maybe that's too much to
> > ask of a vendor.  
> 
> We looked, eq is a common object among many other drivers.
> and DEVLINK_PARAM_GENERIC_ID_MAX_MACS is already a devlink generic
> param, and i am sure other vendors have limited macs per VF :) .. 
> so this applies to all vendors even if they don't advertise it.

Yeah, if you're not willing to model the Event Queue as a queue using
params seems like a better idea than abusing resources.
Jiri Pirko Dec. 6, 2021, 8:18 a.m. UTC | #6
Fri, Dec 03, 2021 at 02:28:03AM CET, kuba@kernel.org wrote:
>On Thu, 2 Dec 2021 18:55:37 +0000 Saeed Mahameed wrote:
>> On Thu, 2021-12-02 at 09:31 -0800, Jakub Kicinski wrote:
>> > On Wed, 1 Dec 2021 10:22:17 +0200 Shay Drory wrote:  
>> > > EQ resides in the host memory. It is RO for host driver, RW by
>> > > device.
>> > > When interrupt is generated EQ entry is placed by device and read
>> > > by driver.
>> > > It indicates about what event occurred such as CQE, async and more.  
>> > 
>> > I understand that. My point was the resource which is being consumed
>> > here is _host_ memory. Is there precedent for configuring host memory
>> > consumption via devlink resource?
>> 
>> it's a device resource size nonetheless, devlink resource API makes
>> total sense.
>
>I disagree. Devlink resources were originally written to partition
>finite device resources. You're just sizing a queue here.
>
>> > I'd even question whether this belongs in devlink in the first place.
>> > It is not global device config in any way. If devlink represents the
>> > entire device it's rather strange to have a case where main instance
>> > limits a size of some resource by VFs and other endpoints can still
>> > choose whatever they want.
>> 
>> This resource is per function instance, we have devlink instance per
>> function, e.g. in the VM, there is a VF devlink instance the VM user
>> can use to control own VF resources. in the PF/Hypervisor, the only
>> devlink representation of the VF will be devlink port function (used
>> for other purposes)
>> 
>> for example:
>> 
>> A tenant can fine-tune a resource size tailored to their needs via the
>> VF's own devlink instance.
>
>Yeah, because it's a device resource. Tenant can consume their host
>DRAM in any way they find suitable.
>
>> An admin can only control or restrict a max size of a resource for a
>> given port function ( the devlink instance that represents the VF in
>> the hypervisor). (note: this patchset is not about that)
>> 
>> > > So far no feedback by other vendors.
>> > > The resources are implemented in generic way, if other vendors
>> > > would
>> > > like to implement them.  
>> > 
>> > Well, I was hoping you'd look around, but maybe that's too much to
>> > ask of a vendor.  
>> 
>> We looked, eq is a common object among many other drivers.
>> and DEVLINK_PARAM_GENERIC_ID_MAX_MACS is already a devlink generic
>> param, and i am sure other vendors have limited macs per VF :) .. 
>> so this applies to all vendors even if they don't advertise it.
>
>Yeah, if you're not willing to model the Event Queue as a queue using
>params seems like a better idea than abusing resources.

I think you are right. On second thought, param look like a better fit.