sched.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. /******************************************************************************
  2. * sched.h
  3. *
  4. * Scheduler state interactions
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7. * of this software and associated documentation files (the "Software"), to
  8. * deal in the Software without restriction, including without limitation the
  9. * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  10. * sell copies of the Software, and to permit persons to whom the Software is
  11. * furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in
  14. * all copies or substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  21. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  22. * DEALINGS IN THE SOFTWARE.
  23. *
  24. * Copyright (c) 2005, Keir Fraser <keir@xensource.com>
  25. */
  26. #ifndef __XEN_PUBLIC_SCHED_H__
  27. #define __XEN_PUBLIC_SCHED_H__
  28. #include "event_channel.h"
  29. /*
  30. * `incontents 150 sched Guest Scheduler Operations
  31. *
  32. * The SCHEDOP interface provides mechanisms for a guest to interact
  33. * with the scheduler, including yield, blocking and shutting itself
  34. * down.
  35. */
  36. /*
  37. * The prototype for this hypercall is:
  38. * ` long HYPERVISOR_sched_op(enum sched_op cmd, void *arg, ...)
  39. *
  40. * @cmd == SCHEDOP_??? (scheduler operation).
  41. * @arg == Operation-specific extra argument(s), as described below.
  42. * ... == Additional Operation-specific extra arguments, described below.
  43. *
  44. * Versions of Xen prior to 3.0.2 provided only the following legacy version
  45. * of this hypercall, supporting only the commands yield, block and shutdown:
  46. * long sched_op(int cmd, unsigned long arg)
  47. * @cmd == SCHEDOP_??? (scheduler operation).
  48. * @arg == 0 (SCHEDOP_yield and SCHEDOP_block)
  49. * == SHUTDOWN_* code (SCHEDOP_shutdown)
  50. *
  51. * This legacy version is available to new guests as:
  52. * ` long HYPERVISOR_sched_op_compat(enum sched_op cmd, unsigned long arg)
  53. */
  54. /* ` enum sched_op { // SCHEDOP_* => struct sched_* */
  55. /*
  56. * Voluntarily yield the CPU.
  57. * @arg == NULL.
  58. */
  59. #define SCHEDOP_yield 0
  60. /*
  61. * Block execution of this VCPU until an event is received for processing.
  62. * If called with event upcalls masked, this operation will atomically
  63. * reenable event delivery and check for pending events before blocking the
  64. * VCPU. This avoids a "wakeup waiting" race.
  65. * @arg == NULL.
  66. */
  67. #define SCHEDOP_block 1
  68. /*
  69. * Halt execution of this domain (all VCPUs) and notify the system controller.
  70. * @arg == pointer to sched_shutdown_t structure.
  71. *
  72. * If the sched_shutdown_t reason is SHUTDOWN_suspend then
  73. * x86 PV guests must also set RDX (EDX for 32-bit guests) to the MFN
  74. * of the guest's start info page. RDX/EDX is the third hypercall
  75. * argument.
  76. *
  77. * In addition, which reason is SHUTDOWN_suspend this hypercall
  78. * returns 1 if suspend was cancelled or the domain was merely
  79. * checkpointed, and 0 if it is resuming in a new domain.
  80. */
  81. #define SCHEDOP_shutdown 2
  82. /*
  83. * Poll a set of event-channel ports. Return when one or more are pending. An
  84. * optional timeout may be specified.
  85. * @arg == pointer to sched_poll_t structure.
  86. */
  87. #define SCHEDOP_poll 3
  88. /*
  89. * Declare a shutdown for another domain. The main use of this function is
  90. * in interpreting shutdown requests and reasons for fully-virtualized
  91. * domains. A para-virtualized domain may use SCHEDOP_shutdown directly.
  92. * @arg == pointer to sched_remote_shutdown_t structure.
  93. */
  94. #define SCHEDOP_remote_shutdown 4
  95. /*
  96. * Latch a shutdown code, so that when the domain later shuts down it
  97. * reports this code to the control tools.
  98. * @arg == sched_shutdown_t, as for SCHEDOP_shutdown.
  99. */
  100. #define SCHEDOP_shutdown_code 5
  101. /*
  102. * Setup, poke and destroy a domain watchdog timer.
  103. * @arg == pointer to sched_watchdog_t structure.
  104. * With id == 0, setup a domain watchdog timer to cause domain shutdown
  105. * after timeout, returns watchdog id.
  106. * With id != 0 and timeout == 0, destroy domain watchdog timer.
  107. * With id != 0 and timeout != 0, poke watchdog timer and set new timeout.
  108. */
  109. #define SCHEDOP_watchdog 6
  110. /*
  111. * Override the current vcpu affinity by pinning it to one physical cpu or
  112. * undo this override restoring the previous affinity.
  113. * @arg == pointer to sched_pin_override_t structure.
  114. *
  115. * A negative pcpu value will undo a previous pin override and restore the
  116. * previous cpu affinity.
  117. * This call is allowed for the hardware domain only and requires the cpu
  118. * to be part of the domain's cpupool.
  119. */
  120. #define SCHEDOP_pin_override 7
  121. /* ` } */
  122. struct sched_shutdown {
  123. unsigned int reason; /* SHUTDOWN_* => enum sched_shutdown_reason */
  124. };
  125. typedef struct sched_shutdown sched_shutdown_t;
  126. DEFINE_XEN_GUEST_HANDLE(sched_shutdown_t);
  127. struct sched_poll {
  128. XEN_GUEST_HANDLE(evtchn_port_t) ports;
  129. unsigned int nr_ports;
  130. uint64_t timeout;
  131. };
  132. typedef struct sched_poll sched_poll_t;
  133. DEFINE_XEN_GUEST_HANDLE(sched_poll_t);
  134. struct sched_remote_shutdown {
  135. domid_t domain_id; /* Remote domain ID */
  136. unsigned int reason; /* SHUTDOWN_* => enum sched_shutdown_reason */
  137. };
  138. typedef struct sched_remote_shutdown sched_remote_shutdown_t;
  139. DEFINE_XEN_GUEST_HANDLE(sched_remote_shutdown_t);
  140. struct sched_watchdog {
  141. uint32_t id; /* watchdog ID */
  142. uint32_t timeout; /* timeout */
  143. };
  144. typedef struct sched_watchdog sched_watchdog_t;
  145. DEFINE_XEN_GUEST_HANDLE(sched_watchdog_t);
  146. struct sched_pin_override {
  147. int32_t pcpu;
  148. };
  149. typedef struct sched_pin_override sched_pin_override_t;
  150. DEFINE_XEN_GUEST_HANDLE(sched_pin_override_t);
  151. /*
  152. * Reason codes for SCHEDOP_shutdown. These may be interpreted by control
  153. * software to determine the appropriate action. For the most part, Xen does
  154. * not care about the shutdown code.
  155. */
  156. /* ` enum sched_shutdown_reason { */
  157. #define SHUTDOWN_poweroff 0 /* Domain exited normally. Clean up and kill. */
  158. #define SHUTDOWN_reboot 1 /* Clean up, kill, and then restart. */
  159. #define SHUTDOWN_suspend 2 /* Clean up, save suspend info, kill. */
  160. #define SHUTDOWN_crash 3 /* Tell controller we've crashed. */
  161. #define SHUTDOWN_watchdog 4 /* Restart because watchdog time expired. */
  162. /*
  163. * Domain asked to perform 'soft reset' for it. The expected behavior is to
  164. * reset internal Xen state for the domain returning it to the point where it
  165. * was created but leaving the domain's memory contents and vCPU contexts
  166. * intact. This will allow the domain to start over and set up all Xen specific
  167. * interfaces again.
  168. */
  169. #define SHUTDOWN_soft_reset 5
  170. #define SHUTDOWN_MAX 5 /* Maximum valid shutdown reason. */
  171. /* ` } */
  172. #endif /* __XEN_PUBLIC_SCHED_H__ */
  173. /*
  174. * Local variables:
  175. * mode: C
  176. * c-file-style: "BSD"
  177. * c-basic-offset: 4
  178. * tab-width: 4
  179. * indent-tabs-mode: nil
  180. * End:
  181. */