Deleted Added
full compact
kern_rwlock.c (242515) kern_rwlock.c (244582)
1/*-
2 * Copyright (c) 2006 John Baldwin <jhb@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 18 unchanged lines hidden (view full) ---

27 * SUCH DAMAGE.
28 */
29
30/*
31 * Machine independent bits of reader/writer lock implementation.
32 */
33
34#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2006 John Baldwin <jhb@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 18 unchanged lines hidden (view full) ---

27 * SUCH DAMAGE.
28 */
29
30/*
31 * Machine independent bits of reader/writer lock implementation.
32 */
33
34#include <sys/cdefs.h>
35__FBSDID("$FreeBSD: head/sys/kern/kern_rwlock.c 242515 2012-11-03 15:57:37Z attilio $");
35__FBSDID("$FreeBSD: head/sys/kern/kern_rwlock.c 244582 2012-12-22 09:37:34Z attilio $");
36
37#include "opt_ddb.h"
38#include "opt_hwpmc_hooks.h"
39#include "opt_kdtrace.h"
40#include "opt_no_adaptive_rwlocks.h"
41
42#include <sys/param.h>
36
37#include "opt_ddb.h"
38#include "opt_hwpmc_hooks.h"
39#include "opt_kdtrace.h"
40#include "opt_no_adaptive_rwlocks.h"
41
42#include <sys/param.h>
43#include <sys/kdb.h>
43#include <sys/ktr.h>
44#include <sys/kernel.h>
45#include <sys/lock.h>
46#include <sys/mutex.h>
47#include <sys/proc.h>
48#include <sys/rwlock.h>
49#include <sys/sysctl.h>
50#include <sys/systm.h>

--- 202 unchanged lines hidden (view full) ---

253{
254 struct rwlock *rw;
255
256 if (SCHEDULER_STOPPED())
257 return;
258
259 rw = rwlock2rw(c);
260
44#include <sys/ktr.h>
45#include <sys/kernel.h>
46#include <sys/lock.h>
47#include <sys/mutex.h>
48#include <sys/proc.h>
49#include <sys/rwlock.h>
50#include <sys/sysctl.h>
51#include <sys/systm.h>

--- 202 unchanged lines hidden (view full) ---

254{
255 struct rwlock *rw;
256
257 if (SCHEDULER_STOPPED())
258 return;
259
260 rw = rwlock2rw(c);
261
261 KASSERT(!TD_IS_IDLETHREAD(curthread),
262 KASSERT(kdb_active != 0 || !TD_IS_IDLETHREAD(curthread),
262 ("rw_wlock() by idle thread %p on rwlock %s @ %s:%d",
263 curthread, rw->lock_object.lo_name, file, line));
264 KASSERT(rw->rw_lock != RW_DESTROYED,
265 ("rw_wlock() of destroyed rwlock @ %s:%d", file, line));
266 WITNESS_CHECKORDER(&rw->lock_object, LOP_NEWORDER | LOP_EXCLUSIVE, file,
267 line, NULL);
268 __rw_wlock(rw, curthread, file, line);
269 LOCK_LOG_LOCK("WLOCK", &rw->lock_object, 0, rw->rw_recurse, file, line);

--- 7 unchanged lines hidden (view full) ---

277 struct rwlock *rw;
278 int rval;
279
280 if (SCHEDULER_STOPPED())
281 return (1);
282
283 rw = rwlock2rw(c);
284
263 ("rw_wlock() by idle thread %p on rwlock %s @ %s:%d",
264 curthread, rw->lock_object.lo_name, file, line));
265 KASSERT(rw->rw_lock != RW_DESTROYED,
266 ("rw_wlock() of destroyed rwlock @ %s:%d", file, line));
267 WITNESS_CHECKORDER(&rw->lock_object, LOP_NEWORDER | LOP_EXCLUSIVE, file,
268 line, NULL);
269 __rw_wlock(rw, curthread, file, line);
270 LOCK_LOG_LOCK("WLOCK", &rw->lock_object, 0, rw->rw_recurse, file, line);

--- 7 unchanged lines hidden (view full) ---

278 struct rwlock *rw;
279 int rval;
280
281 if (SCHEDULER_STOPPED())
282 return (1);
283
284 rw = rwlock2rw(c);
285
285 KASSERT(!TD_IS_IDLETHREAD(curthread),
286 KASSERT(kdb_active != 0 || !TD_IS_IDLETHREAD(curthread),
286 ("rw_try_wlock() by idle thread %p on rwlock %s @ %s:%d",
287 curthread, rw->lock_object.lo_name, file, line));
288 KASSERT(rw->rw_lock != RW_DESTROYED,
289 ("rw_try_wlock() of destroyed rwlock @ %s:%d", file, line));
290
291 if (rw_wlocked(rw) &&
292 (rw->lock_object.lo_flags & LO_RECURSABLE) != 0) {
293 rw->rw_recurse++;

--- 65 unchanged lines hidden (view full) ---

359 int64_t sleep_time = 0;
360#endif
361
362 if (SCHEDULER_STOPPED())
363 return;
364
365 rw = rwlock2rw(c);
366
287 ("rw_try_wlock() by idle thread %p on rwlock %s @ %s:%d",
288 curthread, rw->lock_object.lo_name, file, line));
289 KASSERT(rw->rw_lock != RW_DESTROYED,
290 ("rw_try_wlock() of destroyed rwlock @ %s:%d", file, line));
291
292 if (rw_wlocked(rw) &&
293 (rw->lock_object.lo_flags & LO_RECURSABLE) != 0) {
294 rw->rw_recurse++;

--- 65 unchanged lines hidden (view full) ---

360 int64_t sleep_time = 0;
361#endif
362
363 if (SCHEDULER_STOPPED())
364 return;
365
366 rw = rwlock2rw(c);
367
367 KASSERT(!TD_IS_IDLETHREAD(curthread),
368 KASSERT(kdb_active != 0 || !TD_IS_IDLETHREAD(curthread),
368 ("rw_rlock() by idle thread %p on rwlock %s @ %s:%d",
369 curthread, rw->lock_object.lo_name, file, line));
370 KASSERT(rw->rw_lock != RW_DESTROYED,
371 ("rw_rlock() of destroyed rwlock @ %s:%d", file, line));
372 KASSERT(rw_wowner(rw) != curthread,
373 ("%s (%s): wlock already held @ %s:%d", __func__,
374 rw->lock_object.lo_name, file, line));
375 WITNESS_CHECKORDER(&rw->lock_object, LOP_NEWORDER, file, line, NULL);

--- 177 unchanged lines hidden (view full) ---

553 struct rwlock *rw;
554 uintptr_t x;
555
556 if (SCHEDULER_STOPPED())
557 return (1);
558
559 rw = rwlock2rw(c);
560
369 ("rw_rlock() by idle thread %p on rwlock %s @ %s:%d",
370 curthread, rw->lock_object.lo_name, file, line));
371 KASSERT(rw->rw_lock != RW_DESTROYED,
372 ("rw_rlock() of destroyed rwlock @ %s:%d", file, line));
373 KASSERT(rw_wowner(rw) != curthread,
374 ("%s (%s): wlock already held @ %s:%d", __func__,
375 rw->lock_object.lo_name, file, line));
376 WITNESS_CHECKORDER(&rw->lock_object, LOP_NEWORDER, file, line, NULL);

--- 177 unchanged lines hidden (view full) ---

554 struct rwlock *rw;
555 uintptr_t x;
556
557 if (SCHEDULER_STOPPED())
558 return (1);
559
560 rw = rwlock2rw(c);
561
561 KASSERT(!TD_IS_IDLETHREAD(curthread),
562 KASSERT(kdb_active != 0 || !TD_IS_IDLETHREAD(curthread),
562 ("rw_try_rlock() by idle thread %p on rwlock %s @ %s:%d",
563 curthread, rw->lock_object.lo_name, file, line));
564
565 for (;;) {
566 x = rw->rw_lock;
567 KASSERT(rw->rw_lock != RW_DESTROYED,
568 ("rw_try_rlock() of destroyed rwlock @ %s:%d", file, line));
569 if (!(x & RW_LOCK_READ))

--- 660 unchanged lines hidden ---
563 ("rw_try_rlock() by idle thread %p on rwlock %s @ %s:%d",
564 curthread, rw->lock_object.lo_name, file, line));
565
566 for (;;) {
567 x = rw->rw_lock;
568 KASSERT(rw->rw_lock != RW_DESTROYED,
569 ("rw_try_rlock() of destroyed rwlock @ %s:%d", file, line));
570 if (!(x & RW_LOCK_READ))

--- 660 unchanged lines hidden ---