Re: [PATCH -v6 11/13] futex: Rework futex_lock_pi() to use rt_mutex_*_proxy_lock()

From: Thomas Gleixner
Date: Mon Apr 10 2017 - 12:03:53 EST


On Mon, 10 Apr 2017, alexander.levin@xxxxxxxxxxx wrote:
> On Wed, Mar 22, 2017 at 11:35:58AM +0100, Peter Zijlstra wrote:
> > By changing futex_lock_pi() to use rt_mutex_*_proxy_lock() we arrive
> > at a point where all wait_list modifications are done under both
> > hb->lock and wait_lock.
> [...]
>
> Hey Peter,
>
> I'm seeing the following, which seems to be related to this patch:
>
> [ 21.762875] ODEBUG: free active (active state 0) object type: hrtimer hint: hrtimer_wakeup (kernel/time/hrtimer.c:1423)

> [ 21.788050] debug_object_free (lib/debugobjects.c:603)
> [ 21.791105] destroy_hrtimer_on_stack (kernel/time/hrtimer.c:427)
> [ 21.791746] futex_lock_pi (kernel/futex.c:2740)
> [ 21.800721] do_futex (kernel/futex.c:3399)
> [ 21.818395] SyS_futex (kernel/futex.c:3447 kernel/futex.c:3415)
> [ 21.822260] do_syscall_64 (arch/x86/entry/common.c:284)
> [ 21.827328] entry_SYSCALL64_slow_path (arch/x86/entry/entry_64.S:249)

Yep, that rework dropped the hrtimer cancel. Fix below.

Thanks,

tglx

8<------------------------

diff --git a/kernel/futex.c b/kernel/futex.c
index c3eebcdac206..7ac167683c9f 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -2736,8 +2736,10 @@ static int futex_lock_pi(u32 __user *uaddr, unsigned int flags,
out_put_key:
put_futex_key(&q.key);
out:
- if (to)
+ if (to) {
+ hrtimer_cancel(&to->timer);
destroy_hrtimer_on_stack(&to->timer);
+ }
return ret != -EINTR ? ret : -ERESTARTNOINTR;

uaddr_faulted: