[IMPROVE] Add uretprobe_instance data field 50/33650/2
authorVasiliy Ulyanov <v.ulyanov@samsung.com>
Mon, 2 Jun 2014 14:18:17 +0000 (18:18 +0400)
committerAlexander Aksenov <a.aksenov@samsung.com>
Tue, 24 Feb 2015 08:18:31 +0000 (11:18 +0300)
Change-Id: Ic852d3d40b4b0dcb0dfa5f867aa3f02d3647aa03
Signed-off-by: Vasiliy Ulyanov <v.ulyanov@samsung.com>
uprobe/swap_uprobes.c
uprobe/swap_uprobes.h

index ea1436a..6f9237f 100644 (file)
@@ -424,7 +424,7 @@ static int alloc_nodes_uretprobe(struct uretprobe *rp)
        alloc_nodes = COMMON_URP_NR;
 
        for (i = 0; i < alloc_nodes; ++i) {
-               inst = kmalloc(sizeof(*inst), GFP_ATOMIC);
+               inst = kmalloc(sizeof(*inst) + rp->data_size, GFP_ATOMIC);
                if (inst == NULL) {
                        free_urp_inst(rp);
                        return -ENOMEM;
@@ -815,7 +815,7 @@ int swap_register_uretprobe(struct uretprobe *rp)
        INIT_HLIST_HEAD(&rp->free_instances);
 
        for (i = 0; i < rp->maxactive; i++) {
-               inst = kmalloc(sizeof(*inst), GFP_ATOMIC);
+               inst = kmalloc(sizeof(*inst) + rp->data_size, GFP_ATOMIC);
                if (inst == NULL) {
                        free_urp_inst(rp);
                        return -ENOMEM;
index da06aff..e2a417f 100644 (file)
@@ -92,6 +92,7 @@ struct uretprobe {
        /** Tracks the number of times the probed function's return was
         * ignored, due to maxactive being too low. */
        int nmissed;
+       size_t data_size;                   /**< Instance data size */
        struct hlist_head free_instances;   /**< Free instances list */
        struct hlist_head used_instances;   /**< Used instances list */
 
@@ -113,6 +114,7 @@ struct uretprobe_instance {
        kprobe_opcode_t *ret_addr;          /**< Return address */
        kprobe_opcode_t *sp;                /**< Pointer to stack */
        struct task_struct *task;           /**< Pointer to the task struct */
+       char data[0];                       /**< Custom data */
 };
 
 int swap_register_uprobe(struct uprobe *p);