Wait for all VFs pages to be reclaimed before closing EQ pages.

MFC after:		1 week
Sponsored by:		Mellanox Technologies
This commit is contained in:
Hans Petter Selasky 2017-01-27 11:19:06 +00:00
parent 310804912a
commit 44a03e91f3
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=312880
3 changed files with 32 additions and 2 deletions

View File

@ -43,6 +43,7 @@
#include <dev/mlx5/doorbell.h>
#define MLX5_QCOUNTER_SETS_NETDEV 64
#define MLX5_MAX_NUMBER_OF_VFS 128
enum {
MLX5_BOARD_ID_LEN = 64,
@ -521,7 +522,7 @@ struct mlx5_priv {
s64 fw_pages;
atomic_t reg_pages;
struct list_head free_list;
s64 pages_per_func[MLX5_MAX_NUMBER_OF_VFS];
struct mlx5_core_health health;
struct mlx5_srq_table srq_table;
@ -850,6 +851,7 @@ void mlx5_core_req_pages_handler(struct mlx5_core_dev *dev, u16 func_id,
s32 npages);
int mlx5_satisfy_startup_pages(struct mlx5_core_dev *dev, int boot);
int mlx5_reclaim_startup_pages(struct mlx5_core_dev *dev);
s64 mlx5_wait_for_reclaim_vfs_pages(struct mlx5_core_dev *dev);
void mlx5_register_debugfs(void);
void mlx5_unregister_debugfs(void);
int mlx5_eq_init(struct mlx5_core_dev *dev);

View File

@ -853,6 +853,7 @@ static void mlx5_dev_cleanup(struct mlx5_core_dev *dev)
mlx5_cleanup_qp_table(dev);
mlx5_cleanup_cq_table(dev);
unmap_bf_area(dev);
mlx5_wait_for_reclaim_vfs_pages(dev);
free_comp_eqs(dev);
mlx5_stop_eqs(dev);
mlx5_free_uuars(dev, &priv->uuari);

View File

@ -27,6 +27,7 @@
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/delay.h>
#include <dev/mlx5/driver.h>
#include "mlx5_core.h"
@ -282,6 +283,7 @@ static int give_pages(struct mlx5_core_dev *dev, u16 func_id, int npages,
goto out_alloc;
}
dev->priv.fw_pages += npages;
dev->priv.pages_per_func[func_id] += npages;
if (out.hdr.status) {
err = mlx5_cmd_status_to_err(&out.hdr);
@ -355,7 +357,7 @@ static int reclaim_pages(struct mlx5_core_dev *dev, u32 func_id, int npages,
*nclaimed = num_claimed;
dev->priv.fw_pages -= num_claimed;
dev->priv.pages_per_func[func_id] -= num_claimed;
for (i = 0; i < num_claimed; i++) {
addr = be64_to_cpu(out->pas[i]);
free_4k(dev, addr);
@ -423,6 +425,31 @@ enum {
MLX5_BLKS_FOR_RECLAIM_PAGES = 12
};
s64 mlx5_wait_for_reclaim_vfs_pages(struct mlx5_core_dev *dev)
{
int end = jiffies + msecs_to_jiffies(MAX_RECLAIM_TIME_MSECS);
s64 prevpages = 0;
s64 npages = 0;
while (!time_after(jiffies, end)) {
/* exclude own function, VFs only */
npages = dev->priv.fw_pages - dev->priv.pages_per_func[0];
if (!npages)
break;
if (npages != prevpages)
end = end + msecs_to_jiffies(100);
prevpages = npages;
msleep(1);
}
if (npages)
mlx5_core_warn(dev, "FW did not return all VFs pages, will cause to memory leak\n");
return -npages;
}
static int optimal_reclaimed_pages(void)
{
struct mlx5_cmd_prot_block *block;