From 4e20e9b9d2a207b0eb35e1689147de1e06cfe1f5 Mon Sep 17 00:00:00 2001 From: Kris Van Hees Date: Thu, 3 Nov 2011 13:59:00 -0400 Subject: [PATCH] Fixed the allocation of cyclics that was the cuase for some obscure crashes during the testsuite execution. Problem was that cyclics were being allocated in chunks, with a new array being allocated as (prev-size + chink-size), and then the old entries being copied over. However, because the hrtimer struct is embedded in the cyclic struct, this meant that hrtimer structs were being moved outside the hrtimer code. Signed-off-by: Kris Van Hees --- dtrace/dtrace_dev.c | 6 ++---- dtrace/dtrace_state.c | 2 +- dtrace/dtrace_util.c | 16 ++-------------- dtrace/profile_dev.c | 22 +++++++++++++++++----- 4 files changed, 22 insertions(+), 24 deletions(-) diff --git a/dtrace/dtrace_dev.c b/dtrace/dtrace_dev.c index 821ef540b284..62d17ab061ee 100644 --- a/dtrace/dtrace_dev.c +++ b/dtrace/dtrace_dev.c @@ -902,7 +902,7 @@ static int dtrace_open(struct inode *inode, struct file *file) static int dtrace_close(struct inode *inode, struct file *file) { - dtrace_state_t *state; + dtrace_state_t *state = file->private_data; mutex_lock(&cpu_lock); mutex_lock(&dtrace_lock); @@ -910,7 +910,6 @@ static int dtrace_close(struct inode *inode, struct file *file) /* * If there is anonymous state, destroy that first. */ - state = file->private_data; if (state->dts_anon) { ASSERT(dtrace_anon.dta_state == NULL); @@ -1285,8 +1284,7 @@ int dtrace_dev_init(void) if (dtrace_helptrace_enabled) { ASSERT(dtrace_helptrace_buffer == NULL); - dtrace_helptrace_buffer = dtrace_vzalloc( - dtrace_helptrace_bufsize); + dtrace_helptrace_buffer = vzalloc(dtrace_helptrace_bufsize); dtrace_helptrace_next = 0; } diff --git a/dtrace/dtrace_state.c b/dtrace/dtrace_state.c index afbccb4ae7d7..379772da22ee 100644 --- a/dtrace/dtrace_state.c +++ b/dtrace/dtrace_state.c @@ -169,7 +169,7 @@ int dtrace_dstate_init(dtrace_dstate_t *dstate, size_t size) if (size < (min = dstate->dtds_chunksize + sizeof (dtrace_dynhash_t))) size = min; - if ((base = dtrace_vzalloc(size)) == NULL) + if ((base = dtrace_vzalloc_try(size)) == NULL) return -ENOMEM; dstate->dtds_size = size; diff --git a/dtrace/dtrace_util.c b/dtrace/dtrace_util.c index 92b5a73700ea..9b4abf7c92d3 100644 --- a/dtrace/dtrace_util.c +++ b/dtrace/dtrace_util.c @@ -46,23 +46,11 @@ int dtrace_badattr(const dtrace_attribute_t *a) void *dtrace_vzalloc_try(unsigned long size) { return __vmalloc(size, - __GFP_IO | __GFP_FS | __GFP_NORETRY | __GFP_ZERO, + __GFP_WAIT | __GFP_IO | __GFP_FS | __GFP_NORETRY | + __GFP_ZERO, PAGE_KERNEL); } -/* - * Allocate a chunk of virtual memory in kernel space, and zero it out. - */ -void *dtrace_vzalloc(unsigned long size) -{ - void *ptr = vmalloc(size); - - if (ptr == NULL) - return NULL; - - return memset(ptr, 0, size); -} - /* * Return a duplicate copy of a string. If the specified string is NULL, this * function returs a zero-length string. diff --git a/dtrace/profile_dev.c b/dtrace/profile_dev.c index ee7956be8348..95e7ad99c0f1 100644 --- a/dtrace/profile_dev.c +++ b/dtrace/profile_dev.c @@ -36,6 +36,9 @@ #include "dtrace_dev.h" #include "profile.h" +/* #define OMNI_CYCLICS */ +/* #define PROBE_PCS */ + #define PROF_NAMELEN 15 #define PROF_PROFILE 0 #define PROF_TICK 1 @@ -59,12 +62,14 @@ typedef struct profile_probe_percpu { static ktime_t profile_interval_min = KTIME_INIT(0, NANOSEC / 5000); static int profile_aframes = 0; +#ifdef OMNI_CYCLICS static int profile_rates[] = { 97, 199, 499, 997, 1999, 4001, 4999, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; +#endif static int profile_ticks[] = { 1, 10, 100, 500, 1000, 5000, 0, 0, 0, 0, @@ -90,16 +95,17 @@ static void profile_tick(void *arg) struct pt_regs *regs = get_irq_regs(); unsigned long pc = 0, upc = 0; -if (regs) { +#ifdef PROBE_PCS if (user_mode(regs)) upc = GET_IP(regs); else pc = GET_IP(regs); -} +#endif dtrace_probe(prof->prof_id, pc, upc, 0, 0, 0); } +#ifdef OMNI_CYCLICS static void profile_prof(void *arg) { profile_probe_percpu_t *pcpu = arg; @@ -112,12 +118,12 @@ static void profile_prof(void *arg) pcpu->profc_expected = ktime_add(pcpu->profc_expected, pcpu->profc_interval); -if (regs) { +#ifdef PROBE_PCS if (user_mode(regs)) upc = GET_IP(regs); else pc = GET_IP(regs); -} +#endif dtrace_probe(prof->prof_id, pc, upc, ktime_to_ns(late), 0, 0); } @@ -150,6 +156,7 @@ static void profile_offline(void *arg, processorid_t cpu, void *oarg) kfree(pcpu); } +#endif static void profile_create(ktime_t interval, const char *name, int kind) { @@ -190,7 +197,9 @@ void profile_provide(void *arg, const dtrace_probedesc_t *desc) char *prefix; int kind; } types[] = { +#ifdef OMNI_CYCLIC { PROF_PREFIX_PROFILE, PROF_PROFILE }, +#endif { PROF_PREFIX_TICK, PROF_TICK }, { NULL, 0 }, }; @@ -224,6 +233,7 @@ void profile_provide(void *arg, const dtrace_probedesc_t *desc) /* * If no description was provided, provide all of our probes. */ +#ifdef OMNI_CYCLICS for (i = 0; i < sizeof(profile_rates) / sizeof(int); i++) { if ((rate = profile_rates[i]) == 0) continue; @@ -233,6 +243,7 @@ void profile_provide(void *arg, const dtrace_probedesc_t *desc) profile_create(ktime_set(0, NANOSEC / rate), n, PROF_PROFILE); } +#endif for (i = 0; i < sizeof(profile_ticks) / sizeof(int); i++) { if ((rate = profile_ticks[i]) == 0) @@ -341,6 +352,7 @@ int profile_enable(void *arg, dtrace_id_t id, void *parg) when.cyt_when = ktime_set(0, 0); prof->prof_cyclic = cyclic_add(&hdlr, &when); +#ifdef OMNI_CYCLICS } else { ASSERT(prof->prof_kind == PROF_PROFILE); @@ -349,6 +361,7 @@ int profile_enable(void *arg, dtrace_id_t id, void *parg) omni.cyo_arg = prof; prof->prof_cyclic = cyclic_add_omni(&omni); +#endif } return 0; @@ -358,7 +371,6 @@ void profile_disable(void *arg, dtrace_id_t id, void *parg) { profile_probe_t *prof = parg; -if (prof->prof_cyclic == CYCLIC_NONE) return; ASSERT(prof->prof_cyclic != CYCLIC_NONE); ASSERT(mutex_is_locked(&cpu_lock)); -- 2.50.1