Lines Matching +full:constant +full:- +full:on +full:- +full:time
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 #include "cgroup-internal.h"
4 #include "cpuset-internal.h"
15 * Frequency meter - How fast is some event occurring?
17 * These routines manage a digitally filtered, constant time based,
19 * fmeter_init() - initialize a frequency meter.
20 * fmeter_markevent() - called each time the event happens.
21 * fmeter_getrate() - returns the recent rate of such events.
22 * fmeter_update() - internal routine used to update fmeter.
28 * The filter works on the number of events marked per unit time.
29 * The filter is single-pole low-pass recursive (IIR). The time unit
30 * is 1 second. Arithmetic is done using 32-bit integers scaled to
33 * With an FM_COEF of 933, and a time base of 1 second, the filter
34 * has a half-life of 10 seconds, meaning that if the events quit
48 * one per 32 (approx) seconds. At constant rates faster than one
49 * per msec it maxes out at values just under 1,000,000. At constant
52 * At constant rates between one per second and one per 32 seconds,
53 * it will be choppy, moving up on the seconds that have an event,
59 #define FM_COEF 933 /* coefficient for half-life of 10 secs */
67 fmp->cnt = 0; in fmeter_init()
68 fmp->val = 0; in fmeter_init()
69 fmp->time = 0; in fmeter_init()
70 spin_lock_init(&fmp->lock); in fmeter_init()
73 /* Internal meter update - process cnt events and update value */
80 ticks = now - fmp->time; in fmeter_update()
86 while (ticks-- > 0) in fmeter_update()
87 fmp->val = (FM_COEF * fmp->val) / FM_SCALE; in fmeter_update()
88 fmp->time = now; in fmeter_update()
90 fmp->val += ((FM_SCALE - FM_COEF) * fmp->cnt) / FM_SCALE; in fmeter_update()
91 fmp->cnt = 0; in fmeter_update()
97 spin_lock(&fmp->lock); in fmeter_markevent()
99 fmp->cnt = min(FM_MAXCNT, fmp->cnt + FM_SCALE); in fmeter_markevent()
100 spin_unlock(&fmp->lock); in fmeter_markevent()
108 spin_lock(&fmp->lock); in fmeter_getrate()
110 val = fmp->val; in fmeter_getrate()
111 spin_unlock(&fmp->lock); in fmeter_getrate()
124 * __cpuset_memory_pressure_bump - keep stats of per-cpuset reclaims.
130 * ran low on memory on all nodes it was allowed to use, and
135 * Display to user space in the per-cpuset read-only file
144 fmeter_markevent(&task_cs(current)->fmeter); in __cpuset_memory_pressure_bump()
151 if (val < -1 || val > sched_domain_level_max + 1) in update_relax_domain_level()
152 return -EINVAL; in update_relax_domain_level()
155 if (val != cs->relax_domain_level) { in update_relax_domain_level()
156 cs->relax_domain_level = val; in update_relax_domain_level()
157 if (!cpumask_empty(cs->cpus_allowed) && in update_relax_domain_level()
169 cpuset_filetype_t type = cft->private; in cpuset_write_s64()
170 int retval = -ENODEV; in cpuset_write_s64()
178 pr_info_once("cpuset.%s is deprecated\n", cft->name); in cpuset_write_s64()
182 retval = -EINVAL; in cpuset_write_s64()
193 cpuset_filetype_t type = cft->private; in cpuset_read_s64()
197 return cs->relax_domain_level; in cpuset_read_s64()
210 * if on default hierarchy.
230 * cpuset1_update_tasks_flags - update the spread flags of tasks in the cpuset.
242 css_task_iter_start(&cs->css, 0, &it); in cpuset1_update_tasks_flags()
253 * cpuset to its next-highest non-empty parent.
260 * Find its next-highest non-empty parent, (top cpuset in remove_tasks_in_empty_cpuset()
264 while (cpumask_empty(parent->cpus_allowed) || in remove_tasks_in_empty_cpuset()
265 nodes_empty(parent->mems_allowed)) in remove_tasks_in_empty_cpuset()
268 if (cgroup_transfer_tasks(parent->css.cgroup, cs->css.cgroup)) { in remove_tasks_in_empty_cpuset()
270 pr_cont_cgroup_name(cs->css.cgroup); in remove_tasks_in_empty_cpuset()
280 remove_tasks_in_empty_cpuset(s->cs); in cpuset_migrate_tasks_workfn()
281 css_put(&s->cs->css); in cpuset_migrate_tasks_workfn()
292 cpumask_copy(cs->cpus_allowed, new_cpus); in cpuset1_hotplug_update_tasks()
293 cpumask_copy(cs->effective_cpus, new_cpus); in cpuset1_hotplug_update_tasks()
294 cs->mems_allowed = *new_mems; in cpuset1_hotplug_update_tasks()
295 cs->effective_mems = *new_mems; in cpuset1_hotplug_update_tasks()
302 if (cpus_updated && !cpumask_empty(cs->cpus_allowed)) in cpuset1_hotplug_update_tasks()
304 if (mems_updated && !nodes_empty(cs->mems_allowed)) in cpuset1_hotplug_update_tasks()
307 is_empty = cpumask_empty(cs->cpus_allowed) || in cpuset1_hotplug_update_tasks()
308 nodes_empty(cs->mems_allowed); in cpuset1_hotplug_update_tasks()
315 if (is_empty && cs->css.cgroup->nr_populated_csets && in cpuset1_hotplug_update_tasks()
316 css_tryget_online(&cs->css)) { in cpuset1_hotplug_update_tasks()
321 css_put(&cs->css); in cpuset1_hotplug_update_tasks()
325 s->cs = cs; in cpuset1_hotplug_update_tasks()
326 INIT_WORK(&s->work, cpuset_migrate_tasks_workfn); in cpuset1_hotplug_update_tasks()
327 schedule_work(&s->work); in cpuset1_hotplug_update_tasks()
332 * is_cpuset_subset(p, q) - Is cpuset p a subset of cpuset q?
341 return cpumask_subset(p->cpus_allowed, q->cpus_allowed) && in is_cpuset_subset()
342 nodes_subset(p->mems_allowed, q->mems_allowed) && in is_cpuset_subset()
348 * cpuset1_validate_change() - Validate conditions specific to legacy (v1)
360 ret = -EBUSY; in cpuset1_validate_change()
365 /* On legacy hierarchy, we must be a subset of our parent cpuset. */ in cpuset1_validate_change()
366 ret = -EACCES; in cpuset1_validate_change()
379 * - Print tasks cpuset path into seq_file.
380 * - Used for /proc/<pid>/cpuset.
389 retval = -ENOMEM; in proc_cpuset_show()
397 retval = cgroup_path_ns_locked(css->cgroup, buf, PATH_MAX, in proc_cpuset_show()
398 current->nsproxy->cgroup_ns); in proc_cpuset_show()
402 if (retval == -E2BIG) in proc_cpuset_show()
403 retval = -ENAMETOOLONG; in proc_cpuset_show()
419 cpuset_filetype_t type = cft->private; in cpuset_read_u64()
435 return fmeter_getrate(&cs->fmeter); in cpuset_read_u64()
452 cpuset_filetype_t type = cft->private; in cpuset_write_u64()
457 retval = -ENODEV; in cpuset_write_u64()
466 pr_info_once("cpuset.%s is deprecated\n", cft->name); in cpuset_write_u64()
470 pr_info_once("cpuset.%s is deprecated\n", cft->name); in cpuset_write_u64()
474 pr_info_once("cpuset.%s is deprecated, use cpuset.cpus.partition instead\n", cft->name); in cpuset_write_u64()
478 pr_info_once("cpuset.%s is deprecated\n", cft->name); in cpuset_write_u64()
482 pr_info_once("cpuset.%s is deprecated, use memory.pressure with CONFIG_PSI instead\n", cft->name); in cpuset_write_u64()
486 pr_info_once("cpuset.%s is deprecated\n", cft->name); in cpuset_write_u64()
490 pr_warn_once("cpuset.%s is deprecated\n", cft->name); in cpuset_write_u64()
494 retval = -EINVAL; in cpuset_write_u64()