Initialize the new_thread_stack so syslet support testing has one
[fio.git] / engines / syslet-rw.c
index a293e7f4715d415622f50b971ac1012a513ec9a2..dcfcb79f4b16b62c4c0c5038b9548a72ee3cfaf6 100644 (file)
@@ -13,7 +13,6 @@
 #include <asm/unistd.h>
 
 #include "../fio.h"
-#include "../os.h"
 
 #ifdef FIO_HAVE_SYSLET
 
@@ -237,6 +236,11 @@ static int fio_syslet_commit(struct thread_data *td)
         */
        done = async_exec(sd->head, &sd->ahu);
 
+       if (done == (void *) -1) {
+               log_err("fio: syslets don't appear to work\n");
+               return -1;
+       }
+
        sd->head = sd->tail = NULL;
 
        if (done)
@@ -249,6 +253,8 @@ static int fio_syslet_queue(struct thread_data *td, struct io_u *io_u)
 {
        struct syslet_data *sd = td->io_ops->data;
 
+       fio_ro_check(td, io_u);
+
        if (sd->tail) {
                sd->tail->next = &io_u->req.atom;
                sd->tail = &io_u->req.atom;
@@ -275,6 +281,7 @@ static int async_head_init(struct syslet_data *sd, unsigned int depth)
        sd->ahu.head_stack = thread_stack_alloc();
        sd->ahu.head_eip = (unsigned long) cachemiss_thread_start;
        sd->ahu.new_thread_eip = (unsigned long) cachemiss_thread_start;
+       sd->ahu.new_thread_stack = thread_stack_alloc();
 
        return 0;
 }
@@ -284,6 +291,19 @@ static void async_head_exit(struct syslet_data *sd)
        free(sd->ring);
 }
 
+static int check_syslet_support(struct syslet_data *sd)
+{
+       struct syslet_uatom atom;
+       void *ret;
+
+       init_atom(&atom, __NR_getpid, NULL, NULL, NULL, NULL, NULL, 0, NULL);
+       ret = async_exec(sd->head, &sd->ahu);
+       if (ret == (void *) -1)
+               return 1;
+
+       return 0;
+}
+
 static void fio_syslet_cleanup(struct thread_data *td)
 {
        struct syslet_data *sd = td->io_ops->data;
@@ -300,7 +320,6 @@ static int fio_syslet_init(struct thread_data *td)
 {
        struct syslet_data *sd;
 
-
        sd = malloc(sizeof(*sd));
        memset(sd, 0, sizeof(*sd));
        sd->events = malloc(sizeof(struct io_u *) * td->o.iodepth);
@@ -315,6 +334,13 @@ static int fio_syslet_init(struct thread_data *td)
                return 1;
        }
 
+       if (check_syslet_support(sd)) {
+               log_err("fio: syslets do not appear to work\n");
+               free(sd->events);
+               free(sd);
+               return 1;
+       }
+
        td->io_ops->data = sd;
        return 0;
 }