1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * include/linux/reclaim_acct.h
4 *
5 * Copyright (c) 2022 Huawei Technologies Co., Ltd.
6 */
7
8 #ifndef _RECLAIM_ACCT_H
9 #define _RECLAIM_ACCT_H
10
11 #include <linux/sched.h>
12 #include <linux/shrinker.h>
13
14 /* RA is the abbreviation of reclaim accouting */
15 enum reclaimacct_stubs {
16 RA_RECLAIM = 0,
17 RA_DRAINALLPAGES,
18 RA_SHRINKFILE,
19 RA_SHRINKANON,
20 RA_SHRINKSLAB,
21 NR_RA_STUBS
22 };
23
24 enum reclaim_type {
25 DIRECT_RECLAIMS = 0,
26 KSWAPD_RECLAIM,
27 ZSWAPD_RECLAIM,
28 RECLAIM_TYPES
29 };
30
31 #ifdef CONFIG_RECLAIM_ACCT
is_system_reclaim(enum reclaim_type type)32 static inline bool is_system_reclaim(enum reclaim_type type)
33 {
34 return (type == KSWAPD_RECLAIM || type == ZSWAPD_RECLAIM);
35 }
36
37 void reclaimacct_tsk_init(struct task_struct *tsk);
38 void reclaimacct_init(void);
39
40 void reclaimacct_start(enum reclaim_type type, struct reclaim_acct *ra);
41 void reclaimacct_end(enum reclaim_type type);
42
43 void reclaimacct_substage_start(enum reclaimacct_stubs stub);
44 void reclaimacct_substage_end(enum reclaimacct_stubs stub, unsigned long freed,
45 const struct shrinker *shrinker);
46 #endif
47
48 #endif /* _RECLAIM_ACCT_H */
49