-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for built-in variable walltimestamp
In the pre-compiled function get_bvar(), use bpf_ktime_get_ns() to get the time (in nsec) since boot. This value is adjusted by adding the POSIX time when the system was booted. A few more walltimestamp tests pass now, but existing walltimestamp tests are rather lenient. Add a new, more stringent test. In particular, timestamp is supposed to be fixed for an entire clause while walltimestamp is fresh with every call. Signed-off-by: Eugene Loh <eugene.loh@oracle.com> Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>
- Loading branch information
Showing
10 changed files
with
96 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Oracle Linux DTrace. | ||
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. | ||
* Licensed under the Universal Permissive License v 1.0 as shown at | ||
* http://oss.oracle.com/licenses/upl. | ||
*/ | ||
|
||
#pragma D option quiet | ||
#pragma D option destructive | ||
|
||
BEGIN { | ||
/* baseline time stamp from system("date") */ | ||
system("date +'%%s.%%N'"); | ||
|
||
/* get five consecutive time stamps from DTrace */ | ||
t1 = walltimestamp; | ||
t2 = walltimestamp; | ||
t3 = walltimestamp; | ||
t4 = walltimestamp; | ||
t5 = walltimestamp; | ||
|
||
/* report the first time stamp and the subsequent deltas */ | ||
printf("%d\n", t1); | ||
printf("%d\n", t2 - t1); | ||
printf("%d\n", t3 - t2); | ||
printf("%d\n", t4 - t3); | ||
printf("%d\n", t5 - t4); | ||
exit(0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
success |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/gawk -f | ||
# | ||
# Oracle Linux DTrace. | ||
# Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. | ||
# Licensed under the Universal Permissive License v 1.0 as shown at | ||
# http://oss.oracle.com/licenses/upl. | ||
|
||
{ | ||
# read the value generated by system("date") | ||
t0 = $1; getline; | ||
|
||
# read a walltimestamp value from DTrace | ||
t1 = $1; getline; | ||
|
||
# read a few walltimestamp deltas from DTrace | ||
d2 = $1; getline; | ||
d3 = $1; getline; | ||
d4 = $1; getline; | ||
d5 = $1; | ||
|
||
# check that the deltas are all positive | ||
if (d2 <= 0 || | ||
d3 <= 0 || | ||
d4 <= 0 || | ||
d5 <= 0) print "ERROR: walltimestamp did not advance."; | ||
|
||
# check that the deltas are all under 0.2 seconds | ||
if (d2 > 200000000 || | ||
d3 > 200000000 || | ||
d4 > 200000000 || | ||
d5 > 200000000) print "ERROR: walltimestamp delta is high."; | ||
|
||
# check walltimestamp against system("date") | ||
t_error = 1.e-9 * t1 - t0; | ||
if (t_error < 0) t_error *= -1; | ||
if (t_error > 0.2) print "ERROR: walltimestamp and system(date) disagree."; | ||
|
||
print "success"; | ||
exit 0; | ||
} |