1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_MEMORY_TIERS_H
3 #define _LINUX_MEMORY_TIERS_H
5 #include <linux/types.h>
6 #include <linux/nodemask.h>
7 #include <linux/kref.h>
8 #include <linux/mmzone.h>
10 * Each tier cover a abstrace distance chunk size of 128
12 #define MEMTIER_CHUNK_BITS 7
13 #define MEMTIER_CHUNK_SIZE (1 << MEMTIER_CHUNK_BITS)
15 * Smaller abstract distance values imply faster (higher) memory tiers. Offset
16 * the DRAM adistance so that we can accommodate devices with a slightly lower
17 * adistance value (slightly faster) than default DRAM adistance to be part of
18 * the same memory tier.
20 #define MEMTIER_ADISTANCE_DRAM ((4 * MEMTIER_CHUNK_SIZE) + (MEMTIER_CHUNK_SIZE >> 1))
23 struct memory_dev_type {
24 /* list of memory types that are part of same tier as this type */
25 struct list_head tier_sibiling;
26 /* abstract distance for this specific memory type */
28 /* Nodes of same abstract distance */
34 extern bool numa_demotion_enabled;
35 struct memory_dev_type *alloc_memory_type(int adistance);
36 void put_memory_type(struct memory_dev_type *memtype);
37 void init_node_memory_type(int node, struct memory_dev_type *default_type);
38 void clear_node_memory_type(int node, struct memory_dev_type *memtype);
39 #ifdef CONFIG_MIGRATION
40 int next_demotion_node(int node);
41 void node_get_allowed_targets(pg_data_t *pgdat, nodemask_t *targets);
42 bool node_is_toptier(int node);
44 static inline int next_demotion_node(int node)
49 static inline void node_get_allowed_targets(pg_data_t *pgdat, nodemask_t *targets)
51 *targets = NODE_MASK_NONE;
54 static inline bool node_is_toptier(int node)
62 #define numa_demotion_enabled false
64 * CONFIG_NUMA implementation returns non NULL error.
66 static inline struct memory_dev_type *alloc_memory_type(int adistance)
71 static inline void put_memory_type(struct memory_dev_type *memtype)
76 static inline void init_node_memory_type(int node, struct memory_dev_type *default_type)
81 static inline void clear_node_memory_type(int node, struct memory_dev_type *memtype)
86 static inline int next_demotion_node(int node)
91 static inline void node_get_allowed_targets(pg_data_t *pgdat, nodemask_t *targets)
93 *targets = NODE_MASK_NONE;
96 static inline bool node_is_toptier(int node)
100 #endif /* CONFIG_NUMA */
101 #endif /* _LINUX_MEMORY_TIERS_H */