Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\trace\trace_hwlat.c Create Date:2022-07-28 12:10:48
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:get_sample - sample the CPU TSC and look for likely hardware latencies* Used to repeatedly capture the CPU TSC (or similar), looking for potential* hardware-induced latency. Called with interrupts disabled and with* hwlat_data.lock held.

Proto:static int get_sample(void)

Type:int

Parameter:Nothing

169  tr = hwlat_trace
170  Macros to encapsulate the time capturing infrastructure  start, t1, t2, last_t2
171  last_total = 0
172  sample = 0
173  thresh = tracing_thresh
174  outer_sample = 0
175  ret = -1
177  do_div() is NOT a C function(thresh, NSEC_PER_USEC)
179  nmi_cpu = smp_processor_id()
180  nmi_total_ts = 0
181  nmi_count = 0
183  The "volatile" is due to gcc bugs ()
185  Tells NMIs to call back to the hwlat tracer to record timestamps = true
187  init_time(last_t2, 0)
188  start = time_get()
190  Do
192  t1 = time_get()
193  t2 = time_get()
195  If time_u64(last_t2) Then
199  If diff < 0 Then
200  pr_err(BANNER"time running backwards\n")
201  Go to out
203  If diff > outer_sample Then outer_sample = diff
206  last_t2 = t2
208  total = time_to_us(time_sub(t2, start))
211  If total < last_total Then
212  pr_err("Time total overflowed\n")
213  Break
215  last_total = total
218  diff = time_to_us(time_sub(t2, t1))
221  If diff < 0 Then
222  pr_err(BANNER"time running backwards\n")
223  Go to out
226  If diff > sample Then sample = diff
229  When total <= active sampling portion of window cycle
231  The "volatile" is due to gcc bugs ()
232  Tells NMIs to call back to the hwlat tracer to record timestamps = false
233  The "volatile" is due to gcc bugs ()
235  ret = 0
238  If sample > thresh || outer_sample > thresh Then
242  ret = 1
245  If nmi_total_ts Then do_div() is NOT a C function(nmi_total_ts, NSEC_PER_USEC)
248  al since reset ++
249  unique sequence = al since reset
250  delta = sample
251  delta (outer loop) = outer_sample
252  ktime_get_real_ts64 - Returns the time of day in a timespec64.*@ts: pointer to the timespec to be set* Returns the time of day in a timespec64 (WARN if suspended).
253  Total time spent in NMIs = nmi_total_ts
254  # NMIs during this sample = nmi_count
255  trace_hwlat_sample( & s)
257  latency = max - return maximum of two values of the same or compatible types*@x: first value*@y: second value(sample, outer_sample)
260  If latency > max_latency Then
266  out :
267  Return ret
Caller
NameDescribe
kthread_fnkthread_fn - The CPU time sampling/hardware latency detection kernel thread* Used to periodically sample the CPU TSC via a call to get_sample. We* disable interrupts, which does (intentionally) introduce latency since we