diff options
author | Dave Brolley <brolley@redhat.com> | 2009-12-14 16:39:01 -0500 |
---|---|---|
committer | Dave Brolley <brolley@redhat.com> | 2009-12-14 16:39:01 -0500 |
commit | b8f1753c091d3f75ea4a71bfb709d8e50780d3fb (patch) | |
tree | ea5e83a0556d4df262a2b4f9b26065dc312a8a1e /runtime | |
parent | 61b21980212779b5a35f6a196842bdca55a3ced6 (diff) | |
parent | 958c58e8231563e9349e4d8ea56c04c25e1501c0 (diff) | |
download | systemtap-steved-b8f1753c091d3f75ea4a71bfb709d8e50780d3fb.tar.gz systemtap-steved-b8f1753c091d3f75ea4a71bfb709d8e50780d3fb.tar.xz systemtap-steved-b8f1753c091d3f75ea4a71bfb709d8e50780d3fb.zip |
Merge branch 'master' of ssh://sources.redhat.com/git/systemtap
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/addr-map.c | 11 | ||||
-rw-r--r-- | runtime/alloc.c | 19 | ||||
-rw-r--r-- | runtime/itrace.c | 9 | ||||
-rw-r--r-- | runtime/print.c | 31 | ||||
-rw-r--r-- | runtime/regs.c | 2 | ||||
-rw-r--r-- | runtime/staprun/relay.c | 6 | ||||
-rw-r--r-- | runtime/stat-common.c | 18 |
7 files changed, 51 insertions, 45 deletions
diff --git a/runtime/addr-map.c b/runtime/addr-map.c index 35de7a64..abb723f3 100644 --- a/runtime/addr-map.c +++ b/runtime/addr-map.c @@ -163,12 +163,11 @@ add_bad_addr_entry(unsigned long min_addr, unsigned long max_addr, spin_unlock(&addr_map_lock); if (new_map) { - kfree(new_map); + _stp_kfree(new_map); new_map = 0; } - new_map = kmalloc(sizeof(*new_map) - + sizeof(*new_entry) * (old_size + 1), - GFP_KERNEL); + new_map = _stp_kmalloc(sizeof(*new_map) + + sizeof(*new_entry) * (old_size + 1)); if (!new_map) return -ENOMEM; new_map->size = old_size + 1; @@ -191,7 +190,7 @@ add_bad_addr_entry(unsigned long min_addr, unsigned long max_addr, if (existing_max) *existing_max = max_entry; spin_unlock(&addr_map_lock); - kfree(new_map); + _stp_kfree(new_map); return 1; } existing = upper_bound(min_addr, old_map); @@ -210,7 +209,7 @@ add_bad_addr_entry(unsigned long min_addr, unsigned long max_addr, blackmap = new_map; spin_unlock(&addr_map_lock); if (old_map) - kfree(old_map); + _stp_kfree(old_map); return 0; } diff --git a/runtime/alloc.c b/runtime/alloc.c index 403d20ee..2e98b94e 100644 --- a/runtime/alloc.c +++ b/runtime/alloc.c @@ -16,7 +16,7 @@ static int _stp_allocated_net_memory = 0; #define STP_ALLOC_FLAGS (GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN) -//#define DEBUG_MEM +/* #define DEBUG_MEM */ /* * If DEBUG_MEM is defined (stap -DDEBUG_MEM ...) then full memory * tracking is used. Each allocation is recorded and matched with @@ -32,10 +32,10 @@ static int _stp_allocated_net_memory = 0; * would be nice, but DEBUG_MEM is only for testing. */ -#ifdef DEBUG_MEM +static int _stp_allocated_memory = 0; +#ifdef DEBUG_MEM static DEFINE_SPINLOCK(_stp_mem_lock); -static int _stp_allocated_memory = 0; #define MEM_MAGIC 0xc11cf77f #define MEM_FENCE_SIZE 32 @@ -176,11 +176,11 @@ static void _stp_mem_debug_free(void *addr, enum _stp_memtype type) static void *_stp_kmalloc(size_t size) { + _stp_allocated_memory += size; #ifdef DEBUG_MEM void *ret = kmalloc(size + MEM_DEBUG_SIZE, STP_ALLOC_FLAGS); if (likely(ret)) { ret = _stp_mem_debug_setup(ret, size, MEM_KMALLOC); - _stp_allocated_memory += size; } return ret; #else @@ -196,10 +196,10 @@ static void *_stp_kzalloc(size_t size) if (likely(ret)) { ret = _stp_mem_debug_setup(ret, size, MEM_KMALLOC); memset (ret, 0, size); - _stp_allocated_memory += size; } #else void *ret = kmalloc(size, STP_ALLOC_FLAGS); + _stp_allocated_memory += size; if (likely(ret)) memset (ret, 0, size); #endif /* DEBUG_MEM */ @@ -209,9 +209,9 @@ static void *_stp_kzalloc(size_t size) { #ifdef DEBUG_MEM void *ret = kzalloc(size + MEM_DEBUG_SIZE, STP_ALLOC_FLAGS); + _stp_allocated_memory += size; if (likely(ret)) { ret = _stp_mem_debug_setup(ret, size, MEM_KMALLOC); - _stp_allocated_memory += size; } return ret; #else @@ -222,11 +222,11 @@ static void *_stp_kzalloc(size_t size) static void *_stp_vmalloc(unsigned long size) { + _stp_allocated_memory += size; #ifdef DEBUG_MEM void *ret = __vmalloc(size + MEM_DEBUG_SIZE, STP_ALLOC_FLAGS, PAGE_KERNEL); if (likely(ret)) { ret = _stp_mem_debug_setup(ret, size, MEM_VMALLOC); - _stp_allocated_memory += size; } return ret; #else @@ -248,6 +248,8 @@ static void *_stp_alloc_percpu(size_t size) if (size > _STP_MAX_PERCPU_SIZE) return NULL; + _stp_allocated_memory += size * num_online_cpus(); + #ifdef STAPCONF_ALLOC_PERCPU_ALIGN ret = __alloc_percpu(size, 8); #else @@ -261,7 +263,6 @@ static void *_stp_alloc_percpu(size_t size) return NULL; } _stp_mem_debug_percpu(m, ret, size); - _stp_allocated_memory += size * num_online_cpus(); } #endif return ret; @@ -272,11 +273,11 @@ static void *_stp_alloc_percpu(size_t size) #else static void *_stp_kmalloc_node(size_t size, int node) { + _stp_allocated_memory += size; #ifdef DEBUG_MEM void *ret = kmalloc_node(size + MEM_DEBUG_SIZE, STP_ALLOC_FLAGS, node); if (likely(ret)) { ret = _stp_mem_debug_setup(ret, size, MEM_KMALLOC); - _stp_allocated_memory += size; } return ret; #else diff --git a/runtime/itrace.c b/runtime/itrace.c index f2ed86f2..5b2437a4 100644 --- a/runtime/itrace.c +++ b/runtime/itrace.c @@ -219,7 +219,12 @@ static struct itrace_info *create_itrace_info( if (debug) printk(KERN_INFO "create_itrace_info: tid=%d\n", tsk->pid); /* initialize ui */ - ui = kzalloc(sizeof(struct itrace_info), GFP_USER); + ui = _stp_kzalloc(sizeof(struct itrace_info)); + if (ui == NULL) { + printk(KERN_ERR "%s:%d: Unable to allocate memory\n", + __FUNCTION__, __LINE__); + return NULL; + } ui->tsk = tsk; ui->tid = tsk->pid; ui->step_flag = step_flag; @@ -329,7 +334,7 @@ void static remove_usr_itrace_info(struct itrace_info *ui) spin_lock(&itrace_lock); list_del(&ui->link); spin_unlock(&itrace_lock); - kfree(ui); + _stp_kfree(ui); } void static cleanup_usr_itrace(void) diff --git a/runtime/print.c b/runtime/print.c index 335403fb..09ebd05e 100644 --- a/runtime/print.c +++ b/runtime/print.c @@ -217,14 +217,8 @@ static void _stp_print_char (const char c) static void _stp_print_kernel_info(char *vstr, int ctx, int num_probes) { printk(KERN_DEBUG - "%s: systemtap: %s, base: %p, memory: %lu+%lu+%u+%u" -#ifdef DEBUG_MEM - "+%u" -#endif - " data+text+ctx+net" -#ifdef DEBUG_MEM - "+alloc" -#endif + "%s: systemtap: %s, base: %p" + ", memory: %ludata/%lutext/%uctx/%unet/%ualloc kb" ", probes: %d" #ifndef STP_PRIVILEGED ", unpriv-uid: %d" @@ -234,19 +228,18 @@ static void _stp_print_kernel_info(char *vstr, int ctx, int num_probes) vstr, #ifndef STAPCONF_GRSECURITY THIS_MODULE->module_core, - (unsigned long) (THIS_MODULE->core_size - THIS_MODULE->core_text_size), - (unsigned long) THIS_MODULE->core_text_size, + (unsigned long) (THIS_MODULE->core_size - THIS_MODULE->core_text_size)/1024, + (unsigned long) (THIS_MODULE->core_text_size)/1024, #else - THIS_MODULE->module_core_rx, - (unsigned long) (THIS_MODULE->core_size_rw - THIS_MODULE->core_size_rx), - (unsigned long) THIS_MODULE->core_size_rx, -#endif - ctx, - _stp_allocated_net_memory, -#ifdef DEBUG_MEM - _stp_allocated_memory - _stp_allocated_net_memory, + 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 - num_probes + 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 #ifndef STP_PRIVILEGED , _stp_uid #endif diff --git a/runtime/regs.c b/runtime/regs.c index e963affa..61f2f317 100644 --- a/runtime/regs.c +++ b/runtime/regs.c @@ -267,7 +267,7 @@ static const char *processor_modes[]= static void _stp_print_regs(struct pt_regs * regs) { - unsigned long flags = condition_codes(regs); + unsigned long flags = regs->ARM_cpsr; #ifdef CONFIG_SMP _stp_printf(" CPU: %d", smp_processor_id()); diff --git a/runtime/staprun/relay.c b/runtime/staprun/relay.c index 59d7ac9a..39a2f393 100644 --- a/runtime/staprun/relay.c +++ b/runtime/staprun/relay.c @@ -166,9 +166,9 @@ static void *reader_thread(void *data) if (stop_threads) break; if (switch_file[cpu]) { - switch_file[cpu] = 0; if (switch_outfile(cpu, &fnum) < 0) goto error_out; + switch_file[cpu] = 0; wsize = 0; } } else { @@ -179,9 +179,11 @@ static void *reader_thread(void *data) while ((rc = read(relay_fd[cpu], buf, sizeof(buf))) > 0) { /* Switching file */ - if (fsize_max && wsize + rc > fsize_max) { + if ((fsize_max && wsize + rc > fsize_max) || + switch_file[cpu]) { if (switch_outfile(cpu, &fnum) < 0) goto error_out; + switch_file[cpu] = 0; wsize = 0; } if (write(out_fd[cpu], buf, rc) != rc) { diff --git a/runtime/stat-common.c b/runtime/stat-common.c index f9703049..fabe8404 100644 --- a/runtime/stat-common.c +++ b/runtime/stat-common.c @@ -34,9 +34,10 @@ static int _stp_stat_calc_buckets(int stop, int start, int interval) return buckets; } -static int needed_space(uint64_t v) +static int needed_space(int64_t v) { int space = 0; + uint64_t tmp; if (v == 0) return 1; @@ -45,9 +46,10 @@ static int needed_space(uint64_t v) space++; v = -v; } - while (v) { + tmp = v; + while (tmp) { /* v /= 10; */ - do_div (v, 10); + do_div(tmp, 10); space++; } return space; @@ -134,7 +136,8 @@ static void _stp_stat_print_histogram_buf(char *buf, size_t size, Hist st, stat { int scale, i, j, val_space, cnt_space; int low_bucket = -1, high_bucket = 0, over = 0, under = 0; - uint64_t val, v, valmax = 0; + int64_t val, valmax = 0; + uint64_t v; int eliding = 0; char *cur_buf = buf, *fake = buf; char **bufptr = (buf == NULL ? &fake : &cur_buf); @@ -282,7 +285,7 @@ static void _stp_stat_print_histogram(Hist st, stat *sd) _stp_print_flush(); } -static void __stp_stat_add (Hist st, stat *sd, uint64_t val) +static void __stp_stat_add(Hist st, stat *sd, int64_t val) { int n; if (sd->count == 0) { @@ -310,7 +313,10 @@ static void __stp_stat_add (Hist st, stat *sd, uint64_t val) if (val < 0) val = 0; else { - do_div (val, st->interval); + uint64_t tmp = val; + + do_div(tmp, st->interval); + val = tmp; val++; } |