/usr/share/systemtap/runtime/linux
NameSizeModeActions
uprobes/-0755rm
uprobes2/-0755rm
access_process_vm.h43110644editdlrm
addr-map.c97490644editdlrm
alloc.c159000644editdlrm
arith.c167990644editdlrm
autoconf-514-panic.c680644editdlrm
autoconf-access_ok_2args.c900644editdlrm
autoconf-alloc-percpu-align.c1180644editdlrm
autoconf-asm-syscall.c510644editdlrm
autoconf-atomic_fetch_add_unless.c940644editdlrm
autoconf-bio-bi_opf.c8240644editdlrm
autoconf-blk-types.c3590644editdlrm
autoconf-compat-utimbuf.c530644editdlrm
autoconf-compat_sigaction.c4480644editdlrm
autoconf-constant-tsc.c630644editdlrm
autoconf-cpu-clock.c12770644editdlrm
autoconf-dpath-path.c1210644editdlrm
autoconf-files_lookup_fd_raw.c1360644editdlrm
autoconf-from_kuid_munged.c1910644editdlrm
autoconf-fs_supers-hlist.c3540644editdlrm
autoconf-generated-compile.c560644editdlrm
autoconf-genhd.c2010644editdlrm
autoconf-get-kretprobe.c1070644editdlrm
autoconf-get_user_pages-flags.c15490644editdlrm
autoconf-get_user_pages-notask_struct.c13010644editdlrm
autoconf-get_user_pages_remote-flags.c15500644editdlrm
autoconf-get_user_pages_remote-flags_locked.c13310644editdlrm
autoconf-get_user_pages_remote-notask_struct.c14380644editdlrm
autoconf-grsecurity.c2190644editdlrm
autoconf-hlist-4args.c2960644editdlrm
autoconf-hlist_add_tail_rcu.c1120644editdlrm
autoconf-hrtimer-getset-expires.c1260644editdlrm
autoconf-hrtimer-rel.c870644editdlrm
autoconf-hw_breakpoint_context.c3150644editdlrm
autoconf-inode-private.c1730644editdlrm
autoconf-inode-rwsem.c1720644editdlrm
autoconf-inode-uretprobes.c2640644editdlrm
autoconf-kernel_read-new-args.c10300644editdlrm
autoconf-kprobe-symbol-name.c900644editdlrm
autoconf-ktime-get-real.c980644editdlrm
autoconf-linux-sched_headers.c16780644editdlrm
autoconf-local-clock.c12820644editdlrm
autoconf-lockdown-debugfs.c1020644editdlrm
autoconf-lockdown-kernel.c900644editdlrm
autoconf-mm-context-vdso-base.c1170644editdlrm
autoconf-mm-context-vdso.c1140644editdlrm
autoconf-mm-shmempages.c720644editdlrm
autoconf-mmap_lock.c1750644editdlrm
autoconf-module-sect-attrs.c1580644editdlrm
autoconf-module_layout.c520644editdlrm
autoconf-mod_kallsyms.c510644editdlrm
autoconf-nameidata.c960644editdlrm
autoconf-netfilter-4_1.c7690644editdlrm
autoconf-netfilter-4_4.c14600644editdlrm
autoconf-netfilter-313b.c6020644editdlrm
autoconf-netfilter.c4220644editdlrm
autoconf-old-inode-uprobes.c3570644editdlrm
autoconf-oneachcpu-retry.c9570644editdlrm
autoconf-pagefault_disable.c1370644editdlrm
autoconf-pde_data.c2260644editdlrm
autoconf-perf-structpid.c4440644editdlrm
autoconf-procfs-owner.c1580644editdlrm
autoconf-proc_ops.c5660644editdlrm
autoconf-rcu_is_watching.c3850644editdlrm
autoconf-real-parent.c4270644editdlrm
autoconf-regset.c2390644editdlrm
autoconf-relay-umode_t.c7300644editdlrm
autoconf-relay_buf-per_cpu_ptr.c9200644editdlrm
autoconf-ring_buffer-flags.c1120644editdlrm
autoconf-ring_buffer_lost_events.c2960644editdlrm
autoconf-ring_buffer_read_prepare.c1810644editdlrm
autoconf-save-stack-trace-no-bp.c4980644editdlrm
autoconf-save-stack-trace.c5010644editdlrm
autoconf-set_fs.c2210644editdlrm
autoconf-smpcall-4args.c1660644editdlrm
autoconf-smpcall-5args.c1690644editdlrm
autoconf-stack-trace-save-regs.c1760644editdlrm
autoconf-stacktrace_ops-int-address.c4090644editdlrm
autoconf-stacktrace_ops-warning.c1880644editdlrm
autoconf-syscall_get_args_3args.c2390644editdlrm
autoconf-task-state.c5500644editdlrm
autoconf-task-uid.c1520644editdlrm
autoconf-task_work-struct.c2190644editdlrm
autoconf-time32-old.c520644editdlrm
autoconf-time32.c530644editdlrm
autoconf-timerfd.c2320644editdlrm
autoconf-trace-printk.c1510644editdlrm
autoconf-tracepoint-has-data.c4930644editdlrm
autoconf-tracepoint-strings.c2330644editdlrm
autoconf-uaccess.c280644editdlrm
autoconf-uapi-mount.c520644editdlrm
autoconf-udelay_simple.c900644editdlrm
autoconf-uidgid.c500644editdlrm
autoconf-unwind-stack-trace.c3260644editdlrm
autoconf-uprobe-get-pc.c3740644editdlrm
autoconf-utrace-regset.c2730644editdlrm
autoconf-utrace-via-tracepoints.c17120644editdlrm
autoconf-vm-area-pte.c1410644editdlrm
autoconf-walk-stack.c2170644editdlrm
autoconf-x86-fs.c900644editdlrm
autoconf-x86-gs.c900644editdlrm
autoconf-x86-uniregs.c1400644editdlrm
autoconf-x86-xfs.c910644editdlrm
common_session_state.h32490644editdlrm
compat_net.h8580644editdlrm
compat_structs.h44090644editdlrm
compat_unistd.h683840644editdlrm
copy.c27170644editdlrm
debug.h29780644editdlrm
io.c52910644editdlrm
itrace.c148740644editdlrm
kprobes.c251260644editdlrm
loc2c-runtime.h298740644editdlrm
map_list.h12200644editdlrm
map_runtime.h52660644editdlrm
namespaces.h71280644editdlrm
netfilter.c14100644editdlrm
perf.c75960644editdlrm
perf.h12720644editdlrm
perf_event_counter_context.c3360644editdlrm
perf_probe_handler_nmi.c2780644editdlrm
perf_read.h9590644editdlrm
print.c114020644editdlrm
probe_lock.h18070644editdlrm
regs-ia64.c37410644editdlrm
regs.c134900644editdlrm
runtime.h125910644editdlrm
runtime_context.h60890644editdlrm
runtime_defines.h10410644editdlrm
stap_mmap_lock.h3430644editdlrm
stat_runtime.h17740644editdlrm
stp_tls.h11810644editdlrm
stp_tracepoint.c114810644editdlrm
stp_tracepoint.h22700644editdlrm
syscalls-common.h9760644editdlrm
task_finder.c538600644editdlrm
task_finder2.c576400644editdlrm
task_finder_map.c51940644editdlrm
task_finder_stubs.c24420644editdlrm
task_work_compatibility.h12830644editdlrm
timer.c22000644editdlrm
timer.h13830644editdlrm
timer_compatibility.h23170644editdlrm
uprobes-common.c155730644editdlrm
uprobes-common.h16530644editdlrm
uprobes-inc.h4840644editdlrm
uprobes-inode.c340860644editdlrm
Edit: /usr/share/systemtap/runtime/linux/runtime_context.h (6089B)
/* -*- linux-c -*- * Context Runtime Functions * Copyright (C) 2014 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_RUNTIME_CONTEXT_H_ #define _LINUX_RUNTIME_CONTEXT_H_ /* Can't use a lock primitive for this because lock_acquire() has tracepoints */ static atomic_t _stp_contexts_busy_ctr = ATOMIC_INIT(0); /* Per-cpu data is always initialized with zero filled. */ static DEFINE_PER_CPU(struct context *, contexts); static int _stp_runtime_contexts_alloc(void) { unsigned int cpu; /* 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 context structs were * allocated for online CPUs at this point, we will discard any context * fetching operations on any future online CPUs dynamically added * through the kernel's CPU hotplug feature. Memory allocations of the * context structs can only happen right here. */ for_each_online_cpu(cpu) { /* Module init, so in user context, safe to use * "sleeping" allocation. */ struct context *c = _stp_vzalloc_node(sizeof (struct context), cpu_to_node(cpu)); if (unlikely(c == NULL)) { _stp_error ("context (size %lu per cpu) allocation failed", (unsigned long) sizeof (struct context)); return -ENOMEM; } per_cpu(contexts, cpu) = c; } return 0; } static bool _stp_runtime_context_trylock(void) { bool locked; /* Need to disable preemption because of the smp_processor_id() call in _stp_runtime_get_context(). */ preempt_disable(); /* fast path to ignore new online CPUs without percpu context memory * allocations. this also serves as an extra safe guard for NULL context * pointers. */ if (unlikely(_stp_runtime_get_context() == NULL)) { preempt_enable_no_resched(); return false; } locked = atomic_add_unless(&_stp_contexts_busy_ctr, 1, INT_MAX); if (!locked) preempt_enable_no_resched(); return locked; } static void _stp_runtime_context_unlock(void) { atomic_dec(&_stp_contexts_busy_ctr); preempt_enable_no_resched(); } /* We should be free of all probes by this time, but for example the timer for * _stp_ctl_work_callback may still be running and looking for contexts. We * use _stp_contexts_busy_ctr to be sure its safe to free them. */ static void _stp_runtime_contexts_free(void) { unsigned int cpu; /* Sync to make sure existing readers are done */ while (atomic_cmpxchg(&_stp_contexts_busy_ctr, 0, INT_MAX)) cpu_relax(); /* Now we can actually free the contexts */ /* 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 the context structs on original * online CPUs when _stp_runtime_contexts_alloc() was called. And we * cannot allocate new memory from within this context. */ for_each_possible_cpu(cpu) { struct context *c = per_cpu(contexts, cpu); if (likely(c)) _stp_vfree(c); } } static inline struct context * _stp_runtime_get_context(void) { return per_cpu(contexts, smp_processor_id()); } static struct context * _stp_runtime_entryfn_get_context(void) { struct context* __restrict__ c = NULL; if (!_stp_runtime_context_trylock()) return NULL; c = _stp_runtime_get_context(); if (c != NULL) { if (!atomic_cmpxchg(&c->busy, 0, 1)) { // NB: Notice we're not releasing _stp_contexts_busy_ctr // here. We exepect the calling code to call // _stp_runtime_entryfn_get_context() and // _stp_runtime_entryfn_put_context() as a // pair. return c; } } _stp_runtime_context_unlock(); return NULL; } static inline void _stp_runtime_entryfn_put_context(struct context *c) { if (c) { atomic_set(&c->busy, 0); _stp_runtime_context_unlock(); } } static void _stp_runtime_context_wait(void) { int holdon; unsigned long hold_start; int hold_index; hold_start = jiffies; hold_index = -1; do { int i; holdon = 0; if (!_stp_runtime_context_trylock()) break; for_each_possible_cpu(i) { struct context *c = per_cpu(contexts, i); if (c != NULL && atomic_read (& c->busy)) { holdon = 1; /* Just in case things are really * stuck, let's print some diagnostics. */ if (time_after(jiffies, hold_start + HZ) // > 1 second && (i > hold_index)) { // not already printed hold_index = i; printk(KERN_ERR "%s context[%d] stuck: %s\n", THIS_MODULE->name, i, c->probe_point); } } } _stp_runtime_context_unlock(); /* * Just in case things are really really stuck, a * handler probably suffered a fault, and the kernel * probably killed a task/thread already. We can't be * quite sure in what state everything is in, however * auxiliary stuff like kprobes / uprobes / locks have * already been unregistered. So it's *probably* safe * to pretend/assume/hope everything is OK, and let * the cleanup finish. * * In the worst case, there may occur a fault, as a * genuinely running probe handler tries to access * script globals (about to be freed), or something * accesses module memory (about to be unloaded). * This is sometimes stinky, so the alternative * (default) is to change from a livelock to a * livelock that sleeps awhile. */ #ifdef STAP_OVERRIDE_STUCK_CONTEXT if (time_after(jiffies, hold_start + HZ*10)) { // > 10 seconds printk(KERN_ERR "%s overriding stuck context to allow module shutdown.", THIS_MODULE->name); holdon = 0; // allow loop to exit } #else /* at least stop sucking down the staprun cpu */ msleep(250); #endif /* NB: we run at least one of these during the * shutdown sequence: */ yield(); /* aka schedule() and then some */ } while (holdon); } #endif /* _LINUX_RUNTIME_CONTEXT_H_ */