Lines Matching +full:local +full:- +full:pid

1 // SPDX-License-Identifier: GPL-2.0-only
9 * in place, PIDs are a fundamental resource. As such, PID exhaustion must be
18 * violate a cgroup policy through fork(). fork() will return -EAGAIN if forking
22 * for all new cgroups (N.B. that PID limits are hierarchical, so the most
53 * Use 64-bit types so that we can safely represent "max" as
60 /* Handles for pids.events[.local] */
75 return css_pids(pids->css.parent); in parent_pids()
85 return ERR_PTR(-ENOMEM); in pids_css_alloc()
87 atomic64_set(&pids->limit, PIDS_MAX); in pids_css_alloc()
88 return &pids->css; in pids_css_alloc()
102 if (nr_pids > READ_ONCE(p->watermark)) in pids_update_watermark()
103 WRITE_ONCE(p->watermark, nr_pids); in pids_update_watermark()
107 * pids_cancel - uncharge the local pid count
108 * @pids: the pid cgroup state
111 * This function will WARN if the pid count goes under 0, because such a case is
120 WARN_ON_ONCE(atomic64_add_negative(-num, &pids->counter)); in pids_cancel()
124 * pids_uncharge - hierarchically uncharge the pid count
125 * @pids: the pid cgroup state
137 * pids_charge - hierarchically charge the pid count
138 * @pids: the pid cgroup state
141 * This function does *not* follow the pid limit set. It cannot fail and the new
142 * pid count may exceed the limit. This is only used for reverting failed
150 int64_t new = atomic64_add_return(num, &p->counter); in pids_charge()
157 * pids_try_charge - hierarchically try to charge the pid count
158 * @pids: the pid cgroup state
160 * @fail: storage of pid cgroup causing the fail
164 * succeeded, otherwise -EAGAIN.
171 int64_t new = atomic64_add_return(num, &p->counter); in pids_try_charge()
172 int64_t limit = atomic64_read(&p->limit); in pids_try_charge()
176 * p->limit is %PIDS_MAX then we know that this test will never in pids_try_charge()
197 return -EAGAIN; in pids_try_charge()
249 if (atomic64_inc_return(&p->events_local[PIDCG_FORKFAIL]) == 1) { in pids_event()
251 pr_cont_cgroup_path(p->css.cgroup); in pids_event()
256 cgroup_file_notify(&p->events_local_file); in pids_event()
260 atomic64_inc(&pids_over_limit->events_local[PIDCG_MAX]); in pids_event()
261 cgroup_file_notify(&pids_over_limit->events_local_file); in pids_event()
264 atomic64_inc(&p->events[PIDCG_MAX]); in pids_event()
265 cgroup_file_notify(&p->events_file); in pids_event()
278 pids = css_pids(cset->subsys[pids_cgrp_id]); in pids_can_fork()
290 pids = css_pids(cset->subsys[pids_cgrp_id]); in pids_cancel_fork()
320 return -EINVAL; in pids_max_write()
327 atomic64_set(&pids->limit, limit); in pids_max_write()
335 int64_t limit = atomic64_read(&pids->limit); in pids_max_show()
350 return atomic64_read(&pids->counter); in pids_current_read()
358 return READ_ONCE(pids->watermark); in pids_peak_read()
361 static int __pids_events_show(struct seq_file *sf, bool local) in __pids_events_show() argument
370 local = true; in __pids_events_show()
372 events = local ? pids->events_local : pids->events; in __pids_events_show()
414 .name = "events.local",