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

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
235 * only in-kernel users are notified.
257 * Indirect reclaim (kswapd) sets sc->gfp_mask to GFP_KERNEL, so in vmpressure()
275 spin_lock(&vmpr->sr_lock); in vmpressure()
276 scanned = vmpr->tree_scanned += scanned; in vmpressure()
277 vmpr->tree_reclaimed += reclaimed; in vmpressure()
278 spin_unlock(&vmpr->sr_lock); in vmpressure()
282 schedule_work(&vmpr->work); in vmpressure()
286 /* For now, no users for root-level efficiency */ in vmpressure()
290 spin_lock(&vmpr->sr_lock); in vmpressure()
291 scanned = vmpr->scanned += scanned; in vmpressure()
292 reclaimed = vmpr->reclaimed += reclaimed; in vmpressure()
294 spin_unlock(&vmpr->sr_lock); in vmpressure()
297 vmpr->scanned = vmpr->reclaimed = 0; in vmpressure()
298 spin_unlock(&vmpr->sr_lock); in vmpressure()
311 WRITE_ONCE(memcg->socket_pressure, jiffies + HZ); in vmpressure()
317 * vmpressure_prio() - Account memory pressure through reclaimer priority level
349 * vmpressure_register_event() - Bind vmpressure notifications to an eventfd
356 * @eventfd. The @args parameter is a comma-delimited string that denotes a
363 * Return: 0 on success, -ENOMEM on memory failure or -EINVAL if @args could
374 char *token; in vmpressure_register_event() local
379 return -ENOMEM; in vmpressure_register_event()
382 token = strsep(&spec, ","); in vmpressure_register_event()
383 ret = match_string(vmpressure_str_levels, VMPRESSURE_NUM_LEVELS, token); in vmpressure_register_event()
389 token = strsep(&spec, ","); in vmpressure_register_event()
390 if (token) { in vmpressure_register_event()
391 ret = match_string(vmpressure_str_modes, VMPRESSURE_NUM_MODES, token); in vmpressure_register_event()
399 ret = -ENOMEM; in vmpressure_register_event()
403 ev->efd = eventfd; in vmpressure_register_event()
404 ev->level = level; in vmpressure_register_event()
405 ev->mode = mode; in vmpressure_register_event()
407 mutex_lock(&vmpr->events_lock); in vmpressure_register_event()
408 list_add(&ev->node, &vmpr->events); in vmpressure_register_event()
409 mutex_unlock(&vmpr->events_lock); in vmpressure_register_event()
417 * vmpressure_unregister_event() - Unbind eventfd from vmpressure
433 mutex_lock(&vmpr->events_lock); in vmpressure_unregister_event()
434 list_for_each_entry(ev, &vmpr->events, node) { in vmpressure_unregister_event()
435 if (ev->efd != eventfd) in vmpressure_unregister_event()
437 list_del(&ev->node); in vmpressure_unregister_event()
441 mutex_unlock(&vmpr->events_lock); in vmpressure_unregister_event()
445 * vmpressure_init() - Initialize vmpressure control structure
453 spin_lock_init(&vmpr->sr_lock); in vmpressure_init()
454 mutex_init(&vmpr->events_lock); in vmpressure_init()
455 INIT_LIST_HEAD(&vmpr->events); in vmpressure_init()
456 INIT_WORK(&vmpr->work, vmpressure_work_fn); in vmpressure_init()
460 * vmpressure_cleanup() - shuts down vmpressure control structure
472 flush_work(&vmpr->work); in vmpressure_cleanup()