diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 2f821f4b7c7e..1a22772d64f1 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -106,6 +106,12 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_rwsem_write_finished); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_alter_rwsem_list_add); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_alter_futex_plist_add); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_futex_sleep_start); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_do_futex); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_futex_wait_start); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_futex_wait_end); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_futex_wake_traverse_plist); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_futex_wake_this); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_futex_wake_up_q_finish); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mutex_wait_start); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mutex_wait_finish); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_rtmutex_wait_start); diff --git a/include/trace/hooks/futex.h b/include/trace/hooks/futex.h index f8bf394ea013..829fe5605b02 100644 --- a/include/trace/hooks/futex.h +++ b/include/trace/hooks/futex.h @@ -8,6 +8,10 @@ #include #include #include +#ifndef __GENKSYMS__ +#include +#endif + /* * Following tracepoints are not exported in tracefs and provide a * mechanism for vendor modules to hook and extend functionality @@ -22,6 +26,36 @@ DECLARE_HOOK(android_vh_futex_sleep_start, TP_PROTO(struct task_struct *p), TP_ARGS(p)); +DECLARE_HOOK(android_vh_do_futex, + TP_PROTO(int cmd, + unsigned int *flags, + u32 __user *uaddr2), + TP_ARGS(cmd, flags, uaddr2)); + +DECLARE_HOOK(android_vh_futex_wait_start, + TP_PROTO(unsigned int flags, + u32 bitset), + TP_ARGS(flags, bitset)); + +DECLARE_HOOK(android_vh_futex_wait_end, + TP_PROTO(unsigned int flags, + u32 bitset), + TP_ARGS(flags, bitset)); + +DECLARE_HOOK(android_vh_futex_wake_traverse_plist, + TP_PROTO(struct plist_head *chain, int *target_nr, + union futex_key key, u32 bitset), + TP_ARGS(chain, target_nr, key, bitset)); + +DECLARE_HOOK(android_vh_futex_wake_this, + TP_PROTO(int ret, int nr_wake, int target_nr, + struct task_struct *p), + TP_ARGS(ret, nr_wake, target_nr, p)); + +DECLARE_HOOK(android_vh_futex_wake_up_q_finish, + TP_PROTO(int nr_wake, int target_nr), + TP_ARGS(nr_wake, target_nr)); + /* macro versions of hooks are no longer required */ #endif /* _TRACE_HOOK_FUTEX_H */ diff --git a/kernel/futex.c b/kernel/futex.c index 29bd9cd92468..b223cc525032 100644 --- a/kernel/futex.c +++ b/kernel/futex.c @@ -1594,6 +1594,7 @@ futex_wake(u32 __user *uaddr, unsigned int flags, int nr_wake, u32 bitset) struct futex_q *this, *next; union futex_key key = FUTEX_KEY_INIT; int ret; + int target_nr; DEFINE_WAKE_Q(wake_q); if (!bitset) @@ -1611,6 +1612,7 @@ futex_wake(u32 __user *uaddr, unsigned int flags, int nr_wake, u32 bitset) spin_lock(&hb->lock); + trace_android_vh_futex_wake_traverse_plist(&hb->chain, &target_nr, key, bitset); plist_for_each_entry_safe(this, next, &hb->chain, list) { if (match_futex (&this->key, &key)) { if (this->pi_state || this->rt_waiter) { @@ -1622,6 +1624,7 @@ futex_wake(u32 __user *uaddr, unsigned int flags, int nr_wake, u32 bitset) if (!(this->bitset & bitset)) continue; + trace_android_vh_futex_wake_this(ret, nr_wake, target_nr, this->task); mark_wake_futex(&wake_q, this); if (++ret >= nr_wake) break; @@ -1630,6 +1633,7 @@ futex_wake(u32 __user *uaddr, unsigned int flags, int nr_wake, u32 bitset) spin_unlock(&hb->lock); wake_up_q(&wake_q); + trace_android_vh_futex_wake_up_q_finish(nr_wake, target_nr); return ret; } @@ -2699,6 +2703,7 @@ static int futex_wait(u32 __user *uaddr, unsigned int flags, u32 val, if (!bitset) return -EINVAL; q.bitset = bitset; + trace_android_vh_futex_wait_start(flags, bitset); to = futex_setup_timer(abs_time, &timeout, flags, current->timer_slack_ns); @@ -2748,6 +2753,7 @@ out: hrtimer_cancel(&to->timer); destroy_hrtimer_on_stack(&to->timer); } + trace_android_vh_futex_wait_end(flags, bitset); return ret; } @@ -3733,6 +3739,7 @@ long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout, return -ENOSYS; } + trace_android_vh_do_futex(cmd, &flags, uaddr2); switch (cmd) { case FUTEX_WAIT: val3 = FUTEX_BITSET_MATCH_ANY;