[CRIU] [PATCH] lock: print a message if a futex is locked for more than 120 second
Andrey Vagin
avagin at openvz.org
Thu Nov 12 11:32:38 PST 2015
2015-11-12 21:24 GMT+03:00 Pavel Emelyanov <xemul at parallels.com>:
> On 11/12/2015 07:09 PM, Andrey Vagin wrote:
>> From: Andrew Vagin <avagin at virtuozzo.com>
>>
>> Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
>> ---
>> include/lock.h | 19 ++++++++++---------
>> 1 file changed, 10 insertions(+), 9 deletions(-)
>>
>> diff --git a/include/lock.h b/include/lock.h
>> index 89d71b1..392318e 100644
>> --- a/include/lock.h
>> +++ b/include/lock.h
>> @@ -39,12 +39,17 @@ static inline void futex_set(futex_t *f, u32 v)
>> u32 tmp; \
>> \
>> while (1) { \
>> + struct timespec to = {.tv_sec = 120}; \
>> tmp = (u32)atomic_read(&(__f)->raw); \
>> if ((tmp & FUTEX_ABORT_FLAG) || \
>> (tmp __cond (__v))) \
>> break; \
>> ret = sys_futex((u32 *)&(__f)->raw.counter, FUTEX_WAIT,\
>> - tmp, NULL, NULL, 0); \
>> + tmp, &to, NULL, 0); \
>> + if (ret == -ETIMEDOUT) { \
>> + pr_warn("blocked for more than 120 seconds\n"); \
>
> I guess it's not extremely informative. Can we add __file__ & __line__ from the
> calling macros here?
pr_warn prints these information and I convert inline functions into
macroses to get proper __file__ and __line__ here
>
>> + continue; \
>> + } \
>> BUG_ON(ret < 0 && ret != -EWOULDBLOCK); \
>> } \
>> } while (0)
>> @@ -84,20 +89,16 @@ static inline void futex_inc(futex_t *f) { atomic_inc(&f->raw); }
>> static inline void futex_dec(futex_t *f) { atomic_dec(&f->raw); }
>>
>> /* Wait until futex @f value become @v */
>> -static inline void futex_wait_until(futex_t *f, u32 v)
>> -{ futex_wait_if_cond(f, v, ==); }
>> +#define futex_wait_until(f, v) futex_wait_if_cond(f, v, ==)
>>
>> /* Wait while futex @f value is greater than @v */
>> -static inline void futex_wait_while_gt(futex_t *f, u32 v)
>> -{ futex_wait_if_cond(f, v, <=); }
>> +#define futex_wait_while_gt(f, v) futex_wait_if_cond(f, v, <=)
>>
>> /* Wait while futex @f value is less than @v */
>> -static inline void futex_wait_while_lt(futex_t *f, u32 v)
>> -{ futex_wait_if_cond(f, v, >=); }
>> +#define futex_wait_while_lt(f, v) futex_wait_if_cond(f, v, >=)
>>
>> /* Wait while futex @f value is equal to @v */
>> -static inline void futex_wait_while_eq(futex_t *f, u32 v)
>> -{ futex_wait_if_cond(f, v, !=); }
>> +#define futex_wait_while_eq(f, v) futex_wait_if_cond(f, v, !=)
>>
>> /* Wait while futex @f value is @v */
>> static inline void futex_wait_while(futex_t *f, u32 v)
>>
>
More information about the CRIU
mailing list