tsc.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * linux/include/asm-i386/tsc.h
  3. *
  4. * i386 TSC related functions
  5. */
  6. #ifndef _ASM_i386_TSC_H
  7. #define _ASM_i386_TSC_H
  8. #include <linux/config.h>
  9. #include <asm/processor.h>
  10. /*
  11. * Standard way to access the cycle counter on i586+ CPUs.
  12. * Currently only used on SMP.
  13. *
  14. * If you really have a SMP machine with i486 chips or older,
  15. * compile for that, and this will just always return zero.
  16. * That's ok, it just means that the nicer scheduling heuristics
  17. * won't work for you.
  18. *
  19. * We only use the low 32 bits, and we'd simply better make sure
  20. * that we reschedule before that wraps. Scheduling at least every
  21. * four billion cycles just basically sounds like a good idea,
  22. * regardless of how fast the machine is.
  23. */
  24. typedef unsigned long long cycles_t;
  25. extern unsigned int cpu_khz;
  26. extern unsigned int tsc_khz;
  27. static inline cycles_t get_cycles(void)
  28. {
  29. unsigned long long ret = 0;
  30. #ifndef CONFIG_X86_TSC
  31. if (!cpu_has_tsc)
  32. return 0;
  33. #endif
  34. #if defined(CONFIG_X86_GENERIC) || defined(CONFIG_X86_TSC)
  35. rdtscll(ret);
  36. #endif
  37. return ret;
  38. }
  39. extern void tsc_init(void);
  40. extern void mark_tsc_unstable(void);
  41. #endif