projects
/
fio.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Allow randommap allocation to fail
[fio.git]
/
engines
/
syslet-rw.c
diff --git
a/engines/syslet-rw.c
b/engines/syslet-rw.c
index e3be4859503bc9e897c1f7bd29e118f07d0d3734..0fdf75227295540de9defc4976a8b2a84dfb8957 100644
(file)
--- a/
engines/syslet-rw.c
+++ b/
engines/syslet-rw.c
@@
-14,8
+14,7
@@
#include <asm/unistd.h>
#include "../fio.h"
#include <asm/unistd.h>
#include "../fio.h"
-#include "../indirect.h"
-#include "../syslet.h"
+#include "../fls.h"
#ifdef FIO_HAVE_SYSLET
#ifdef FIO_HAVE_SYSLET
@@
-32,6
+31,7
@@
struct syslet_data {
unsigned int nr_events;
struct syslet_ring *ring;
unsigned int nr_events;
struct syslet_ring *ring;
+ unsigned int ring_mask;
void *stack;
};
void *stack;
};
@@
-46,10
+46,13
@@
static void fio_syslet_add_event(struct thread_data *td, struct io_u *io_u)
static void fio_syslet_add_events(struct thread_data *td, unsigned int nr)
{
struct syslet_data *sd = td->io_ops->data;
static void fio_syslet_add_events(struct thread_data *td, unsigned int nr)
{
struct syslet_data *sd = td->io_ops->data;
- unsigned int i;
+ unsigned int i, uidx;
+
+ uidx = sd->ring->user_tail;
+ read_barrier();
for (i = 0; i < nr; i++) {
for (i = 0; i < nr; i++) {
- unsigned int idx = (i +
sd->ring->user_tail) % td->o.iodepth
;
+ unsigned int idx = (i +
uidx) & sd->ring_mask
;
struct syslet_completion *comp = &sd->ring->comp[idx];
struct io_u *io_u = (struct io_u *) (long) comp->caller_data;
long ret;
struct syslet_completion *comp = &sd->ring->comp[idx];
struct io_u *io_u = (struct io_u *) (long) comp->caller_data;
long ret;
@@
-71,9
+74,7
@@
static void fio_syslet_wait_for_events(struct thread_data *td)
{
struct syslet_data *sd = td->io_ops->data;
struct syslet_ring *ring = sd->ring;
{
struct syslet_data *sd = td->io_ops->data;
struct syslet_ring *ring = sd->ring;
- unsigned int events;
- events = 0;
do {
unsigned int kh = ring->kernel_head;
int ret;
do {
unsigned int kh = ring->kernel_head;
int ret;
@@
-85,9
+86,8
@@
static void fio_syslet_wait_for_events(struct thread_data *td)
unsigned int nr = kh - ring->user_tail;
fio_syslet_add_events(td, nr);
unsigned int nr = kh - ring->user_tail;
fio_syslet_add_events(td, nr);
- events += nr;
ring->user_tail = kh;
ring->user_tail = kh;
-
continue
;
+
break
;
}
/*
}
/*
@@
-95,25
+95,23
@@
static void fio_syslet_wait_for_events(struct thread_data *td)
*/
ret = syscall(__NR_syslet_ring_wait, ring, ring->user_tail);
assert(!ret);
*/
ret = syscall(__NR_syslet_ring_wait, ring, ring->user_tail);
assert(!ret);
- } while (
!events
);
+ } while (
1
);
}
}
-static int fio_syslet_getevents(struct thread_data *td, int min,
- int fio_unused max,
+static int fio_syslet_getevents(struct thread_data *td,
unsigned
int min,
+
unsigned
int fio_unused max,
struct timespec fio_unused *t)
{
struct syslet_data *sd = td->io_ops->data;
long ret;
struct timespec fio_unused *t)
{
struct syslet_data *sd = td->io_ops->data;
long ret;
- do {
- /*
- * do we have enough immediate completions?
- */
- if (sd->nr_events >= (unsigned int) min)
- break;
-
+ /*
+ * While we have less events than requested, block waiting for them
+ * (if we have to, there may already be more completed events ready
+ * for us - see fio_syslet_wait_for_events()
+ */
+ while (sd->nr_events < min)
fio_syslet_wait_for_events(td);
fio_syslet_wait_for_events(td);
- } while (1);
ret = sd->nr_events;
sd->nr_events = 0;
ret = sd->nr_events;
sd->nr_events = 0;
@@
-223,7
+221,6
@@
static void fio_syslet_cleanup(struct thread_data *td)
if (sd) {
free(sd->events);
free(sd->ring);
if (sd) {
free(sd->events);
free(sd->ring);
- free(sd->stack);
free(sd);
td->io_ops->data = NULL;
}
free(sd);
td->io_ops->data = NULL;
}
@@
-245,14
+242,8
@@
static int fio_syslet_init(struct thread_data *td)
* The ring needs to be a power-of-2, so round it up if we have to
*/
ring_nr = td->o.iodepth;
* The ring needs to be a power-of-2, so round it up if we have to
*/
ring_nr = td->o.iodepth;
- if (ring_nr & (ring_nr - 1)) {
- int bits = 1;
-
- while (ring_nr >>= 1)
- bits++;
-
- ring_nr = 1 << bits;
- }
+ if (ring_nr & (ring_nr - 1))
+ ring_nr = 1 << fls(ring_nr);
ring_size = sizeof(struct syslet_ring) +
ring_nr * sizeof(struct syslet_completion);
ring_size = sizeof(struct syslet_ring) +
ring_nr * sizeof(struct syslet_completion);
@@
-262,6
+253,7
@@
static int fio_syslet_init(struct thread_data *td)
goto err_mem;
sd->ring = ring;
goto err_mem;
sd->ring = ring;
+ sd->ring_mask = ring_nr - 1;
sd->stack = stack;
memset(sd->ring, 0, ring_size);
sd->stack = stack;
memset(sd->ring, 0, ring_size);