Lines Matching refs:type
69 static inline bool valid_type(enum misc_res_type type) in valid_type() argument
71 return type >= 0 && type < MISC_CG_RES_TYPES; in valid_type()
86 int misc_cg_set_capacity(enum misc_res_type type, u64 capacity) in misc_cg_set_capacity() argument
88 if (!valid_type(type)) in misc_cg_set_capacity()
91 WRITE_ONCE(misc_res_capacity[type], capacity); in misc_cg_set_capacity()
104 static void misc_cg_cancel_charge(enum misc_res_type type, struct misc_cg *cg, in misc_cg_cancel_charge() argument
107 WARN_ONCE(atomic64_add_negative(-amount, &cg->res[type].usage), in misc_cg_cancel_charge()
109 misc_res_name[type]); in misc_cg_cancel_charge()
125 static void misc_cg_event(enum misc_res_type type, struct misc_cg *cg) in misc_cg_event() argument
127 atomic64_inc(&cg->res[type].events_local); in misc_cg_event()
131 atomic64_inc(&cg->res[type].events); in misc_cg_event()
152 int misc_cg_try_charge(enum misc_res_type type, struct misc_cg *cg, u64 amount) in misc_cg_try_charge() argument
159 if (!(valid_type(type) && cg && READ_ONCE(misc_res_capacity[type]))) in misc_cg_try_charge()
166 res = &i->res[type]; in misc_cg_try_charge()
170 new_usage > READ_ONCE(misc_res_capacity[type])) { in misc_cg_try_charge()
179 misc_cg_event(type, i); in misc_cg_try_charge()
182 misc_cg_cancel_charge(type, j, amount); in misc_cg_try_charge()
183 misc_cg_cancel_charge(type, i, amount); in misc_cg_try_charge()
196 void misc_cg_uncharge(enum misc_res_type type, struct misc_cg *cg, u64 amount) in misc_cg_uncharge() argument
200 if (!(amount && valid_type(type) && cg)) in misc_cg_uncharge()
204 misc_cg_cancel_charge(type, i, amount); in misc_cg_uncharge()
260 enum misc_res_type type = MISC_CG_RES_TYPES; in misc_cg_max_write() local
271 type = i; in misc_cg_max_write()
276 if (type == MISC_CG_RES_TYPES) in misc_cg_max_write()
289 if (READ_ONCE(misc_res_capacity[type])) in misc_cg_max_write()
290 WRITE_ONCE(cg->res[type].max, max); in misc_cg_max_write()