0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef _LINUX_MEMORY_H_
0017 #define _LINUX_MEMORY_H_
0018
0019 #include <linux/node.h>
0020 #include <linux/compiler.h>
0021 #include <linux/mutex.h>
0022 #include <linux/notifier.h>
0023
0024 #define MIN_MEMORY_BLOCK_SIZE (1UL << SECTION_SIZE_BITS)
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052 struct memory_group {
0053 int nid;
0054 struct list_head memory_blocks;
0055 unsigned long present_kernel_pages;
0056 unsigned long present_movable_pages;
0057 bool is_dynamic;
0058 union {
0059 struct {
0060 unsigned long max_pages;
0061 } s;
0062 struct {
0063 unsigned long unit_pages;
0064 } d;
0065 };
0066 };
0067
0068 struct memory_block {
0069 unsigned long start_section_nr;
0070 unsigned long state;
0071 int online_type;
0072 int nid;
0073
0074
0075
0076
0077
0078
0079 struct zone *zone;
0080 struct device dev;
0081
0082
0083
0084
0085 unsigned long nr_vmemmap_pages;
0086 struct memory_group *group;
0087 struct list_head group_next;
0088 };
0089
0090 int arch_get_memory_phys_device(unsigned long start_pfn);
0091 unsigned long memory_block_size_bytes(void);
0092 int set_memory_block_size_order(unsigned int order);
0093
0094
0095 #define MEM_ONLINE (1<<0)
0096 #define MEM_GOING_OFFLINE (1<<1)
0097 #define MEM_OFFLINE (1<<2)
0098 #define MEM_GOING_ONLINE (1<<3)
0099 #define MEM_CANCEL_ONLINE (1<<4)
0100 #define MEM_CANCEL_OFFLINE (1<<5)
0101
0102 struct memory_notify {
0103 unsigned long start_pfn;
0104 unsigned long nr_pages;
0105 int status_change_nid_normal;
0106 int status_change_nid;
0107 };
0108
0109 struct notifier_block;
0110 struct mem_section;
0111
0112
0113
0114
0115
0116 #define SLAB_CALLBACK_PRI 1
0117 #define IPC_CALLBACK_PRI 10
0118
0119 #ifndef CONFIG_MEMORY_HOTPLUG
0120 static inline void memory_dev_init(void)
0121 {
0122 return;
0123 }
0124 static inline int register_memory_notifier(struct notifier_block *nb)
0125 {
0126 return 0;
0127 }
0128 static inline void unregister_memory_notifier(struct notifier_block *nb)
0129 {
0130 }
0131 static inline int memory_notify(unsigned long val, void *v)
0132 {
0133 return 0;
0134 }
0135 static inline int hotplug_memory_notifier(notifier_fn_t fn, int pri)
0136 {
0137 return 0;
0138 }
0139
0140 #define register_hotmemory_notifier(nb) ({ (void)(nb); 0; })
0141 #define unregister_hotmemory_notifier(nb) ({ (void)(nb); })
0142 #else
0143 extern int register_memory_notifier(struct notifier_block *nb);
0144 extern void unregister_memory_notifier(struct notifier_block *nb);
0145 int create_memory_block_devices(unsigned long start, unsigned long size,
0146 unsigned long vmemmap_pages,
0147 struct memory_group *group);
0148 void remove_memory_block_devices(unsigned long start, unsigned long size);
0149 extern void memory_dev_init(void);
0150 extern int memory_notify(unsigned long val, void *v);
0151 extern struct memory_block *find_memory_block(unsigned long section_nr);
0152 typedef int (*walk_memory_blocks_func_t)(struct memory_block *, void *);
0153 extern int walk_memory_blocks(unsigned long start, unsigned long size,
0154 void *arg, walk_memory_blocks_func_t func);
0155 extern int for_each_memory_block(void *arg, walk_memory_blocks_func_t func);
0156
0157 extern int memory_group_register_static(int nid, unsigned long max_pages);
0158 extern int memory_group_register_dynamic(int nid, unsigned long unit_pages);
0159 extern int memory_group_unregister(int mgid);
0160 struct memory_group *memory_group_find_by_id(int mgid);
0161 typedef int (*walk_memory_groups_func_t)(struct memory_group *, void *);
0162 int walk_dynamic_memory_groups(int nid, walk_memory_groups_func_t func,
0163 struct memory_group *excluded, void *arg);
0164 #define hotplug_memory_notifier(fn, pri) ({ \
0165 static __meminitdata struct notifier_block fn##_mem_nb =\
0166 { .notifier_call = fn, .priority = pri };\
0167 register_memory_notifier(&fn##_mem_nb); \
0168 })
0169 #define register_hotmemory_notifier(nb) register_memory_notifier(nb)
0170 #define unregister_hotmemory_notifier(nb) unregister_memory_notifier(nb)
0171
0172 #ifdef CONFIG_NUMA
0173 void memory_block_add_nid(struct memory_block *mem, int nid,
0174 enum meminit_context context);
0175 #endif
0176 #endif
0177
0178
0179
0180
0181
0182 extern struct mutex text_mutex;
0183
0184 #endif