Project

General

Profile

Bug #6739

userland version of cv_timedwait_hires() always assumes absolute time

Added by Matthew Ahrens over 3 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Normal
Category:
zfs - Zettabyte File System
Start date:
2016-03-10
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
needs-triage

Description

While running ztest I noticed a deadlock when calling cv_timedwait_hires().
The call was being performed in a while loop so the thread would call this function and immediately return without ever dropping the mutex. Any other thread trying to acquire the lock would just stall forever.
It turns out that consumers of cv_timedwait_hires() may specify either absolute time or relative time but the userland implementation never implemented relative time:
clock_t
cv_timedwait_hires(kcondvar_t *cv, kmutex_t *mp, hrtime_t tim, hrtime_t res,
int flag) {
int error;
timestruc_t ts;
hrtime_t delta;

ASSERT(flag == 0);

top:
delta = tim - gethrtime();
if (delta <= 0)
return (-1);
This leads to a deadlock since the consumer thread never drops the lock.

History

#1

Updated by Electric Monk over 3 years ago

  • % Done changed from 0 to 100
  • Status changed from New to Closed

git commit 41c6413cb54bf338d7a59ed789ec2e0e44c35e6f

commit  41c6413cb54bf338d7a59ed789ec2e0e44c35e6f
Author: George Wilson <george.wilson@delphix.com>
Date:   2016-03-31T00:01:09.000Z

    6739 userland version of cv_timedwait_hires() always assumes absolute time
    Reviewed by: Paul Dagnelie <pcd@delphix.com>
    Reviewed by: Matthew Ahrens <mahrens@delphix.com>
    Reviewed by: Dan McDonald <danmcd@omniti.com>
    Reviewed by: Robert Mustacchi <rm@joyent.com>
    Approved by: Robert Mustacchi <rm@joyent.com>

Also available in: Atom PDF