Lines Matching defs:rpool
82 static void set_resource_limit(struct rdmacg_resource_pool *rpool,
86 if (rpool->resources[index].max != S32_MAX)
87 rpool->num_max_cnt++;
89 if (rpool->resources[index].max == S32_MAX)
90 rpool->num_max_cnt--;
92 rpool->resources[index].max = new_max;
95 static void set_all_resource_max_limit(struct rdmacg_resource_pool *rpool)
100 set_resource_limit(rpool, i, S32_MAX);
103 static void free_cg_rpool_locked(struct rdmacg_resource_pool *rpool)
107 list_del(&rpool->cg_node);
108 list_del(&rpool->dev_node);
109 kfree(rpool);
131 struct rdmacg_resource_pool *rpool;
133 rpool = find_cg_rpool_locked(cg, device);
134 if (rpool)
135 return rpool;
137 rpool = kzalloc(sizeof(*rpool), GFP_KERNEL);
138 if (!rpool)
141 rpool->device = device;
142 set_all_resource_max_limit(rpool);
144 INIT_LIST_HEAD(&rpool->cg_node);
145 INIT_LIST_HEAD(&rpool->dev_node);
146 list_add_tail(&rpool->cg_node, &cg->rpools);
147 list_add_tail(&rpool->dev_node, &device->rpools);
148 return rpool;
166 struct rdmacg_resource_pool *rpool;
168 rpool = find_cg_rpool_locked(cg, device);
171 * rpool cannot be null at this stage. Let kernel operate in case
175 if (unlikely(!rpool)) {
180 rpool->resources[index].usage--;
186 WARN_ON_ONCE(rpool->resources[index].usage < 0);
187 rpool->usage_sum--;
188 if (rpool->usage_sum == 0 &&
189 rpool->num_max_cnt == RDMACG_RESOURCE_MAX) {
191 * No user of the rpool and all entries are set to max, so
192 * safe to delete this rpool.
194 free_cg_rpool_locked(rpool);
266 struct rdmacg_resource_pool *rpool;
281 rpool = get_cg_rpool_locked(p, device);
282 if (IS_ERR(rpool)) {
283 ret = PTR_ERR(rpool);
286 new = rpool->resources[index].usage + 1;
287 if (new > rpool->resources[index].max) {
291 rpool->resources[index].usage = new;
292 rpool->usage_sum++;
338 struct rdmacg_resource_pool *rpool, *tmp;
349 * all the rpool resources.
351 list_for_each_entry_safe(rpool, tmp, &device->rpools, dev_node)
352 free_cg_rpool_locked(rpool);
432 struct rdmacg_resource_pool *rpool;
465 rpool = get_cg_rpool_locked(cg, device);
466 if (IS_ERR(rpool)) {
467 ret = PTR_ERR(rpool);
471 /* now set the new limits of the rpool */
473 set_resource_limit(rpool, i, new_limits[i]);
475 if (rpool->usage_sum == 0 &&
476 rpool->num_max_cnt == RDMACG_RESOURCE_MAX) {
478 * No user of the rpool and all entries are set to max, so
479 * safe to delete this rpool.
481 free_cg_rpool_locked(rpool);
495 struct rdmacg_resource_pool *rpool)
507 if (rpool)
508 value = rpool->resources[i].max;
512 if (rpool)
513 value = rpool->resources[i].usage;
529 struct rdmacg_resource_pool *rpool;
537 rpool = find_cg_rpool_locked(cg, device);
538 print_rpool_values(sf, rpool);
596 struct rdmacg_resource_pool *rpool;
600 list_for_each_entry(rpool, &cg->rpools, cg_node)
601 set_all_resource_max_limit(rpool);