File Index
Files and directories
Sign in
FILE

thp_settings.h

File preview with syntax highlighting.

linux-6.19.14/tools/testing/selftests/mm/thp_settings.h C
 1/* SPDX-License-Identifier: GPL-2.0 */
 2#ifndef __THP_SETTINGS_H__
 3#define __THP_SETTINGS_H__
 4
 5#include <stdbool.h>
 6#include <stddef.h>
 7#include <stdint.h>
 8
 9enum thp_enabled {
10	THP_NEVER,
11	THP_ALWAYS,
12	THP_INHERIT,
13	THP_MADVISE,
14};
15
16enum thp_defrag {
17	THP_DEFRAG_ALWAYS,
18	THP_DEFRAG_DEFER,
19	THP_DEFRAG_DEFER_MADVISE,
20	THP_DEFRAG_MADVISE,
21	THP_DEFRAG_NEVER,
22};
23
24enum shmem_enabled {
25	SHMEM_NEVER,
26	SHMEM_ALWAYS,
27	SHMEM_WITHIN_SIZE,
28	SHMEM_ADVISE,
29	SHMEM_INHERIT,
30	SHMEM_DENY,
31	SHMEM_FORCE,
32};
33
34#define NR_ORDERS 20
35
36struct hugepages_settings {
37	enum thp_enabled enabled;
38};
39
40struct khugepaged_settings {
41	bool defrag;
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;
48};
49
50struct shmem_hugepages_settings {
51	enum shmem_enabled enabled;
52};
53
54struct thp_settings {
55	enum thp_enabled thp_enabled;
56	enum thp_defrag thp_defrag;
57	enum shmem_enabled shmem_enabled;
58	bool use_zero_page;
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];
63};
64
65int read_file(const char *path, char *buf, size_t buflen);
66int write_file(const char *path, const char *buf, size_t buflen);
67unsigned long read_num(const char *path);
68void write_num(const char *path, unsigned long num);
69
70int thp_read_string(const char *name, const char * const strings[]);
71void thp_write_string(const char *name, const char *val);
72unsigned long thp_read_num(const char *name);
73void thp_write_num(const char *name, unsigned long num);
74
75void thp_write_settings(struct thp_settings *settings);
76void thp_read_settings(struct thp_settings *settings);
77struct thp_settings *thp_current_settings(void);
78void thp_push_settings(struct thp_settings *settings);
79void thp_pop_settings(void);
80void thp_restore_settings(void);
81void thp_save_settings(void);
82
83void thp_set_read_ahead_path(char *path);
84unsigned long thp_supported_orders(void);
85unsigned long thp_shmem_supported_orders(void);
86
87bool thp_available(void);
88bool thp_is_enabled(void);
89
90#endif /* __THP_SETTINGS_H__ */
~/ Read-only file preview.