@@ -28,21 +28,31 @@ void pcpu_freelist_destroy(struct pcpu_freelist *s)
28
28
free_percpu (s -> freelist );
29
29
}
30
30
31
- static inline void __pcpu_freelist_push (struct pcpu_freelist_head * head ,
32
- struct pcpu_freelist_node * node )
31
+ static inline void ___pcpu_freelist_push (struct pcpu_freelist_head * head ,
32
+ struct pcpu_freelist_node * node )
33
33
{
34
34
raw_spin_lock (& head -> lock );
35
35
node -> next = head -> first ;
36
36
head -> first = node ;
37
37
raw_spin_unlock (& head -> lock );
38
38
}
39
39
40
- void pcpu_freelist_push (struct pcpu_freelist * s ,
40
+ void __pcpu_freelist_push (struct pcpu_freelist * s ,
41
41
struct pcpu_freelist_node * node )
42
42
{
43
43
struct pcpu_freelist_head * head = this_cpu_ptr (s -> freelist );
44
44
45
- __pcpu_freelist_push (head , node );
45
+ ___pcpu_freelist_push (head , node );
46
+ }
47
+
48
+ void pcpu_freelist_push (struct pcpu_freelist * s ,
49
+ struct pcpu_freelist_node * node )
50
+ {
51
+ unsigned long flags ;
52
+
53
+ local_irq_save (flags );
54
+ __pcpu_freelist_push (s , node );
55
+ local_irq_restore (flags );
46
56
}
47
57
48
58
void pcpu_freelist_populate (struct pcpu_freelist * s , void * buf , u32 elem_size ,
@@ -63,7 +73,7 @@ void pcpu_freelist_populate(struct pcpu_freelist *s, void *buf, u32 elem_size,
63
73
for_each_possible_cpu (cpu ) {
64
74
again :
65
75
head = per_cpu_ptr (s -> freelist , cpu );
66
- __pcpu_freelist_push (head , buf );
76
+ ___pcpu_freelist_push (head , buf );
67
77
i ++ ;
68
78
buf += elem_size ;
69
79
if (i == nr_elems )
@@ -74,31 +84,38 @@ void pcpu_freelist_populate(struct pcpu_freelist *s, void *buf, u32 elem_size,
74
84
local_irq_restore (flags );
75
85
}
76
86
77
- struct pcpu_freelist_node * pcpu_freelist_pop (struct pcpu_freelist * s )
87
+ struct pcpu_freelist_node * __pcpu_freelist_pop (struct pcpu_freelist * s )
78
88
{
79
89
struct pcpu_freelist_head * head ;
80
90
struct pcpu_freelist_node * node ;
81
- unsigned long flags ;
82
91
int orig_cpu , cpu ;
83
92
84
- local_irq_save (flags );
85
93
orig_cpu = cpu = raw_smp_processor_id ();
86
94
while (1 ) {
87
95
head = per_cpu_ptr (s -> freelist , cpu );
88
96
raw_spin_lock (& head -> lock );
89
97
node = head -> first ;
90
98
if (node ) {
91
99
head -> first = node -> next ;
92
- raw_spin_unlock_irqrestore (& head -> lock , flags );
100
+ raw_spin_unlock (& head -> lock );
93
101
return node ;
94
102
}
95
103
raw_spin_unlock (& head -> lock );
96
104
cpu = cpumask_next (cpu , cpu_possible_mask );
97
105
if (cpu >= nr_cpu_ids )
98
106
cpu = 0 ;
99
- if (cpu == orig_cpu ) {
100
- local_irq_restore (flags );
107
+ if (cpu == orig_cpu )
101
108
return NULL ;
102
- }
103
109
}
104
110
}
111
+
112
+ struct pcpu_freelist_node * pcpu_freelist_pop (struct pcpu_freelist * s )
113
+ {
114
+ struct pcpu_freelist_node * ret ;
115
+ unsigned long flags ;
116
+
117
+ local_irq_save (flags );
118
+ ret = __pcpu_freelist_pop (s );
119
+ local_irq_restore (flags );
120
+ return ret ;
121
+ }
0 commit comments