#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt#include<linux/kernel.h>#include<linux/sched.h>#include<linux/sched/clock.h>#include<linux/init.h>#include<linux/export.h>#include<linux/timer.h>#include<linux/acpi_pmtmr.h>#include<linux/cpufreq.h>#include<linux/delay.h>#include<linux/clocksource.h>#include<linux/percpu.h>#include<linux/timex.h>#include<linux/static_key.h>#include<asm/hpet.h>#include<asm/timer.h>#include<asm/vgtod.h>#include<asm/time.h>#include<asm/delay.h>#include<asm/hypervisor.h>#include<asm/nmi.h>#include<asm/x86_init.h>#include<asm/geode.h>#include<asm/apic.h>#include<asm/intel-family.h>unsignedint__read_mostlycpu_khz;/* TSC clocks / usec, not used here */EXPORT_SYMBOL(cpu_khz);unsignedint__read_mostlytsc_khz;EXPORT_SYMBOL(tsc_khz);/* * TSC can be unstable due to cpufreq or due to unsynced TSCs */staticint__read_mostlytsc_unstable;/* native_sched_clock() is called before tsc_init(), so we must start with the TSC soft disabled to prevent erroneous rdtsc usage on !boot_cpu_has(X86_FEATURE_TSC) processors */staticint__read_mostlytsc_disabled=-1;staticDEFINE_STATIC_KEY_FALSE(__use_tsc);inttsc_clocksource_reliable;staticu32art_to_tsc_numerator;staticu32art_to_tsc_denominator;staticu64art_to_tsc_offset;structclocksource*art_related_clocksource;structcyc2ns{structcyc2ns_datadata[2];/* 0 + 2*16 = 32 */seqcount_tseq;/* 32 + 4 = 36 */};/* fits one cacheline */staticDEFINE_PER_CPU_ALIGNED(structcyc2ns,cyc2ns);voidcyc2ns_read_begin(structcyc2ns_data*data){intseq,idx;preempt_disable_notrace();do{seq=this_cpu_read(cyc2ns.seq.sequence);idx=seq&1;data->cyc2ns_offset=this_cpu_read(cyc2ns.data[idx].cyc2ns_offset);data->cyc2ns_mul=this_cpu_read(cyc2ns.data[idx].cyc2ns_mul);data->cyc2ns_shift=this_cpu_read(cyc2ns.data[idx].cyc2ns_shift);}while(unlikely(seq!=this_cpu_read(cyc2ns.seq.sequence)));