| 1 |
// rcu tapset |
| 2 |
// Copyright (C) 2013, 2017 Red Hat |
| 3 |
// |
| 4 |
// This file is part of systemtap, and is free software. You can |
| 5 |
// redistribute it and/or modify it under the terms of the GNU General |
| 6 |
// Public License (GPL); either version 2, or (at your option) any |
| 7 |
// later version. |
| 8 |
|
| 9 |
%{ |
| 10 |
#include <linux/rcupdate.h> |
| 11 |
%} |
| 12 |
|
| 13 |
function rcu_dereference:long (protected_pointer:long) %{ /* pure */ |
| 14 |
void *protected_pointer = (void *)(uintptr_t)STAP_ARG_protected_pointer; |
| 15 |
long fetched_value; |
| 16 |
|
| 17 |
/* We call kderef() here to ensure the memory is valid to read. |
| 18 |
* Note the result is thrown away, then we use the "real" |
| 19 |
* rcu_dereference function now that we know the address is |
| 20 |
* safe. */ |
| 21 |
(void)kderef(sizeof(*protected_pointer), protected_pointer); |
| 22 |
|
| 23 |
rcu_read_lock(); |
| 24 |
fetched_value = (long)rcu_dereference(protected_pointer); |
| 25 |
rcu_read_unlock(); |
| 26 |
STAP_RETVALUE = fetched_value; |
| 27 |
|
| 28 |
CATCH_DEREF_FAULT(); |
| 29 |
%} |