mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	cma: Convert portspace IDRs to XArray
Signed-off-by: Matthew Wilcox <willy@infradead.org> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
This commit is contained in:
		
							parent
							
								
									81cc440883
								
							
						
					
					
						commit
						638267537a
					
				
					 1 changed files with 21 additions and 20 deletions
				
			
		| 
						 | 
				
			
			@ -39,7 +39,7 @@
 | 
			
		|||
#include <linux/mutex.h>
 | 
			
		||||
#include <linux/random.h>
 | 
			
		||||
#include <linux/igmp.h>
 | 
			
		||||
#include <linux/idr.h>
 | 
			
		||||
#include <linux/xarray.h>
 | 
			
		||||
#include <linux/inetdevice.h>
 | 
			
		||||
#include <linux/slab.h>
 | 
			
		||||
#include <linux/module.h>
 | 
			
		||||
| 
						 | 
				
			
			@ -191,10 +191,10 @@ static struct workqueue_struct *cma_wq;
 | 
			
		|||
static unsigned int cma_pernet_id;
 | 
			
		||||
 | 
			
		||||
struct cma_pernet {
 | 
			
		||||
	struct idr tcp_ps;
 | 
			
		||||
	struct idr udp_ps;
 | 
			
		||||
	struct idr ipoib_ps;
 | 
			
		||||
	struct idr ib_ps;
 | 
			
		||||
	struct xarray tcp_ps;
 | 
			
		||||
	struct xarray udp_ps;
 | 
			
		||||
	struct xarray ipoib_ps;
 | 
			
		||||
	struct xarray ib_ps;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static struct cma_pernet *cma_pernet(struct net *net)
 | 
			
		||||
| 
						 | 
				
			
			@ -202,7 +202,8 @@ static struct cma_pernet *cma_pernet(struct net *net)
 | 
			
		|||
	return net_generic(net, cma_pernet_id);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static struct idr *cma_pernet_idr(struct net *net, enum rdma_ucm_port_space ps)
 | 
			
		||||
static
 | 
			
		||||
struct xarray *cma_pernet_xa(struct net *net, enum rdma_ucm_port_space ps)
 | 
			
		||||
{
 | 
			
		||||
	struct cma_pernet *pernet = cma_pernet(net);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -247,25 +248,25 @@ struct class_port_info_context {
 | 
			
		|||
static int cma_ps_alloc(struct net *net, enum rdma_ucm_port_space ps,
 | 
			
		||||
			struct rdma_bind_list *bind_list, int snum)
 | 
			
		||||
{
 | 
			
		||||
	struct idr *idr = cma_pernet_idr(net, ps);
 | 
			
		||||
	struct xarray *xa = cma_pernet_xa(net, ps);
 | 
			
		||||
 | 
			
		||||
	return idr_alloc(idr, bind_list, snum, snum + 1, GFP_KERNEL);
 | 
			
		||||
	return xa_insert(xa, snum, bind_list, GFP_KERNEL);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static struct rdma_bind_list *cma_ps_find(struct net *net,
 | 
			
		||||
					  enum rdma_ucm_port_space ps, int snum)
 | 
			
		||||
{
 | 
			
		||||
	struct idr *idr = cma_pernet_idr(net, ps);
 | 
			
		||||
	struct xarray *xa = cma_pernet_xa(net, ps);
 | 
			
		||||
 | 
			
		||||
	return idr_find(idr, snum);
 | 
			
		||||
	return xa_load(xa, snum);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void cma_ps_remove(struct net *net, enum rdma_ucm_port_space ps,
 | 
			
		||||
			  int snum)
 | 
			
		||||
{
 | 
			
		||||
	struct idr *idr = cma_pernet_idr(net, ps);
 | 
			
		||||
	struct xarray *xa = cma_pernet_xa(net, ps);
 | 
			
		||||
 | 
			
		||||
	idr_remove(idr, snum);
 | 
			
		||||
	xa_erase(xa, snum);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
enum {
 | 
			
		||||
| 
						 | 
				
			
			@ -4655,10 +4656,10 @@ static int cma_init_net(struct net *net)
 | 
			
		|||
{
 | 
			
		||||
	struct cma_pernet *pernet = cma_pernet(net);
 | 
			
		||||
 | 
			
		||||
	idr_init(&pernet->tcp_ps);
 | 
			
		||||
	idr_init(&pernet->udp_ps);
 | 
			
		||||
	idr_init(&pernet->ipoib_ps);
 | 
			
		||||
	idr_init(&pernet->ib_ps);
 | 
			
		||||
	xa_init(&pernet->tcp_ps);
 | 
			
		||||
	xa_init(&pernet->udp_ps);
 | 
			
		||||
	xa_init(&pernet->ipoib_ps);
 | 
			
		||||
	xa_init(&pernet->ib_ps);
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -4667,10 +4668,10 @@ static void cma_exit_net(struct net *net)
 | 
			
		|||
{
 | 
			
		||||
	struct cma_pernet *pernet = cma_pernet(net);
 | 
			
		||||
 | 
			
		||||
	idr_destroy(&pernet->tcp_ps);
 | 
			
		||||
	idr_destroy(&pernet->udp_ps);
 | 
			
		||||
	idr_destroy(&pernet->ipoib_ps);
 | 
			
		||||
	idr_destroy(&pernet->ib_ps);
 | 
			
		||||
	WARN_ON(!xa_empty(&pernet->tcp_ps));
 | 
			
		||||
	WARN_ON(!xa_empty(&pernet->udp_ps));
 | 
			
		||||
	WARN_ON(!xa_empty(&pernet->ipoib_ps));
 | 
			
		||||
	WARN_ON(!xa_empty(&pernet->ib_ps));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static struct pernet_operations cma_pernet_operations = {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue