Exemple #1
0
static long c1latency_ioctl(struct file *file, unsigned int cmd,
			    unsigned long arg)
{

  c1_tsc[1] = use_rdtscp();
  // asm volatile("hlt");
  __monitor((void *)c1_tsc, 0, 0);
  __sti_mwait(0,0);
  c1_tsc[2] = use_rdtscp();
  //  printk(KERN_INFO "write to %p(%lx),%p(%lx)\n",&(c1_tsc[0]),__pa(&(c1_tsc[0])), &(c1_tsc[1]), __pa(&(c1_tsc[1])));
  //  printk(KERN_INFO "%lx,%lx\n", c1_tsc[0], c1_tsc[1]);
  return 0;
}
Exemple #2
0
/*
 * MONITOR/MWAIT with no hints, used for default C1 state. This invokes MWAIT
 * with interrupts enabled and no flags, which is backwards compatible with the
 * original MWAIT implementation.
 */
static void mwait_idle(void)
{
	if (!current_set_polling_and_test()) {
		trace_cpu_idle_rcuidle(1, smp_processor_id());
		if (this_cpu_has(X86_BUG_CLFLUSH_MONITOR)) {
			smp_mb(); /* quirk */
			clflush((void *)&current_thread_info()->flags);
			smp_mb(); /* quirk */
		}

		__monitor((void *)&current_thread_info()->flags, 0, 0);
		if (!need_resched())
			__sti_mwait(0, 0);
		else
			local_irq_enable();
		trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id());
	} else {
		local_irq_enable();
	}
	__current_clr_polling();
}