mbox series

[RFC,rdma-core,0/5] libhns: Add support for Dynamic Context Attachment

Message ID 1612667574-56673-1-git-send-email-liweihang@huawei.com (mailing list archive)
Headers show
Series libhns: Add support for Dynamic Context Attachment | expand

Message

Weihang Li Feb. 7, 2021, 3:12 a.m. UTC
The HIP09 introduces the DCA(Dynamic Context Attachment) feature which
supports many RC QPs to share the WQE buffer in a memory pool. If a QP
enables DCA feature, the WQE's buffer will not be allocated when creating
but when the users start to post WRs. This will reduce the memory
consumption when there are too many QPs are inactive.

Please note that we didn't find the right way to get user's configuration,
so in #4 we still use environment variable to achieve this. We will be
appreciated if anyone can provide some sugggestions.

This series is associated with the kernel series "RDMA/hns: Add support for
Dynamic Context Attachment", you can review it at:
https://patchwork.kernel.org/project/linux-rdma/cover/1611394994-50363-1-git-send-email-liweihang@huawei.com/

Weihang Li (1):
  Update kernel headers

Xi Wang (4):
  libhns: Introduce DCA for RC QP
  libhns: Add support for shrinking DCA memory pool
  libhns: Add support for attaching QP's WQE buffer
  libhns: Add support for configuring DCA

 kernel-headers/rdma/hns-abi.h    |  64 +++++++
 libibverbs/cmd_qp.c              |   3 +-
 libibverbs/verbs.h               |   1 +
 providers/hns/hns_roce_u.c       |  89 +++++++++
 providers/hns/hns_roce_u.h       |  42 +++++
 providers/hns/hns_roce_u_buf.c   | 384 +++++++++++++++++++++++++++++++++++++++
 providers/hns/hns_roce_u_hw_v2.c | 138 +++++++++++++-
 providers/hns/hns_roce_u_hw_v2.h |   7 +
 providers/hns/hns_roce_u_verbs.c |  44 ++++-
 9 files changed, 754 insertions(+), 18 deletions(-)

Comments

Jason Gunthorpe Feb. 9, 2021, 7:38 p.m. UTC | #1
On Sun, Feb 07, 2021 at 11:12:49AM +0800, Weihang Li wrote:
> The HIP09 introduces the DCA(Dynamic Context Attachment) feature which
> supports many RC QPs to share the WQE buffer in a memory pool. If a QP
> enables DCA feature, the WQE's buffer will not be allocated when creating
> but when the users start to post WRs. This will reduce the memory
> consumption when there are too many QPs are inactive.
> 
> Please note that we didn't find the right way to get user's configuration,
> so in #4 we still use environment variable to achieve this. We will be
> appreciated if anyone can provide some sugggestions.

That is definately not going to work.. It should be some dv thing,
dv create qp or a dv customization of the parent domain spring to mind

Jason
Jason Gunthorpe Feb. 9, 2021, 7:53 p.m. UTC | #2
On Sun, Feb 07, 2021 at 11:12:49AM +0800, Weihang Li wrote:
> The HIP09 introduces the DCA(Dynamic Context Attachment) feature which
> supports many RC QPs to share the WQE buffer in a memory pool. If a QP
> enables DCA feature, the WQE's buffer will not be allocated when creating
> but when the users start to post WRs. This will reduce the memory
> consumption when there are too many QPs are inactive.

One a WQE buffer is allocated it still acts as a normal WQE ring
buffer? So this DCA logic is to remap the send queue buffer based on
demand for SQEs? How does it interact with the normal max send queue
entries reported?

Would like to see proper man pages explaining how this all works for
rdma-core.

Jason
Weihang Li Feb. 20, 2021, 8:40 a.m. UTC | #3
On 2021/2/10 3:54, Jason Gunthorpe wrote:
> On Sun, Feb 07, 2021 at 11:12:49AM +0800, Weihang Li wrote:
>> The HIP09 introduces the DCA(Dynamic Context Attachment) feature which
>> supports many RC QPs to share the WQE buffer in a memory pool. If a QP
>> enables DCA feature, the WQE's buffer will not be allocated when creating
>> but when the users start to post WRs. This will reduce the memory
>> consumption when there are too many QPs are inactive.
>> One a WQE buffer is allocated it still acts as a normal WQE ring
> buffer? So this DCA logic is to remap the send queue buffer based on
> demand for SQEs? How does it interact with the normal max send queue
> entries reported?
> 

Not exactly. If DCA is enabled, we first allocate a memory pool with a
default size when opening device. Each time we trying to post WR(s) to a
QP, the driver will check if current QP has WQE buffer.

If not, the driver will check whether there is enough free memory in the
DCA memory pool. If there is, the QP will get WQE buffer from the pool,
including SQ buffer in size of max_send_wr, RQ buffer in size of
max_recv_wr and extended sge buffer. If there is no enough space for the
WQE buffer in the DCA pool, the driver will expand the size of pool and
then assign the buffer to the QP.

And if the WQE buffer of a QP is not used, this buffer would be recycled
and the DCA memory pool would be shrinked.

> Would like to see proper man pages explaining how this all works for
> rdma-core.
> 
> Jason
> 
OK, will add man pages for DCA in next version.

Thanks
Weihang
Weihang Li Feb. 20, 2021, 9:47 a.m. UTC | #4
On 2021/2/10 3:39, Jason Gunthorpe wrote:
> On Sun, Feb 07, 2021 at 11:12:49AM +0800, Weihang Li wrote:
>> The HIP09 introduces the DCA(Dynamic Context Attachment) feature which
>> supports many RC QPs to share the WQE buffer in a memory pool. If a QP
>> enables DCA feature, the WQE's buffer will not be allocated when creating
>> but when the users start to post WRs. This will reduce the memory
>> consumption when there are too many QPs are inactive.
>>
>> Please note that we didn't find the right way to get user's configuration,
>> so in #4 we still use environment variable to achieve this. We will be
>> appreciated if anyone can provide some sugggestions.
> 
> That is definately not going to work.. It should be some dv thing,
> dv create qp or a dv customization of the parent domain spring to mind
> 
> Jason
> 

Thank you, we will use the parameter of verbs_open_device() named
private_data to allow user pass the DCA configurations into the driver
according to the way of mlx5dv_open_device().

Weihang
Jason Gunthorpe Feb. 22, 2021, 4:01 p.m. UTC | #5
On Sat, Feb 20, 2021 at 08:40:02AM +0000, liweihang wrote:
> On 2021/2/10 3:54, Jason Gunthorpe wrote:
> > On Sun, Feb 07, 2021 at 11:12:49AM +0800, Weihang Li wrote:
> >> The HIP09 introduces the DCA(Dynamic Context Attachment) feature which
> >> supports many RC QPs to share the WQE buffer in a memory pool. If a QP
> >> enables DCA feature, the WQE's buffer will not be allocated when creating
> >> but when the users start to post WRs. This will reduce the memory
> >> consumption when there are too many QPs are inactive.
> >> One a WQE buffer is allocated it still acts as a normal WQE ring
> > buffer? So this DCA logic is to remap the send queue buffer based on
> > demand for SQEs? How does it interact with the normal max send queue
> > entries reported?
> > 
> 
> Not exactly. If DCA is enabled, we first allocate a memory pool with a
> default size when opening device. Each time we trying to post WR(s) to a
> QP, the driver will check if current QP has WQE buffer.
> 
> If not, the driver will check whether there is enough free memory in the
> DCA memory pool. If there is, the QP will get WQE buffer from the
> pool,

Does that mean the QP can have a non-contiguous list of buffers? Ie it
isn't just a linear ring of memory?

Jason
Weihang Li Feb. 23, 2021, 8:07 a.m. UTC | #6
On 2021/2/23 0:02, Jason Gunthorpe wrote:
> On Sat, Feb 20, 2021 at 08:40:02AM +0000, liweihang wrote:
>> On 2021/2/10 3:54, Jason Gunthorpe wrote:
>>> On Sun, Feb 07, 2021 at 11:12:49AM +0800, Weihang Li wrote:
>>>> The HIP09 introduces the DCA(Dynamic Context Attachment) feature which
>>>> supports many RC QPs to share the WQE buffer in a memory pool. If a QP
>>>> enables DCA feature, the WQE's buffer will not be allocated when creating
>>>> but when the users start to post WRs. This will reduce the memory
>>>> consumption when there are too many QPs are inactive.
>>>> One a WQE buffer is allocated it still acts as a normal WQE ring
>>> buffer? So this DCA logic is to remap the send queue buffer based on
>>> demand for SQEs? How does it interact with the normal max send queue
>>> entries reported?
>>>
>>
>> Not exactly. If DCA is enabled, we first allocate a memory pool with a
>> default size when opening device. Each time we trying to post WR(s) to a
>> QP, the driver will check if current QP has WQE buffer.
>>
>> If not, the driver will check whether there is enough free memory in the
>> DCA memory pool. If there is, the QP will get WQE buffer from the
>> pool,
> 
> Does that mean the QP can have a non-contiguous list of buffers? Ie it
> isn't just a linear ring of memory?
> 
> Jason
> 

Yes, when using multilevel addressing, the virtual address of QP's buffers
may be non-contiguous to avoid memory fragmentation.

Weihang
Weihang Li Feb. 24, 2021, 9:48 a.m. UTC | #7
On 2021/2/10 3:54, Jason Gunthorpe wrote:
> On Sun, Feb 07, 2021 at 11:12:49AM +0800, Weihang Li wrote:
>> The HIP09 introduces the DCA(Dynamic Context Attachment) feature which
>> supports many RC QPs to share the WQE buffer in a memory pool. If a QP
>> enables DCA feature, the WQE's buffer will not be allocated when creating
>> but when the users start to post WRs. This will reduce the memory
>> consumption when there are too many QPs are inactive.
> 
> One a WQE buffer is allocated it still acts as a normal WQE ring
> buffer? So this DCA logic is to remap the send queue buffer based on
> demand for SQEs? How does it interact with the normal max send queue
> entries reported?
> 
> Would like to see proper man pages explaining how this all works for
> rdma-core.
> 
> Jason
> 

Hi Jason,

I'm confused about how to introduce DCA in man pages. Current man pages
in rdma-core can be classifed into public and vendor-defined ones.
For example, ibv_create_qp.3 in libibverbs/man and mlx5dv.7 in
providers/mlx5/man, but most of them is a description for a single
interface. If we want to explain how to use DCA and how does it work,
should we put a hns_dca.x file in providers/hns/man? Or add a file
about hns_dca_open_device() and introduce DCA in it?

And another question, I know the files with a number suffix like
ibv_create_qp.3 is for man pages in linux. What about the markdown files
with .md suffix like ibv_fork_init.3.md? If we want to add a new one about
DCA, which type should we choose?

Thanks
Weihang
Jason Gunthorpe Feb. 24, 2021, 6:55 p.m. UTC | #8
On Wed, Feb 24, 2021 at 09:48:34AM +0000, liweihang wrote:

> I'm confused about how to introduce DCA in man pages. Current man pages
> in rdma-core can be classifed into public and vendor-defined ones.
> For example, ibv_create_qp.3 in libibverbs/man and mlx5dv.7 in
> providers/mlx5/man, but most of them is a description for a single
> interface. If we want to explain how to use DCA and how does it work,
> should we put a hns_dca.x file in providers/hns/man? 

You could do that, yes

> And another question, I know the files with a number suffix like
> ibv_create_qp.3 is for man pages in linux. What about the markdown files
> with .md suffix like ibv_fork_init.3.md? If we want to add a new one about
> DCA, which type should we choose?

Always use the md files for new man pages please

Jason