/
usr
/
share
/
systemtap
/
runtime
/
linux
/
/usr/share/systemtap/runtime/linux
mkdir
upload
Name
Size
Mode
Actions
uprobes/
-
0755
rm
uprobes2/
-
0755
rm
access_process_vm.h
4311
0644
edit
dl
rm
addr-map.c
9749
0644
edit
dl
rm
alloc.c
15900
0644
edit
dl
rm
arith.c
16799
0644
edit
dl
rm
autoconf-514-panic.c
68
0644
edit
dl
rm
autoconf-access_ok_2args.c
90
0644
edit
dl
rm
autoconf-alloc-percpu-align.c
118
0644
edit
dl
rm
autoconf-asm-syscall.c
51
0644
edit
dl
rm
autoconf-atomic_fetch_add_unless.c
94
0644
edit
dl
rm
autoconf-bio-bi_opf.c
824
0644
edit
dl
rm
autoconf-blk-types.c
359
0644
edit
dl
rm
autoconf-compat-utimbuf.c
53
0644
edit
dl
rm
autoconf-compat_sigaction.c
448
0644
edit
dl
rm
autoconf-constant-tsc.c
63
0644
edit
dl
rm
autoconf-cpu-clock.c
1277
0644
edit
dl
rm
autoconf-dpath-path.c
121
0644
edit
dl
rm
autoconf-files_lookup_fd_raw.c
136
0644
edit
dl
rm
autoconf-from_kuid_munged.c
191
0644
edit
dl
rm
autoconf-fs_supers-hlist.c
354
0644
edit
dl
rm
autoconf-generated-compile.c
56
0644
edit
dl
rm
autoconf-genhd.c
201
0644
edit
dl
rm
autoconf-get-kretprobe.c
107
0644
edit
dl
rm
autoconf-get_user_pages-flags.c
1549
0644
edit
dl
rm
autoconf-get_user_pages-notask_struct.c
1301
0644
edit
dl
rm
autoconf-get_user_pages_remote-flags.c
1550
0644
edit
dl
rm
autoconf-get_user_pages_remote-flags_locked.c
1331
0644
edit
dl
rm
autoconf-get_user_pages_remote-notask_struct.c
1438
0644
edit
dl
rm
autoconf-grsecurity.c
219
0644
edit
dl
rm
autoconf-hlist-4args.c
296
0644
edit
dl
rm
autoconf-hlist_add_tail_rcu.c
112
0644
edit
dl
rm
autoconf-hrtimer-getset-expires.c
126
0644
edit
dl
rm
autoconf-hrtimer-rel.c
87
0644
edit
dl
rm
autoconf-hw_breakpoint_context.c
315
0644
edit
dl
rm
autoconf-inode-private.c
173
0644
edit
dl
rm
autoconf-inode-rwsem.c
172
0644
edit
dl
rm
autoconf-inode-uretprobes.c
264
0644
edit
dl
rm
autoconf-kernel_read-new-args.c
1030
0644
edit
dl
rm
autoconf-kprobe-symbol-name.c
90
0644
edit
dl
rm
autoconf-ktime-get-real.c
98
0644
edit
dl
rm
autoconf-linux-sched_headers.c
1678
0644
edit
dl
rm
autoconf-local-clock.c
1282
0644
edit
dl
rm
autoconf-lockdown-debugfs.c
102
0644
edit
dl
rm
autoconf-lockdown-kernel.c
90
0644
edit
dl
rm
autoconf-mm-context-vdso-base.c
117
0644
edit
dl
rm
autoconf-mm-context-vdso.c
114
0644
edit
dl
rm
autoconf-mm-shmempages.c
72
0644
edit
dl
rm
autoconf-mmap_lock.c
175
0644
edit
dl
rm
autoconf-module-sect-attrs.c
158
0644
edit
dl
rm
autoconf-module_layout.c
52
0644
edit
dl
rm
autoconf-mod_kallsyms.c
51
0644
edit
dl
rm
autoconf-nameidata.c
96
0644
edit
dl
rm
autoconf-netfilter-4_1.c
769
0644
edit
dl
rm
autoconf-netfilter-4_4.c
1460
0644
edit
dl
rm
autoconf-netfilter-313b.c
602
0644
edit
dl
rm
autoconf-netfilter.c
422
0644
edit
dl
rm
autoconf-old-inode-uprobes.c
357
0644
edit
dl
rm
autoconf-oneachcpu-retry.c
957
0644
edit
dl
rm
autoconf-pagefault_disable.c
137
0644
edit
dl
rm
autoconf-pde_data.c
226
0644
edit
dl
rm
autoconf-perf-structpid.c
444
0644
edit
dl
rm
autoconf-procfs-owner.c
158
0644
edit
dl
rm
autoconf-proc_ops.c
566
0644
edit
dl
rm
autoconf-rcu_is_watching.c
385
0644
edit
dl
rm
autoconf-real-parent.c
427
0644
edit
dl
rm
autoconf-regset.c
239
0644
edit
dl
rm
autoconf-relay-umode_t.c
730
0644
edit
dl
rm
autoconf-relay_buf-per_cpu_ptr.c
920
0644
edit
dl
rm
autoconf-ring_buffer-flags.c
112
0644
edit
dl
rm
autoconf-ring_buffer_lost_events.c
296
0644
edit
dl
rm
autoconf-ring_buffer_read_prepare.c
181
0644
edit
dl
rm
autoconf-save-stack-trace-no-bp.c
498
0644
edit
dl
rm
autoconf-save-stack-trace.c
501
0644
edit
dl
rm
autoconf-set_fs.c
221
0644
edit
dl
rm
autoconf-smpcall-4args.c
166
0644
edit
dl
rm
autoconf-smpcall-5args.c
169
0644
edit
dl
rm
autoconf-stack-trace-save-regs.c
176
0644
edit
dl
rm
autoconf-stacktrace_ops-int-address.c
409
0644
edit
dl
rm
autoconf-stacktrace_ops-warning.c
188
0644
edit
dl
rm
autoconf-syscall_get_args_3args.c
239
0644
edit
dl
rm
autoconf-task-state.c
550
0644
edit
dl
rm
autoconf-task-uid.c
152
0644
edit
dl
rm
autoconf-task_work-struct.c
219
0644
edit
dl
rm
autoconf-time32-old.c
52
0644
edit
dl
rm
autoconf-time32.c
53
0644
edit
dl
rm
autoconf-timerfd.c
232
0644
edit
dl
rm
autoconf-trace-printk.c
151
0644
edit
dl
rm
autoconf-tracepoint-has-data.c
493
0644
edit
dl
rm
autoconf-tracepoint-strings.c
233
0644
edit
dl
rm
autoconf-uaccess.c
28
0644
edit
dl
rm
autoconf-uapi-mount.c
52
0644
edit
dl
rm
autoconf-udelay_simple.c
90
0644
edit
dl
rm
autoconf-uidgid.c
50
0644
edit
dl
rm
autoconf-unwind-stack-trace.c
326
0644
edit
dl
rm
autoconf-uprobe-get-pc.c
374
0644
edit
dl
rm
autoconf-utrace-regset.c
273
0644
edit
dl
rm
autoconf-utrace-via-tracepoints.c
1712
0644
edit
dl
rm
autoconf-vm-area-pte.c
141
0644
edit
dl
rm
autoconf-walk-stack.c
217
0644
edit
dl
rm
autoconf-x86-fs.c
90
0644
edit
dl
rm
autoconf-x86-gs.c
90
0644
edit
dl
rm
autoconf-x86-uniregs.c
140
0644
edit
dl
rm
autoconf-x86-xfs.c
91
0644
edit
dl
rm
common_session_state.h
3249
0644
edit
dl
rm
compat_net.h
858
0644
edit
dl
rm
compat_structs.h
4409
0644
edit
dl
rm
compat_unistd.h
68384
0644
edit
dl
rm
copy.c
2717
0644
edit
dl
rm
debug.h
2978
0644
edit
dl
rm
io.c
5291
0644
edit
dl
rm
itrace.c
14874
0644
edit
dl
rm
kprobes.c
25126
0644
edit
dl
rm
loc2c-runtime.h
29874
0644
edit
dl
rm
map_list.h
1220
0644
edit
dl
rm
map_runtime.h
5266
0644
edit
dl
rm
namespaces.h
7128
0644
edit
dl
rm
netfilter.c
1410
0644
edit
dl
rm
perf.c
7596
0644
edit
dl
rm
perf.h
1272
0644
edit
dl
rm
perf_event_counter_context.c
336
0644
edit
dl
rm
perf_probe_handler_nmi.c
278
0644
edit
dl
rm
perf_read.h
959
0644
edit
dl
rm
print.c
11402
0644
edit
dl
rm
probe_lock.h
1807
0644
edit
dl
rm
regs-ia64.c
3741
0644
edit
dl
rm
regs.c
13490
0644
edit
dl
rm
runtime.h
12591
0644
edit
dl
rm
runtime_context.h
6089
0644
edit
dl
rm
runtime_defines.h
1041
0644
edit
dl
rm
stap_mmap_lock.h
343
0644
edit
dl
rm
stat_runtime.h
1774
0644
edit
dl
rm
stp_tls.h
1181
0644
edit
dl
rm
stp_tracepoint.c
11481
0644
edit
dl
rm
stp_tracepoint.h
2270
0644
edit
dl
rm
syscalls-common.h
976
0644
edit
dl
rm
task_finder.c
53860
0644
edit
dl
rm
task_finder2.c
57640
0644
edit
dl
rm
task_finder_map.c
5194
0644
edit
dl
rm
task_finder_stubs.c
2442
0644
edit
dl
rm
task_work_compatibility.h
1283
0644
edit
dl
rm
timer.c
2200
0644
edit
dl
rm
timer.h
1383
0644
edit
dl
rm
timer_compatibility.h
2317
0644
edit
dl
rm
uprobes-common.c
15573
0644
edit
dl
rm
uprobes-common.h
1653
0644
edit
dl
rm
uprobes-inc.h
484
0644
edit
dl
rm
uprobes-inode.c
34086
0644
edit
dl
rm
Edit:
/usr/share/systemtap/runtime/linux/print.c
(11402B)
/* -*- linux-c -*- * Print Functions * Copyright (C) 2007-2018 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 _STAPLINUX_PRINT_C_ #define _STAPLINUX_PRINT_C_ #include "stp_string.h" #include "print.h" #include "transport/transport.c" #include "vsprintf.c" /** @file print.c * Printing Functions. */ /** @addtogroup print Print Functions * The print buffer is for collecting output to send to the user daemon. * This is a per-cpu static buffer. The buffer is sent when * _stp_print_flush() is called. * * The reason to do this is to allow multiple small prints to be combined then * timestamped and sent together to staprun. This is more efficient than sending * numerous small packets. * * This function is called automatically when the print buffer is full. * It MUST also be called at the end of every probe that prints something. * @{ */ struct _stp_log { unsigned int len; /* Bytes used in the buffer */ char *buf; /* NB we don't use arrays here to avoid allocating memory on offline CPUs (but still possible ones) */ atomic_t reentrancy_lock; }; #include "print_flush.c" static struct _stp_log *_stp_log_pcpu; /* * An atomic counter is used to synchronize every possible print buffer usage * with the _stp_print_cleanup() function. The cleanup function sets the counter * to INT_MAX after waiting for everything using the print buffer to finish. We * cannot use a lock primitive to implement this because lock_acquire() contains * tracepoints and print statements are used both inside and outside of probes. * If the lock were only used inside probes, the runtime context would protect * us from recursing into the lock_acquire() tracepoints and deadlocking. We * instead use _stp_print_ctr as if it were a read-write lock. */ static atomic_t _stp_print_ctr = ATOMIC_INIT(0); /* * This disables IRQs to make per-CPU print buffer accesses atomic. There is a * reentrancy protection mechanism specifically for NMIs, since they can violate * our atomic guarantee. Reentrancy is otherwise allowed within code sections * that have the runtime context held (via _stp_runtime_entryfn_get_context()). */ static bool _stp_print_trylock_irqsave(unsigned long *flags) { bool context_held = false; struct _stp_log *log; log = per_cpu_ptr(_stp_log_pcpu, raw_smp_processor_id()); /* We have to check log->buf == NULL here since the online * CPUs may change at any time through the CPU hotplug * feature of the kernel. So the current CPU's log->buf could be NULL * if it is a new online CPU. And we cannot allocate new memory from within * this context. */ if (unlikely(log->buf == NULL)) return false; local_irq_save(*flags); if (!atomic_add_unless(&_stp_print_ctr, 1, INT_MAX)) goto irq_restore; /* * Check the per-CPU reentrancy lock for contention, unless the runtime * context is already held, in which case we already have reentrancy * protection. Otherwise, if the reentrancy lock is contented, that * means we're either inside an NMI that fired while the current CPU was * accessing the log buffer, or something is trying to nest calls to * _stp_print_trylock_irqsave(). Our only choice is to reject the log * access attempt in this case because log buffer corruption and panics * could ensue if we're inside an NMI. */ if (_stp_runtime_context_trylock()) { struct context *c = _stp_runtime_get_context(); context_held = c && atomic_read(&c->busy); _stp_runtime_context_unlock(); } /* Fall back onto the reentrancy lock if the context isn't held */ if (!context_held) { if (atomic_cmpxchg(&log->reentrancy_lock, 0, 1)) goto print_unlock; } return true; print_unlock: atomic_dec(&_stp_print_ctr); irq_restore: local_irq_restore(*flags); return false; } static void _stp_print_unlock_irqrestore(unsigned long *flags) { bool context_held = false; struct _stp_log *log; if (_stp_runtime_context_trylock()) { struct context *c = _stp_runtime_get_context(); context_held = c && atomic_read(&c->busy); _stp_runtime_context_unlock(); } if (!context_held) { log = per_cpu_ptr(_stp_log_pcpu, raw_smp_processor_id()); atomic_set(&log->reentrancy_lock, 0); } atomic_dec(&_stp_print_ctr); local_irq_restore(*flags); } /* create percpu print and io buffers */ static int _stp_print_init (void) { unsigned int cpu; /* _stp_alloc_percpu() always zero-fills the allocated percpu memory * since the kernel's __alloc_percpu() always does that. */ _stp_log_pcpu = _stp_alloc_percpu(sizeof(*_stp_log_pcpu)); if (!_stp_log_pcpu) return -ENOMEM; /* We don't use for_aech_possible_cpu() here since the number of possible * CPUs may be very large even though there are many fewere online CPUs. * For example, VMWare guests usually have 128 possible CPUs while only * have a few online CPUs. Once the bufs were allocated for * online CPUs at this point, we will discard any printing operations on * any future online CPUs dynamically added through the kernel's CPU * hotplug feature. Memory allocations of the bufs can only happen right * here. */ for_each_online_cpu(cpu) { struct _stp_log *log = per_cpu_ptr(_stp_log_pcpu, cpu); log->reentrancy_lock = (atomic_t)ATOMIC_INIT(0); log->buf = _stp_vzalloc_node(STP_BUFFER_SIZE, cpu_to_node(cpu)); if (unlikely(log->buf == NULL)) { _stp_error ("print log buf (size %lu per cpu) allocation failed", (unsigned long) STP_BUFFER_SIZE); return -ENOMEM; } } return 0; } static void _stp_print_cleanup (void) { unsigned int cpu; /* Wait for the loggers to finish modifying the print buffers */ while (atomic_cmpxchg(&_stp_print_ctr, 0, INT_MAX)) cpu_relax(); /* NB We cannot use the for_each_online_cpu() here since online * CPUs may get changed on-the-fly through the CPU hotplug feature * of the kernel. We only allocated bufs on original online CPUs * when _stp_print_init() was called. */ for_each_possible_cpu(cpu) { struct _stp_log *log = per_cpu_ptr(_stp_log_pcpu, cpu); /* * Flush anything that could be left in the print buffer. It is * safe to do this without any kind of synchronization mechanism * because nothing is using this print buffer anymore. */ if (likely(log->buf)) { /* We have to check log->buf != NULL here since the * online CPUs may change at any time through the CPU * hotplug feature of the kernel. */ __stp_print_flush(log); _stp_vfree(log->buf); log->buf = NULL; } } _stp_free_percpu(_stp_log_pcpu); } static inline void _stp_print_flush(void) { struct _stp_log *log; unsigned long flags; if (!_stp_print_trylock_irqsave(&flags)) return; log = per_cpu_ptr(_stp_log_pcpu, raw_smp_processor_id()); __stp_print_flush(log); _stp_print_unlock_irqrestore(&flags); } #ifndef STP_MAXBINARYARGS #define STP_MAXBINARYARGS 127 #endif /** Reserves space in the output buffer for direct I/O. Must be called with * _stp_print_trylock_irqsave() held. */ static void * _stp_reserve_bytes (int numbytes) { struct _stp_log *log; char *ret; if (unlikely(numbytes == 0 || numbytes > STP_BUFFER_SIZE)) return NULL; log = per_cpu_ptr(_stp_log_pcpu, raw_smp_processor_id()); /* _stp_print_trylock_irqsave already checks log->buf != NULL */ if (unlikely(numbytes > (STP_BUFFER_SIZE - log->len))) __stp_print_flush(log); ret = &log->buf[log->len]; log->len += numbytes; return ret; } static void _stp_unreserve_bytes (int numbytes) { struct _stp_log *log; log = per_cpu_ptr(_stp_log_pcpu, raw_smp_processor_id()); /* We have to check log->buf == NULL here since the online CPUs may * change at any time through the CPU hotplug feature of the kernel. * So the current CPU's log->buf could be NULL if it is a new online * CPU. */ if (unlikely(log->buf == NULL)) return; if (numbytes <= log->len) log->len -= numbytes; } /** Write 64-bit args directly into the output stream. * This function takes a variable number of 64-bit arguments * and writes them directly into the output stream. Marginally faster * than doing the same in _stp_vsnprintf(). * @sa _stp_vsnprintf() */ static void _stp_print_binary (int num, ...) { unsigned long flags; va_list vargs; int i; int64_t *args; if (unlikely(num > STP_MAXBINARYARGS)) num = STP_MAXBINARYARGS; if (!_stp_print_trylock_irqsave(&flags)) return; args = _stp_reserve_bytes(num * sizeof(int64_t)); if (args) { va_start(vargs, num); for (i = 0; i < num; i++) args[i] = va_arg(vargs, int64_t); va_end(vargs); } _stp_print_unlock_irqrestore(&flags); } /** Print into the print buffer. * Like C printf. * * @sa _stp_print_flush() */ static void _stp_printf (const char *fmt, ...) { va_list args; va_start(args, fmt); _stp_vsnprintf(NULL, 0, fmt, args); va_end(args); } /** Write a string into the print buffer. * @param str A C string (char *) */ static void _stp_print (const char *str) { struct _stp_log *log; unsigned long flags; if (!_stp_print_trylock_irqsave(&flags)) return; log = per_cpu_ptr(_stp_log_pcpu, raw_smp_processor_id()); while (1) { while (log->len < STP_BUFFER_SIZE && *str) log->buf[log->len++] = *str++; if (likely(!*str)) break; __stp_print_flush(log); } _stp_print_unlock_irqrestore(&flags); } static void _stp_print_char (const char c) { struct _stp_log *log; unsigned long flags; if (!_stp_print_trylock_irqsave(&flags)) return; log = per_cpu_ptr(_stp_log_pcpu, raw_smp_processor_id()); if (unlikely(log->len == STP_BUFFER_SIZE)) __stp_print_flush(log); log->buf[log->len++] = c; _stp_print_unlock_irqrestore(&flags); } static void _stp_print_kernel_info(char *sname, char *vstr, int ctx, int num_probes) { printk(KERN_DEBUG "%s (%s): systemtap: %s, base: %lx" ", memory: %ludata/%lutext/%uctx/%lunet/%lualloc kb" ", probes: %d" #if ! STP_PRIVILEGE_CONTAINS (STP_PRIVILEGE, STP_PR_STAPDEV) ", unpriv-uid: %d" #endif "\n", THIS_MODULE->name, sname, /* name of source file */ vstr, /* stap version */ #ifdef STAPCONF_MODULE_LAYOUT (unsigned long) THIS_MODULE->core_layout.base, (unsigned long) (THIS_MODULE->core_layout.size - THIS_MODULE->core_layout.text_size)/1024, (unsigned long) (THIS_MODULE->core_layout.text_size)/1024, #else #ifndef STAPCONF_GRSECURITY (unsigned long) THIS_MODULE->module_core, (unsigned long) (THIS_MODULE->core_size - THIS_MODULE->core_text_size)/1024, (unsigned long) (THIS_MODULE->core_text_size)/1024, #else (unsigned long) THIS_MODULE->module_core_rx, (unsigned long) (THIS_MODULE->core_size_rw - THIS_MODULE->core_size_rx)/1024, (unsigned long) (THIS_MODULE->core_size_rx)/1024, #endif #endif ctx/1024, _stp_allocated_net_memory/1024, (_stp_allocated_memory - _stp_allocated_net_memory - ctx)/1024, /* (un-double-counting net/ctx because they're also stp_alloc'd) */ num_probes #if ! STP_PRIVILEGE_CONTAINS (STP_PRIVILEGE, STP_PR_STAPDEV) , _stp_uid #endif ); } /** @} */ #endif /* _STAPLINUX_PRINT_C_ */
Save
cmd:
run