blob: 4b08bc947578680ce4f014e986e19a90e2dba00e [file] [log] [blame]
Dave Hansen208d54e2005-10-29 18:16:52 -07001#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 */
11static inline
12void pgdat_resize_lock(struct pglist_data *pgdat, unsigned long *flags)
13{
14 spin_lock_irqsave(&pgdat->node_size_lock, *flags);
15}
16static inline
17void pgdat_resize_unlock(struct pglist_data *pgdat, unsigned long *flags)
18{
Dave Hansenbdc8cb92005-10-29 18:16:53 -070019 spin_unlock_irqrestore(&pgdat->node_size_lock, *flags);
Dave Hansen208d54e2005-10-29 18:16:52 -070020}
21static inline
22void pgdat_resize_init(struct pglist_data *pgdat)
23{
24 spin_lock_init(&pgdat->node_size_lock);
25}
Dave Hansenbdc8cb92005-10-29 18:16:53 -070026/*
27 * Zone resizing functions
28 */
29static inline unsigned zone_span_seqbegin(struct zone *zone)
30{
31 return read_seqbegin(&zone->span_seqlock);
32}
33static inline int zone_span_seqretry(struct zone *zone, unsigned iv)
34{
35 return read_seqretry(&zone->span_seqlock, iv);
36}
37static inline void zone_span_writelock(struct zone *zone)
38{
39 write_seqlock(&zone->span_seqlock);
40}
41static inline void zone_span_writeunlock(struct zone *zone)
42{
43 write_sequnlock(&zone->span_seqlock);
44}
45static inline void zone_seqlock_init(struct zone *zone)
46{
47 seqlock_init(&zone->span_seqlock);
48}
Dave Hansen208d54e2005-10-29 18:16:52 -070049#else /* ! CONFIG_MEMORY_HOTPLUG */
50/*
51 * Stub functions for when hotplug is off
52 */
53static inline void pgdat_resize_lock(struct pglist_data *p, unsigned long *f) {}
54static inline void pgdat_resize_unlock(struct pglist_data *p, unsigned long *f) {}
55static inline void pgdat_resize_init(struct pglist_data *pgdat) {}
Dave Hansenbdc8cb92005-10-29 18:16:53 -070056
57static inline unsigned zone_span_seqbegin(struct zone *zone)
58{
59 return 0;
60}
61static inline int zone_span_seqretry(struct zone *zone, unsigned iv)
62{
63 return 0;
64}
65static inline void zone_span_writelock(struct zone *zone) {}
66static inline void zone_span_writeunlock(struct zone *zone) {}
67static inline void zone_seqlock_init(struct zone *zone) {}
68#endif /* ! CONFIG_MEMORY_HOTPLUG */
Dave Hansen208d54e2005-10-29 18:16:52 -070069#endif /* __LINUX_MEMORY_HOTPLUG_H */