Lines Matching refs:type
65 static inline bool valid_type(enum misc_res_type type) in valid_type() argument
67 return type >= 0 && type < MISC_CG_RES_TYPES; in valid_type()
77 unsigned long misc_cg_res_total_usage(enum misc_res_type type) in misc_cg_res_total_usage() argument
79 if (valid_type(type)) in misc_cg_res_total_usage()
80 return atomic_long_read(&root_cg.res[type].usage); in misc_cg_res_total_usage()
98 int misc_cg_set_capacity(enum misc_res_type type, unsigned long capacity) in misc_cg_set_capacity() argument
100 if (!valid_type(type)) in misc_cg_set_capacity()
103 WRITE_ONCE(misc_res_capacity[type], capacity); in misc_cg_set_capacity()
116 static void misc_cg_cancel_charge(enum misc_res_type type, struct misc_cg *cg, in misc_cg_cancel_charge() argument
119 WARN_ONCE(atomic_long_add_negative(-amount, &cg->res[type].usage), in misc_cg_cancel_charge()
121 misc_res_name[type]); in misc_cg_cancel_charge()
140 int misc_cg_try_charge(enum misc_res_type type, struct misc_cg *cg, in misc_cg_try_charge() argument
148 if (!(valid_type(type) && cg && READ_ONCE(misc_res_capacity[type]))) in misc_cg_try_charge()
155 res = &i->res[type]; in misc_cg_try_charge()
159 new_usage > READ_ONCE(misc_res_capacity[type])) { in misc_cg_try_charge()
168 atomic_long_inc(&j->res[type].events); in misc_cg_try_charge()
173 misc_cg_cancel_charge(type, j, amount); in misc_cg_try_charge()
174 misc_cg_cancel_charge(type, i, amount); in misc_cg_try_charge()
187 void misc_cg_uncharge(enum misc_res_type type, struct misc_cg *cg, in misc_cg_uncharge() argument
192 if (!(amount && valid_type(type) && cg)) in misc_cg_uncharge()
196 misc_cg_cancel_charge(type, i, amount); in misc_cg_uncharge()
252 enum misc_res_type type = MISC_CG_RES_TYPES; in misc_cg_max_write() local
263 type = i; in misc_cg_max_write()
268 if (type == MISC_CG_RES_TYPES) in misc_cg_max_write()
281 if (READ_ONCE(misc_res_capacity[type])) in misc_cg_max_write()
282 WRITE_ONCE(cg->res[type].max, max); in misc_cg_max_write()