forked from Minki/linux
RDMA/restrack: Add support to get resource tracking for SRQ
In order to track SRQ resources, a new restrack object is initialized and added to the resource tracking database. Link: https://lore.kernel.org/r/0db71c409f24f2f6b019bf8797a8fed96fe7079c.1618753110.git.leonro@nvidia.com Signed-off-by: Neta Ostrovsky <netao@nvidia.com> Reviewed-by: Mark Zhang <markzhang@nvidia.com> Signed-off-by: Leon Romanovsky <leonro@nvidia.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
This commit is contained in:
parent
12ce208f40
commit
48f8a70e89
@ -47,6 +47,7 @@ static const char *type2str(enum rdma_restrack_type type)
|
||||
[RDMA_RESTRACK_MR] = "MR",
|
||||
[RDMA_RESTRACK_CTX] = "CTX",
|
||||
[RDMA_RESTRACK_COUNTER] = "COUNTER",
|
||||
[RDMA_RESTRACK_SRQ] = "SRQ",
|
||||
};
|
||||
|
||||
return names[type];
|
||||
@ -141,6 +142,8 @@ static struct ib_device *res_to_dev(struct rdma_restrack_entry *res)
|
||||
return container_of(res, struct ib_ucontext, res)->device;
|
||||
case RDMA_RESTRACK_COUNTER:
|
||||
return container_of(res, struct rdma_counter, res)->device;
|
||||
case RDMA_RESTRACK_SRQ:
|
||||
return container_of(res, struct ib_srq, res)->device;
|
||||
default:
|
||||
WARN_ONCE(true, "Wrong resource tracking type %u\n", res->type);
|
||||
return NULL;
|
||||
|
@ -1039,8 +1039,12 @@ struct ib_srq *ib_create_srq_user(struct ib_pd *pd,
|
||||
}
|
||||
atomic_inc(&pd->usecnt);
|
||||
|
||||
rdma_restrack_new(&srq->res, RDMA_RESTRACK_SRQ);
|
||||
rdma_restrack_parent_name(&srq->res, &pd->res);
|
||||
|
||||
ret = pd->device->ops.create_srq(srq, srq_init_attr, udata);
|
||||
if (ret) {
|
||||
rdma_restrack_put(&srq->res);
|
||||
atomic_dec(&srq->pd->usecnt);
|
||||
if (srq->srq_type == IB_SRQT_XRC)
|
||||
atomic_dec(&srq->ext.xrc.xrcd->usecnt);
|
||||
@ -1050,6 +1054,8 @@ struct ib_srq *ib_create_srq_user(struct ib_pd *pd,
|
||||
return ERR_PTR(ret);
|
||||
}
|
||||
|
||||
rdma_restrack_add(&srq->res);
|
||||
|
||||
return srq;
|
||||
}
|
||||
EXPORT_SYMBOL(ib_create_srq_user);
|
||||
@ -1088,6 +1094,7 @@ int ib_destroy_srq_user(struct ib_srq *srq, struct ib_udata *udata)
|
||||
atomic_dec(&srq->ext.xrc.xrcd->usecnt);
|
||||
if (ib_srq_has_cq(srq->srq_type))
|
||||
atomic_dec(&srq->ext.cq->usecnt);
|
||||
rdma_restrack_del(&srq->res);
|
||||
kfree(srq);
|
||||
|
||||
return ret;
|
||||
|
@ -1610,6 +1610,11 @@ struct ib_srq {
|
||||
} xrc;
|
||||
};
|
||||
} ext;
|
||||
|
||||
/*
|
||||
* Implementation details of the RDMA core, don't use in drivers:
|
||||
*/
|
||||
struct rdma_restrack_entry res;
|
||||
};
|
||||
|
||||
enum ib_raw_packet_caps {
|
||||
|
@ -49,6 +49,10 @@ enum rdma_restrack_type {
|
||||
* @RDMA_RESTRACK_COUNTER: Statistic Counter
|
||||
*/
|
||||
RDMA_RESTRACK_COUNTER,
|
||||
/**
|
||||
* @RDMA_RESTRACK_SRQ: Shared receive queue (SRQ)
|
||||
*/
|
||||
RDMA_RESTRACK_SRQ,
|
||||
/**
|
||||
* @RDMA_RESTRACK_MAX: Last entry, used for array dclarations
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user