rdma controller support
Subsystems (3)
v2 cover rdma controller support
This patchset adds support for RDMA cgroup by addressing review comments of [2], [1] and by implementing published RFC [3].
Overview:
Currently user space applications can easily take away all the rdma device specific resources such as AH, CQ, QP, MR etc. Due to which other applications in other cgroup or kernel space ULPs may not even get chance to allocate any rdma resources. This results into service unavailibility.
RDMA cgroup addresses this issue by allowing resource accounting, limit enforcement on per cgroup, per rdma device basis.
Resources are not defined by the RDMA cgroup. Resources are defined by RDMA/IB stack & optionally by HCA vendor device drivers. This allows rdma cgroup to remain constant while RDMA/IB stack can evolve without the need of rdma cgroup update. A new resource can be easily added by the RDMA/IB stack without touching rdma cgroup.
RDMA uverbs layer will enforce limits on well defined RDMA verb resources without any HCA vendor device driver involvement.
RDMA uverbs layer will not do accounting of hw vendor specific resources. Instead rdma cgroup provides set of APIs through which vendor specific drivers can define their own resources (upto 64) that can be accounted by rdma cgroup.
Resource limit enforcement is hierarchical.
When process is migrated with active RDMA resources, rdma cgroup continues to uncharge original cgroup for allocated resource. New resource is charged to current process's cgroup, which means if the process is migrated with active resources, for new resources it will be charged to new cgroup and old resources will be correctly uncharged from old cgroup.
Changes from v1:
* (To address comments from Tejun)
a. reduces 3 patches to single patch
b. removed resource word from the cgroup configuration files c. changed cgroup configuration file names to match other cgroups d. removed .list file and merged functionality with .max file
* Based on comment to merge to single patch for rdma controller; IB/core patches are reduced to single patch.
* Removed pid cgroup map and simplified design - Charge/Uncharge caller stack keeps track of the rdmacg for given resource. This removes the need to maintain and perform hash lookup. This also allows little more accurate resource charging/uncharging when process moved from one to other cgroup with active resources and continue to allocate more.
* Critical fix: Removed rdma cgroup's dependency on the kernel module header files to avoid crashes when modules are upgraded without kernel upgrade, which is very common due to high amount of changes in IB stack and it is also shipped as individual kernel modules.
* uboject extended to keep track of the owner rdma cgroup, so that same rdmacg can be used while uncharging.
* Added support functions to hide details of rdmacg device in uverbs modules for cases of cgroup enabled/disabled at compile time. This avoids multiple ifdefs for every API in uverbs layer.
* Removed failure counters in first patch, which will be added once initial feature is merged.
* Fixed stale rpool access which is getting freed, while doing configuration to rdma.verb.max file.
* Fixed rpool resource leak while querying max, current values.
Changes from v0:
(To address comments from Haggai, Doug, Liran, Tejun, Sean, Jason)
* Redesigned to support per device per cgroup limit settings by bringing concept of resource pool.
* Redesigned to let IB stack define the resources instead of rdma controller using resource template.
* Redesigned to support hw vendor specific limits setting (optional to drivers).
* Created new rdma controller instead of piggyback on device cgroup.
* Fixed race conditions for multiple tasks sharing rdma resources.
* Removed dependency on the task_struct.
[1] https://lkml.org/lkml/2016/1/5/632
[2] https://lkml.org/lkml/2015/9/7/476
[3] https://lkml.org/lkml/2015/10/28/144
This patchset is for Tejun's for-4.5 branch.
It is not attempted on Doug's rdma tree yet, which I will do once I receive comments for this pathset.
Parav Pandit (3):
rdmacg: Added rdma cgroup controller. IB/core: added support to use rdma cgroup controller
rdmacg: Added documentation for rdma controller
Documentation/cgroup-v1/rdma.txt | 122 ++++ Documentation/cgroup-v2.txt | 43 ++ drivers/infiniband/core/Makefile | 1 + drivers/infiniband/core/cgroup.c | 108 ++++ drivers/infiniband/core/core_priv.h | 45 ++ drivers/infiniband/core/device.c | 8 + drivers/infiniband/core/uverbs_cmd.c | 209 ++++++- drivers/infiniband/core/uverbs_main.c | 28 + include/linux/cgroup_rdma.h | 78 +++ include/linux/cgroup_subsys.h | 4 + include/rdma/ib_verbs.h | 27 +- init/Kconfig | 12 + kernel/Makefile | 1 + kernel/cgroup_rdma.c | 1021 +++++++++++++++++++++++++++++++++ 14 files changed, 1691 insertions(+), 16 deletions(-) create mode 100644 Documentation/cgroup-v1/rdma.txt create mode 100644 drivers/infiniband/core/cgroup.c create mode 100644 include/linux/cgroup_rdma.h create mode 100644 kernel/cgroup_rdma.c
Signature · 1 line
1.8.3.1
PATCH v2 1/3 rdmacg: Added rdma cgroup controller.
Added rdma cgroup controller that does accounting, limit enforcement on rdma/IB verbs and hw resources.
Added rdma cgroup header file which defines its APIs to perform charing/uncharing functionality and device registration which will participate in controller functions of accounting and limit enforcements. It also define rdmacg_device structure to bind IB stack and RDMA cgroup controller.
RDMA resources are tracked using resource pool. Resource pool is per device, per cgroup, per resource pool_type entity which allows setting up accounting limits on per device basis.
RDMA cgroup returns error when user space applications try to allocate resources more than its configured limit.
Rdma cgroup implements resource accounting for two types of resource pools.
(a) RDMA IB specification level verb resources defined by IB stack
(b) HCA vendor device specific resources defined by vendor device driver
Resources are not defined by the RDMA cgroup, instead they are defined by the external module, typically IB stack and optionally by HCA drivers for those RDMA devices which doesn't have one to one mapping of IB verb resource with hardware resource. This allows extending IB stack without changing kernel, which is frequent as IB stack is going through changes and enhancements.
--- include/linux/cgroup_rdma.h | 78 ++++ include/linux/cgroup_subsys.h | 4 + init/Kconfig | 12 + kernel/Makefile | 1 + kernel/cgroup_rdma.c | 1021 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 1116 insertions(+) create mode 100644 include/linux/cgroup_rdma.h create mode 100644 kernel/cgroup_rdma.c
include/linux/cgroup_rdma.h new file +78 -0
@@ -0,0 +1,78 @@ +#ifndef _CGROUP_RDMA_H +#define _CGROUP_RDMA_H + +#include <linux/cgroup.h> + +/* +* This file is subject to the terms and conditions of version 2 of the GNU +* General Public License. See the file COPYING in the main directory of the +* Linux distribution for more details. +*/ + +enum rdmacg_resource_pool_type { +RDMACG_RESOURCE_POOL_VERB , +RDMACG_RESOURCE_POOL_HW , +RDMACG_RESOURCE_POOL_TYPE_MAX , +}; + +struct rdma_cgroup { +struct cgroup_subsys_state css; + +spinlock_t cg_list_lock;/* protects cgroup resource pool list */ +struct list_head rpool_head;/* head to keep track of all resource +* pools that belongs to this cgroup. +*/ +}; + +#ifdef CONFIG_CGROUP_RDMA +#define RDMACG_MAX_RESOURCE_INDEX (64) + +struct match_token ; +struct rdmacg_device ; + +struct rdmacg_pool_info { +struct match_token *resource_table; +int resource_count; +}; + +struct rdmacg_resource_pool_ops { +struct rdmacg_pool_info * + (*get_resource_pool_tokens)(struct rdmacg_device *); +}; + +struct rdmacg_device { +struct rdmacg_resource_pool_ops + *rpool_ops[RDMACG_RESOURCE_POOL_TYPE_MAX ]; +struct list_head rdmacg_list; +char *name; +}; + +/* APIs for RDMA/IB stack to publish when a device wants to +* participate in resource accounting +*/ +void rdmacg_register_device (struct rdmacg_device *device,char *dev_name); +void rdmacg_unregister_device (struct rdmacg_device *device); + +/* APIs for RDMA/IB stack to charge/uncharge pool specific resources */ +int rdmacg_try_charge (struct rdma_cgroup **rdmacg, +struct rdmacg_device *device, +enum rdmacg_resource_pool_type type, +int resource_index, +int num); +void rdmacg_uncharge (struct rdma_cgroup *cg, +struct rdmacg_device *device, +enum rdmacg_resource_pool_type type, +int resource_index, +int num); + +void rdmacg_set_rpool_ops (struct rdmacg_device *device, +enum rdmacg_resource_pool_type pool_type, +struct rdmacg_resource_pool_ops *ops); +void rdmacg_clear_rpool_ops (struct rdmacg_device *device, +enum rdmacg_resource_pool_type pool_type); +int rdmacg_query_limit (struct rdmacg_device *device, +enum rdmacg_resource_pool_type type, +int *limits,int max_count); + +#endif /* CONFIG_CGROUP_RDMA */ +#endif /* _CGROUP_RDMA_H */
include/linux/cgroup_subsys.h +4 -0
@@ -56,6 +56,10 @@ SUBSYS(hugetlb) SUBSYS(pids)#endif +#if IS_ENABLED (CONFIG_CGROUP_RDMA ) +SUBSYS(rdma) +#endif +/* * The following subsystems are not supported on the default hierarchy. */
init/Kconfig +12 -0
@@ -1070,6 +1070,18 @@ config CGROUP_PIDS since the PIDs limit only affects a process's ability to fork, not to attach to a cgroup. +config CGROUP_RDMA + bool "RDMA controller" + help + Provides enforcement of RDMA resources at RDMA/IB verb level and + enforcement of any RDMA/IB capable hardware advertized resources. + Its fairly easy for applications to exhaust RDMA resources, which + can result into kernel consumers or other application consumers of + RDMA resources left with no resources. RDMA controller is designed + to stop this from happening. + Attaching existing processes with active RDMA resources to the cgroup + hierarchy will be allowed even if can cross the hierarchy's limit. + config CGROUP_FREEZER bool "Freezer controller" help
kernel/Makefile +1 -0
@@ -57,6 +57,7 @@ obj-$(CONFIG_COMPAT) += compat.o obj-$(CONFIG_CGROUPS) += cgroup.o obj-$(CONFIG_CGROUP_FREEZER) += cgroup_freezer.o obj-$(CONFIG_CGROUP_PIDS) += cgroup_pids.o +obj-$(CONFIG_CGROUP_RDMA) += cgroup_rdma.o obj-$(CONFIG_CPUSETS) += cpuset.o obj-$(CONFIG_UTS_NS) += utsname.o obj-$(CONFIG_USER_NS) += user_namespace.o
kernel/cgroup_rdma.c new file +1021 -0
1,021 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v2 2/3 IB/core: added support to use rdma cgroup controller
In reply to Parav PanditAdded support APIs for IB core to register/unregister every RDMA device with rdma cgroup for tracking verbs and hw resources.
IB core registers with rdma cgroup controller and also defines resources that can be accounted.
Added support APIs for uverbs layer to make use of rdma controller.
Added uverbs layer to perform resource charge/uncharge functionality.
--- drivers/infiniband/core/Makefile | 1 + drivers/infiniband/core/cgroup.c | 108 ++++++++++++++++++ drivers/infiniband/core/core_priv.h | 45 ++++++++ drivers/infiniband/core/device.c | 8 ++ drivers/infiniband/core/uverbs_cmd.c | 209 +++++++++++++++++++++++++++++++--- drivers/infiniband/core/uverbs_main.c | 28 +++++ include/rdma/ib_verbs.h | 27 ++++- 7 files changed, 410 insertions(+), 16 deletions(-) create mode 100644 drivers/infiniband/core/cgroup.c
drivers/infiniband/core/Makefile +1 -0
@@ -13,6 +13,7 @@ ib_core-y := packer.o ud_header.o verbs.o sysfs.o \ roce_gid_mgmt.o ib_core-$(CONFIG_INFINIBAND_USER_MEM) += umem.o ib_core-$(CONFIG_INFINIBAND_ON_DEMAND_PAGING) += umem_odp.o umem_rbtree.o +ib_core-$(CONFIG_CGROUP_RDMA) += cgroup.o ib_mad-y := mad.o smi.o agent.o mad_rmpp.o
drivers/infiniband/core/cgroup.c new file +108 -0
108 lines not on this page · raw message
drivers/infiniband/core/core_priv.h +45 -0
55 lines not on this page · raw message
drivers/infiniband/core/device.c +8 -0
@@ -352,6 +352,10 @@ int ib_register_device(struct ib_device *device, goto out; } +#ifdef CONFIG_CGROUP_RDMA +ib_device_register_rdmacg (device); +#endif + ret =ib_device_register_sysfs (device, port_callback);if (ret) { printk(KERN_WARNING "Couldn't register device %s with driver model\n",
@@ -405,6 +409,10 @@ void ib_unregister_device(struct ib_device *device)mutex_unlock (&device_mutex); +#ifdef CONFIG_CGROUP_RDMA +ib_device_unregister_rdmacg (device); +#endif +ib_device_unregister_sysfs (device);ib_cache_cleanup_one (device);
drivers/infiniband/core/uverbs_cmd.c +194 -15
539 lines not on this page · raw message
drivers/infiniband/core/uverbs_main.c +28 -0
@@ -49,6 +49,7 @@#include <asm/uaccess.h> #include "uverbs.h" +#include "core_priv.h" MODULE_AUTHOR ("Roland Dreier" );MODULE_DESCRIPTION ("InfiniBand userspace verbs access" );
@@ -214,6 +215,9 @@ static int ib_uverbs_cleanup_ucontext(struct ib_uverbs_file *file,list_for_each_entry_safe (uobj, tmp, &context->ah_list, list) {struct ib_ah *ah = uobj->object; +ib_rdmacg_uncharge (&uobj->cg_obj, ah->pd->device, +RDMACG_RESOURCE_POOL_VERB , +RDMA_VERB_RESOURCE_AH ,1 );idr_remove_uobj (&ib_uverbs_ah_idr, uobj);ib_destroy_ah (ah);kfree (uobj);
@@ -223,6 +227,9 @@ static int ib_uverbs_cleanup_ucontext(struct ib_uverbs_file *file,list_for_each_entry_safe (uobj, tmp, &context->mw_list, list) {struct ib_mw *mw = uobj->object; +ib_rdmacg_uncharge (&uobj->cg_obj, mw->pd->device, +RDMACG_RESOURCE_POOL_VERB , +RDMA_VERB_RESOURCE_MW ,1 );idr_remove_uobj (&ib_uverbs_mw_idr, uobj);ib_dealloc_mw (mw);kfree (uobj);
@@ -231,6 +238,9 @@ static int ib_uverbs_cleanup_ucontext(struct ib_uverbs_file *file,list_for_each_entry_safe (uobj, tmp, &context->rule_list, list) {struct ib_flow *flow_id = uobj->object; +ib_rdmacg_uncharge (&uobj->cg_obj, flow_id->qp->pd->device, +RDMACG_RESOURCE_POOL_VERB , +RDMA_VERB_RESOURCE_FLOW ,1 );idr_remove_uobj (&ib_uverbs_rule_idr, uobj);ib_destroy_flow (flow_id);kfree (uobj);
@@ -245,6 +255,9 @@ static int ib_uverbs_cleanup_ucontext(struct ib_uverbs_file *file,if (qp != qp->real_qp) {ib_close_qp (qp); }else { +ib_rdmacg_uncharge (&uobj->cg_obj, qp->pd->device, +RDMACG_RESOURCE_POOL_VERB , +RDMA_VERB_RESOURCE_QP ,1 );ib_uverbs_detach_umcast (qp, uqp);ib_destroy_qp (qp); }
@@ -257,6 +270,9 @@ static int ib_uverbs_cleanup_ucontext(struct ib_uverbs_file *file,struct ib_uevent_object *uevent = container_of(uobj, struct ib_uevent_object, uobject); +ib_rdmacg_uncharge (&uobj->cg_obj, srq->pd->device, +RDMACG_RESOURCE_POOL_VERB , +RDMA_VERB_RESOURCE_SRQ ,1 );idr_remove_uobj (&ib_uverbs_srq_idr, uobj);ib_destroy_srq (srq);ib_uverbs_release_uevent (file, uevent);
@@ -269,6 +285,9 @@ static int ib_uverbs_cleanup_ucontext(struct ib_uverbs_file *file,struct ib_ucq_object *ucq = container_of(uobj, struct ib_ucq_object, uobject); +ib_rdmacg_uncharge (&uobj->cg_obj, cq->device, +RDMACG_RESOURCE_POOL_VERB , +RDMA_VERB_RESOURCE_CQ ,1 );idr_remove_uobj (&ib_uverbs_cq_idr, uobj);ib_destroy_cq (cq);ib_uverbs_release_ucq (file, ev_file, ucq);
@@ -278,6 +297,9 @@ static int ib_uverbs_cleanup_ucontext(struct ib_uverbs_file *file,list_for_each_entry_safe (uobj, tmp, &context->mr_list, list) {struct ib_mr *mr = uobj->object; +ib_rdmacg_uncharge (&uobj->cg_obj, mr->pd->device, +RDMACG_RESOURCE_POOL_VERB , +RDMA_VERB_RESOURCE_MR ,1 );idr_remove_uobj (&ib_uverbs_mr_idr, uobj);ib_dereg_mr (mr);kfree (uobj);
@@ -298,11 +320,17 @@ static int ib_uverbs_cleanup_ucontext(struct ib_uverbs_file *file,list_for_each_entry_safe (uobj, tmp, &context->pd_list, list) {struct ib_pd *pd = uobj->object; +ib_rdmacg_uncharge (&uobj->cg_obj, pd->device, +RDMACG_RESOURCE_POOL_VERB , +RDMA_VERB_RESOURCE_PD ,1 );idr_remove_uobj (&ib_uverbs_pd_idr, uobj);ib_dealloc_pd (pd);kfree (uobj); } +ib_rdmacg_uncharge (&context->cg_obj, context->device, +RDMACG_RESOURCE_POOL_VERB , +RDMA_VERB_RESOURCE_UCTX ,1 );put_pid (context->tgid);return context->device->dealloc_ucontext (context);
include/rdma/ib_verbs.h +26 -1
@@ -55,6 +55,8 @@#include <linux/mmu_notifier.h> #include <asm/uaccess.h> +#include <linux/cgroup_rdma.h> +extern struct workqueue_struct *ib_wq;union ib_gid {
@@ -95,6 +97,19 @@ enum rdma_protocol_type {RDMA_PROTOCOL_USNIC_UDP }; +enum rdma_resource_type { +RDMA_VERB_RESOURCE_UCTX , +RDMA_VERB_RESOURCE_AH , +RDMA_VERB_RESOURCE_PD , +RDMA_VERB_RESOURCE_CQ , +RDMA_VERB_RESOURCE_MR , +RDMA_VERB_RESOURCE_MW , +RDMA_VERB_RESOURCE_SRQ , +RDMA_VERB_RESOURCE_QP , +RDMA_VERB_RESOURCE_FLOW , +RDMA_VERB_RESOURCE_MAX , +}; + __attribute_const__ enum rdma_transport_typerdma_node_get_transport (enum rdma_node_type node_type);
@@ -1231,6 +1246,12 @@ struct ib_fmr_attr {struct ib_umem ; +struct ib_rdmacg_object { +#ifdef CONFIG_CGROUP_RDMA +struct rdma_cgroup *cg;/* owner rdma cgroup */ +#endif +}; +struct ib_ucontext {struct ib_device *device;struct list_head pd_list;
@@ -1261,12 +1282,14 @@ struct ib_ucontext {struct list_head no_private_counters;int odp_mrs_count;#endif +struct ib_rdmacg_object cg_obj; };struct ib_uobject {u64 user_handle;/* handle given to us by userspace */ struct ib_ucontext *context;/* associated user context */ void *object;/* containing object */ +struct ib_rdmacg_object cg_obj;struct list_head list;/* link to context's list */ int id;/* index into kernel idr */ struct kref ref;
@@ -1822,7 +1845,9 @@ struct ib_device { u16 is_switch:1;u8 node_type;u8 phys_port_cnt; - +#ifdef CONFIG_CGROUP_RDMA +struct rdmacg_device cg_device; +#endif /** * The following mandatory functions are used only at device * registration. Keep functions such as these at the end of this
Signature · 1 line
1.8.3.1
kbuild test robot
build botRe: [PATCHv2 2/3] IB/core: added support to use rdma cgroup controller
reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree…
Hi Parav,
[auto build test ERROR on cgroup/for-next]
[cannot apply to v4.5-rc1 next-20160129]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]
url: https://github.com/0day-ci/linux/commits/Parav-Pandit/rdma-controller-support/20160130-194534 base: https://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup.git for-next config: m68k-sun3_defconfig (attached as .config)
reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=m68k
All errors (new ones prefixed by >>):
In file included from include/rdma/ib_verbs.h:58:0,
from include/rdma/ib_addr.h:47,
from include/rdma/rdma_cm.h:39,
from net/rds/rds.h:7,
from net/rds/af_rds.c:41:
>> include/linux/cgroup_rdma.h:19:29: error: field 'css' has incomplete type
struct cgroup_subsys_state css;
^vim +/css +19 include/linux/cgroup_rdma.h
f74be9d0 Parav Pandit 2016-01-30 13 RDMACG_RESOURCE_POOL_VERB,
f74be9d0 Parav Pandit 2016-01-30 14 RDMACG_RESOURCE_POOL_HW,
f74be9d0 Parav Pandit 2016-01-30 15 RDMACG_RESOURCE_POOL_TYPE_MAX,
f74be9d0 Parav Pandit 2016-01-30 16 };
f74be9d0 Parav Pandit 2016-01-30 17
f74be9d0 Parav Pandit 2016-01-30 18 struct rdma_cgroup {
f74be9d0 Parav Pandit 2016-01-30 @19 struct cgroup_subsys_state css;
f74be9d0 Parav Pandit 2016-01-30 20
f74be9d0 Parav Pandit 2016-01-30 21 spinlock_t cg_list_lock; /* protects cgroup resource pool list */
f74be9d0 Parav Pandit 2016-01-30 22 struct list_head rpool_head; /* head to keep track of all resource:::::: The code at line 19 was first introduced by commit
:::::: f74be9d0a094f209c9b8127317d9ce8d2f5dafea rdmacg: Added rdma cgroup controller.
:::::: TO: Parav Pandit <[email protected]> :::::: CC: 0day robot <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Re: [PATCHv2 2/3] IB/core: added support to use rdma cgroup controller
I am able to reproduce it.
Spinning v3 for the fix which will be actually in patch_1.
Parav
Quoted 48 lines · kbuild test robot
Hi Parav,
[auto build test ERROR on cgroup/for-next]
[cannot apply to v4.5-rc1 next-20160129]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]url: https://github.com/0day-ci/linux/commits/Parav-Pandit/rdma-controller-support/20160130-194534 base: https://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup.git for-next config: m68k-sun3_defconfig (attached as .config)reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=m68kAll errors (new ones prefixed by >>):
In file included from include/rdma/ib_verbs.h:58:0, from include/rdma/ib_addr.h:47, from include/rdma/rdma_cm.h:39, from net/rds/rds.h:7, from net/rds/af_rds.c:41:Quoted 1 line
Quoted 1 line
include/linux/cgroup_rdma.h:19:29: error: field 'css' has incomplete typestruct cgroup_subsys_state css; ^vim +/css +19
include/linux/cgroup_rdma.hf74be9d0 Parav Pandit 2016-01-30 13 RDMACG_RESOURCE_POOL_VERB, f74be9d0 Parav Pandit 2016-01-30 14 RDMACG_RESOURCE_POOL_HW, f74be9d0 Parav Pandit 2016-01-30 15 RDMACG_RESOURCE_POOL_TYPE_MAX, f74be9d0 Parav Pandit 2016-01-30 16 }; f74be9d0 Parav Pandit 2016-01-30 17 f74be9d0 Parav Pandit 2016-01-30 18 struct rdma_cgroup { f74be9d0 Parav Pandit 2016-01-30 @19 struct cgroup_subsys_state css; f74be9d0 Parav Pandit 2016-01-30 20 f74be9d0 Parav Pandit 2016-01-30 21 spinlock_t cg_list_lock; /* protects cgroup resource pool list */ f74be9d0 Parav Pandit 2016-01-30 22 struct list_head rpool_head; /* head to keep track of all resource:::::: The code at line 19 was first introduced by commit
::::::f74be9d0a094f209c9b8127317d9ce8d2f5dafeardmacg: Added rdma cgroup controller.:::::: TO: Parav Pandit <[email protected]> :::::: CC: 0day robot <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
PATCH v2 3/3 rdmacg: Added documentation for rdma controller
In reply to Parav PanditAdded documentation for rdma controller to use in legacy mode and using new unified hirerchy.
--- Documentation/cgroup-v1/rdma.txt | 122 +++++++++++++++++++++++++++++++++++++++ Documentation/cgroup-v2.txt | 43 ++++++++++++++ 2 files changed, 165 insertions(+) create mode 100644 Documentation/cgroup-v1/rdma.txt
Documentation/cgroup-v1/rdma.txt new file +122 -0
@@ -0,0 +1,122 @@ + RDMA Controller + ---------------- + +Contents +-------- + +1. Overview + 1-1. What is RDMA controller? + 1-2. Why RDMA controller needed? + 1-3. How is RDMA controller implemented? +2. Usage Examples + +1. Overview + +1-1. What is RDMA controller? +------------------------------------- + +RDMA controller allows user to limit RDMA/IB specific resources +that a given set of processes can use. These processes are grouped using +RDMA controller. + +RDMA controller currently allows two different type of resource +pools. +(a) RDMA IB specification level verb resources defined by IB stack +(b) HCA vendor device specific resources + +RDMA controller controller allows maximum of upto 64 resources in +a resource pool which is the internal construct of rdma cgroup explained +at later part of this document. + +1-2. Why RDMA controller needed? +---------------------------------------- + +Currently user space applications can easily take away all the rdma device +specific resources such as AH, CQ, QP, MR etc. Due to which other applications +in other cgroup or kernel space ULPs may not even get chance to allocate any +rdma resources. This leads to service unavailability. + +Therefore RDMA controller is needed through which resource consumption +of processes can be limited. Through this controller various different rdma +resources described by IB uverbs layer and any HCA vendor driver can be +accounted. + +1-3. How is RDMA controller implemented? +------------------------------------------------ + +RDMA cgroup allows limit configuration of resources. These resources are not +defined by the rdma controller. Instead they are defined by the IB stack +and HCA device drivers(optionally). +This provides great flexibility to allow IB stack to define new resources, +without any changes to rdma cgroup. +Rdma cgroup maintains resource accounting per cgroup, per device, per resource +type using resource pool structure. Each such resource pool is limited up to +64 resources in given resource pool by rdma cgroup, which can be extended +later if required. + +This resource pool object is linked to the cgroup css. Typically there +are 0 to 4 resource pool instances per cgroup, per device in most use cases. +But nothing limits to have it more. At present hundreds of RDMA devices per +single cgroup may not be handled optimally, however there is no known use case +for such configuration either. + +Since RDMA resources can be allocated from any process and can be freed by any +of the child processes which shares the address space, rdma resources are +always owned by the creator cgroup css. This allows process migration from one +to other cgroup without major complexity of transferring resource ownership; +because such ownership is not really present due to shared nature of +rdma resources. Linking resources around css also ensures that cgroups can be +deleted after processes migrated. This allow progress migration as well with +active resources, even though that’s not the primary use case. + +Whenever RDMA resource charing occurs, owner rdma cgroup is returned to +the caller. Same rdma cgroup should be passed while uncharging the resource. +This also allows process migrated with active RDMA resource to charge +to new owner cgroup for new resource. It also allows to uncharge resource of +a process from previously charged cgroup which is migrated to new cgroup, +even though that is not a primary use case. + +Resource pool object is created in following situations. +(a) User sets the limit and no previous resource pool exist for the device +of interest for the cgroup. +(b) No resource limits were configured, but IB/RDMA stack tries to +charge the resource. So that it correctly uncharge them when applications are +running without limits and later on when limits are enforced during uncharging, +otherwise usage count will drop to negative. This is done using default +resource pool. Instead of implementing any sort of time markers, default pool +simplifies the design. + +Resource pool is destroyed if it was of default type (not created +by administrative operation) and it’s the last resource getting +deallocated. Resource pool created as administrative operation is not +deleted, as it’s expected to be used in near future. + +If user setting tries to delete all the resource limit +with active resources per device, RDMA cgroup just marks the pool as +default pool with maximum limits for each resource, otherwise it deletes the +default resource pool. + +2. Usage Examples +----------------- + +(a) Configure resource limit: +echo mlx4_0 mr=100 qp=10 ah=2 > /sys/fs/cgroup/rdma/1/rdma.verb.max +echo ocrdma1 mr=120 qp=20 cq=10 > /sys/fs/cgroup/rdma/2/rdma.verb.max + +(b) Query resource limit: +cat /sys/fs/cgroup/rdma/2/rdma.verb.max +#Output: +mlx4_0 mr=100 qp=10 ah=2 +ocrdma1 mr=120 qp=20 cq=10 + +(c) Query current usage: +cat /sys/fs/cgroup/rdma/2/rdma.verb.current +#Output: +mlx4_0 mr=95 qp=8 ah=2 +ocrdma1 mr=0 qp=20 cq=10 + +(d) Delete resource limit: +echo mlx4_0 remove > /sys/fs/cgroup/rdma/1/rdma.verb.max + +(e) Configure hw specific resource limit: (optional) +echo vendor1 hw_qp=56 > /sys/fs/cgroup/rdma/2/rdma.hw.max
Documentation/cgroup-v2.txt +43 -0
55 lines not on this page · raw message
Signature · 1 line
1.8.3.1