ioprio.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2. #ifndef _UAPI_LINUX_IOPRIO_H
  3. #define _UAPI_LINUX_IOPRIO_H
  4. /*
  5. * Gives us 8 prio classes with 13-bits of data for each class
  6. */
  7. #define IOPRIO_CLASS_SHIFT 13
  8. #define IOPRIO_CLASS_MASK 0x07
  9. #define IOPRIO_PRIO_MASK ((1UL << IOPRIO_CLASS_SHIFT) - 1)
  10. #define IOPRIO_PRIO_CLASS(ioprio) \
  11. (((ioprio) >> IOPRIO_CLASS_SHIFT) & IOPRIO_CLASS_MASK)
  12. #define IOPRIO_PRIO_DATA(ioprio) ((ioprio) & IOPRIO_PRIO_MASK)
  13. #define IOPRIO_PRIO_VALUE(class, data) \
  14. ((((class) & IOPRIO_CLASS_MASK) << IOPRIO_CLASS_SHIFT) | \
  15. ((data) & IOPRIO_PRIO_MASK))
  16. /*
  17. * These are the io priority groups as implemented by the BFQ and mq-deadline
  18. * schedulers. RT is the realtime class, it always gets premium service. For
  19. * ATA disks supporting NCQ IO priority, RT class IOs will be processed using
  20. * high priority NCQ commands. BE is the best-effort scheduling class, the
  21. * default for any process. IDLE is the idle scheduling class, it is only
  22. * served when no one else is using the disk.
  23. */
  24. enum {
  25. IOPRIO_CLASS_NONE,
  26. IOPRIO_CLASS_RT,
  27. IOPRIO_CLASS_BE,
  28. IOPRIO_CLASS_IDLE,
  29. };
  30. /*
  31. * The RT and BE priority classes both support up to 8 priority levels.
  32. */
  33. #define IOPRIO_NR_LEVELS 8
  34. #define IOPRIO_BE_NR IOPRIO_NR_LEVELS
  35. enum {
  36. IOPRIO_WHO_PROCESS = 1,
  37. IOPRIO_WHO_PGRP,
  38. IOPRIO_WHO_USER,
  39. };
  40. /*
  41. * Fallback BE priority level.
  42. */
  43. #define IOPRIO_NORM 4
  44. #define IOPRIO_BE_NORM IOPRIO_NORM
  45. #endif /* _UAPI_LINUX_IOPRIO_H */