18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef __LINUX_VMPRESSURE_H 38c2ecf20Sopenharmony_ci#define __LINUX_VMPRESSURE_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci#include <linux/mutex.h> 68c2ecf20Sopenharmony_ci#include <linux/list.h> 78c2ecf20Sopenharmony_ci#include <linux/workqueue.h> 88c2ecf20Sopenharmony_ci#include <linux/gfp.h> 98c2ecf20Sopenharmony_ci#include <linux/types.h> 108c2ecf20Sopenharmony_ci#include <linux/cgroup.h> 118c2ecf20Sopenharmony_ci#include <linux/eventfd.h> 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_cistruct vmpressure { 148c2ecf20Sopenharmony_ci unsigned long scanned; 158c2ecf20Sopenharmony_ci unsigned long reclaimed; 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci unsigned long tree_scanned; 188c2ecf20Sopenharmony_ci unsigned long tree_reclaimed; 198c2ecf20Sopenharmony_ci /* The lock is used to keep the scanned/reclaimed above in sync. */ 208c2ecf20Sopenharmony_ci spinlock_t sr_lock; 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci /* The list of vmpressure_event structs. */ 238c2ecf20Sopenharmony_ci struct list_head events; 248c2ecf20Sopenharmony_ci /* Have to grab the lock on events traversal or modifications. */ 258c2ecf20Sopenharmony_ci struct mutex events_lock; 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci struct work_struct work; 288c2ecf20Sopenharmony_ci}; 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_cistruct mem_cgroup; 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci#ifdef CONFIG_MEMCG 338c2ecf20Sopenharmony_ciextern void vmpressure(gfp_t gfp, struct mem_cgroup *memcg, bool tree, 348c2ecf20Sopenharmony_ci unsigned long scanned, unsigned long reclaimed); 358c2ecf20Sopenharmony_ciextern void vmpressure_prio(gfp_t gfp, struct mem_cgroup *memcg, int prio); 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ciextern void vmpressure_init(struct vmpressure *vmpr); 388c2ecf20Sopenharmony_ciextern void vmpressure_cleanup(struct vmpressure *vmpr); 398c2ecf20Sopenharmony_ciextern struct vmpressure *memcg_to_vmpressure(struct mem_cgroup *memcg); 408c2ecf20Sopenharmony_ciextern struct cgroup_subsys_state *vmpressure_to_css(struct vmpressure *vmpr); 418c2ecf20Sopenharmony_ciextern int vmpressure_register_event(struct mem_cgroup *memcg, 428c2ecf20Sopenharmony_ci struct eventfd_ctx *eventfd, 438c2ecf20Sopenharmony_ci const char *args); 448c2ecf20Sopenharmony_ciextern void vmpressure_unregister_event(struct mem_cgroup *memcg, 458c2ecf20Sopenharmony_ci struct eventfd_ctx *eventfd); 468c2ecf20Sopenharmony_ci#else 478c2ecf20Sopenharmony_cistatic inline void vmpressure(gfp_t gfp, struct mem_cgroup *memcg, bool tree, 488c2ecf20Sopenharmony_ci unsigned long scanned, unsigned long reclaimed) {} 498c2ecf20Sopenharmony_cistatic inline void vmpressure_prio(gfp_t gfp, struct mem_cgroup *memcg, 508c2ecf20Sopenharmony_ci int prio) {} 518c2ecf20Sopenharmony_ci#endif /* CONFIG_MEMCG */ 528c2ecf20Sopenharmony_ci#endif /* __LINUX_VMPRESSURE_H */ 53