kern_lock.c revision 83420
1219820Sjeff/*
2219820Sjeff * Copyright (c) 1995
3219820Sjeff *	The Regents of the University of California.  All rights reserved.
4219820Sjeff *
5219820Sjeff * Copyright (C) 1997
6219820Sjeff *	John S. Dyson.  All rights reserved.
7219820Sjeff *
8219820Sjeff * This code contains ideas from software contributed to Berkeley by
9219820Sjeff * Avadis Tevanian, Jr., Michael Wayne Young, and the Mach Operating
10219820Sjeff * System project at Carnegie-Mellon University.
11219820Sjeff *
12219820Sjeff * Redistribution and use in source and binary forms, with or without
13219820Sjeff * modification, are permitted provided that the following conditions
14219820Sjeff * are met:
15219820Sjeff * 1. Redistributions of source code must retain the above copyright
16219820Sjeff *    notice, this list of conditions and the following disclaimer.
17219820Sjeff * 2. Redistributions in binary form must reproduce the above copyright
18219820Sjeff *    notice, this list of conditions and the following disclaimer in the
19219820Sjeff *    documentation and/or other materials provided with the distribution.
20219820Sjeff * 3. All advertising materials mentioning features or use of this software
21219820Sjeff *    must display the following acknowledgement:
22219820Sjeff *	This product includes software developed by the University of
23219820Sjeff *	California, Berkeley and its contributors.
24219820Sjeff * 4. Neither the name of the University nor the names of its contributors
25219820Sjeff *    may be used to endorse or promote products derived from this software
26219820Sjeff *    without specific prior written permission.
27219820Sjeff *
28219820Sjeff * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
29219820Sjeff * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30219820Sjeff * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31219820Sjeff * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
32219820Sjeff * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33219820Sjeff * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34219820Sjeff * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35219820Sjeff * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36219820Sjeff * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37219820Sjeff * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38219820Sjeff * SUCH DAMAGE.
39272407Shselasky *
40219820Sjeff *	@(#)kern_lock.c	8.18 (Berkeley) 5/21/95
41277160Shselasky * $FreeBSD: head/sys/kern/kern_lock.c 83420 2001-09-13 22:33:37Z jhb $
42277160Shselasky */
43277160Shselasky
44277160Shselasky#include <sys/param.h>
45277160Shselasky#include <sys/proc.h>
46277160Shselasky#include <sys/kernel.h>
47277160Shselasky#include <sys/lock.h>
48219820Sjeff#include <sys/malloc.h>
49219820Sjeff#include <sys/mutex.h>
50275228Shselasky#include <sys/systm.h>
51219820Sjeff
52219820Sjeff/*
53219820Sjeff * Locking primitives implementation.
54275228Shselasky * Locks provide shared/exclusive sychronization.
55219820Sjeff */
56219820Sjeff
57219820Sjeff#define LOCK_WAIT_TIME 100
58219820Sjeff#define LOCK_SAMPLE_WAIT 7
59219820Sjeff
60219820Sjeff#if defined(DIAGNOSTIC)
61219820Sjeff#define LOCK_INLINE
62219820Sjeff#else
63219820Sjeff#define LOCK_INLINE __inline
64219820Sjeff#endif
65219820Sjeff
66219820Sjeff#define LK_ALL (LK_HAVE_EXCL | LK_WANT_EXCL | LK_WANT_UPGRADE | \
67219820Sjeff	LK_SHARE_NONZERO | LK_WAIT_NONZERO)
68219820Sjeff
69219820Sjeff/*
70219820Sjeff * Mutex array variables.  Rather than each lockmgr lock having its own mutex,
71219820Sjeff * share a fixed (at boot time) number of mutexes across all lockmgr locks in
72219820Sjeff * order to keep sizeof(struct lock) down.
73219820Sjeff */
74219820Sjeffextern int lock_nmtx;
75219820Sjeffint lock_mtx_selector;
76219820Sjeffstruct mtx *lock_mtx_array;
77219820Sjeffstatic struct mtx lock_mtx;
78219820Sjeff
79219820Sjeffstatic int acquire(struct lock *lkp, int extflags, int wanted);
80219820Sjeffstatic int apause(struct lock *lkp, int flags);
81219820Sjeffstatic int acquiredrain(struct lock *lkp, int extflags) ;
82219820Sjeff
83219820Sjeffstatic void
84219820Sjefflockmgr_init(void *dummy __unused)
85219820Sjeff{
86219820Sjeff	int	i;
87219820Sjeff
88219820Sjeff	/*
89219820Sjeff	 * Initialize the lockmgr protection mutex if it hasn't already been
90219820Sjeff	 * done.  Unless something changes about kernel startup order, VM
91219820Sjeff	 * initialization will always cause this mutex to already be
92219820Sjeff	 * initialized in a call to lockinit().
93219820Sjeff	 */
94219820Sjeff	if (lock_mtx_selector == 0)
95219820Sjeff		mtx_init(&lock_mtx, "lockmgr", MTX_DEF);
96219820Sjeff	else {
97219820Sjeff		/*
98219820Sjeff		 * This is necessary if (lock_nmtx == 1) and doesn't hurt
99219820Sjeff		 * otherwise.
100219820Sjeff		 */
101219820Sjeff		lock_mtx_selector = 0;
102219820Sjeff	}
103219820Sjeff
104219820Sjeff	lock_mtx_array = (struct mtx *)malloc(sizeof(struct mtx) * lock_nmtx,
105219820Sjeff	    M_CACHE, M_WAITOK);
106219820Sjeff	for (i = 0; i < lock_nmtx; i++)
107219820Sjeff		mtx_init(&lock_mtx_array[i], "lockmgr interlock", MTX_DEF);
108219820Sjeff}
109219820SjeffSYSINIT(lmgrinit, SI_SUB_LOCK, SI_ORDER_FIRST, lockmgr_init, NULL)
110219820Sjeff
111219820Sjeffstatic LOCK_INLINE void
112219820Sjeffsharelock(struct lock *lkp, int incr) {
113219820Sjeff	lkp->lk_flags |= LK_SHARE_NONZERO;
114219820Sjeff	lkp->lk_sharecount += incr;
115219820Sjeff}
116219820Sjeff
117219820Sjeffstatic LOCK_INLINE void
118219820Sjeffshareunlock(struct lock *lkp, int decr) {
119
120	KASSERT(lkp->lk_sharecount >= decr, ("shareunlock: count < decr"));
121
122	if (lkp->lk_sharecount == decr) {
123		lkp->lk_flags &= ~LK_SHARE_NONZERO;
124		if (lkp->lk_flags & (LK_WANT_UPGRADE | LK_WANT_EXCL)) {
125			wakeup(lkp);
126		}
127		lkp->lk_sharecount = 0;
128	} else {
129		lkp->lk_sharecount -= decr;
130	}
131}
132
133/*
134 * This is the waitloop optimization.
135 */
136static int
137apause(struct lock *lkp, int flags)
138{
139#ifdef SMP
140	int i, lock_wait;
141#endif
142
143	if ((lkp->lk_flags & flags) == 0)
144		return 0;
145#ifdef SMP
146	for (lock_wait = LOCK_WAIT_TIME; lock_wait > 0; lock_wait--) {
147		mtx_unlock(lkp->lk_interlock);
148		for (i = LOCK_SAMPLE_WAIT; i > 0; i--)
149			if ((lkp->lk_flags & flags) == 0)
150				break;
151		mtx_lock(lkp->lk_interlock);
152		if ((lkp->lk_flags & flags) == 0)
153			return 0;
154	}
155#endif
156	return 1;
157}
158
159static int
160acquire(struct lock *lkp, int extflags, int wanted) {
161	int s, error;
162
163	CTR3(KTR_LOCKMGR,
164	    "acquire(): lkp == %p, extflags == 0x%x, wanted == 0x%x\n",
165	    lkp, extflags, wanted);
166
167	if ((extflags & LK_NOWAIT) && (lkp->lk_flags & wanted)) {
168		return EBUSY;
169	}
170
171	if (((lkp->lk_flags | extflags) & LK_NOPAUSE) == 0) {
172		error = apause(lkp, wanted);
173		if (error == 0)
174			return 0;
175	}
176
177	s = splhigh();
178	while ((lkp->lk_flags & wanted) != 0) {
179		lkp->lk_flags |= LK_WAIT_NONZERO;
180		lkp->lk_waitcount++;
181		error = msleep(lkp, lkp->lk_interlock, lkp->lk_prio,
182		    lkp->lk_wmesg, lkp->lk_timo);
183		if (lkp->lk_waitcount == 1) {
184			lkp->lk_flags &= ~LK_WAIT_NONZERO;
185			lkp->lk_waitcount = 0;
186		} else {
187			lkp->lk_waitcount--;
188		}
189		if (error) {
190			splx(s);
191			return error;
192		}
193		if (extflags & LK_SLEEPFAIL) {
194			splx(s);
195			return ENOLCK;
196		}
197	}
198	splx(s);
199	return 0;
200}
201
202/*
203 * Set, change, or release a lock.
204 *
205 * Shared requests increment the shared count. Exclusive requests set the
206 * LK_WANT_EXCL flag (preventing further shared locks), and wait for already
207 * accepted shared locks and shared-to-exclusive upgrades to go away.
208 */
209int
210#ifndef	DEBUG_LOCKS
211lockmgr(lkp, flags, interlkp, td)
212#else
213debuglockmgr(lkp, flags, interlkp, td, name, file, line)
214#endif
215	struct lock *lkp;
216	u_int flags;
217	struct mtx *interlkp;
218	struct thread *td;
219#ifdef	DEBUG_LOCKS
220	const char *name;	/* Name of lock function */
221	const char *file;	/* Name of file call is from */
222	int line;		/* Line number in file */
223#endif
224{
225	int error;
226	pid_t pid;
227	int extflags, lockflags;
228
229	CTR5(KTR_LOCKMGR,
230	    "lockmgr(): lkp == %p (lk_wmesg == \"%s\"), flags == 0x%x, "
231	    "interlkp == %p, td == %p", lkp, lkp->lk_wmesg, flags, interlkp, td);
232
233	error = 0;
234	if (td == NULL)
235		pid = LK_KERNPROC;
236	else
237		pid = td->td_proc->p_pid;
238
239	mtx_lock(lkp->lk_interlock);
240	if (flags & LK_INTERLOCK) {
241		mtx_assert(interlkp, MA_OWNED | MA_NOTRECURSED);
242		mtx_unlock(interlkp);
243	}
244
245	if (panicstr != NULL) {
246		mtx_unlock(lkp->lk_interlock);
247		return (0);
248	}
249
250	extflags = (flags | lkp->lk_flags) & LK_EXTFLG_MASK;
251
252	switch (flags & LK_TYPE_MASK) {
253
254	case LK_SHARED:
255		/*
256		 * If we are not the exclusive lock holder, we have to block
257		 * while there is an exclusive lock holder or while an
258		 * exclusive lock request or upgrade request is in progress.
259		 *
260		 * However, if TDF_DEADLKTREAT is set, we override exclusive
261		 * lock requests or upgrade requests ( but not the exclusive
262		 * lock itself ).
263		 */
264		if (lkp->lk_lockholder != pid) {
265			lockflags = LK_HAVE_EXCL;
266			mtx_lock_spin(&sched_lock);
267			if (td != NULL && !(td->td_flags & TDF_DEADLKTREAT))
268				lockflags |= LK_WANT_EXCL | LK_WANT_UPGRADE;
269			mtx_unlock_spin(&sched_lock);
270			error = acquire(lkp, extflags, lockflags);
271			if (error)
272				break;
273			sharelock(lkp, 1);
274			break;
275		}
276		/*
277		 * We hold an exclusive lock, so downgrade it to shared.
278		 * An alternative would be to fail with EDEADLK.
279		 */
280		sharelock(lkp, 1);
281		/* fall into downgrade */
282
283	case LK_DOWNGRADE:
284		KASSERT(lkp->lk_lockholder == pid && lkp->lk_exclusivecount != 0,
285			("lockmgr: not holding exclusive lock "
286			"(owner pid (%d) != pid (%d), exlcnt (%d) != 0",
287			lkp->lk_lockholder, pid, lkp->lk_exclusivecount));
288		sharelock(lkp, lkp->lk_exclusivecount);
289		lkp->lk_exclusivecount = 0;
290		lkp->lk_flags &= ~LK_HAVE_EXCL;
291		lkp->lk_lockholder = LK_NOPROC;
292		if (lkp->lk_waitcount)
293			wakeup((void *)lkp);
294		break;
295
296	case LK_EXCLUPGRADE:
297		/*
298		 * If another process is ahead of us to get an upgrade,
299		 * then we want to fail rather than have an intervening
300		 * exclusive access.
301		 */
302		if (lkp->lk_flags & LK_WANT_UPGRADE) {
303			shareunlock(lkp, 1);
304			error = EBUSY;
305			break;
306		}
307		/* fall into normal upgrade */
308
309	case LK_UPGRADE:
310		/*
311		 * Upgrade a shared lock to an exclusive one. If another
312		 * shared lock has already requested an upgrade to an
313		 * exclusive lock, our shared lock is released and an
314		 * exclusive lock is requested (which will be granted
315		 * after the upgrade). If we return an error, the file
316		 * will always be unlocked.
317		 */
318		if ((lkp->lk_lockholder == pid) || (lkp->lk_sharecount <= 0))
319			panic("lockmgr: upgrade exclusive lock");
320		shareunlock(lkp, 1);
321		/*
322		 * If we are just polling, check to see if we will block.
323		 */
324		if ((extflags & LK_NOWAIT) &&
325		    ((lkp->lk_flags & LK_WANT_UPGRADE) ||
326		     lkp->lk_sharecount > 1)) {
327			error = EBUSY;
328			break;
329		}
330		if ((lkp->lk_flags & LK_WANT_UPGRADE) == 0) {
331			/*
332			 * We are first shared lock to request an upgrade, so
333			 * request upgrade and wait for the shared count to
334			 * drop to zero, then take exclusive lock.
335			 */
336			lkp->lk_flags |= LK_WANT_UPGRADE;
337			error = acquire(lkp, extflags, LK_SHARE_NONZERO);
338			lkp->lk_flags &= ~LK_WANT_UPGRADE;
339
340			if (error)
341				break;
342			lkp->lk_flags |= LK_HAVE_EXCL;
343			lkp->lk_lockholder = pid;
344			if (lkp->lk_exclusivecount != 0)
345				panic("lockmgr: non-zero exclusive count");
346			lkp->lk_exclusivecount = 1;
347#if defined(DEBUG_LOCKS)
348			lkp->lk_filename = file;
349			lkp->lk_lineno = line;
350			lkp->lk_lockername = name;
351#endif
352			break;
353		}
354		/*
355		 * Someone else has requested upgrade. Release our shared
356		 * lock, awaken upgrade requestor if we are the last shared
357		 * lock, then request an exclusive lock.
358		 */
359		if ( (lkp->lk_flags & (LK_SHARE_NONZERO|LK_WAIT_NONZERO)) ==
360			LK_WAIT_NONZERO)
361			wakeup((void *)lkp);
362		/* fall into exclusive request */
363
364	case LK_EXCLUSIVE:
365		if (lkp->lk_lockholder == pid && pid != LK_KERNPROC) {
366			/*
367			 *	Recursive lock.
368			 */
369			if ((extflags & (LK_NOWAIT | LK_CANRECURSE)) == 0)
370				panic("lockmgr: locking against myself");
371			if ((extflags & LK_CANRECURSE) != 0) {
372				lkp->lk_exclusivecount++;
373				break;
374			}
375		}
376		/*
377		 * If we are just polling, check to see if we will sleep.
378		 */
379		if ((extflags & LK_NOWAIT) &&
380		    (lkp->lk_flags & (LK_HAVE_EXCL | LK_WANT_EXCL | LK_WANT_UPGRADE | LK_SHARE_NONZERO))) {
381			error = EBUSY;
382			break;
383		}
384		/*
385		 * Try to acquire the want_exclusive flag.
386		 */
387		error = acquire(lkp, extflags, (LK_HAVE_EXCL | LK_WANT_EXCL));
388		if (error)
389			break;
390		lkp->lk_flags |= LK_WANT_EXCL;
391		/*
392		 * Wait for shared locks and upgrades to finish.
393		 */
394		error = acquire(lkp, extflags, LK_WANT_UPGRADE | LK_SHARE_NONZERO);
395		lkp->lk_flags &= ~LK_WANT_EXCL;
396		if (error)
397			break;
398		lkp->lk_flags |= LK_HAVE_EXCL;
399		lkp->lk_lockholder = pid;
400		if (lkp->lk_exclusivecount != 0)
401			panic("lockmgr: non-zero exclusive count");
402		lkp->lk_exclusivecount = 1;
403#if defined(DEBUG_LOCKS)
404			lkp->lk_filename = file;
405			lkp->lk_lineno = line;
406			lkp->lk_lockername = name;
407#endif
408		break;
409
410	case LK_RELEASE:
411		if (lkp->lk_exclusivecount != 0) {
412			if (lkp->lk_lockholder != pid &&
413			    lkp->lk_lockholder != LK_KERNPROC) {
414				panic("lockmgr: pid %d, not %s %d unlocking",
415				    pid, "exclusive lock holder",
416				    lkp->lk_lockholder);
417			}
418			if (lkp->lk_exclusivecount == 1) {
419				lkp->lk_flags &= ~LK_HAVE_EXCL;
420				lkp->lk_lockholder = LK_NOPROC;
421				lkp->lk_exclusivecount = 0;
422			} else {
423				lkp->lk_exclusivecount--;
424			}
425		} else if (lkp->lk_flags & LK_SHARE_NONZERO)
426			shareunlock(lkp, 1);
427		if (lkp->lk_flags & LK_WAIT_NONZERO)
428			wakeup((void *)lkp);
429		break;
430
431	case LK_DRAIN:
432		/*
433		 * Check that we do not already hold the lock, as it can
434		 * never drain if we do. Unfortunately, we have no way to
435		 * check for holding a shared lock, but at least we can
436		 * check for an exclusive one.
437		 */
438		if (lkp->lk_lockholder == pid)
439			panic("lockmgr: draining against myself");
440
441		error = acquiredrain(lkp, extflags);
442		if (error)
443			break;
444		lkp->lk_flags |= LK_DRAINING | LK_HAVE_EXCL;
445		lkp->lk_lockholder = pid;
446		lkp->lk_exclusivecount = 1;
447#if defined(DEBUG_LOCKS)
448			lkp->lk_filename = file;
449			lkp->lk_lineno = line;
450			lkp->lk_lockername = name;
451#endif
452		break;
453
454	default:
455		mtx_unlock(lkp->lk_interlock);
456		panic("lockmgr: unknown locktype request %d",
457		    flags & LK_TYPE_MASK);
458		/* NOTREACHED */
459	}
460	if ((lkp->lk_flags & LK_WAITDRAIN) &&
461	    (lkp->lk_flags & (LK_HAVE_EXCL | LK_WANT_EXCL | LK_WANT_UPGRADE |
462		LK_SHARE_NONZERO | LK_WAIT_NONZERO)) == 0) {
463		lkp->lk_flags &= ~LK_WAITDRAIN;
464		wakeup((void *)&lkp->lk_flags);
465	}
466	mtx_unlock(lkp->lk_interlock);
467	return (error);
468}
469
470static int
471acquiredrain(struct lock *lkp, int extflags) {
472	int error;
473
474	if ((extflags & LK_NOWAIT) && (lkp->lk_flags & LK_ALL)) {
475		return EBUSY;
476	}
477
478	error = apause(lkp, LK_ALL);
479	if (error == 0)
480		return 0;
481
482	while (lkp->lk_flags & LK_ALL) {
483		lkp->lk_flags |= LK_WAITDRAIN;
484		error = msleep(&lkp->lk_flags, lkp->lk_interlock, lkp->lk_prio,
485			lkp->lk_wmesg, lkp->lk_timo);
486		if (error)
487			return error;
488		if (extflags & LK_SLEEPFAIL) {
489			return ENOLCK;
490		}
491	}
492	return 0;
493}
494
495/*
496 * Initialize a lock; required before use.
497 */
498void
499lockinit(lkp, prio, wmesg, timo, flags)
500	struct lock *lkp;
501	int prio;
502	char *wmesg;
503	int timo;
504	int flags;
505{
506	CTR5(KTR_LOCKMGR, "lockinit(): lkp == %p, prio == %d, wmesg == \"%s\", "
507	    "timo == %d, flags = 0x%x\n", lkp, prio, wmesg, timo, flags);
508
509	if (lock_mtx_array != NULL) {
510		mtx_lock(&lock_mtx);
511		lkp->lk_interlock = &lock_mtx_array[lock_mtx_selector];
512		lock_mtx_selector++;
513		if (lock_mtx_selector == lock_nmtx)
514			lock_mtx_selector = 0;
515		mtx_unlock(&lock_mtx);
516	} else {
517		/*
518		 * Giving lockmgr locks that are initialized during boot a
519		 * pointer to the internal lockmgr mutex is safe, since the
520		 * lockmgr code itself doesn't call lockinit() (which could
521		 * cause mutex recursion).
522		 */
523		if (lock_mtx_selector == 0) {
524			/*
525			 * This  case only happens during kernel bootstrapping,
526			 * so there's no reason to protect modification of
527			 * lock_mtx_selector or lock_mtx.
528			 */
529			mtx_init(&lock_mtx, "lockmgr", MTX_DEF);
530			lock_mtx_selector = 1;
531		}
532		lkp->lk_interlock = &lock_mtx;
533	}
534	lkp->lk_flags = (flags & LK_EXTFLG_MASK);
535	lkp->lk_sharecount = 0;
536	lkp->lk_waitcount = 0;
537	lkp->lk_exclusivecount = 0;
538	lkp->lk_prio = prio;
539	lkp->lk_wmesg = wmesg;
540	lkp->lk_timo = timo;
541	lkp->lk_lockholder = LK_NOPROC;
542}
543
544/*
545 * Destroy a lock.
546 */
547void
548lockdestroy(lkp)
549	struct lock *lkp;
550{
551	CTR2(KTR_LOCKMGR, "lockdestroy(): lkp == %p (lk_wmesg == \"%s\")",
552	    lkp, lkp->lk_wmesg);
553}
554
555/*
556 * Determine the status of a lock.
557 */
558int
559lockstatus(lkp, td)
560	struct lock *lkp;
561	struct thread *td;
562{
563	int lock_type = 0;
564
565	mtx_lock(lkp->lk_interlock);
566	if (lkp->lk_exclusivecount != 0) {
567		if (td == NULL || lkp->lk_lockholder == td->td_proc->p_pid)
568			lock_type = LK_EXCLUSIVE;
569		else
570			lock_type = LK_EXCLOTHER;
571	} else if (lkp->lk_sharecount != 0)
572		lock_type = LK_SHARED;
573	mtx_unlock(lkp->lk_interlock);
574	return (lock_type);
575}
576
577/*
578 * Determine the number of holders of a lock.
579 */
580int
581lockcount(lkp)
582	struct lock *lkp;
583{
584	int count;
585
586	mtx_lock(lkp->lk_interlock);
587	count = lkp->lk_exclusivecount + lkp->lk_sharecount;
588	mtx_unlock(lkp->lk_interlock);
589	return (count);
590}
591
592/*
593 * Print out information about state of a lock. Used by VOP_PRINT
594 * routines to display status about contained locks.
595 */
596void
597lockmgr_printinfo(lkp)
598	struct lock *lkp;
599{
600
601	if (lkp->lk_sharecount)
602		printf(" lock type %s: SHARED (count %d)", lkp->lk_wmesg,
603		    lkp->lk_sharecount);
604	else if (lkp->lk_flags & LK_HAVE_EXCL)
605		printf(" lock type %s: EXCL (count %d) by pid %d",
606		    lkp->lk_wmesg, lkp->lk_exclusivecount, lkp->lk_lockholder);
607	if (lkp->lk_waitcount > 0)
608		printf(" with %d pending", lkp->lk_waitcount);
609}
610