diff options
Diffstat (limited to 'include/linux/percpu_ida.h')
-rw-r--r-- | include/linux/percpu_ida.h | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/include/linux/percpu_ida.h b/include/linux/percpu_ida.h index 0b23edbee309..1900bd0fa639 100644 --- a/include/linux/percpu_ida.h +++ b/include/linux/percpu_ida.h | |||
@@ -16,6 +16,8 @@ struct percpu_ida { | |||
16 | * percpu_ida_init() | 16 | * percpu_ida_init() |
17 | */ | 17 | */ |
18 | unsigned nr_tags; | 18 | unsigned nr_tags; |
19 | unsigned percpu_max_size; | ||
20 | unsigned percpu_batch_size; | ||
19 | 21 | ||
20 | struct percpu_ida_cpu __percpu *tag_cpu; | 22 | struct percpu_ida_cpu __percpu *tag_cpu; |
21 | 23 | ||
@@ -51,10 +53,29 @@ struct percpu_ida { | |||
51 | } ____cacheline_aligned_in_smp; | 53 | } ____cacheline_aligned_in_smp; |
52 | }; | 54 | }; |
53 | 55 | ||
56 | /* | ||
57 | * Number of tags we move between the percpu freelist and the global freelist at | ||
58 | * a time | ||
59 | */ | ||
60 | #define IDA_DEFAULT_PCPU_BATCH_MOVE 32U | ||
61 | /* Max size of percpu freelist, */ | ||
62 | #define IDA_DEFAULT_PCPU_SIZE ((IDA_DEFAULT_PCPU_BATCH_MOVE * 3) / 2) | ||
63 | |||
54 | int percpu_ida_alloc(struct percpu_ida *pool, gfp_t gfp); | 64 | int percpu_ida_alloc(struct percpu_ida *pool, gfp_t gfp); |
55 | void percpu_ida_free(struct percpu_ida *pool, unsigned tag); | 65 | void percpu_ida_free(struct percpu_ida *pool, unsigned tag); |
56 | 66 | ||
57 | void percpu_ida_destroy(struct percpu_ida *pool); | 67 | void percpu_ida_destroy(struct percpu_ida *pool); |
58 | int percpu_ida_init(struct percpu_ida *pool, unsigned long nr_tags); | 68 | int __percpu_ida_init(struct percpu_ida *pool, unsigned long nr_tags, |
69 | unsigned long max_size, unsigned long batch_size); | ||
70 | static inline int percpu_ida_init(struct percpu_ida *pool, unsigned long nr_tags) | ||
71 | { | ||
72 | return __percpu_ida_init(pool, nr_tags, IDA_DEFAULT_PCPU_SIZE, | ||
73 | IDA_DEFAULT_PCPU_BATCH_MOVE); | ||
74 | } | ||
75 | |||
76 | typedef int (*percpu_ida_cb)(unsigned, void *); | ||
77 | int percpu_ida_for_each_free(struct percpu_ida *pool, percpu_ida_cb fn, | ||
78 | void *data); | ||
59 | 79 | ||
80 | unsigned percpu_ida_free_tags(struct percpu_ida *pool, int cpu); | ||
60 | #endif /* __PERCPU_IDA_H__ */ | 81 | #endif /* __PERCPU_IDA_H__ */ |