Deleted Added
full compact
kern_sx.c (252212) kern_sx.c (255745)
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:

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

37 */
38
39#include "opt_ddb.h"
40#include "opt_hwpmc_hooks.h"
41#include "opt_kdtrace.h"
42#include "opt_no_adaptive_sx.h"
43
44#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:

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

37 */
38
39#include "opt_ddb.h"
40#include "opt_hwpmc_hooks.h"
41#include "opt_kdtrace.h"
42#include "opt_no_adaptive_sx.h"
43
44#include <sys/cdefs.h>
45__FBSDID("$FreeBSD: head/sys/kern/kern_sx.c 252212 2013-06-25 20:23:08Z jhb $");
45__FBSDID("$FreeBSD: head/sys/kern/kern_sx.c 255745 2013-09-20 23:06:21Z davide $");
46
47#include <sys/param.h>
48#include <sys/systm.h>
49#include <sys/kdb.h>
50#include <sys/ktr.h>
51#include <sys/lock.h>
52#include <sys/mutex.h>
53#include <sys/proc.h>

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

111 */
112#define sx_recurse lock_object.lo_data
113#define sx_recursed(sx) ((sx)->sx_recurse != 0)
114
115static void assert_sx(const struct lock_object *lock, int what);
116#ifdef DDB
117static void db_show_sx(const struct lock_object *lock);
118#endif
46
47#include <sys/param.h>
48#include <sys/systm.h>
49#include <sys/kdb.h>
50#include <sys/ktr.h>
51#include <sys/lock.h>
52#include <sys/mutex.h>
53#include <sys/proc.h>

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

111 */
112#define sx_recurse lock_object.lo_data
113#define sx_recursed(sx) ((sx)->sx_recurse != 0)
114
115static void assert_sx(const struct lock_object *lock, int what);
116#ifdef DDB
117static void db_show_sx(const struct lock_object *lock);
118#endif
119static void lock_sx(struct lock_object *lock, int how);
119static void lock_sx(struct lock_object *lock, uintptr_t how);
120#ifdef KDTRACE_HOOKS
121static int owner_sx(const struct lock_object *lock, struct thread **owner);
122#endif
120#ifdef KDTRACE_HOOKS
121static int owner_sx(const struct lock_object *lock, struct thread **owner);
122#endif
123static int unlock_sx(struct lock_object *lock);
123static uintptr_t unlock_sx(struct lock_object *lock);
124
125struct lock_class lock_class_sx = {
126 .lc_name = "sx",
127 .lc_flags = LC_SLEEPLOCK | LC_SLEEPABLE | LC_RECURSABLE | LC_UPGRADABLE,
128 .lc_assert = assert_sx,
129#ifdef DDB
130 .lc_ddb_show = db_show_sx,
131#endif

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

151void
152assert_sx(const struct lock_object *lock, int what)
153{
154
155 sx_assert((const struct sx *)lock, what);
156}
157
158void
124
125struct lock_class lock_class_sx = {
126 .lc_name = "sx",
127 .lc_flags = LC_SLEEPLOCK | LC_SLEEPABLE | LC_RECURSABLE | LC_UPGRADABLE,
128 .lc_assert = assert_sx,
129#ifdef DDB
130 .lc_ddb_show = db_show_sx,
131#endif

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

151void
152assert_sx(const struct lock_object *lock, int what)
153{
154
155 sx_assert((const struct sx *)lock, what);
156}
157
158void
159lock_sx(struct lock_object *lock, int how)
159lock_sx(struct lock_object *lock, uintptr_t how)
160{
161 struct sx *sx;
162
163 sx = (struct sx *)lock;
164 if (how)
165 sx_xlock(sx);
166 else
167 sx_slock(sx);
168}
169
160{
161 struct sx *sx;
162
163 sx = (struct sx *)lock;
164 if (how)
165 sx_xlock(sx);
166 else
167 sx_slock(sx);
168}
169
170int
170uintptr_t
171unlock_sx(struct lock_object *lock)
172{
173 struct sx *sx;
174
175 sx = (struct sx *)lock;
176 sx_assert(sx, SA_LOCKED | SA_NOTRECURSED);
177 if (sx_xlocked(sx)) {
178 sx_xunlock(sx);

--- 1036 unchanged lines hidden ---
171unlock_sx(struct lock_object *lock)
172{
173 struct sx *sx;
174
175 sx = (struct sx *)lock;
176 sx_assert(sx, SA_LOCKED | SA_NOTRECURSED);
177 if (sx_xlocked(sx)) {
178 sx_xunlock(sx);

--- 1036 unchanged lines hidden ---