Deleted Added
full compact
kern_sx.c (182914) kern_sx.c (189846)
1/*-
2 * Copyright (c) 2007 Attilio Rao <attilio@freebsd.org>
3 * Copyright (c) 2001 Jason Evans <jasone@freebsd.org>
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

35 * Priority propagation will not generally raise the priority of lock holders,
36 * so should not be relied upon in combination with sx locks.
37 */
38
39#include "opt_adaptive_sx.h"
40#include "opt_ddb.h"
41
42#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2007 Attilio Rao <attilio@freebsd.org>
3 * Copyright (c) 2001 Jason Evans <jasone@freebsd.org>
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

35 * Priority propagation will not generally raise the priority of lock holders,
36 * so should not be relied upon in combination with sx locks.
37 */
38
39#include "opt_adaptive_sx.h"
40#include "opt_ddb.h"
41
42#include <sys/cdefs.h>
43__FBSDID("$FreeBSD: head/sys/kern/kern_sx.c 182914 2008-09-10 19:13:30Z jhb $");
43__FBSDID("$FreeBSD: head/sys/kern/kern_sx.c 189846 2009-03-15 08:03:54Z jeff $");
44
45#include <sys/param.h>
46#include <sys/ktr.h>
47#include <sys/lock.h>
48#include <sys/mutex.h>
49#include <sys/proc.h>
50#include <sys/sleepqueue.h>
51#include <sys/sx.h>

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

426int
427_sx_xlock_hard(struct sx *sx, uintptr_t tid, int opts, const char *file,
428 int line)
429{
430 GIANT_DECLARE;
431#ifdef ADAPTIVE_SX
432 volatile struct thread *owner;
433#endif
44
45#include <sys/param.h>
46#include <sys/ktr.h>
47#include <sys/lock.h>
48#include <sys/mutex.h>
49#include <sys/proc.h>
50#include <sys/sleepqueue.h>
51#include <sys/sx.h>

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

426int
427_sx_xlock_hard(struct sx *sx, uintptr_t tid, int opts, const char *file,
428 int line)
429{
430 GIANT_DECLARE;
431#ifdef ADAPTIVE_SX
432 volatile struct thread *owner;
433#endif
434 uint64_t waittime = 0;
435 uintptr_t x;
434 uintptr_t x;
436 int contested = 0, error = 0;
435#ifdef LOCK_PROFILING
436 uint64_t waittime = 0;
437 int contested = 0;
438#endif
439 int error = 0;
437
438 /* If we already hold an exclusive lock, then recurse. */
439 if (sx_xlocked(sx)) {
440 KASSERT((sx->lock_object.lo_flags & SX_RECURSE) != 0,
441 ("_sx_xlock_hard: recursed on non-recursive sx %s @ %s:%d\n",
442 sx->lock_object.lo_name, file, line));
443 sx->sx_recurse++;
444 atomic_set_ptr(&sx->sx_lock, SX_LOCK_RECURSED);

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

647 */
648int
649_sx_slock_hard(struct sx *sx, int opts, const char *file, int line)
650{
651 GIANT_DECLARE;
652#ifdef ADAPTIVE_SX
653 volatile struct thread *owner;
654#endif
440
441 /* If we already hold an exclusive lock, then recurse. */
442 if (sx_xlocked(sx)) {
443 KASSERT((sx->lock_object.lo_flags & SX_RECURSE) != 0,
444 ("_sx_xlock_hard: recursed on non-recursive sx %s @ %s:%d\n",
445 sx->lock_object.lo_name, file, line));
446 sx->sx_recurse++;
447 atomic_set_ptr(&sx->sx_lock, SX_LOCK_RECURSED);

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

650 */
651int
652_sx_slock_hard(struct sx *sx, int opts, const char *file, int line)
653{
654 GIANT_DECLARE;
655#ifdef ADAPTIVE_SX
656 volatile struct thread *owner;
657#endif
658#ifdef LOCK_PROFILING
655 uint64_t waittime = 0;
656 int contested = 0;
659 uint64_t waittime = 0;
660 int contested = 0;
661#endif
657 uintptr_t x;
658 int error = 0;
659
660 /*
661 * As with rwlocks, we don't make any attempt to try to block
662 * shared locks once there is an exclusive waiter.
663 */
664 for (;;) {

--- 383 unchanged lines hidden ---
662 uintptr_t x;
663 int error = 0;
664
665 /*
666 * As with rwlocks, we don't make any attempt to try to block
667 * shared locks once there is an exclusive waiter.
668 */
669 for (;;) {

--- 383 unchanged lines hidden ---