Git Product home page Git Product logo

async-sys-module's Introduction

Design Doc

User space API

Structs

/* Struct which is used to request a particular system call from the user library. */
struct async_cb {
    long number; /* The syscall number. */
    void * vargs[]; /* NULL terminated list of arguments to the syscall of given number. */
};

/* Used to store information about results. */
struct async_event {
    struct async_cb* cbp; /* Pointer to the async_cb where event came from. */
    __s64 res; /* Result of syscall. */
};

Request Async Call Ring

int async_setup(unsigned long nr_events, async_context_t *ctx_idp)

Returns: -1 and sets errno if fail else returns NULL.

Dealloc Async Call Ring Manually

int async_destroy(async_context_t ctx)

Returns: -1 and sets errno if fail else returns NULL.

Get Events (Just a user space check)

int async_check_events(async_context_t ctx, long min_nr, long max_nr, struct async_event events[], 
struct timespec *timeout)

Returns the number of events which were handled.

Add Syscalls (Just a user space placement)

async_cbps should be an array of async_cb pointers filled with syscall information.

int async_submit(async_context_t ctx, long nr, struct async_cb * async_cbps[])

Returns: -1 and sets errno if fail else returns NULL.

Force block in kernel to get queue updates

int async_getevents(async_context_t ctx, long min_nr, long max_nr, struct
async_event events[], struct timespec *timeout)

Returns the number of events which were handled.

Shared Memory Ring Layout

The shared memory ring should be implemented as a thread safe, multi-producer, multi-consumer, queue. In order for this to remain safe for both the kernel and user, this queue will NOT be lock-free (if it were it would be even more complicated [possibly impossible] for the kernel to remain safe from a user).

This queue will contain elements with system calls listed to be executed asynchronously. Elements on this queue will be of max syscall size. (I.E. even write(int,void*) will take up a slot to hold six args that are available for use on linux.) The alternative would be to determine the next space in a queue for a system call after inserting the last one and this would difficult the queue implementation further.

ioctl API (go between user library and kernel)

Create a shared memory ring with the kernel to be able to submit async requests

int async_setup(unsigned long nr_events, async_context_t *ctx_idp)

Returns: -1 and sets errno if fail else returns NULL.

Block in the kernel for a set number of events or a timeout.

int async_getevents(async_context_t ctx, long min_nr, long max_nr, struct async_event events[], 
struct timespec *timeout)

Returns: the number of events which were handled.

Destroy the async ring manually

int async_destroy(async_context_t ctx)

Returns: -1 and sets errno if fail else returns NULL.

Thinking space...

Additional System calls:

  • Request Space to queue up system calls
  • Block to force kernel to handle queue TODO: Might want info receiving system calls?

Kernel Modifications:

  • Create System Calls
  • Create kernel thread routine for reading from buffer

Q: How do we improve concurrency in the shared memory? We would just block on a single item in the queue in the kernel. We could instead use a less circular layout and be much more concurrent?

RE: In order to make the queue more time efficient, we won't use only a single queue for requests and return values. Instead we will keep a single queue with syscall requests, return values will be sent to user space to locations allocated by the user when they submitted a request.

Other Design Notes

NOTE: Rather than trying to intercept system calls (sounds like bad practice) or implement a system call (not portable since is built into the kernel), we'll be creating our own 'device' file and communicate with our kernel module through the ioctl call. (Likely will be wrapped by a user library in order to keep the call structured [it's vararg as defined by header].)

TODO: Might be worth switching from a struct which contains a lot of extra garbage for the async_submit to a va_args type function.

See for help.

Authors & Acknowledgements (Some omitted until more progress is made.)

Sean Wilson [email protected]

This project follows up on previous work to improve filesystem performance in Go.

This project is also heavily inspired by FlexSC written by Livio Soares & Michael Stumm.

async-sys-module's People

Contributors

spwilson2 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.