Debian Codegraph @

tapset/linux/atomic.stp

raw
1 // Atomic functions.
2 // Copyright (C) 2010 Red Hat Inc.
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 * sfunction atomic_read - Retrieves an atomic variable from kernel memory
11 *
12 * @addr: pointer to atomic variable
13 *
14 * Safely perform the read of an atomic variable.
15 */
16 function atomic_read:long(addr:long)
17 %{ /* pure */
18 atomic_t *a = (atomic_t *)(uintptr_t)STAP_ARG_addr;
19
20 /* We call deref() here to ensure the memory is valid to read.
21 * Note the result is thrown away, then we use the "real"
22 * atomic read function now that we know the address is safe. */
23 (void)kderef(sizeof(*a), a);
24 STAP_RETVALUE = atomic_read(a);
25 CATCH_DEREF_FAULT();
26 %}
27
28 /**
29 * sfunction atomic_long_read - Retrieves an atomic long variable from kernel memory
30 *
31 * @addr: pointer to atomic long variable
32 *
33 * Safely perform the read of an atomic long variable. This will be a
34 * NOP on kernels that do not have ATOMIC_LONG_INIT set on the kernel config.
35 */
36 function atomic_long_read:long(addr:long)
37 %{ /* pure */
38 #ifdef ATOMIC_LONG_INIT
39 atomic_long_t *a = (atomic_long_t *)(uintptr_t)STAP_ARG_addr;
40
41 /* We call deref() here to ensure the memory is valid to read.
42 * Note the result is thrown away, then we use the "real"
43 * atomic read function now that we know the address is safe. */
44 (void)kderef(sizeof(*a), a);
45 STAP_RETVALUE = atomic_long_read(a);
46 CATCH_DEREF_FAULT();
47 #endif
48 %}