Commit 7527a7b1 authored by Parav Pandit's avatar Parav Pandit Committed by Jason Gunthorpe

IB/core: Simplify rdma cgroup registration

RDMA cgroup registration routine always returns success, so simplify
function to be void and run clang formatter over whole CONFIG_CGROUP_RDMA
art of core_priv.h.

This reduces unwinding error path for regular registration and future net
namespace change functionality for rdma device.
Signed-off-by: default avatarParav Pandit <parav@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Acked-by: default avatarTejun Heo <tj@kernel.org>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent 8ea175f0
...@@ -21,12 +21,11 @@ ...@@ -21,12 +21,11 @@
* Register with the rdma cgroup. Should be called before * Register with the rdma cgroup. Should be called before
* exposing rdma device to user space applications to avoid * exposing rdma device to user space applications to avoid
* resource accounting leak. * resource accounting leak.
* Returns 0 on success or otherwise failure code.
*/ */
int ib_device_register_rdmacg(struct ib_device *device) void ib_device_register_rdmacg(struct ib_device *device)
{ {
device->cg_device.name = device->name; device->cg_device.name = device->name;
return rdmacg_register_device(&device->cg_device); rdmacg_register_device(&device->cg_device);
} }
/** /**
......
...@@ -115,7 +115,7 @@ void ib_cache_cleanup_one(struct ib_device *device); ...@@ -115,7 +115,7 @@ void ib_cache_cleanup_one(struct ib_device *device);
void ib_cache_release_one(struct ib_device *device); void ib_cache_release_one(struct ib_device *device);
#ifdef CONFIG_CGROUP_RDMA #ifdef CONFIG_CGROUP_RDMA
int ib_device_register_rdmacg(struct ib_device *device); void ib_device_register_rdmacg(struct ib_device *device);
void ib_device_unregister_rdmacg(struct ib_device *device); void ib_device_unregister_rdmacg(struct ib_device *device);
int ib_rdmacg_try_charge(struct ib_rdmacg_object *cg_obj, int ib_rdmacg_try_charge(struct ib_rdmacg_object *cg_obj,
...@@ -126,21 +126,26 @@ void ib_rdmacg_uncharge(struct ib_rdmacg_object *cg_obj, ...@@ -126,21 +126,26 @@ void ib_rdmacg_uncharge(struct ib_rdmacg_object *cg_obj,
struct ib_device *device, struct ib_device *device,
enum rdmacg_resource_type resource_index); enum rdmacg_resource_type resource_index);
#else #else
static inline int ib_device_register_rdmacg(struct ib_device *device) static inline void ib_device_register_rdmacg(struct ib_device *device)
{ return 0; } {
}
static inline void ib_device_unregister_rdmacg(struct ib_device *device) static inline void ib_device_unregister_rdmacg(struct ib_device *device)
{ } {
}
static inline int ib_rdmacg_try_charge(struct ib_rdmacg_object *cg_obj, static inline int ib_rdmacg_try_charge(struct ib_rdmacg_object *cg_obj,
struct ib_device *device, struct ib_device *device,
enum rdmacg_resource_type resource_index) enum rdmacg_resource_type resource_index)
{ return 0; } {
return 0;
}
static inline void ib_rdmacg_uncharge(struct ib_rdmacg_object *cg_obj, static inline void ib_rdmacg_uncharge(struct ib_rdmacg_object *cg_obj,
struct ib_device *device, struct ib_device *device,
enum rdmacg_resource_type resource_index) enum rdmacg_resource_type resource_index)
{ } {
}
#endif #endif
static inline bool rdma_is_upper_dev_rcu(struct net_device *dev, static inline bool rdma_is_upper_dev_rcu(struct net_device *dev,
......
...@@ -599,12 +599,7 @@ int ib_register_device(struct ib_device *device, const char *name) ...@@ -599,12 +599,7 @@ int ib_register_device(struct ib_device *device, const char *name)
device->index = __dev_new_index(); device->index = __dev_new_index();
ret = ib_device_register_rdmacg(device); ib_device_register_rdmacg(device);
if (ret) {
dev_warn(&device->dev,
"Couldn't register device with rdma cgroup\n");
goto dev_cleanup;
}
ret = ib_device_register_sysfs(device); ret = ib_device_register_sysfs(device);
if (ret) { if (ret) {
...@@ -627,7 +622,6 @@ int ib_register_device(struct ib_device *device, const char *name) ...@@ -627,7 +622,6 @@ int ib_register_device(struct ib_device *device, const char *name)
cg_cleanup: cg_cleanup:
ib_device_unregister_rdmacg(device); ib_device_unregister_rdmacg(device);
dev_cleanup:
cleanup_device(device); cleanup_device(device);
out: out:
mutex_unlock(&device_mutex); mutex_unlock(&device_mutex);
......
...@@ -39,7 +39,7 @@ struct rdmacg_device { ...@@ -39,7 +39,7 @@ struct rdmacg_device {
* APIs for RDMA/IB stack to publish when a device wants to * APIs for RDMA/IB stack to publish when a device wants to
* participate in resource accounting * participate in resource accounting
*/ */
int rdmacg_register_device(struct rdmacg_device *device); void rdmacg_register_device(struct rdmacg_device *device);
void rdmacg_unregister_device(struct rdmacg_device *device); void rdmacg_unregister_device(struct rdmacg_device *device);
/* APIs for RDMA/IB stack to charge/uncharge pool specific resources */ /* APIs for RDMA/IB stack to charge/uncharge pool specific resources */
......
...@@ -313,10 +313,8 @@ EXPORT_SYMBOL(rdmacg_try_charge); ...@@ -313,10 +313,8 @@ EXPORT_SYMBOL(rdmacg_try_charge);
* If IB stack wish a device to participate in rdma cgroup resource * If IB stack wish a device to participate in rdma cgroup resource
* tracking, it must invoke this API to register with rdma cgroup before * tracking, it must invoke this API to register with rdma cgroup before
* any user space application can start using the RDMA resources. * any user space application can start using the RDMA resources.
* Returns 0 on success or EINVAL when table length given is beyond
* supported size.
*/ */
int rdmacg_register_device(struct rdmacg_device *device) void rdmacg_register_device(struct rdmacg_device *device)
{ {
INIT_LIST_HEAD(&device->dev_node); INIT_LIST_HEAD(&device->dev_node);
INIT_LIST_HEAD(&device->rpools); INIT_LIST_HEAD(&device->rpools);
...@@ -324,7 +322,6 @@ int rdmacg_register_device(struct rdmacg_device *device) ...@@ -324,7 +322,6 @@ int rdmacg_register_device(struct rdmacg_device *device)
mutex_lock(&rdmacg_mutex); mutex_lock(&rdmacg_mutex);
list_add_tail(&device->dev_node, &rdmacg_devices); list_add_tail(&device->dev_node, &rdmacg_devices);
mutex_unlock(&rdmacg_mutex); mutex_unlock(&rdmacg_mutex);
return 0;
} }
EXPORT_SYMBOL(rdmacg_register_device); EXPORT_SYMBOL(rdmacg_register_device);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment