summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorOmar Sandoval <osandov@fb.com>2016-09-17 11:28:24 +0300
committerJens Axboe <axboe@fb.com>2016-09-17 17:39:12 +0300
commitf4a644db86669d938c71f19560aebf69d4720d63 (patch)
tree9a3f2df232414fdeae47881639ed1ed77406198a /lib
parent40aabb67464d5aad9ca3d2a5fedee56e2ff45aa0 (diff)
downloadlinux-f4a644db86669d938c71f19560aebf69d4720d63.tar.xz
sbitmap: push alloc policy into sbitmap_queue
Again, there's no point in passing this in every time. Make it part of struct sbitmap_queue and clean up the API. Signed-off-by: Omar Sandoval <osandov@fb.com> Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/sbitmap.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/sbitmap.c b/lib/sbitmap.c
index 1651ad9d5530..be55f744b771 100644
--- a/lib/sbitmap.c
+++ b/lib/sbitmap.c
@@ -196,7 +196,7 @@ static unsigned int sbq_calc_wake_batch(unsigned int depth)
}
int sbitmap_queue_init_node(struct sbitmap_queue *sbq, unsigned int depth,
- int shift, gfp_t flags, int node)
+ int shift, bool round_robin, gfp_t flags, int node)
{
int ret;
int i;
@@ -225,6 +225,8 @@ int sbitmap_queue_init_node(struct sbitmap_queue *sbq, unsigned int depth,
init_waitqueue_head(&sbq->ws[i].wait);
atomic_set(&sbq->ws[i].wait_cnt, sbq->wake_batch);
}
+
+ sbq->round_robin = round_robin;
return 0;
}
EXPORT_SYMBOL_GPL(sbitmap_queue_init_node);
@@ -236,18 +238,18 @@ void sbitmap_queue_resize(struct sbitmap_queue *sbq, unsigned int depth)
}
EXPORT_SYMBOL_GPL(sbitmap_queue_resize);
-int __sbitmap_queue_get(struct sbitmap_queue *sbq, bool round_robin)
+int __sbitmap_queue_get(struct sbitmap_queue *sbq)
{
unsigned int hint;
int nr;
hint = this_cpu_read(*sbq->alloc_hint);
- nr = sbitmap_get(&sbq->sb, hint, round_robin);
+ nr = sbitmap_get(&sbq->sb, hint, sbq->round_robin);
if (nr == -1) {
/* If the map is full, a hint won't do us much good. */
this_cpu_write(*sbq->alloc_hint, 0);
- } else if (nr == hint || unlikely(round_robin)) {
+ } else if (nr == hint || unlikely(sbq->round_robin)) {
/* Only update the hint if we used it. */
hint = nr + 1;
if (hint >= sbq->sb.depth - 1)
@@ -304,11 +306,11 @@ static void sbq_wake_up(struct sbitmap_queue *sbq)
}
void sbitmap_queue_clear(struct sbitmap_queue *sbq, unsigned int nr,
- bool round_robin, unsigned int cpu)
+ unsigned int cpu)
{
sbitmap_clear_bit(&sbq->sb, nr);
sbq_wake_up(sbq);
- if (likely(!round_robin))
+ if (likely(!sbq->round_robin))
*per_cpu_ptr(sbq->alloc_hint, cpu) = nr;
}
EXPORT_SYMBOL_GPL(sbitmap_queue_clear);