[IMPROVE] implement bidirectionality sspt tree
authorVyacheslav Cherkashin <v.cherkashin@samsung.com>
Mon, 8 Apr 2013 09:11:33 +0000 (13:11 +0400)
committerVyacheslav Cherkashin <v.cherkashin@samsung.com>
Mon, 8 Apr 2013 09:11:33 +0000 (13:11 +0400)
driver/sspt/ip.h
driver/sspt/sspt_file.c
driver/sspt/sspt_file.h
driver/sspt/sspt_page.c
driver/sspt/sspt_page.h
driver/sspt/sspt_procs.c

index b74e23e..0079d7c 100644 (file)
@@ -46,6 +46,7 @@ struct sspt_file;
 
 struct us_ip {
        struct list_head list;
+       struct sspt_page *page;
 
        struct ujprobe jprobe;
        struct uretprobe retprobe;
index 08697d5..5e408ab 100644 (file)
@@ -42,6 +42,8 @@ struct sspt_file *sspt_file_create(char *name, struct dentry *dentry, int page_c
 
        if (obj) {
                int i, table_size;
+               INIT_LIST_HEAD(&obj->list);
+               obj->procs = NULL;
                obj->name = name;
                obj->dentry = dentry;
                obj->loaded = 0;
@@ -82,6 +84,7 @@ void sspt_file_free(struct sspt_file *file)
 
 static void sspt_add_page(struct sspt_file *file, struct sspt_page *page)
 {
+       page->file = file;
        hlist_add_head(&page->hlist, &file->page_probes_table[hash_ptr((void *)page->offset,
                                file->page_probes_hash_bits)]);
 }
@@ -102,6 +105,7 @@ struct sspt_file *sspt_file_copy(const struct sspt_file *file)
                struct hlist_head *head = NULL;
                int i, table_size;
                INIT_LIST_HEAD(&file_out->list);
+               file_out->procs = NULL;
                file_out->dentry = file->dentry;
                file_out->name = file->name;
                file_out->loaded = 0;
index 3d4d2e4..b85a66e 100644 (file)
@@ -31,6 +31,7 @@
 
 struct sspt_file {
        struct list_head list;                  // for proc_probes
+       struct sspt_procs *procs;
        struct dentry *dentry;
        char *name;
        int loaded;
index 6b481a9..26f8e4a 100644 (file)
@@ -36,6 +36,7 @@ struct sspt_page *sspt_page_create(unsigned long offset)
                obj->offset = offset;
                obj->install = 0;
                spin_lock_init(&obj->lock);
+               obj->file = NULL;
                INIT_HLIST_NODE(&obj->hlist);
        }
 
@@ -54,6 +55,12 @@ void sspt_page_free(struct sspt_page *page)
        kfree(page);
 }
 
+static void sspt_list_add_ip(struct sspt_page *page, struct us_ip *ip)
+{
+       list_add(&ip->list, &page->ip_list);
+       ip->page = page;
+}
+
 struct sspt_page *sspt_page_copy(const struct sspt_page *page)
 {
        struct us_ip *ip, *new_ip;
@@ -68,13 +75,14 @@ struct sspt_page *sspt_page_copy(const struct sspt_page *page)
                                return NULL;
                        }
 
-                       list_add(&new_ip->list, &new_page->ip_list);
+                       sspt_list_add_ip(new_page, new_ip);
                }
 
                new_page->offset = page->offset;
                new_page->install = 0;
                spin_lock_init(&new_page->lock);
                INIT_HLIST_NODE(&new_page->hlist);
+               new_page->file = NULL;
        }
 
        return new_page;
@@ -93,8 +101,7 @@ void sspt_add_ip(struct sspt_page *page, struct us_ip *ip)
                }
        }
 
-       INIT_LIST_HEAD(&ip->list);
-       list_add(&ip->list, &page->ip_list);
+       sspt_list_add_ip(page, ip);
 }
 
 struct us_ip *sspt_find_ip(struct sspt_page *page, unsigned long offset)
index 26dabc5..9bc6ceb 100644 (file)
@@ -37,6 +37,7 @@ struct sspt_page {
        int install;
        spinlock_t lock;
 
+       struct sspt_file *file;
        struct hlist_node hlist; // for file_probes
 };
 
index 1b8e304..8d1d52f 100644 (file)
@@ -81,6 +81,7 @@ void sspt_procs_free_all(void)
 static void sspt_procs_add_file(struct sspt_procs *procs, struct sspt_file *file)
 {
        list_add(&file->list, &procs->file_list);
+       file->procs = procs;
 }
 
 struct sspt_file *sspt_procs_find_file_or_new(struct sspt_procs *procs,