Dave Hansen | 208d54e | 2005-10-29 18:16:52 -0700 | [diff] [blame] | 1 | #ifndef __LINUX_MEMORY_HOTPLUG_H |
| 2 | #define __LINUX_MEMORY_HOTPLUG_H |
| 3 | |
| 4 | #include <linux/mmzone.h> |
| 5 | #include <linux/spinlock.h> |
| 6 | |
| 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 | { |
Dave Hansen | bdc8cb9 | 2005-10-29 18:16:53 -0700 | [diff] [blame^] | 19 | spin_unlock_irqrestore(&pgdat->node_size_lock, *flags); |
Dave Hansen | 208d54e | 2005-10-29 18:16:52 -0700 | [diff] [blame] | 20 | } |
| 21 | static inline |
| 22 | void pgdat_resize_init(struct pglist_data *pgdat) |
| 23 | { |
| 24 | spin_lock_init(&pgdat->node_size_lock); |
| 25 | } |
Dave Hansen | bdc8cb9 | 2005-10-29 18:16:53 -0700 | [diff] [blame^] | 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 | } |
Dave Hansen | 208d54e | 2005-10-29 18:16:52 -0700 | [diff] [blame] | 49 | #else /* ! CONFIG_MEMORY_HOTPLUG */ |
| 50 | /* |
| 51 | * Stub functions for when hotplug is off |
| 52 | */ |
| 53 | static inline void pgdat_resize_lock(struct pglist_data *p, unsigned long *f) {} |
| 54 | static inline void pgdat_resize_unlock(struct pglist_data *p, unsigned long *f) {} |
| 55 | static inline void pgdat_resize_init(struct pglist_data *pgdat) {} |
Dave Hansen | bdc8cb9 | 2005-10-29 18:16:53 -0700 | [diff] [blame^] | 56 | |
| 57 | static inline unsigned zone_span_seqbegin(struct zone *zone) |
| 58 | { |
| 59 | return 0; |
| 60 | } |
| 61 | static inline int zone_span_seqretry(struct zone *zone, unsigned iv) |
| 62 | { |
| 63 | return 0; |
| 64 | } |
| 65 | static inline void zone_span_writelock(struct zone *zone) {} |
| 66 | static inline void zone_span_writeunlock(struct zone *zone) {} |
| 67 | static inline void zone_seqlock_init(struct zone *zone) {} |
| 68 | #endif /* ! CONFIG_MEMORY_HOTPLUG */ |
Dave Hansen | 208d54e | 2005-10-29 18:16:52 -0700 | [diff] [blame] | 69 | #endif /* __LINUX_MEMORY_HOTPLUG_H */ |