multicalls.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #ifndef _XEN_MULTICALLS_H
  2. #define _XEN_MULTICALLS_H
  3. #include <trace/events/xen.h>
  4. #include "xen-ops.h"
  5. /* Multicalls */
  6. struct multicall_space
  7. {
  8. struct multicall_entry *mc;
  9. void *args;
  10. };
  11. /* Allocate room for a multicall and its args */
  12. struct multicall_space __xen_mc_entry(size_t args);
  13. DECLARE_PER_CPU(unsigned long, xen_mc_irq_flags);
  14. /* Call to start a batch of multiple __xen_mc_entry()s. Must be
  15. paired with xen_mc_issue() */
  16. static inline void xen_mc_batch(void)
  17. {
  18. unsigned long flags;
  19. /* need to disable interrupts until this entry is complete */
  20. local_irq_save(flags);
  21. trace_xen_mc_batch(paravirt_get_lazy_mode());
  22. __this_cpu_write(xen_mc_irq_flags, flags);
  23. }
  24. static inline struct multicall_space xen_mc_entry(size_t args)
  25. {
  26. xen_mc_batch();
  27. return __xen_mc_entry(args);
  28. }
  29. /* Flush all pending multicalls */
  30. void xen_mc_flush(void);
  31. /* Issue a multicall if we're not in a lazy mode */
  32. static inline void xen_mc_issue(unsigned mode)
  33. {
  34. trace_xen_mc_issue(mode);
  35. if ((paravirt_get_lazy_mode() & mode) == 0)
  36. xen_mc_flush();
  37. /* restore flags saved in xen_mc_batch */
  38. local_irq_restore(this_cpu_read(xen_mc_irq_flags));
  39. }
  40. /* Set up a callback to be called when the current batch is flushed */
  41. void xen_mc_callback(void (*fn)(void *), void *data);
  42. /*
  43. * Try to extend the arguments of the previous multicall command. The
  44. * previous command's op must match. If it does, then it attempts to
  45. * extend the argument space allocated to the multicall entry by
  46. * arg_size bytes.
  47. *
  48. * The returned multicall_space will return with mc pointing to the
  49. * command on success, or NULL on failure, and args pointing to the
  50. * newly allocated space.
  51. */
  52. struct multicall_space xen_mc_extend_args(unsigned long op, size_t arg_size);
  53. #endif /* _XEN_MULTICALLS_H */