示例#1
0
/*
 * As outlined at the top, provides a fast, high resolution, nanosecond
 * time source that is monotonic per cpu argument and has bounded drift
 * between cpus.
 *
 * ######################### BIG FAT WARNING ##########################
 * # when comparing cpu_clock(i) to cpu_clock(j) for i != j, time can #
 * # go backwards !!                                                  #
 * ####################################################################
 */
u64 cpu_clock(int cpu)
{
	u64 clock;
	unsigned long flags;

	flags = hard_local_irq_save_notrace();
	clock = sched_clock_cpu(cpu);
	hard_local_irq_restore_notrace(flags);

	return clock;
}
示例#2
0
/*
 * Similar to cpu_clock() for the current cpu. Time will only be observed
 * to be monotonic if care is taken to only compare timestampt taken on the
 * same CPU.
 *
 * See cpu_clock().
 */
u64 local_clock(void)
{
	u64 clock;
	unsigned long flags;

	flags = hard_local_irq_save_notrace();
	clock = sched_clock_cpu(smp_processor_id());
	hard_local_irq_restore_notrace(flags);

	return clock;
}
示例#3
0
int notrace __ipipe_check_percpu_access(void)
{
	struct ipipe_percpu_domain_data *p;
	struct ipipe_domain *this_domain;
	unsigned long flags;
	int ret = 0;

	flags = hard_local_irq_save_notrace();

	/*
	 * Don't use __ipipe_current_domain here, this would recurse
	 * indefinitely.
	 */
	this_domain = __this_cpu_read(ipipe_percpu.curr)->domain;

	/*
	 * Only the root domain may implement preemptive CPU migration
	 * of tasks, so anything above in the pipeline should be fine.
	 */
	if (this_domain != ipipe_root_domain)
		goto out;

	if (raw_irqs_disabled_flags(flags))
		goto out;

	/*
	 * Last chance: hw interrupts were enabled on entry while
	 * running over the root domain, but the root stage might be
	 * currently stalled, in which case preemption would be
	 * disabled, and no migration could occur.
	 */
	if (this_domain == ipipe_root_domain) {
		p = ipipe_this_cpu_root_context();
		if (test_bit(IPIPE_STALL_FLAG, &p->status))
			goto out;
	}
	/*
	 * Our caller may end up accessing the wrong per-cpu variable
	 * instance due to CPU migration; tell it to complain about
	 * this.
	 */
	ret = 1;
out:
	hard_local_irq_restore_notrace(flags);

	return ret;
}