This file is indexed.

/usr/share/systemtap/runtime/linux/timer.c is in systemtap-common 2.9-2ubuntu2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/* -*- linux-c -*- 
 * Kernel Timer Functions
 * Copyright (C) 2012 Red Hat Inc.
 *
 * This file is part of systemtap, and is free software.  You can
 * redistribute it and/or modify it under the terms of the GNU General
 * Public License (GPL); either version 2, or (at your option) any
 * later version.
 */

#ifndef _LINUX_TIMER_C_
#define _LINUX_TIMER_C_

#include "timer.h"

static void _stp_hrtimer_init(void)
{
#if defined(STAPCONF_HRTIMER_GET_RES)
	struct timespec res;
	hrtimer_get_res (CLOCK_MONOTONIC, &res);
	stap_hrtimer_resolution = timespec_to_ns(&res);
#else
	stap_hrtimer_resolution = hrtimer_resolution;
#endif
}


static inline ktime_t _stp_hrtimer_get_interval(struct stap_hrtimer_probe *stp)
{
	unsigned long nsecs;
	uint64_t i = stp->intrv;

	if (stp->rnd != 0) {
#if 1
		// XXX: why not use stp_random_pm instead of this?
	        int64_t r;
	        get_random_bytes(&r, sizeof(r));

		// ensure that r is positive
	        r &= ((uint64_t)1 << (8*sizeof(r) - 1)) - 1;
	        r = _stp_mod64(NULL, r, (2*stp->rnd+1));
	        r -= stp->rnd;
	        i += r;
#else
		i += _stp_random_pm(stp->rnd);
#endif
	}
	if (unlikely(i < stap_hrtimer_resolution))
		i = stap_hrtimer_resolution;
	nsecs = do_div(i, NSEC_PER_SEC);
	return ktime_set(i, nsecs);
}


static inline void _stp_hrtimer_update(struct stap_hrtimer_probe *stp)
{
	ktime_t time;

	time = ktime_add(hrtimer_get_expires(&stp->hrtimer),
			 _stp_hrtimer_get_interval(stp));
	hrtimer_set_expires(&stp->hrtimer, time);
}


static int
_stp_hrtimer_start(struct stap_hrtimer_probe *stp)
{
	(void)hrtimer_start(&stp->hrtimer, _stp_hrtimer_get_interval(stp),
			    HRTIMER_MODE_REL);
	return 0;
}

static int
_stp_hrtimer_create(struct stap_hrtimer_probe *stp,
		    hrtimer_return_t (*function)(struct hrtimer *))
{
	hrtimer_init(&stp->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	stp->hrtimer.function = function;
	return 0;
}

// For kernel-mode, there is no difference between cancel/delete.

static void
_stp_hrtimer_cancel(struct stap_hrtimer_probe *stp)
{
	hrtimer_cancel(&stp->hrtimer);
}

static void
_stp_hrtimer_delete(struct stap_hrtimer_probe *stp)
{
	_stp_hrtimer_cancel(stp);
}

#endif /* _LINUX_TIMER_C_ */