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))
21 #define MEMTIER_HOTPLUG_PRIO 100
24 struct memory_dev_type {
25 /* list of memory types that are part of same tier as this type */
26 struct list_head tier_sibiling;
27 /* abstract distance for this specific memory type */
29 /* Nodes of same abstract distance */
35 extern bool numa_demotion_enabled;
36 struct memory_dev_type *alloc_memory_type(int adistance);
37 void destroy_memory_type(struct memory_dev_type *memtype);
38 void init_node_memory_type(int node, struct memory_dev_type *default_type);
39 void clear_node_memory_type(int node, struct memory_dev_type *memtype);
40 #ifdef CONFIG_MIGRATION
41 int next_demotion_node(int node);
42 void node_get_allowed_targets(pg_data_t *pgdat, nodemask_t *targets);
43 bool node_is_toptier(int node);
45 static inline int next_demotion_node(int node)
50 static inline void node_get_allowed_targets(pg_data_t *pgdat, nodemask_t *targets)
52 *targets = NODE_MASK_NONE;
55 static inline bool node_is_toptier(int node)
63 #define numa_demotion_enabled false
65 * CONFIG_NUMA implementation returns non NULL error.
67 static inline struct memory_dev_type *alloc_memory_type(int adistance)
72 static inline void destroy_memory_type(struct memory_dev_type *memtype)
77 static inline void init_node_memory_type(int node, struct memory_dev_type *default_type)
82 static inline void clear_node_memory_type(int node, struct memory_dev_type *memtype)
87 static inline int next_demotion_node(int node)
92 static inline void node_get_allowed_targets(pg_data_t *pgdat, nodemask_t *targets)
94 *targets = NODE_MASK_NONE;
97 static inline bool node_is_toptier(int node)
101 #endif /* CONFIG_NUMA */
102 #endif /* _LINUX_MEMORY_TIERS_H */