blob: 74b34d7f0ec7335022284db05f0f12baa0014b42 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
/*
* Copyright 2012 Google Inc. All Rights Reserved.
* Author: koverstreet@google.com (Kent Overstreet)
*
* Per cpu tag allocator.
*/
#ifndef _LINUX_TAGS_H
#define _LINUX_TAGS_H
#include <linux/list.h>
#include <linux/spinlock.h>
struct tag_cpu_freelist;
struct tag_pool {
uint16_t watermark;
uint16_t nr_tags;
struct tag_cpu_freelist *tag_cpu;
struct {
/* Global freelist */
uint16_t nr_free;
uint16_t *free;
spinlock_t lock;
struct list_head wait;
} ____cacheline_aligned;
};
uint16_t tag_alloc(struct tag_pool *pool, bool wait);
void tag_free(struct tag_pool *pool, uint16_t tag);
void tag_pool_free(struct tag_pool *pool);
int tag_pool_init(struct tag_pool *pool, uint16_t nr_tags);
#endif
|