memory_hotplug.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #ifndef __LINUX_MEMORY_HOTPLUG_H
  2. #define __LINUX_MEMORY_HOTPLUG_H
  3. #include <linux/mmzone.h>
  4. #include <linux/spinlock.h>
  5. #include <linux/mmzone.h>
  6. #include <linux/notifier.h>
  7. #ifdef CONFIG_MEMORY_HOTPLUG
  8. /*
  9. * pgdat resizing functions
  10. */
  11. static inline
  12. void pgdat_resize_lock(struct pglist_data *pgdat, unsigned long *flags)
  13. {
  14. spin_lock_irqsave(&pgdat->node_size_lock, *flags);
  15. }
  16. static inline
  17. void pgdat_resize_unlock(struct pglist_data *pgdat, unsigned long *flags)
  18. {
  19. spin_unlock_irqrestore(&pgdat->node_size_lock, *flags);
  20. }
  21. static inline
  22. void pgdat_resize_init(struct pglist_data *pgdat)
  23. {
  24. spin_lock_init(&pgdat->node_size_lock);
  25. }
  26. /*
  27. * Zone resizing functions
  28. */
  29. static inline unsigned zone_span_seqbegin(struct zone *zone)
  30. {
  31. return read_seqbegin(&zone->span_seqlock);
  32. }
  33. static inline int zone_span_seqretry(struct zone *zone, unsigned iv)
  34. {
  35. return read_seqretry(&zone->span_seqlock, iv);
  36. }
  37. static inline void zone_span_writelock(struct zone *zone)
  38. {
  39. write_seqlock(&zone->span_seqlock);
  40. }
  41. static inline void zone_span_writeunlock(struct zone *zone)
  42. {
  43. write_sequnlock(&zone->span_seqlock);
  44. }
  45. static inline void zone_seqlock_init(struct zone *zone)
  46. {
  47. seqlock_init(&zone->span_seqlock);
  48. }
  49. extern int zone_grow_free_lists(struct zone *zone, unsigned long new_nr_pages);
  50. extern int zone_grow_waitqueues(struct zone *zone, unsigned long nr_pages);
  51. extern int add_one_highpage(struct page *page, int pfn, int bad_ppro);
  52. /* need some defines for these for archs that don't support it */
  53. extern void online_page(struct page *page);
  54. /* VM interface that may be used by firmware interface */
  55. extern int add_memory(u64 start, u64 size);
  56. extern int remove_memory(u64 start, u64 size);
  57. extern int online_pages(unsigned long, unsigned long);
  58. /* reasonably generic interface to expand the physical pages in a zone */
  59. extern int __add_pages(struct zone *zone, unsigned long start_pfn,
  60. unsigned long nr_pages);
  61. #else /* ! CONFIG_MEMORY_HOTPLUG */
  62. /*
  63. * Stub functions for when hotplug is off
  64. */
  65. static inline void pgdat_resize_lock(struct pglist_data *p, unsigned long *f) {}
  66. static inline void pgdat_resize_unlock(struct pglist_data *p, unsigned long *f) {}
  67. static inline void pgdat_resize_init(struct pglist_data *pgdat) {}
  68. static inline unsigned zone_span_seqbegin(struct zone *zone)
  69. {
  70. return 0;
  71. }
  72. static inline int zone_span_seqretry(struct zone *zone, unsigned iv)
  73. {
  74. return 0;
  75. }
  76. static inline void zone_span_writelock(struct zone *zone) {}
  77. static inline void zone_span_writeunlock(struct zone *zone) {}
  78. static inline void zone_seqlock_init(struct zone *zone) {}
  79. static inline int mhp_notimplemented(const char *func)
  80. {
  81. printk(KERN_WARNING "%s() called, with CONFIG_MEMORY_HOTPLUG disabled\n", func);
  82. dump_stack();
  83. return -ENOSYS;
  84. }
  85. static inline int __add_pages(struct zone *zone, unsigned long start_pfn,
  86. unsigned long nr_pages)
  87. {
  88. return mhp_notimplemented(__FUNCTION__);
  89. }
  90. #endif /* ! CONFIG_MEMORY_HOTPLUG */
  91. static inline int __remove_pages(struct zone *zone, unsigned long start_pfn,
  92. unsigned long nr_pages)
  93. {
  94. printk(KERN_WARNING "%s() called, not yet supported\n", __FUNCTION__);
  95. dump_stack();
  96. return -ENOSYS;
  97. }
  98. #endif /* __LINUX_MEMORY_HOTPLUG_H */