vmpressure.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #ifndef __LINUX_VMPRESSURE_H
  2. #define __LINUX_VMPRESSURE_H
  3. #include <linux/mutex.h>
  4. #include <linux/list.h>
  5. #include <linux/workqueue.h>
  6. #include <linux/gfp.h>
  7. #include <linux/types.h>
  8. #include <linux/cgroup.h>
  9. #include <linux/eventfd.h>
  10. struct vmpressure {
  11. unsigned long scanned;
  12. unsigned long reclaimed;
  13. /* The lock is used to keep the scanned/reclaimed above in sync. */
  14. struct spinlock sr_lock;
  15. /* The list of vmpressure_event structs. */
  16. struct list_head events;
  17. /* Have to grab the lock on events traversal or modifications. */
  18. struct mutex events_lock;
  19. struct work_struct work;
  20. };
  21. struct mem_cgroup;
  22. #ifdef CONFIG_MEMCG
  23. extern void vmpressure(gfp_t gfp, struct mem_cgroup *memcg,
  24. unsigned long scanned, unsigned long reclaimed);
  25. extern void vmpressure_prio(gfp_t gfp, struct mem_cgroup *memcg, int prio);
  26. extern void vmpressure_init(struct vmpressure *vmpr);
  27. extern void vmpressure_cleanup(struct vmpressure *vmpr);
  28. extern struct vmpressure *memcg_to_vmpressure(struct mem_cgroup *memcg);
  29. extern struct cgroup_subsys_state *vmpressure_to_css(struct vmpressure *vmpr);
  30. extern int vmpressure_register_event(struct mem_cgroup *memcg,
  31. struct eventfd_ctx *eventfd,
  32. const char *args);
  33. extern void vmpressure_unregister_event(struct mem_cgroup *memcg,
  34. struct eventfd_ctx *eventfd);
  35. #else
  36. static inline void vmpressure(gfp_t gfp, struct mem_cgroup *memcg,
  37. unsigned long scanned, unsigned long reclaimed) {}
  38. static inline void vmpressure_prio(gfp_t gfp, struct mem_cgroup *memcg,
  39. int prio) {}
  40. #endif /* CONFIG_MEMCG */
  41. #endif /* __LINUX_VMPRESSURE_H */