1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __THP_SETTINGS_H__
3 #define __THP_SETTINGS_H__
19 THP_DEFRAG_DEFER_MADVISE,
36 struct hugepages_settings {
37 enum thp_enabled enabled;
40 struct khugepaged_settings {
42 unsigned int alloc_sleep_millisecs;
43 unsigned int scan_sleep_millisecs;
44 unsigned int max_ptes_none;
45 unsigned int max_ptes_swap;
46 unsigned int max_ptes_shared;
47 unsigned long pages_to_scan;
50 struct shmem_hugepages_settings {
51 enum shmem_enabled enabled;
55 enum thp_enabled thp_enabled;
56 enum thp_defrag thp_defrag;
57 enum shmem_enabled shmem_enabled;
59 struct khugepaged_settings khugepaged;
60 unsigned long read_ahead_kb;
61 struct hugepages_settings hugepages[NR_ORDERS];
62 struct shmem_hugepages_settings shmem_hugepages[NR_ORDERS];
65 int read_file(const char *path, char *buf, size_t buflen);
66 int write_file(const char *path, const char *buf, size_t buflen);
67 const unsigned long read_num(const char *path);
68 void write_num(const char *path, unsigned long num);
70 int thp_read_string(const char *name, const char * const strings[]);
71 void thp_write_string(const char *name, const char *val);
72 const unsigned long thp_read_num(const char *name);
73 void thp_write_num(const char *name, unsigned long num);
75 void thp_write_settings(struct thp_settings *settings);
76 void thp_read_settings(struct thp_settings *settings);
77 struct thp_settings *thp_current_settings(void);
78 void thp_push_settings(struct thp_settings *settings);
79 void thp_pop_settings(void);
80 void thp_restore_settings(void);
81 void thp_save_settings(void);
83 void thp_set_read_ahead_path(char *path);
84 unsigned long thp_supported_orders(void);
85 unsigned long thp_shmem_supported_orders(void);
87 #endif /* __THP_SETTINGS_H__ */