tsc.h 1.1 KB

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