summaryrefslogtreecommitdiff
path: root/include/linux/tags.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/tags.h')
-rw-r--r--include/linux/tags.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/include/linux/tags.h b/include/linux/tags.h
new file mode 100644
index 000000000000..74b34d7f0ec7
--- /dev/null
+++ b/include/linux/tags.h
@@ -0,0 +1,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