sched.h 6.1 KB

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