History

mm/hotplug: make remove_memory() interface usable

Presently the remove_memory() interface is inherently broken. It tries to remove memory but panics if some memory is not offline. The problem is that it is impossible to ensure that all memory blocks are offline as this function also takes lock_device_hotplug that is required to change memory state via sysfs. So, between calling this function and offlining all memory blocks there is always a window when lock_device_hotplug is released, and therefore, there is always a chance for a panic during this window. Make this interface to return an error if memory removal fails. This way it is safe to call this function without panicking machine, and also makes it symmetric to add_memory() which already returns an error.

Pavel Tatashin committed 7 years ago

Commit eca499a1 parent 31e4ca92 files · +49 −23Browse files

Showing the changes to include/linux (1 of 2 files). Show all

Unified · Split

include/linux/memory_hotplug.h+6−2
@@ -324,7 +324,7 @@ static inline void pgdat_resize_init(struct pglist_data *pgdat) {} · 323 unmodified lines
324extern bool is_mem_section_removable(unsigned long pfn, unsigned long nr_pages);324extern bool is_mem_section_removable(unsigned long pfn, unsigned long nr_pages);
325extern void try_offline_node(int nid);325extern void try_offline_node(int nid);
326extern int offline_pages(unsigned long start_pfn, unsigned long nr_pages);326extern int offline_pages(unsigned long start_pfn, unsigned long nr_pages);
327extern void remove_memory(int nid, u64 start, u64 size);327extern int remove_memory(int nid, u64 start, u64 size);
328extern void __remove_memory(int nid, u64 start, u64 size);328extern void __remove_memory(int nid, u64 start, u64 size);
329 329
330#else330#else
@@ -341,7 +341,11 @@ static inline int offline_pages(unsigned long start_pfn, unsigned long nr_pages) · 10 unmodified lines
341 return -EINVAL;341 return -EINVAL;
342}342}
343 343
344static inline void remove_memory(int nid, u64 start, u64 size) {}344static inline int remove_memory(int nid, u64 start, u64 size)
345{
346 return -EBUSY;
347}
348
345static inline void __remove_memory(int nid, u64 start, u64 size) {}349static inline void __remove_memory(int nid, u64 start, u64 size) {}
346#endif /* CONFIG_MEMORY_HOTREMOVE */350#endif /* CONFIG_MEMORY_HOTREMOVE */
347 351

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t