sched.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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 <xen/interface/event_channel.h>
  29. /*
  30. * 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. /*
  55. * Voluntarily yield the CPU.
  56. * @arg == NULL.
  57. */
  58. #define SCHEDOP_yield 0
  59. /*
  60. * Block execution of this VCPU until an event is received for processing.
  61. * If called with event upcalls masked, this operation will atomically
  62. * reenable event delivery and check for pending events before blocking the
  63. * VCPU. This avoids a "wakeup waiting" race.
  64. * @arg == NULL.
  65. */
  66. #define SCHEDOP_block 1
  67. /*
  68. * Halt execution of this domain (all VCPUs) and notify the system controller.
  69. * @arg == pointer to sched_shutdown structure.
  70. *
  71. * If the sched_shutdown_t reason is SHUTDOWN_suspend then
  72. * x86 PV guests must also set RDX (EDX for 32-bit guests) to the MFN
  73. * of the guest's start info page. RDX/EDX is the third hypercall
  74. * argument.
  75. *
  76. * In addition, which reason is SHUTDOWN_suspend this hypercall
  77. * returns 1 if suspend was cancelled or the domain was merely
  78. * checkpointed, and 0 if it is resuming in a new domain.
  79. */
  80. #define SCHEDOP_shutdown 2
  81. /*
  82. * Poll a set of event-channel ports. Return when one or more are pending. An
  83. * optional timeout may be specified.
  84. * @arg == pointer to sched_poll structure.
  85. */
  86. #define SCHEDOP_poll 3
  87. /*
  88. * Declare a shutdown for another domain. The main use of this function is
  89. * in interpreting shutdown requests and reasons for fully-virtualized
  90. * domains. A para-virtualized domain may use SCHEDOP_shutdown directly.
  91. * @arg == pointer to sched_remote_shutdown structure.
  92. */
  93. #define SCHEDOP_remote_shutdown 4
  94. /*
  95. * Latch a shutdown code, so that when the domain later shuts down it
  96. * reports this code to the control tools.
  97. * @arg == sched_shutdown, as for SCHEDOP_shutdown.
  98. */
  99. #define SCHEDOP_shutdown_code 5
  100. /*
  101. * Setup, poke and destroy a domain watchdog timer.
  102. * @arg == pointer to sched_watchdog structure.
  103. * With id == 0, setup a domain watchdog timer to cause domain shutdown
  104. * after timeout, returns watchdog id.
  105. * With id != 0 and timeout == 0, destroy domain watchdog timer.
  106. * With id != 0 and timeout != 0, poke watchdog timer and set new timeout.
  107. */
  108. #define SCHEDOP_watchdog 6
  109. /*
  110. * Override the current vcpu affinity by pinning it to one physical cpu or
  111. * undo this override restoring the previous affinity.
  112. * @arg == pointer to sched_pin_override structure.
  113. *
  114. * A negative pcpu value will undo a previous pin override and restore the
  115. * previous cpu affinity.
  116. * This call is allowed for the hardware domain only and requires the cpu
  117. * to be part of the domain's cpupool.
  118. */
  119. #define SCHEDOP_pin_override 7
  120. struct sched_shutdown {
  121. unsigned int reason; /* SHUTDOWN_* => shutdown reason */
  122. };
  123. DEFINE_GUEST_HANDLE_STRUCT(sched_shutdown);
  124. struct sched_poll {
  125. GUEST_HANDLE(evtchn_port_t) ports;
  126. unsigned int nr_ports;
  127. uint64_t timeout;
  128. };
  129. DEFINE_GUEST_HANDLE_STRUCT(sched_poll);
  130. struct sched_remote_shutdown {
  131. domid_t domain_id; /* Remote domain ID */
  132. unsigned int reason; /* SHUTDOWN_* => shutdown reason */
  133. };
  134. DEFINE_GUEST_HANDLE_STRUCT(sched_remote_shutdown);
  135. struct sched_watchdog {
  136. uint32_t id; /* watchdog ID */
  137. uint32_t timeout; /* timeout */
  138. };
  139. DEFINE_GUEST_HANDLE_STRUCT(sched_watchdog);
  140. struct sched_pin_override {
  141. int32_t pcpu;
  142. };
  143. DEFINE_GUEST_HANDLE_STRUCT(sched_pin_override);
  144. /*
  145. * Reason codes for SCHEDOP_shutdown. These may be interpreted by control
  146. * software to determine the appropriate action. For the most part, Xen does
  147. * not care about the shutdown code.
  148. */
  149. #define SHUTDOWN_poweroff 0 /* Domain exited normally. Clean up and kill. */
  150. #define SHUTDOWN_reboot 1 /* Clean up, kill, and then restart. */
  151. #define SHUTDOWN_suspend 2 /* Clean up, save suspend info, kill. */
  152. #define SHUTDOWN_crash 3 /* Tell controller we've crashed. */
  153. #define SHUTDOWN_watchdog 4 /* Restart because watchdog time expired. */
  154. /*
  155. * Domain asked to perform 'soft reset' for it. The expected behavior is to
  156. * reset internal Xen state for the domain returning it to the point where it
  157. * was created but leaving the domain's memory contents and vCPU contexts
  158. * intact. This will allow the domain to start over and set up all Xen specific
  159. * interfaces again.
  160. */
  161. #define SHUTDOWN_soft_reset 5
  162. #define SHUTDOWN_MAX 5 /* Maximum valid shutdown reason. */
  163. #endif /* __XEN_PUBLIC_SCHED_H__ */