dscr.rst 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. ===================================
  2. DSCR (Data Stream Control Register)
  3. ===================================
  4. DSCR register in powerpc allows user to have some control of prefetch of data
  5. stream in the processor. Please refer to the ISA documents or related manual
  6. for more detailed information regarding how to use this DSCR to attain this
  7. control of the prefetches . This document here provides an overview of kernel
  8. support for DSCR, related kernel objects, it's functionalities and exported
  9. user interface.
  10. (A) Data Structures:
  11. (1) thread_struct::
  12. dscr /* Thread DSCR value */
  13. dscr_inherit /* Thread has changed default DSCR */
  14. (2) PACA::
  15. dscr_default /* per-CPU DSCR default value */
  16. (3) sysfs.c::
  17. dscr_default /* System DSCR default value */
  18. (B) Scheduler Changes:
  19. Scheduler will write the per-CPU DSCR default which is stored in the
  20. CPU's PACA value into the register if the thread has dscr_inherit value
  21. cleared which means that it has not changed the default DSCR till now.
  22. If the dscr_inherit value is set which means that it has changed the
  23. default DSCR value, scheduler will write the changed value which will
  24. now be contained in thread struct's dscr into the register instead of
  25. the per-CPU default PACA based DSCR value.
  26. NOTE: Please note here that the system wide global DSCR value never
  27. gets used directly in the scheduler process context switch at all.
  28. (C) SYSFS Interface:
  29. - Global DSCR default: /sys/devices/system/cpu/dscr_default
  30. - CPU specific DSCR default: /sys/devices/system/cpu/cpuN/dscr
  31. Changing the global DSCR default in the sysfs will change all the CPU
  32. specific DSCR defaults immediately in their PACA structures. Again if
  33. the current process has the dscr_inherit clear, it also writes the new
  34. value into every CPU's DSCR register right away and updates the current
  35. thread's DSCR value as well.
  36. Changing the CPU specific DSCR default value in the sysfs does exactly
  37. the same thing as above but unlike the global one above, it just changes
  38. stuff for that particular CPU instead for all the CPUs on the system.
  39. (D) User Space Instructions:
  40. The DSCR register can be accessed in the user space using any of these
  41. two SPR numbers available for that purpose.
  42. (1) Problem state SPR: 0x03 (Un-privileged, POWER8 only)
  43. (2) Privileged state SPR: 0x11 (Privileged)
  44. Accessing DSCR through privileged SPR number (0x11) from user space
  45. works, as it is emulated following an illegal instruction exception
  46. inside the kernel. Both mfspr and mtspr instructions are emulated.
  47. Accessing DSCR through user level SPR (0x03) from user space will first
  48. create a facility unavailable exception. Inside this exception handler
  49. all mfspr instruction based read attempts will get emulated and returned
  50. where as the first mtspr instruction based write attempts will enable
  51. the DSCR facility for the next time around (both for read and write) by
  52. setting DSCR facility in the FSCR register.
  53. (E) Specifics about 'dscr_inherit':
  54. The thread struct element 'dscr_inherit' represents whether the thread
  55. in question has attempted and changed the DSCR itself using any of the
  56. following methods. This element signifies whether the thread wants to
  57. use the CPU default DSCR value or its own changed DSCR value in the
  58. kernel.
  59. (1) mtspr instruction (SPR number 0x03)
  60. (2) mtspr instruction (SPR number 0x11)
  61. (3) ptrace interface (Explicitly set user DSCR value)
  62. Any child of the process created after this event in the process inherits
  63. this same behaviour as well.