Skip to content

Commit

Permalink
Log ARC hash_lock holder [DEBUG ONLY]
Browse files Browse the repository at this point in the history
A debug patch for openzfs#3160 designed to log the holder of the ARC
hash_lock if it cannot be acquired for over 60 seconds.  This
patch may impact performance and is for debug purposes only.t

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue openzfs#3160
  • Loading branch information
behlendorf committed Mar 9, 2015
1 parent 3e68f41 commit 501b954
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions module/zfs/arc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1718,6 +1718,10 @@ arc_buf_remove_ref(arc_buf_t *buf, void* tag)
arc_buf_hdr_t *hdr = buf->b_hdr;
kmutex_t *hash_lock = NULL;
boolean_t no_callback = (buf->b_efunc == NULL);
#ifdef _KERNEL
int count = 1, timeout = 60 * MICROSEC;
struct task_struct *task;
#endif

if (hdr->b_state == arc_anon) {
ASSERT(hdr->b_datacnt == 1);
Expand All @@ -1726,7 +1730,24 @@ arc_buf_remove_ref(arc_buf_t *buf, void* tag)
}

hash_lock = HDR_LOCK(hdr);
#ifdef _KERNEL
retry:
if ((mutex_tryenter(hash_lock)) == 0) {
if (((count++) % timeout) == 0) {
task = mutex_owner(hash_lock);
cmn_err(CE_WARN,
"%s (%d) holding hash lock for %ds\n",
task ? task->comm : "NULL",
task ? task->pid : -1,
count / MICROSEC);
}

udelay(1);
goto retry;
}
#else
mutex_enter(hash_lock);
#endif
hdr = buf->b_hdr;
ASSERT3P(hash_lock, ==, HDR_LOCK(hdr));
ASSERT(hdr->b_state != arc_anon);
Expand Down

0 comments on commit 501b954

Please sign in to comment.