at master 2.0 kB view raw
1/* SPDX-License-Identifier: MIT */ 2/* 3 * Copyright © 2023-2024 Intel Corporation 4 */ 5 6#ifndef _CGROUP_DMEM_H 7#define _CGROUP_DMEM_H 8 9#include <linux/types.h> 10#include <linux/llist.h> 11 12struct dmem_cgroup_pool_state; 13 14/* Opaque definition of a cgroup region, used internally */ 15struct dmem_cgroup_region; 16 17#if IS_ENABLED(CONFIG_CGROUP_DMEM) 18struct dmem_cgroup_region *dmem_cgroup_register_region(u64 size, const char *name_fmt, ...) __printf(2,3); 19void dmem_cgroup_unregister_region(struct dmem_cgroup_region *region); 20int dmem_cgroup_try_charge(struct dmem_cgroup_region *region, u64 size, 21 struct dmem_cgroup_pool_state **ret_pool, 22 struct dmem_cgroup_pool_state **ret_limit_pool); 23void dmem_cgroup_uncharge(struct dmem_cgroup_pool_state *pool, u64 size); 24bool dmem_cgroup_state_evict_valuable(struct dmem_cgroup_pool_state *limit_pool, 25 struct dmem_cgroup_pool_state *test_pool, 26 bool ignore_low, bool *ret_hit_low); 27 28void dmem_cgroup_pool_state_put(struct dmem_cgroup_pool_state *pool); 29#else 30static inline __printf(2,3) struct dmem_cgroup_region * 31dmem_cgroup_register_region(u64 size, const char *name_fmt, ...) 32{ 33 return NULL; 34} 35 36static inline void dmem_cgroup_unregister_region(struct dmem_cgroup_region *region) 37{ } 38 39static inline int dmem_cgroup_try_charge(struct dmem_cgroup_region *region, u64 size, 40 struct dmem_cgroup_pool_state **ret_pool, 41 struct dmem_cgroup_pool_state **ret_limit_pool) 42{ 43 *ret_pool = NULL; 44 45 if (ret_limit_pool) 46 *ret_limit_pool = NULL; 47 48 return 0; 49} 50 51static inline void dmem_cgroup_uncharge(struct dmem_cgroup_pool_state *pool, u64 size) 52{ } 53 54static inline 55bool dmem_cgroup_state_evict_valuable(struct dmem_cgroup_pool_state *limit_pool, 56 struct dmem_cgroup_pool_state *test_pool, 57 bool ignore_low, bool *ret_hit_low) 58{ 59 return true; 60} 61 62static inline void dmem_cgroup_pool_state_put(struct dmem_cgroup_pool_state *pool) 63{ } 64 65#endif 66#endif /* _CGROUP_DMEM_H */