Lines Matching +full:high +full:- +full:efficiency
1 // SPDX-License-Identifier: GPL-2.0-only
27 * rate-limit tunable for the "low" level notification, and also for
58 * prio <= DEF_PRIORITY - 2 : kswapd becomes somewhat overwhelmed
140 pressure = scale - (reclaimed * scale / scanned); in vmpressure_calc_level()
164 mutex_lock(&vmpr->events_lock); in vmpressure_event()
165 list_for_each_entry(ev, &vmpr->events, node) { in vmpressure_event()
166 if (ancestor && ev->mode == VMPRESSURE_LOCAL) in vmpressure_event()
168 if (signalled && ev->mode == VMPRESSURE_NO_PASSTHROUGH) in vmpressure_event()
170 if (level < ev->level) in vmpressure_event()
172 eventfd_signal(ev->efd, 1); in vmpressure_event()
175 mutex_unlock(&vmpr->events_lock); in vmpressure_event()
189 spin_lock(&vmpr->sr_lock); in vmpressure_work_fn()
196 * vmpr->reclaimed is in sync. in vmpressure_work_fn()
198 scanned = vmpr->tree_scanned; in vmpressure_work_fn()
200 spin_unlock(&vmpr->sr_lock); in vmpressure_work_fn()
204 reclaimed = vmpr->tree_reclaimed; in vmpressure_work_fn()
205 vmpr->tree_scanned = 0; in vmpressure_work_fn()
206 vmpr->tree_reclaimed = 0; in vmpressure_work_fn()
207 spin_unlock(&vmpr->sr_lock); in vmpressure_work_fn()
219 * vmpressure() - Account memory pressure through scanned/reclaimed ratio
232 * notified of the entire subtree's reclaim efficiency.
234 * If @tree is not set, reclaim efficiency is recorded for @memcg, and
235 * only in-kernel users are notified.
248 * The in-kernel users only care about the reclaim efficiency in vmpressure()
250 * isn't and won't be any in-kernel user in a legacy cgroup. in vmpressure()
265 * Indirect reclaim (kswapd) sets sc->gfp_mask to GFP_KERNEL, so in vmpressure()
276 * (scanning depth) goes too high (deep), we will be notified in vmpressure()
283 spin_lock(&vmpr->sr_lock); in vmpressure()
284 scanned = vmpr->tree_scanned += scanned; in vmpressure()
285 vmpr->tree_reclaimed += reclaimed; in vmpressure()
286 spin_unlock(&vmpr->sr_lock); in vmpressure()
290 schedule_work(&vmpr->work); in vmpressure()
294 /* For now, no users for root-level efficiency */ in vmpressure()
298 spin_lock(&vmpr->sr_lock); in vmpressure()
299 scanned = vmpr->scanned += scanned; in vmpressure()
300 reclaimed = vmpr->reclaimed += reclaimed; in vmpressure()
302 spin_unlock(&vmpr->sr_lock); in vmpressure()
305 vmpr->scanned = vmpr->reclaimed = 0; in vmpressure()
306 spin_unlock(&vmpr->sr_lock); in vmpressure()
319 WRITE_ONCE(memcg->socket_pressure, jiffies + HZ); in vmpressure()
325 * vmpressure_prio() - Account memory pressure through reclaimer priority level
357 * vmpressure_register_event() - Bind vmpressure notifications to an eventfd
364 * @eventfd. The @args parameter is a comma-delimited string that denotes a
371 * Return: 0 on success, -ENOMEM on memory failure or -EINVAL if @args could
387 return -ENOMEM; in vmpressure_register_event()
407 ret = -ENOMEM; in vmpressure_register_event()
411 ev->efd = eventfd; in vmpressure_register_event()
412 ev->level = level; in vmpressure_register_event()
413 ev->mode = mode; in vmpressure_register_event()
415 mutex_lock(&vmpr->events_lock); in vmpressure_register_event()
416 list_add(&ev->node, &vmpr->events); in vmpressure_register_event()
417 mutex_unlock(&vmpr->events_lock); in vmpressure_register_event()
425 * vmpressure_unregister_event() - Unbind eventfd from vmpressure
441 mutex_lock(&vmpr->events_lock); in vmpressure_unregister_event()
442 list_for_each_entry(ev, &vmpr->events, node) { in vmpressure_unregister_event()
443 if (ev->efd != eventfd) in vmpressure_unregister_event()
445 list_del(&ev->node); in vmpressure_unregister_event()
449 mutex_unlock(&vmpr->events_lock); in vmpressure_unregister_event()
453 * vmpressure_init() - Initialize vmpressure control structure
461 spin_lock_init(&vmpr->sr_lock); in vmpressure_init()
462 mutex_init(&vmpr->events_lock); in vmpressure_init()
463 INIT_LIST_HEAD(&vmpr->events); in vmpressure_init()
464 INIT_WORK(&vmpr->work, vmpressure_work_fn); in vmpressure_init()
468 * vmpressure_cleanup() - shuts down vmpressure control structure
480 flush_work(&vmpr->work); in vmpressure_cleanup()