Lines Matching +full:sync +full:- +full:token

1 // SPDX-License-Identifier: GPL-2.0
19 /* Miscellaneous res name, keep it in sync with enum misc_res_type */
24 /* AMD SEV-ES ASIDs resource */
43 * parent_misc() - Get the parent of the passed misc cgroup.
48 * * struct misc_cg* - Parent of the @cgroup.
49 * * %NULL - If @cgroup is null or the passed cgroup does not have a parent.
53 return cgroup ? css_misc(cgroup->css.parent) : NULL; in parent_misc()
57 * valid_type() - Check if @type is valid or not.
62 * * true - If valid type.
63 * * false - If not valid type.
71 * misc_cg_res_total_usage() - Get the current total usage of the resource.
87 * misc_cg_set_capacity() - Set the capacity of the misc cgroup res.
95 * * %0 - Successfully registered the capacity.
96 * * %-EINVAL - If @type is invalid.
101 return -EINVAL; in misc_cg_set_capacity()
109 * misc_cg_cancel_charge() - Cancel the charge from the misc cgroup.
119 WARN_ONCE(atomic_long_add_negative(-amount, &cg->res[type].usage), in misc_cg_cancel_charge()
125 * misc_cg_try_charge() - Try charging the misc cgroup.
135 * * %0 - If successfully charged.
136 * * -EINVAL - If @type is invalid or misc res has 0 capacity.
137 * * -EBUSY - If max limit will be crossed or total usage will be more than the
149 return -EINVAL; in misc_cg_try_charge()
155 res = &i->res[type]; in misc_cg_try_charge()
157 new_usage = atomic_long_add_return(amount, &res->usage); in misc_cg_try_charge()
158 if (new_usage > READ_ONCE(res->max) || in misc_cg_try_charge()
160 ret = -EBUSY; in misc_cg_try_charge()
168 atomic_long_inc(&j->res[type].events); in misc_cg_try_charge()
169 cgroup_file_notify(&j->events_file); in misc_cg_try_charge()
180 * misc_cg_uncharge() - Uncharge the misc cgroup.
201 * misc_cg_max_show() - Show the misc cgroup max limit.
216 max = READ_ONCE(cg->res[i].max); in misc_cg_max_show()
229 * misc_cg_max_write() - Update the maximum limit of the cgroup.
242 * * >= 0 - Number of bytes processed in the input.
243 * * -EINVAL - If buf is not valid.
244 * * -ERANGE - If number is bigger than the unsigned long capacity.
253 char *token; in misc_cg_max_write() local
256 token = strsep(&buf, " "); in misc_cg_max_write()
258 if (!token || !buf) in misc_cg_max_write()
259 return -EINVAL; in misc_cg_max_write()
262 if (!strcmp(misc_res_name[i], token)) { in misc_cg_max_write()
269 return -EINVAL; in misc_cg_max_write()
282 WRITE_ONCE(cg->res[type].max, max); in misc_cg_max_write()
284 ret = -EINVAL; in misc_cg_max_write()
290 * misc_cg_current_show() - Show the current usage of the misc cgroup.
304 usage = atomic_long_read(&cg->res[i].usage); in misc_cg_current_show()
313 * misc_cg_capacity_show() - Show the total capacity of misc res on the host.
342 events = atomic_long_read(&cg->res[i].events); in misc_events_show()
377 * misc_cg_alloc() - Allocate misc cgroup.
382 * * struct cgroup_subsys_state* - css of the allocated cgroup.
383 * * ERR_PTR(-ENOMEM) - No memory available to allocate.
396 return ERR_PTR(-ENOMEM); in misc_cg_alloc()
400 WRITE_ONCE(cg->res[i].max, MAX_NUM); in misc_cg_alloc()
401 atomic_long_set(&cg->res[i].usage, 0); in misc_cg_alloc()
404 return &cg->css; in misc_cg_alloc()
408 * misc_cg_free() - Free the misc cgroup.