]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
Fixed the allocation of cyclics that was the cuase for some obscure crashes
authorKris Van Hees <kris.van.hees@oracle.com>
Thu, 3 Nov 2011 17:59:00 +0000 (13:59 -0400)
committerKris Van Hees <kris.van.hees@oracle.com>
Thu, 3 Nov 2011 17:59:00 +0000 (13:59 -0400)
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 <kris.van.hees@oracle.com>
dtrace/dtrace_dev.c
dtrace/dtrace_state.c
dtrace/dtrace_util.c
dtrace/profile_dev.c

index 821ef540b2847a656474d913a141180cea407177..62d17ab061eef631633cc07cc774b14d00c661b8 100644 (file)
@@ -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;
        }
 
index afbccb4ae7d7941a4b55495419d7e008208ed6b0..379772da22ee12c5ac329a891dfd33eed2ac297c 100644 (file)
@@ -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;
index 92b5a73700ea85ced05936eed544b448abfe0508..9b4abf7c92d340b0f62bd190049993cede472e5c 100644 (file)
@@ -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.
index ee7956be8348d965f4ffdcd1c09cafb98d1ca48d..95e7ad99c0f13a6e163b1c475ed47dcb72734740 100644 (file)
@@ -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));