[PATCH] memory hotplug locking: zone span seqlock
[deliverable/linux.git] / include / linux / memory_hotplug.h
CommitLineData
208d54e5
DH
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 */
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{
bdc8cb98 19 spin_unlock_irqrestore(&pgdat->node_size_lock, *flags);
208d54e5
DH
20}
21static inline
22void pgdat_resize_init(struct pglist_data *pgdat)
23{
24 spin_lock_init(&pgdat->node_size_lock);
25}
bdc8cb98
DH
26/*
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}
208d54e5
DH
49#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) {}
bdc8cb98
DH
56
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 */
208d54e5 69#endif /* __LINUX_MEMORY_HOTPLUG_H */
This page took 0.027146 seconds and 5 git commands to generate.