Skip to content

Commit

Permalink
Add roundup_pow2() as a generic helper
Browse files Browse the repository at this point in the history
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
axboe committed Jul 27, 2020
1 parent 11b280c commit 6d975f2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
6 changes: 1 addition & 5 deletions engines/io_uring.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "../optgroup.h"
#include "../lib/memalign.h"
#include "../lib/fls.h"
#include "../lib/roundup.h"

#ifdef ARCH_HAVE_IOURING

Expand Down Expand Up @@ -654,11 +655,6 @@ static int fio_ioring_post_init(struct thread_data *td)
return 0;
}

static unsigned roundup_pow2(unsigned depth)
{
return 1UL << __fls(depth - 1);
}

static int fio_ioring_init(struct thread_data *td)
{
struct ioring_options *o = td->eo;
Expand Down
11 changes: 11 additions & 0 deletions lib/roundup.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifndef FIO_ROUNDUP_H
#define FIO_ROUNDUP_H

#include "lib/fls.h"

static inline unsigned roundup_pow2(unsigned depth)
{
return 1UL << __fls(depth - 1);
}

#endif

0 comments on commit 6d975f2

Please sign in to comment.