#include <linux/module.h>
#include <linux/init.h>
#include <linux/topology.h>
#include <linux/capability.h>
#include <linux/device.h>
#include <linux/memory.h>
#include <linux/memory_hotplug.h>
#include <linux/mm.h>
#include <linux/stat.h>
#include <linux/slab.h>
#include <linux/xarray.h>
#include <linux/atomic.h>
#include <linux/uaccess.h>
#define MEMORY_CLASS_NAME …
static const char *const online_type_to_str[] = …;
int mhp_online_type_from_str(const char *str)
{ … }
#define to_memory_block(dev) …
static int sections_per_block;
static inline unsigned long memory_block_id(unsigned long section_nr)
{ … }
static inline unsigned long pfn_to_block_id(unsigned long pfn)
{ … }
static inline unsigned long phys_to_block_id(unsigned long phys)
{ … }
static int memory_subsys_online(struct device *dev);
static int memory_subsys_offline(struct device *dev);
static const struct bus_type memory_subsys = …;
static DEFINE_XARRAY(memory_blocks);
static DEFINE_XARRAY_FLAGS(memory_groups, XA_FLAGS_ALLOC);
#define MEMORY_GROUP_MARK_DYNAMIC …
static BLOCKING_NOTIFIER_HEAD(memory_chain);
int register_memory_notifier(struct notifier_block *nb)
{ … }
EXPORT_SYMBOL(…);
void unregister_memory_notifier(struct notifier_block *nb)
{ … }
EXPORT_SYMBOL(…);
static void memory_block_release(struct device *dev)
{ … }
unsigned long __weak memory_block_size_bytes(void)
{ … }
EXPORT_SYMBOL_GPL(…);
static ssize_t phys_index_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t removable_show(struct device *dev, struct device_attribute *attr,
char *buf)
{ … }
static ssize_t state_show(struct device *dev, struct device_attribute *attr,
char *buf)
{ … }
int memory_notify(unsigned long val, void *v)
{ … }
#if defined(CONFIG_MEMORY_FAILURE) && defined(CONFIG_MEMORY_HOTPLUG)
static unsigned long memblk_nr_poison(struct memory_block *mem);
#else
static inline unsigned long memblk_nr_poison(struct memory_block *mem)
{
return 0;
}
#endif
static int memory_block_online(struct memory_block *mem)
{ … }
static int memory_block_offline(struct memory_block *mem)
{ … }
static int
memory_block_action(struct memory_block *mem, unsigned long action)
{ … }
static int memory_block_change_state(struct memory_block *mem,
unsigned long to_state, unsigned long from_state_req)
{ … }
static int memory_subsys_online(struct device *dev)
{ … }
static int memory_subsys_offline(struct device *dev)
{ … }
static ssize_t state_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static ssize_t phys_device_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
#ifdef CONFIG_MEMORY_HOTREMOVE
static int print_allowed_zone(char *buf, int len, int nid,
struct memory_group *group,
unsigned long start_pfn, unsigned long nr_pages,
int online_type, struct zone *default_zone)
{ … }
static ssize_t valid_zones_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static DEVICE_ATTR_RO(valid_zones);
#endif
static DEVICE_ATTR_RO(phys_index);
static DEVICE_ATTR_RW(state);
static DEVICE_ATTR_RO(phys_device);
static DEVICE_ATTR_RO(removable);
static ssize_t block_size_bytes_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static DEVICE_ATTR_RO(block_size_bytes);
static ssize_t auto_online_blocks_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t auto_online_blocks_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static DEVICE_ATTR_RW(auto_online_blocks);
#ifdef CONFIG_CRASH_HOTPLUG
#include <linux/kexec.h>
static ssize_t crash_hotplug_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static DEVICE_ATTR_RO(crash_hotplug);
#endif
#ifdef CONFIG_ARCH_MEMORY_PROBE
static ssize_t probe_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static DEVICE_ATTR_WO(probe);
#endif
#ifdef CONFIG_MEMORY_FAILURE
static ssize_t soft_offline_page_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static ssize_t hard_offline_page_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static DEVICE_ATTR_WO(soft_offline_page);
static DEVICE_ATTR_WO(hard_offline_page);
#endif
int __weak arch_get_memory_phys_device(unsigned long start_pfn)
{ … }
static struct memory_block *find_memory_block_by_id(unsigned long block_id)
{ … }
struct memory_block *find_memory_block(unsigned long section_nr)
{ … }
static struct attribute *memory_memblk_attrs[] = …;
static const struct attribute_group memory_memblk_attr_group = …;
static const struct attribute_group *memory_memblk_attr_groups[] = …;
static int __add_memory_block(struct memory_block *memory)
{ … }
static struct zone *early_node_zone_for_memory_block(struct memory_block *mem,
int nid)
{ … }
#ifdef CONFIG_NUMA
void memory_block_add_nid(struct memory_block *mem, int nid,
enum meminit_context context)
{ … }
#endif
static int add_memory_block(unsigned long block_id, unsigned long state,
struct vmem_altmap *altmap,
struct memory_group *group)
{ … }
static int __init add_boot_memory_block(unsigned long base_section_nr)
{ … }
static int add_hotplug_memory_block(unsigned long block_id,
struct vmem_altmap *altmap,
struct memory_group *group)
{ … }
static void remove_memory_block(struct memory_block *memory)
{ … }
int create_memory_block_devices(unsigned long start, unsigned long size,
struct vmem_altmap *altmap,
struct memory_group *group)
{ … }
void remove_memory_block_devices(unsigned long start, unsigned long size)
{ … }
static struct attribute *memory_root_attrs[] = …;
static const struct attribute_group memory_root_attr_group = …;
static const struct attribute_group *memory_root_attr_groups[] = …;
void __init memory_dev_init(void)
{ … }
int walk_memory_blocks(unsigned long start, unsigned long size,
void *arg, walk_memory_blocks_func_t func)
{ … }
struct for_each_memory_block_cb_data { … };
static int for_each_memory_block_cb(struct device *dev, void *data)
{ … }
int for_each_memory_block(void *arg, walk_memory_blocks_func_t func)
{ … }
static int memory_group_register(struct memory_group group)
{ … }
int memory_group_register_static(int nid, unsigned long max_pages)
{ … }
EXPORT_SYMBOL_GPL(…);
int memory_group_register_dynamic(int nid, unsigned long unit_pages)
{ … }
EXPORT_SYMBOL_GPL(…);
int memory_group_unregister(int mgid)
{ … }
EXPORT_SYMBOL_GPL(…);
struct memory_group *memory_group_find_by_id(int mgid)
{ … }
int walk_dynamic_memory_groups(int nid, walk_memory_groups_func_t func,
struct memory_group *excluded, void *arg)
{ … }
#if defined(CONFIG_MEMORY_FAILURE) && defined(CONFIG_MEMORY_HOTPLUG)
void memblk_nr_poison_inc(unsigned long pfn)
{ … }
void memblk_nr_poison_sub(unsigned long pfn, long i)
{ … }
static unsigned long memblk_nr_poison(struct memory_block *mem)
{ … }
#endif