Lines Matching refs:rpool
82 static void set_resource_limit(struct rdmacg_resource_pool *rpool, in set_resource_limit() argument
86 if (rpool->resources[index].max != S32_MAX) in set_resource_limit()
87 rpool->num_max_cnt++; in set_resource_limit()
89 if (rpool->resources[index].max == S32_MAX) in set_resource_limit()
90 rpool->num_max_cnt--; in set_resource_limit()
92 rpool->resources[index].max = new_max; in set_resource_limit()
95 static void set_all_resource_max_limit(struct rdmacg_resource_pool *rpool) in set_all_resource_max_limit() argument
100 set_resource_limit(rpool, i, S32_MAX); in set_all_resource_max_limit()
103 static void free_cg_rpool_locked(struct rdmacg_resource_pool *rpool) in free_cg_rpool_locked() argument
107 list_del(&rpool->cg_node); in free_cg_rpool_locked()
108 list_del(&rpool->dev_node); in free_cg_rpool_locked()
109 kfree(rpool); in free_cg_rpool_locked()
131 struct rdmacg_resource_pool *rpool; in get_cg_rpool_locked() local
133 rpool = find_cg_rpool_locked(cg, device); in get_cg_rpool_locked()
134 if (rpool) in get_cg_rpool_locked()
135 return rpool; in get_cg_rpool_locked()
137 rpool = kzalloc(sizeof(*rpool), GFP_KERNEL); in get_cg_rpool_locked()
138 if (!rpool) in get_cg_rpool_locked()
141 rpool->device = device; in get_cg_rpool_locked()
142 set_all_resource_max_limit(rpool); in get_cg_rpool_locked()
144 INIT_LIST_HEAD(&rpool->cg_node); in get_cg_rpool_locked()
145 INIT_LIST_HEAD(&rpool->dev_node); in get_cg_rpool_locked()
146 list_add_tail(&rpool->cg_node, &cg->rpools); in get_cg_rpool_locked()
147 list_add_tail(&rpool->dev_node, &device->rpools); in get_cg_rpool_locked()
148 return rpool; in get_cg_rpool_locked()
166 struct rdmacg_resource_pool *rpool; in uncharge_cg_locked() local
168 rpool = find_cg_rpool_locked(cg, device); in uncharge_cg_locked()
175 if (unlikely(!rpool)) { in uncharge_cg_locked()
180 rpool->resources[index].usage--; in uncharge_cg_locked()
186 WARN_ON_ONCE(rpool->resources[index].usage < 0); in uncharge_cg_locked()
187 rpool->usage_sum--; in uncharge_cg_locked()
188 if (rpool->usage_sum == 0 && in uncharge_cg_locked()
189 rpool->num_max_cnt == RDMACG_RESOURCE_MAX) { in uncharge_cg_locked()
194 free_cg_rpool_locked(rpool); in uncharge_cg_locked()
264 struct rdmacg_resource_pool *rpool; in rdmacg_try_charge() local
279 rpool = get_cg_rpool_locked(p, device); in rdmacg_try_charge()
280 if (IS_ERR(rpool)) { in rdmacg_try_charge()
281 ret = PTR_ERR(rpool); in rdmacg_try_charge()
284 new = rpool->resources[index].usage + 1; in rdmacg_try_charge()
285 if (new > rpool->resources[index].max) { in rdmacg_try_charge()
289 rpool->resources[index].usage = new; in rdmacg_try_charge()
290 rpool->usage_sum++; in rdmacg_try_charge()
336 struct rdmacg_resource_pool *rpool, *tmp; in rdmacg_unregister_device() local
349 list_for_each_entry_safe(rpool, tmp, &device->rpools, dev_node) in rdmacg_unregister_device()
350 free_cg_rpool_locked(rpool); in rdmacg_unregister_device()
430 struct rdmacg_resource_pool *rpool; in rdmacg_resource_set_max() local
463 rpool = get_cg_rpool_locked(cg, device); in rdmacg_resource_set_max()
464 if (IS_ERR(rpool)) { in rdmacg_resource_set_max()
465 ret = PTR_ERR(rpool); in rdmacg_resource_set_max()
471 set_resource_limit(rpool, i, new_limits[i]); in rdmacg_resource_set_max()
473 if (rpool->usage_sum == 0 && in rdmacg_resource_set_max()
474 rpool->num_max_cnt == RDMACG_RESOURCE_MAX) { in rdmacg_resource_set_max()
479 free_cg_rpool_locked(rpool); in rdmacg_resource_set_max()
493 struct rdmacg_resource_pool *rpool) in print_rpool_values() argument
505 if (rpool) in print_rpool_values()
506 value = rpool->resources[i].max; in print_rpool_values()
510 if (rpool) in print_rpool_values()
511 value = rpool->resources[i].usage; in print_rpool_values()
527 struct rdmacg_resource_pool *rpool; in rdmacg_resource_read() local
535 rpool = find_cg_rpool_locked(cg, device); in rdmacg_resource_read()
536 print_rpool_values(sf, rpool); in rdmacg_resource_read()
594 struct rdmacg_resource_pool *rpool; in rdmacg_css_offline() local
598 list_for_each_entry(rpool, &cg->rpools, cg_node) in rdmacg_css_offline()
599 set_all_resource_max_limit(rpool); in rdmacg_css_offline()