コード例 #1
0
ファイル: tsc_intf.c プロジェクト: amithash/seeker-scheduler
/********************************************************************************
 * get_tsc_cycles - get cycles from last time,
 * @Return Cycles executed on this cpu from the last call.
 * @Side Effect - tsc_val is updated for the current cpu.
 *
 * Get the cycles executed on this cpu from the last call.
 ********************************************************************************/
unsigned long long get_tsc_cycles(void)
{
	int cpu = get_cpu();
	unsigned long long ret = 0;
	unsigned long long val = native_read_tsc();
	ret = val - tsc_val[cpu];
	tsc_val[cpu] = val;
	put_cpu();
	return ret;
}
コード例 #2
0
ファイル: xmit.c プロジェクト: martinbj2008/koexample
static int __init test_init(void)
{
	spinlock_t  lock;
	u64 count = 1024*1024*50;
	u64 i;
	//unsigned long start, end;
	unsigned long flags;
	struct timespec start, end;
	uint32_t jiff_s, jiff_e;
	unsigned long long tsc_s, tsc_e;
	int cpu = 0;

	spin_lock_init(&lock);
	set_affinity(cpu);
	show_freq(cpu);
	local_irq_save(flags);

	getnstimeofday(&start);
	jiff_s = jiffies;
	tsc_s = native_read_tsc();
	for(i=0; i<count; i++) {
		spin_lock(&lock);
		spin_unlock(&lock);
	}
	tsc_e = native_read_tsc();
	jiff_e = jiffies;
	getnstimeofday(&end);

	local_irq_restore(flags);
	show_freq(cpu);

	printk(KERN_DEBUG "start: %ld,%ld\n", start.tv_sec, start.tv_nsec);
	printk(KERN_DEBUG "end: %ld,%ld\n", end.tv_sec, end.tv_nsec);
	printk(KERN_DEBUG "offset:%ld, %ld\n", end.tv_sec - start.tv_sec,
		(end.tv_sec - start.tv_sec)*1000000 + (end.tv_nsec - start.tv_nsec)/1000);

	printk(KERN_DEBUG "HZ:%u\n", HZ);
	printk(KERN_DEBUG "Jiffies %u,%u, %u\n", jiff_e, jiff_s, jiffies_to_msecs(jiff_e - jiff_s));

	printk(KERN_DEBUG "TSC %llu,%llu, delta %llu\n", tsc_s, tsc_e, (tsc_e - tsc_s) >> 20);
	return 0;
}
コード例 #3
0
ファイル: tsc_intf.c プロジェクト: amithash/seeker-scheduler
/********************************************************************************
 * init_tsc - initialize tsc_val for this cpu.
 * @info - not used
 * @Side Effect - tsc_val is updated
 *
 * initialize tsc_val for the current CPU.
 ********************************************************************************/
static void init_tsc(void *info)
{
	tsc_val[smp_processor_id()] = native_read_tsc();
}
コード例 #4
0
ファイル: pvclock.c プロジェクト: mita/linux-2.6
static u64 pvclock_get_nsec_offset(struct pvclock_shadow_time *shadow)
{
	u64 delta = native_read_tsc() - shadow->tsc_timestamp;
	return pvclock_scale_delta(delta, shadow->tsc_to_nsec_mul,
				   shadow->tsc_shift);
}