const: struct quota_format_ops
[safe/jmp/linux-2.6] / kernel / hw_breakpoint.c
index dd3fb4a..cf5ee16 100644 (file)
@@ -121,7 +121,7 @@ static void toggle_bp_task_slot(struct task_struct *tsk, int cpu, bool enable)
        int count = 0;
        struct perf_event *bp;
        struct perf_event_context *ctx = tsk->perf_event_ctxp;
-       unsigned int *task_bp_pinned;
+       unsigned int *tsk_pinned;
        struct list_head *list;
        unsigned long flags;
 
@@ -146,15 +146,15 @@ static void toggle_bp_task_slot(struct task_struct *tsk, int cpu, bool enable)
        if (WARN_ONCE(count < 0, "No breakpoint counter found in the counter list"))
                return;
 
-       task_bp_pinned = per_cpu(task_bp_pinned, cpu);
+       tsk_pinned = per_cpu(task_bp_pinned, cpu);
        if (enable) {
-               task_bp_pinned[count]++;
+               tsk_pinned[count]++;
                if (count > 0)
-                       task_bp_pinned[count-1]--;
+                       tsk_pinned[count-1]--;
        } else {
-               task_bp_pinned[count]--;
+               tsk_pinned[count]--;
                if (count > 0)
-                       task_bp_pinned[count-1]++;
+                       tsk_pinned[count-1]++;
        }
 }
 
@@ -289,90 +289,32 @@ int register_perf_hw_breakpoint(struct perf_event *bp)
        return __register_perf_hw_breakpoint(bp);
 }
 
-/*
- * Register a breakpoint bound to a task and a given cpu.
- * If cpu is -1, the breakpoint is active for the task in every cpu
- * If the task is -1, the breakpoint is active for every tasks in the given
- * cpu.
- */
-static struct perf_event *
-register_user_hw_breakpoint_cpu(unsigned long addr,
-                               int len,
-                               int type,
-                               perf_callback_t triggered,
-                               pid_t pid,
-                               int cpu,
-                               bool active)
-{
-       struct perf_event_attr *attr;
-       struct perf_event *bp;
-
-       attr = kzalloc(sizeof(*attr), GFP_KERNEL);
-       if (!attr)
-               return ERR_PTR(-ENOMEM);
-
-       attr->type = PERF_TYPE_BREAKPOINT;
-       attr->size = sizeof(*attr);
-       attr->bp_addr = addr;
-       attr->bp_len = len;
-       attr->bp_type = type;
-       /*
-        * Such breakpoints are used by debuggers to trigger signals when
-        * we hit the excepted memory op. We can't miss such events, they
-        * must be pinned.
-        */
-       attr->pinned = 1;
-
-       if (!active)
-               attr->disabled = 1;
-
-       bp = perf_event_create_kernel_counter(attr, cpu, pid, triggered);
-       kfree(attr);
-
-       return bp;
-}
-
 /**
  * register_user_hw_breakpoint - register a hardware breakpoint for user space
- * @addr: is the memory address that triggers the breakpoint
- * @len: the length of the access to the memory (1 byte, 2 bytes etc...)
- * @type: the type of the access to the memory (read/write/exec)
+ * @attr: breakpoint attributes
  * @triggered: callback to trigger when we hit the breakpoint
  * @tsk: pointer to 'task_struct' of the process to which the address belongs
- * @active: should we activate it while registering it
- *
  */
 struct perf_event *
-register_user_hw_breakpoint(unsigned long addr,
-                           int len,
-                           int type,
+register_user_hw_breakpoint(struct perf_event_attr *attr,
                            perf_callback_t triggered,
-                           struct task_struct *tsk,
-                           bool active)
+                           struct task_struct *tsk)
 {
-       return register_user_hw_breakpoint_cpu(addr, len, type, triggered,
-                                              tsk->pid, -1, active);
+       return perf_event_create_kernel_counter(attr, -1, tsk->pid, triggered);
 }
 EXPORT_SYMBOL_GPL(register_user_hw_breakpoint);
 
 /**
  * modify_user_hw_breakpoint - modify a user-space hardware breakpoint
  * @bp: the breakpoint structure to modify
- * @addr: is the memory address that triggers the breakpoint
- * @len: the length of the access to the memory (1 byte, 2 bytes etc...)
- * @type: the type of the access to the memory (read/write/exec)
+ * @attr: new breakpoint attributes
  * @triggered: callback to trigger when we hit the breakpoint
  * @tsk: pointer to 'task_struct' of the process to which the address belongs
- * @active: should we activate it while registering it
  */
 struct perf_event *
-modify_user_hw_breakpoint(struct perf_event *bp,
-                         unsigned long addr,
-                         int len,
-                         int type,
+modify_user_hw_breakpoint(struct perf_event *bp, struct perf_event_attr *attr,
                          perf_callback_t triggered,
-                         struct task_struct *tsk,
-                         bool active)
+                         struct task_struct *tsk)
 {
        /*
         * FIXME: do it without unregistering
@@ -381,8 +323,7 @@ modify_user_hw_breakpoint(struct perf_event *bp,
         */
        unregister_hw_breakpoint(bp);
 
-       return register_user_hw_breakpoint(addr, len, type, triggered,
-                                          tsk, active);
+       return perf_event_create_kernel_counter(attr, -1, tsk->pid, triggered);
 }
 EXPORT_SYMBOL_GPL(modify_user_hw_breakpoint);
 
@@ -398,34 +339,16 @@ void unregister_hw_breakpoint(struct perf_event *bp)
 }
 EXPORT_SYMBOL_GPL(unregister_hw_breakpoint);
 
-static struct perf_event *
-register_kernel_hw_breakpoint_cpu(unsigned long addr,
-                                 int len,
-                                 int type,
-                                 perf_callback_t triggered,
-                                 int cpu,
-                                 bool active)
-{
-       return register_user_hw_breakpoint_cpu(addr, len, type, triggered,
-                                              -1, cpu, active);
-}
-
 /**
  * register_wide_hw_breakpoint - register a wide breakpoint in the kernel
- * @addr: is the memory address that triggers the breakpoint
- * @len: the length of the access to the memory (1 byte, 2 bytes etc...)
- * @type: the type of the access to the memory (read/write/exec)
+ * @attr: breakpoint attributes
  * @triggered: callback to trigger when we hit the breakpoint
- * @active: should we activate it while registering it
  *
  * @return a set of per_cpu pointers to perf events
  */
 struct perf_event **
-register_wide_hw_breakpoint(unsigned long addr,
-                           int len,
-                           int type,
-                           perf_callback_t triggered,
-                           bool active)
+register_wide_hw_breakpoint(struct perf_event_attr *attr,
+                           perf_callback_t triggered)
 {
        struct perf_event **cpu_events, **pevent, *bp;
        long err;
@@ -437,8 +360,7 @@ register_wide_hw_breakpoint(unsigned long addr,
 
        for_each_possible_cpu(cpu) {
                pevent = per_cpu_ptr(cpu_events, cpu);
-               bp = register_kernel_hw_breakpoint_cpu(addr, len, type,
-                                       triggered, cpu, active);
+               bp = perf_event_create_kernel_counter(attr, cpu, -1, triggered);
 
                *pevent = bp;