blob: fbf8a8a2897911e437f5167b090a1724d8665286 [file] [log] [blame]
Thomas Gleixner25763b32019-05-28 10:10:09 -07001/* SPDX-License-Identifier: GPL-2.0-only */
Alexei Starovoitove19494e2016-03-07 21:57:14 -08002/* Copyright (c) 2016 Facebook
Alexei Starovoitove19494e2016-03-07 21:57:14 -08003 */
4#ifndef __PERCPU_FREELIST_H__
5#define __PERCPU_FREELIST_H__
6#include <linux/spinlock.h>
7#include <linux/percpu.h>
8
9struct pcpu_freelist_head {
10 struct pcpu_freelist_node *first;
11 raw_spinlock_t lock;
12};
13
14struct pcpu_freelist {
15 struct pcpu_freelist_head __percpu *freelist;
16};
17
18struct pcpu_freelist_node {
19 struct pcpu_freelist_node *next;
20};
21
Alexei Starovoitova89fac52019-01-30 18:12:43 -080022/* pcpu_freelist_* do spin_lock_irqsave. */
Alexei Starovoitove19494e2016-03-07 21:57:14 -080023void pcpu_freelist_push(struct pcpu_freelist *, struct pcpu_freelist_node *);
24struct pcpu_freelist_node *pcpu_freelist_pop(struct pcpu_freelist *);
Alexei Starovoitova89fac52019-01-30 18:12:43 -080025/* __pcpu_freelist_* do spin_lock only. caller must disable irqs. */
26void __pcpu_freelist_push(struct pcpu_freelist *, struct pcpu_freelist_node *);
27struct pcpu_freelist_node *__pcpu_freelist_pop(struct pcpu_freelist *);
Alexei Starovoitove19494e2016-03-07 21:57:14 -080028void pcpu_freelist_populate(struct pcpu_freelist *s, void *buf, u32 elem_size,
29 u32 nr_elems);
30int pcpu_freelist_init(struct pcpu_freelist *);
31void pcpu_freelist_destroy(struct pcpu_freelist *s);
32#endif