Jens Axboe | a4f4fdd | 2007-02-14 01:16:39 +0100 | [diff] [blame^] | 1 | #ifndef _LINUX_SYSLET_H |
| 2 | #define _LINUX_SYSLET_H |
| 3 | /* |
| 4 | * The syslet subsystem - asynchronous syscall execution support. |
| 5 | * |
| 6 | * Started by Ingo Molnar: |
| 7 | * |
| 8 | * Copyright (C) 2007 Red Hat, Inc., Ingo Molnar <mingo@redhat.com> |
| 9 | * |
| 10 | * User-space API/ABI definitions: |
| 11 | */ |
| 12 | |
| 13 | /* |
| 14 | * This is the 'Syslet Atom' - the basic unit of execution |
| 15 | * within the syslet framework. A syslet always represents |
| 16 | * a single system-call plus its arguments, plus has conditions |
| 17 | * attached to it that allows the construction of larger |
| 18 | * programs from these atoms. User-space variables can be used |
| 19 | * (for example a loop index) via the special sys_umem*() syscalls. |
| 20 | * |
| 21 | * Arguments are implemented via pointers to arguments. This not |
| 22 | * only increases the flexibility of syslet atoms (multiple syslets |
| 23 | * can share the same variable for example), but is also an |
| 24 | * optimization: copy_uatom() will only fetch syscall parameters |
| 25 | * up until the point it meets the first NULL pointer. 50% of all |
| 26 | * syscalls have 2 or less parameters (and 90% of all syscalls have |
| 27 | * 4 or less parameters). |
| 28 | * |
| 29 | * [ Note: since the argument array is at the end of the atom, and the |
| 30 | * kernel will not touch any argument beyond the final NULL one, atoms |
| 31 | * might be packed more tightly. (the only special case exception to |
| 32 | * this rule would be SKIP_TO_NEXT_ON_STOP atoms, where the kernel will |
| 33 | * jump a full syslet_uatom number of bytes.) ] |
| 34 | */ |
| 35 | struct syslet_uatom { |
| 36 | unsigned long flags; |
| 37 | unsigned long nr; |
| 38 | long __user *ret_ptr; |
| 39 | struct syslet_uatom __user *next; |
| 40 | unsigned long __user *arg_ptr[6]; |
| 41 | /* |
| 42 | * User-space can put anything in here, kernel will not |
| 43 | * touch it: |
| 44 | */ |
| 45 | void __user *private; |
| 46 | }; |
| 47 | |
| 48 | /* |
| 49 | * Flags to modify/control syslet atom behavior: |
| 50 | */ |
| 51 | |
| 52 | /* |
| 53 | * Immediately queue this syslet asynchronously - do not even |
| 54 | * attempt to execute it synchronously in the user context: |
| 55 | */ |
| 56 | #define SYSLET_ASYNC 0x00000001 |
| 57 | |
| 58 | /* |
| 59 | * Never queue this syslet asynchronously - even if synchronous |
| 60 | * execution causes a context-switching: |
| 61 | */ |
| 62 | #define SYSLET_SYNC 0x00000002 |
| 63 | |
| 64 | /* |
| 65 | * Do not queue the syslet in the completion ring when done. |
| 66 | * |
| 67 | * ( the default is that the final atom of a syslet is queued |
| 68 | * in the completion ring. ) |
| 69 | * |
| 70 | * Some syscalls generate implicit completion events of their |
| 71 | * own. |
| 72 | */ |
| 73 | #define SYSLET_NO_COMPLETE 0x00000004 |
| 74 | |
| 75 | /* |
| 76 | * Execution control: conditions upon the return code |
| 77 | * of the previous syslet atom. 'Stop' means syslet |
| 78 | * execution is stopped and the atom is put into the |
| 79 | * completion ring: |
| 80 | */ |
| 81 | #define SYSLET_STOP_ON_NONZERO 0x00000008 |
| 82 | #define SYSLET_STOP_ON_ZERO 0x00000010 |
| 83 | #define SYSLET_STOP_ON_NEGATIVE 0x00000020 |
| 84 | #define SYSLET_STOP_ON_NON_POSITIVE 0x00000040 |
| 85 | |
| 86 | #define SYSLET_STOP_MASK \ |
| 87 | ( SYSLET_STOP_ON_NONZERO | \ |
| 88 | SYSLET_STOP_ON_ZERO | \ |
| 89 | SYSLET_STOP_ON_NEGATIVE | \ |
| 90 | SYSLET_STOP_ON_NON_POSITIVE ) |
| 91 | |
| 92 | /* |
| 93 | * Special modifier to 'stop' handling: instead of stopping the |
| 94 | * execution of the syslet, the linearly next syslet is executed. |
| 95 | * (Normal execution flows along atom->next, and execution stops |
| 96 | * if atom->next is NULL or a stop condition becomes true.) |
| 97 | * |
| 98 | * This is what allows true branches of execution within syslets. |
| 99 | */ |
| 100 | #define SYSLET_SKIP_TO_NEXT_ON_STOP 0x00000080 |
| 101 | |
| 102 | /* |
| 103 | * This is the (per-user-context) descriptor of the async completion |
| 104 | * ring. This gets registered via sys_async_register(). |
| 105 | */ |
| 106 | struct async_head_user { |
| 107 | /* |
| 108 | * Pointers to completed async syslets (i.e. syslets that |
| 109 | * generated a cachemiss and went async, returning -EASYNCSYSLET |
| 110 | * to the user context by sys_async_exec()) are queued here. |
| 111 | * Syslets that were executed synchronously are not queued here. |
| 112 | * |
| 113 | * Note: the final atom that generated the exit condition is |
| 114 | * queued here. Normally this would be the last atom of a syslet. |
| 115 | */ |
| 116 | struct syslet_uatom __user **completion_ring; |
| 117 | /* |
| 118 | * Ring size in bytes: |
| 119 | */ |
| 120 | unsigned long ring_size_bytes; |
| 121 | |
| 122 | /* |
| 123 | * Maximum number of asynchronous contexts the kernel creates. |
| 124 | * |
| 125 | * -1UL has a special meaning: the kernel manages the optimal |
| 126 | * size of the async pool. |
| 127 | * |
| 128 | * Note: this field should be valid for the lifetime of async |
| 129 | * processing, because future kernels detect changes to this |
| 130 | * field. (enabling user-space to control the size of the async |
| 131 | * pool in a low-overhead fashion) |
| 132 | */ |
| 133 | unsigned long max_nr_threads; |
| 134 | }; |
| 135 | |
| 136 | #endif |