RDMA/restrack: Convert internal DB from hash to XArray
The additions of .doit callbacks posses new access pattern to the resource entries by some user visible index. Back then, the legacy DB was implemented as hash because per-index access wasn't needed and XArray wasn't accepted yet. Acceptance of XArray together with per-index access requires the refresh of DB implementation. Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
This commit is contained in:

committed by
Jason Gunthorpe

parent
5f8f549900
commit
fd47c2f99f
@@ -13,6 +13,7 @@
|
||||
#include <linux/completion.h>
|
||||
#include <linux/sched/task.h>
|
||||
#include <uapi/rdma/rdma_netlink.h>
|
||||
#include <linux/xarray.h>
|
||||
|
||||
/**
|
||||
* enum rdma_restrack_type - HW objects to track
|
||||
@@ -48,7 +49,6 @@ enum rdma_restrack_type {
|
||||
RDMA_RESTRACK_MAX
|
||||
};
|
||||
|
||||
#define RDMA_RESTRACK_HASH_BITS 8
|
||||
struct ib_device;
|
||||
struct rdma_restrack_entry;
|
||||
|
||||
@@ -62,9 +62,17 @@ struct rdma_restrack_root {
|
||||
*/
|
||||
struct rw_semaphore rwsem;
|
||||
/**
|
||||
* @hash: global database for all resources per-device
|
||||
* @xa: Array of XArray structures to hold restrack entries.
|
||||
* We want to use array of XArrays because insertion is type
|
||||
* dependent. For types with xisiting unique ID (like QPN),
|
||||
* we will insert to that unique index. For other types,
|
||||
* we insert based on pointers and auto-allocate unique index.
|
||||
*/
|
||||
DECLARE_HASHTABLE(hash, RDMA_RESTRACK_HASH_BITS);
|
||||
struct xarray xa[RDMA_RESTRACK_MAX];
|
||||
/**
|
||||
* @next_id: Next ID to support cyclic allocation
|
||||
*/
|
||||
u32 next_id[RDMA_RESTRACK_MAX];
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -102,10 +110,6 @@ struct rdma_restrack_entry {
|
||||
* @kern_name: name of owner for the kernel created entities.
|
||||
*/
|
||||
const char *kern_name;
|
||||
/**
|
||||
* @node: hash table entry
|
||||
*/
|
||||
struct hlist_node node;
|
||||
/**
|
||||
* @type: various objects in restrack database
|
||||
*/
|
||||
@@ -114,6 +118,10 @@ struct rdma_restrack_entry {
|
||||
* @user: user resource
|
||||
*/
|
||||
bool user;
|
||||
/**
|
||||
* @id: ID to expose to users
|
||||
*/
|
||||
u32 id;
|
||||
};
|
||||
|
||||
void rdma_restrack_init(struct ib_device *dev);
|
||||
|
Reference in New Issue
Block a user