Skip to content

Commit 501c300

Browse files
Anand Khojekuba-moo
authored andcommitted
net/mlx5: Reclaim max 50K pages at once
In non FLR context, at times CX-5 requests release of ~8 million FW pages. This needs humongous number of cmd mailboxes, which to be released once the pages are reclaimed. Release of humongous number of cmd mailboxes is consuming cpu time running into many seconds. Which with non preemptible kernels is leading to critical process starving on that cpu’s RQ. On top of it, the FW does not use all the mailbox messages as it has a limit of releasing 50K pages at once per MLX5_CMD_OP_MANAGE_PAGES + MLX5_PAGES_TAKE device command. Hence, the allocation of these many mailboxes is extra and adds unnecessary overhead. To alleviate this, this change restricts the total number of pages a worker will try to reclaim to maximum 50K pages in one go. Our tests have shown significant benefit of this change in terms of time consumed by dma_pool_free(). During a test where an event was raised by HCA to release 1.3 Million pages, following observations were made: - Without this change: Number of mailbox messages allocated was around 20K, to accommodate the DMA addresses of 1.3 million pages. The average time spent by dma_pool_free() to free the DMA pool is between 16 usec to 32 usec. value ------------- Distribution ------------- count 256 | 0 512 |@ 287 1024 |@@@ 1332 2048 |@ 656 4096 |@@@@@ 2599 8192 |@@@@@@@@@@ 4755 16384 |@@@@@@@@@@@@@@@ 7545 32768 |@@@@@ 2501 65536 | 0 - With this change: Number of mailbox messages allocated was around 800; this was to accommodate DMA addresses of only 50K pages. The average time spent by dma_pool_free() to free the DMA pool in this case lies between 1 usec to 2 usec. value ------------- Distribution ------------- count 256 | 0 512 |@@@@@@@@@@@@@@@@@@ 346 1024 |@@@@@@@@@@@@@@@@@@@@@@ 435 2048 | 0 4096 | 0 8192 | 1 16384 | 0 Signed-off-by: Anand Khoje <[email protected]> Reviewed-by: Leon Romanovsky <[email protected]> Reviewed-by: Zhu Yanjun <[email protected]> Acked-by: Saeed Mahameed <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent c9c0ee5 commit 501c300

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,11 @@ enum {
608608
RELEASE_ALL_PAGES_MASK = 0x4000,
609609
};
610610

611+
/* This limit is based on the capability of the firmware as it cannot release
612+
* more than 50000 back to the host in one go.
613+
*/
614+
#define MAX_RECLAIM_NPAGES (-50000)
615+
611616
static int req_pages_handler(struct notifier_block *nb,
612617
unsigned long type, void *data)
613618
{
@@ -639,7 +644,16 @@ static int req_pages_handler(struct notifier_block *nb,
639644

640645
req->dev = dev;
641646
req->func_id = func_id;
642-
req->npages = npages;
647+
648+
/* npages > 0 means HCA asking host to allocate/give pages,
649+
* npages < 0 means HCA asking host to reclaim back the pages allocated.
650+
* Here we are restricting the maximum number of pages that can be
651+
* reclaimed to be MAX_RECLAIM_NPAGES. Note that MAX_RECLAIM_NPAGES is
652+
* a negative value.
653+
* Since MAX_RECLAIM is negative, we are using max() to restrict
654+
* req->npages (and not min ()).
655+
*/
656+
req->npages = max_t(s32, npages, MAX_RECLAIM_NPAGES);
643657
req->ec_function = ec_function;
644658
req->release_all = release_all;
645659
INIT_WORK(&req->work, pages_work_handler);

0 commit comments

Comments
 (0)