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(atomic64_add_negative(-amount, &cg->res[type].usage), in misc_cg_cancel_charge()
129 old = atomic64_read(&res->watermark); in misc_cg_update_watermark()
132 if (atomic64_cmpxchg(&res->watermark, old, new_usage) == old) in misc_cg_update_watermark()
139 atomic64_inc(&cg->res[type].events_local); in misc_cg_event()
140 cgroup_file_notify(&cg->events_local_file); in misc_cg_event()
143 atomic64_inc(&cg->res[type].events); in misc_cg_event()
144 cgroup_file_notify(&cg->events_file); in misc_cg_event()
149 * misc_cg_try_charge() - Try charging the misc cgroup.
159 * * %0 - If successfully charged.
160 * * -EINVAL - If @type is invalid or misc res has 0 capacity.
161 * * -EBUSY - If max limit will be crossed or total usage will be more than the
172 return -EINVAL; in misc_cg_try_charge()
178 res = &i->res[type]; in misc_cg_try_charge()
180 new_usage = atomic64_add_return(amount, &res->usage); in misc_cg_try_charge()
181 if (new_usage > READ_ONCE(res->max) || in misc_cg_try_charge()
183 ret = -EBUSY; in misc_cg_try_charge()
201 * misc_cg_uncharge() - Uncharge the misc cgroup.
221 * misc_cg_max_show() - Show the misc cgroup max limit.
236 max = READ_ONCE(cg->res[i].max); in misc_cg_max_show()
249 * misc_cg_max_write() - Update the maximum limit of the cgroup.
262 * * >= 0 - Number of bytes processed in the input.
263 * * -EINVAL - If buf is not valid.
264 * * -ERANGE - If number is bigger than the u64 capacity.
273 char *token; in misc_cg_max_write() local
276 token = strsep(&buf, " "); in misc_cg_max_write()
278 if (!token || !buf) in misc_cg_max_write()
279 return -EINVAL; in misc_cg_max_write()
282 if (!strcmp(misc_res_name[i], token)) { in misc_cg_max_write()
289 return -EINVAL; in misc_cg_max_write()
302 WRITE_ONCE(cg->res[type].max, max); in misc_cg_max_write()
304 ret = -EINVAL; in misc_cg_max_write()
310 * misc_cg_current_show() - Show the current usage of the misc cgroup.
324 usage = atomic64_read(&cg->res[i].usage); in misc_cg_current_show()
333 * misc_cg_peak_show() - Show the peak usage of the misc cgroup.
347 watermark = atomic64_read(&cg->res[i].watermark); in misc_cg_peak_show()
356 * misc_cg_capacity_show() - Show the total capacity of misc res on the host.
387 events = atomic64_read(&cg->res[i].events_local); in __misc_events_show()
389 events = atomic64_read(&cg->res[i].events); in __misc_events_show()
443 * misc_cg_alloc() - Allocate misc cgroup.
448 * * struct cgroup_subsys_state* - css of the allocated cgroup.
449 * * ERR_PTR(-ENOMEM) - No memory available to allocate.
462 return ERR_PTR(-ENOMEM); in misc_cg_alloc()
466 WRITE_ONCE(cg->res[i].max, MAX_NUM); in misc_cg_alloc()
467 atomic64_set(&cg->res[i].usage, 0); in misc_cg_alloc()
470 return &cg->css; in misc_cg_alloc()
474 * misc_cg_free() - Free the misc cgroup.