Re: When it is save to kfree() hrtimer object?

From: Thomas Gleixner
Date: Mon Dec 07 2009 - 05:35:58 EST


On Mon, 7 Dec 2009, Nikita V. Youshchenko wrote:
> - Isn't it a bug that timer object is accessed after it's callback was
> called and returned HRTIMER_NORESTART?

No, it's not. It's deliberately implemented that way.

> - If that is not a bug, then when it is "officially safe" to deallocate
> struct hrtimer object?

When it's neither enqueued nor running the callback. See the other use
sites.

> - Are there any recommendations on how to implement "single-shot" timers
> like in my case?

Well, you wake up something which waits on completion of that request,
right ? Probably the caller which issued the request. Why don't you
free the request in the waiter context after it got woken up ?

Thanks,

tglx
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/