#include <linux/slab.h>
#include <linux/lockdep.h>
#include <linux/sysfs.h>
#include <linux/kobject.h>
#include <linux/memory.h>
#include <linux/memory-tiers.h>
#include <linux/notifier.h>
#include "internal.h"
struct memory_tier { … };
struct demotion_nodes { … };
struct node_memory_type_map { … };
static DEFINE_MUTEX(memory_tier_lock);
static LIST_HEAD(memory_tiers);
static LIST_HEAD(default_memory_types);
static struct node_memory_type_map node_memory_types[MAX_NUMNODES];
struct memory_dev_type *default_dram_type;
nodemask_t default_dram_nodes __initdata = …;
static const struct bus_type memory_tier_subsys = …;
#ifdef CONFIG_MIGRATION
static int top_tier_adistance;
static struct demotion_nodes *node_demotion __read_mostly;
#endif
static BLOCKING_NOTIFIER_HEAD(mt_adistance_algorithms);
static DEFINE_MUTEX(default_dram_perf_lock);
static bool default_dram_perf_error;
static struct access_coordinate default_dram_perf;
static int default_dram_perf_ref_nid = …;
static const char *default_dram_perf_ref_source;
static inline struct memory_tier *to_memory_tier(struct device *device)
{ … }
static __always_inline nodemask_t get_memtier_nodemask(struct memory_tier *memtier)
{ … }
static void memory_tier_device_release(struct device *dev)
{ … }
static ssize_t nodelist_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static DEVICE_ATTR_RO(nodelist);
static struct attribute *memtier_dev_attrs[] = …;
static const struct attribute_group memtier_dev_group = …;
static const struct attribute_group *memtier_dev_groups[] = …;
static struct memory_tier *find_create_memory_tier(struct memory_dev_type *memtype)
{ … }
static struct memory_tier *__node_get_memory_tier(int node)
{ … }
#ifdef CONFIG_MIGRATION
bool node_is_toptier(int node)
{ … }
void node_get_allowed_targets(pg_data_t *pgdat, nodemask_t *targets)
{ … }
int next_demotion_node(int node)
{ … }
static void disable_all_demotion_targets(void)
{ … }
static void dump_demotion_targets(void)
{ … }
static void establish_demotion_targets(void)
{ … }
#else
static inline void establish_demotion_targets(void) {}
#endif
static inline void __init_node_memory_type(int node, struct memory_dev_type *memtype)
{ … }
static struct memory_tier *set_node_memory_tier(int node)
{ … }
static void destroy_memory_tier(struct memory_tier *memtier)
{ … }
static bool clear_node_memory_tier(int node)
{ … }
static void release_memtype(struct kref *kref)
{ … }
struct memory_dev_type *alloc_memory_type(int adistance)
{ … }
EXPORT_SYMBOL_GPL(…);
void put_memory_type(struct memory_dev_type *memtype)
{ … }
EXPORT_SYMBOL_GPL(…);
void init_node_memory_type(int node, struct memory_dev_type *memtype)
{ … }
EXPORT_SYMBOL_GPL(…);
void clear_node_memory_type(int node, struct memory_dev_type *memtype)
{ … }
EXPORT_SYMBOL_GPL(…);
struct memory_dev_type *mt_find_alloc_memory_type(int adist, struct list_head *memory_types)
{ … }
EXPORT_SYMBOL_GPL(…);
void mt_put_memory_types(struct list_head *memory_types)
{ … }
EXPORT_SYMBOL_GPL(…);
static int __init memory_tier_late_init(void)
{ … }
late_initcall(memory_tier_late_init);
static void dump_hmem_attrs(struct access_coordinate *coord, const char *prefix)
{ … }
int mt_set_default_dram_perf(int nid, struct access_coordinate *perf,
const char *source)
{ … }
int mt_perf_to_adistance(struct access_coordinate *perf, int *adist)
{ … }
EXPORT_SYMBOL_GPL(…);
int register_mt_adistance_algorithm(struct notifier_block *nb)
{ … }
EXPORT_SYMBOL_GPL(…);
int unregister_mt_adistance_algorithm(struct notifier_block *nb)
{ … }
EXPORT_SYMBOL_GPL(…);
int mt_calc_adistance(int node, int *adist)
{ … }
EXPORT_SYMBOL_GPL(…);
static int __meminit memtier_hotplug_callback(struct notifier_block *self,
unsigned long action, void *_arg)
{ … }
static int __init memory_tier_init(void)
{ … }
subsys_initcall(memory_tier_init);
bool numa_demotion_enabled = …;
#ifdef CONFIG_MIGRATION
#ifdef CONFIG_SYSFS
static ssize_t demotion_enabled_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
{ … }
static ssize_t demotion_enabled_store(struct kobject *kobj,
struct kobj_attribute *attr,
const char *buf, size_t count)
{ … }
static struct kobj_attribute numa_demotion_enabled_attr = …;
static struct attribute *numa_attrs[] = …;
static const struct attribute_group numa_attr_group = …;
static int __init numa_init_sysfs(void)
{ … }
subsys_initcall(numa_init_sysfs);
#endif
#endif