Add support for ppc hw tb clock, remove kernelcompat.h
[ust.git] / libust / tracepoint.c
index df94b2cb4c15e7acc091a410de0265251ea52083..8eee320d4149bbc7bca9416ce7264a4c2821a900 100644 (file)
  * Ported to userspace by Pierre-Marc Fournier.
  */
 
-//ust// #include <linux/module.h>
-//ust// #include <linux/mutex.h>
-//ust// #include <linux/types.h>
-//ust// #include <linux/jhash.h>
-//ust// #include <linux/list.h>
-//ust// #include <linux/rcupdate.h>
-//ust// #include <linux/tracepoint.h>
-//ust// #include <linux/err.h>
-//ust// #include <linux/slab.h>
-//ust// #include <linux/immediate.h>
-
 #include <errno.h>
-
-#include "kernelcompat.h"
-#include "tracepoint.h"
+#include <ust/tracepoint.h>
+#include <ust/core.h>
+#include <ust/kcompat/kcompat.h>
 #include "usterr.h"
-//#include "list.h"
 
 #define _LGPL_SOURCE
 #include <urcu-bp.h>
@@ -86,8 +74,8 @@ struct tp_probes {
 
 static inline void *allocate_probes(int count)
 {
-       struct tp_probes *p  = kmalloc(count * sizeof(void *)
-                       + sizeof(struct tp_probes), GFP_KERNEL);
+       struct tp_probes *p  = malloc(count * sizeof(void *)
+                       + sizeof(struct tp_probes));
        return p == NULL ? NULL : p->probes;
 }
 
@@ -103,7 +91,7 @@ static inline void release_probes(void *old)
                        struct tp_probes, probes[0]);
 //ust//                call_rcu_sched(&tp_probes->u.rcu, rcu_free_old_probes);
                synchronize_rcu();
-               kfree(tp_probes);
+               free(tp_probes);
        }
 }
 
@@ -115,7 +103,7 @@ static void debug_print_probes(struct tracepoint_entry *entry)
                return;
 
        for (i = 0; entry->funcs[i]; i++)
-               printk(KERN_DEBUG "Probe %d : %p\n", i, entry->funcs[i]);
+               DBG("Probe %d : %p", i, entry->funcs[i]);
 }
 
 static void *
@@ -225,8 +213,7 @@ static struct tracepoint_entry *add_tracepoint(const char *name)
        head = &tracepoint_table[hash & (TRACEPOINT_TABLE_SIZE - 1)];
        hlist_for_each_entry(e, node, head, hlist) {
                if (!strcmp(name, e->name)) {
-                       printk(KERN_NOTICE
-                               "tracepoint %s busy\n", name);
+                       DBG("tracepoint %s busy", name);
                        return ERR_PTR(-EEXIST);        /* Already there */
                }
        }
@@ -234,7 +221,7 @@ static struct tracepoint_entry *add_tracepoint(const char *name)
         * Using kmalloc here to allocate a variable length element. Could
         * cause some memory fragmentation if overused.
         */
-       e = kmalloc(sizeof(struct tracepoint_entry) + name_len, GFP_KERNEL);
+       e = malloc(sizeof(struct tracepoint_entry) + name_len);
        if (!e)
                return ERR_PTR(-ENOMEM);
        memcpy(&e->name[0], name, name_len);
@@ -251,7 +238,7 @@ static struct tracepoint_entry *add_tracepoint(const char *name)
 static inline void remove_tracepoint(struct tracepoint_entry *e)
 {
        hlist_del(&e->hlist);
-       kfree(e);
+       free(e);
 }
 
 /*
@@ -502,7 +489,7 @@ void tracepoint_probe_update_all(void)
                list_del(&pos->u.list);
 //ust//                call_rcu_sched(&pos->u.rcu, rcu_free_old_probes);
                synchronize_rcu();
-               kfree(pos);
+               free(pos);
        }
 }
 //ust// EXPORT_SYMBOL_GPL(tracepoint_probe_update_all);
@@ -679,10 +666,22 @@ int tracepoint_register_lib(struct tracepoint *tracepoints_start, int tracepoint
        return 0;
 }
 
-int tracepoint_unregister_lib(struct tracepoint *tracepoints_start, int tracepoints_count)
+int tracepoint_unregister_lib(struct tracepoint *tracepoints_start)
 {
-       /*FIXME: implement; but before implementing, tracepoint_register_lib must
-          have appropriate locking. */
+       struct tracepoint_lib *lib;
+
+       mutex_lock(&tracepoints_mutex);
+
+       list_for_each_entry(lib, &libs, list) {
+               if(lib->tracepoints_start == tracepoints_start) {
+                       struct tracepoint_lib *lib2free = lib;
+                       list_del(&lib->list);
+                       free(lib2free);
+                       break;
+               }
+       }
+
+       mutex_unlock(&tracepoints_mutex);
 
        return 0;
 }
This page took 0.024163 seconds and 4 git commands to generate.