|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Minios-devel] [UNIKRAFT PATCH 5/6] lib/ukblkdev: Synchronous operations
On 29.05.19 10:33, Roxana Nicolescu wrote:
Just name it: "Synchronous I/O API" since it is the only operation mode that the API supports for now. If we want to add a busy waiting version at some point, we can still rename it later. + default n + select LIBUKSCHED + select LIBUKLOCK + select LIBUKLOCK_SEMAPHORE + help + Use semaphore for waiting after a request I/O is done. endif diff --git a/lib/ukblkdev/blkdev.c b/lib/ukblkdev/blkdev.c index 3c58061b..534a9ae1 100644 --- a/lib/ukblkdev/blkdev.c +++ b/lib/ukblkdev/blkdev.c @@ -403,3 +403,67 @@ int uk_blkdev_queue_finish_reqs(struct uk_blkdev *dev,return dev->finish_reqs(dev, queue_id); As an optimization you could add `unlikely()` around the condition? I think it is unlikely to fail. By adding this you enable compiler optimizations for the likely case if the architecture supports it.
You should probably document here that `uk_blkdev_queue_finish_reqs()` has to be called while using the function. This can be done via queue interrupts/events or by calling `uk_blkdev_queue_finish_reqs()` from a different thread context. Otherwise we are blocking the thread forever because it got blocked by the semaphore (and never unblocked). + * @param dev + * The Unikraft Block Device + * @param queue_id + * queue_id + * @param sector + * Start Sector + * @param nb_sectors + * @param buf + * Buffer where data is found + * @ param op + * Type of operation + * @return + * - 0: Success + * - (<0): on error returned by driver + */ +int uk_blkdev_sync_io(struct uk_blkdev *dev, + uint16_t queue_id, + size_t sector, Please use the __sector datatype for the start address, I would prefer also to have something inline with the async API: Call the parameter `__sector start_sector` as you have in your request token. I would also move the operation argument before the buffer.This way you group input parameters together. The buffer can be (dependent on the operation) an input and output buffer. + __sector nb_sectors, + void *buf, + enum uk_blkdev_op op); + +/* + * Wrappers for uk_blkdev_sync_io + */ +#define uk_blkdev_write(blkdev,\ + queue_id, \ + sector, \ + nb_sectors, \ + buf) \ + uk_blkdev_sync_io(blkdev, queue_id, sector, nb_sectors, buf,\ + UK_BLKDEV_WRITE) \ + +#define uk_blkdev_read(blkdev,\ + queue_id, \ + sector, \ + nb_sectors, \ + buf) \ + uk_blkdev_sync_io(blkdev, queue_id, sector, nb_sectors, buf,\ + UK_BLKDEV_READ) \ + I would prefer to call these macros: uk_blkdev_sync_write() and uk_blkdev_sync_read() because they are both based on uk_blkdev_sync_io(). +#endif + #ifdef __cplusplus } #endif diff --git a/lib/ukblkdev/include/uk/blkdev_core.h b/lib/ukblkdev/include/uk/blkdev_core.h index 309b7a7f..66831f90 100644 --- a/lib/ukblkdev/include/uk/blkdev_core.h +++ b/lib/ukblkdev/include/uk/blkdev_core.h @@ -39,7 +39,8 @@ #include <uk/list.h> #include <uk/config.h> #include <uk/blkreq.h> -#if defined(CONFIG_LIBUKBLKDEV_DISPATCHERTHREADS) +#if defined(CONFIG_LIBUKBLKDEV_DISPATCHERTHREADS) || \ + defined(CONFIG_LIBUKBLKDEV_SYNC_IO_BLOCKED_WAITING) #include <uk/sched.h> #include <uk/semaphore.h> #endif _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |