Skip to content
Snippets Groups Projects
Select Git revision
  • 99ef33b3e1cd5a23d3adacb169077bd75e8e62d3
  • openEuler-1.0-LTS default protected
  • openEuler-22.09
  • OLK-5.10
  • openEuler-22.03-LTS
  • openEuler-22.03-LTS-Ascend
  • master
  • openEuler-22.03-LTS-LoongArch-NW
  • openEuler-22.09-HCK
  • openEuler-20.03-LTS-SP3
  • openEuler-21.09
  • openEuler-21.03
  • openEuler-20.09
  • 4.19.90-2210.5.0
  • 5.10.0-123.0.0
  • 5.10.0-60.63.0
  • 5.10.0-60.62.0
  • 4.19.90-2210.4.0
  • 5.10.0-121.0.0
  • 5.10.0-60.61.0
  • 4.19.90-2210.3.0
  • 5.10.0-60.60.0
  • 5.10.0-120.0.0
  • 5.10.0-60.59.0
  • 5.10.0-119.0.0
  • 4.19.90-2210.2.0
  • 4.19.90-2210.1.0
  • 5.10.0-118.0.0
  • 5.10.0-106.19.0
  • 5.10.0-60.58.0
  • 4.19.90-2209.6.0
  • 5.10.0-106.18.0
  • 5.10.0-106.17.0
33 results

trace_clock.c

Blame
  • trace_clock.c 4.22 KiB
    // SPDX-License-Identifier: GPL-2.0
    /*
     * tracing clocks
     *
     *  Copyright (C) 2009 Red Hat, Inc., Ingo Molnar <mingo@redhat.com>
     *
     * Implements 3 trace clock variants, with differing scalability/precision
     * tradeoffs:
     *
     *  -   local: CPU-local trace clock
     *  -  medium: scalable global clock with some jitter
     *  -  global: globally monotonic, serialized clock
     *
     * Tracer plugins will chose a default from these clocks.
     */
    #include <linux/spinlock.h>
    #include <linux/irqflags.h>
    #include <linux/hardirq.h>
    #include <linux/module.h>
    #include <linux/percpu.h>
    #include <linux/sched.h>
    #include <linux/sched/clock.h>
    #include <linux/ktime.h>
    #include <linux/trace_clock.h>
    
    /*
     * trace_clock_local(): the simplest and least coherent tracing clock.
     *
     * Useful for tracing that does not cross to other CPUs nor
     * does it go through idle events.
     */
    u64 notrace trace_clock_local(void)
    {
    	u64 clock;
    
    	/*
    	 * sched_clock() is an architecture implemented, fast, scalable,
    	 * lockless clock. It is not guaranteed to be coherent across
    	 * CPUs, nor across CPU idle events.
    	 */
    	preempt_disable_notrace();
    	clock = sched_clock();
    	preempt_enable_notrace();
    
    	return clock;
    }
    EXPORT_SYMBOL_GPL(trace_clock_local);
    
    /*
     * trace_clock(): 'between' trace clock. Not completely serialized,
     * but not completely incorrect when crossing CPUs either.
     *
     * This is based on cpu_clock(), which will allow at most ~1 jiffy of
     * jitter between CPUs. So it's a pretty scalable clock, but there
     * can be offsets in the trace data.
     */
    u64 notrace trace_clock(void)
    {
    	return local_clock();
    }
    EXPORT_SYMBOL_GPL(trace_clock);
    
    /*
     * trace_jiffy_clock(): Simply use jiffies as a clock counter.
     * Note that this use of jiffies_64 is not completely safe on
     * 32-bit systems. But the window is tiny, and the effect if
     * we are affected is that we will have an obviously bogus
     * timestamp on a trace event - i.e. not life threatening.
     */
    u64 notrace trace_clock_jiffies(void)