1 /* Copyright (c) 2016 Facebook
3 * This program is free software; you can redistribute it and/or
4 * modify it under the terms of version 2 of the GNU General Public
5 * License as published by the Free Software Foundation.
7 #ifndef __PERCPU_FREELIST_H__
8 #define __PERCPU_FREELIST_H__
9 #include <linux/spinlock.h>
10 #include <linux/percpu.h>
12 struct pcpu_freelist_head {
13 struct pcpu_freelist_node *first;
17 struct pcpu_freelist {
18 struct pcpu_freelist_head __percpu *freelist;
21 struct pcpu_freelist_node {
22 struct pcpu_freelist_node *next;
25 /* pcpu_freelist_* do spin_lock_irqsave. */
26 void pcpu_freelist_push(struct pcpu_freelist *, struct pcpu_freelist_node *);
27 struct pcpu_freelist_node *pcpu_freelist_pop(struct pcpu_freelist *);
28 /* __pcpu_freelist_* do spin_lock only. caller must disable irqs. */
29 void __pcpu_freelist_push(struct pcpu_freelist *, struct pcpu_freelist_node *);
30 struct pcpu_freelist_node *__pcpu_freelist_pop(struct pcpu_freelist *);
31 void pcpu_freelist_populate(struct pcpu_freelist *s, void *buf, u32 elem_size,
33 int pcpu_freelist_init(struct pcpu_freelist *);
34 void pcpu_freelist_destroy(struct pcpu_freelist *s);