Commit | Line | Data |
---|---|---|
25763b3c | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
e19494ed | 2 | /* Copyright (c) 2016 Facebook |
e19494ed AS |
3 | */ |
4 | #ifndef __PERCPU_FREELIST_H__ | |
5 | #define __PERCPU_FREELIST_H__ | |
6 | #include <linux/spinlock.h> | |
7 | #include <linux/percpu.h> | |
8 | ||
9 | struct pcpu_freelist_head { | |
10 | struct pcpu_freelist_node *first; | |
11 | raw_spinlock_t lock; | |
12 | }; | |
13 | ||
14 | struct pcpu_freelist { | |
15 | struct pcpu_freelist_head __percpu *freelist; | |
16 | }; | |
17 | ||
18 | struct pcpu_freelist_node { | |
19 | struct pcpu_freelist_node *next; | |
20 | }; | |
21 | ||
a89fac57 | 22 | /* pcpu_freelist_* do spin_lock_irqsave. */ |
e19494ed AS |
23 | void pcpu_freelist_push(struct pcpu_freelist *, struct pcpu_freelist_node *); |
24 | struct pcpu_freelist_node *pcpu_freelist_pop(struct pcpu_freelist *); | |
a89fac57 AS |
25 | /* __pcpu_freelist_* do spin_lock only. caller must disable irqs. */ |
26 | void __pcpu_freelist_push(struct pcpu_freelist *, struct pcpu_freelist_node *); | |
27 | struct pcpu_freelist_node *__pcpu_freelist_pop(struct pcpu_freelist *); | |
e19494ed AS |
28 | void pcpu_freelist_populate(struct pcpu_freelist *s, void *buf, u32 elem_size, |
29 | u32 nr_elems); | |
30 | int pcpu_freelist_init(struct pcpu_freelist *); | |
31 | void pcpu_freelist_destroy(struct pcpu_freelist *s); | |
32 | #endif |