dscr.txt 3.4 KB

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