Deleted Added
full compact
kern_mutex.c (167365) kern_mutex.c (167368)
1/*-
2 * Copyright (c) 1998 Berkeley Software Design, Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.

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

29 * and BSDI $Id: synch_machdep.c,v 2.3.2.39 2000/04/27 03:10:25 cp Exp $
30 */
31
32/*
33 * Machine independent bits of mutex implementation.
34 */
35
36#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1998 Berkeley Software Design, Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.

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

29 * and BSDI $Id: synch_machdep.c,v 2.3.2.39 2000/04/27 03:10:25 cp Exp $
30 */
31
32/*
33 * Machine independent bits of mutex implementation.
34 */
35
36#include <sys/cdefs.h>
37__FBSDID("$FreeBSD: head/sys/kern/kern_mutex.c 167365 2007-03-09 16:04:44Z jhb $");
37__FBSDID("$FreeBSD: head/sys/kern/kern_mutex.c 167368 2007-03-09 16:27:11Z jhb $");
38
39#include "opt_adaptive_mutexes.h"
40#include "opt_ddb.h"
41#include "opt_global.h"
42#include "opt_mutex_wake_all.h"
43#include "opt_sched.h"
44
45#include <sys/param.h>

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

86 */
87#define mtx_unowned(m) ((m)->mtx_lock == MTX_UNOWNED)
88
89#define mtx_owner(m) ((struct thread *)((m)->mtx_lock & ~MTX_FLAGMASK))
90
91#ifdef DDB
92static void db_show_mtx(struct lock_object *lock);
93#endif
38
39#include "opt_adaptive_mutexes.h"
40#include "opt_ddb.h"
41#include "opt_global.h"
42#include "opt_mutex_wake_all.h"
43#include "opt_sched.h"
44
45#include <sys/param.h>

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

86 */
87#define mtx_unowned(m) ((m)->mtx_lock == MTX_UNOWNED)
88
89#define mtx_owner(m) ((struct thread *)((m)->mtx_lock & ~MTX_FLAGMASK))
90
91#ifdef DDB
92static void db_show_mtx(struct lock_object *lock);
93#endif
94static void lock_mtx(struct lock_object *lock, int how);
95static void lock_spin(struct lock_object *lock, int how);
96static int unlock_mtx(struct lock_object *lock);
97static int unlock_spin(struct lock_object *lock);
94
95/*
96 * Lock classes for sleep and spin mutexes.
97 */
98struct lock_class lock_class_mtx_sleep = {
99 .lc_name = "sleep mutex",
100 .lc_flags = LC_SLEEPLOCK | LC_RECURSABLE,
101#ifdef DDB
102 .lc_ddb_show = db_show_mtx,
103#endif
98
99/*
100 * Lock classes for sleep and spin mutexes.
101 */
102struct lock_class lock_class_mtx_sleep = {
103 .lc_name = "sleep mutex",
104 .lc_flags = LC_SLEEPLOCK | LC_RECURSABLE,
105#ifdef DDB
106 .lc_ddb_show = db_show_mtx,
107#endif
108 .lc_lock = lock_mtx,
109 .lc_unlock = unlock_mtx,
104};
105struct lock_class lock_class_mtx_spin = {
106 .lc_name = "spin mutex",
107 .lc_flags = LC_SPINLOCK | LC_RECURSABLE,
108#ifdef DDB
109 .lc_ddb_show = db_show_mtx,
110#endif
110};
111struct lock_class lock_class_mtx_spin = {
112 .lc_name = "spin mutex",
113 .lc_flags = LC_SPINLOCK | LC_RECURSABLE,
114#ifdef DDB
115 .lc_ddb_show = db_show_mtx,
116#endif
117 .lc_lock = lock_spin,
118 .lc_unlock = unlock_spin,
111};
112
113/*
114 * System-wide mutexes
115 */
116struct mtx sched_lock;
117struct mtx Giant;
118

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

125 mtx_init(&lprof_locks[i], "mprof lock",
126 NULL, MTX_SPIN|MTX_QUIET|MTX_NOPROFILE);
127 }
128}
129#else
130static inline void lock_profile_init(void) {;}
131#endif
132
119};
120
121/*
122 * System-wide mutexes
123 */
124struct mtx sched_lock;
125struct mtx Giant;
126

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

133 mtx_init(&lprof_locks[i], "mprof lock",
134 NULL, MTX_SPIN|MTX_QUIET|MTX_NOPROFILE);
135 }
136}
137#else
138static inline void lock_profile_init(void) {;}
139#endif
140
141void
142lock_mtx(struct lock_object *lock, int how)
143{
144
145 mtx_lock((struct mtx *)lock);
146}
147
148void
149lock_spin(struct lock_object *lock, int how)
150{
151
152 panic("spin locks can only use msleep_spin");
153}
154
155int
156unlock_mtx(struct lock_object *lock)
157{
158 struct mtx *m;
159
160 m = (struct mtx *)lock;
161 mtx_assert(m, MA_OWNED | MA_NOTRECURSED);
162 mtx_unlock(m);
163 return (0);
164}
165
166int
167unlock_spin(struct lock_object *lock)
168{
169
170 panic("spin locks can only use msleep_spin");
171}
172
133/*
134 * Function versions of the inlined __mtx_* macros. These are used by
135 * modules and can also be called from assembly language if needed.
136 */
137void
138_mtx_lock_flags(struct mtx *m, int opts, const char *file, int line)
139{
140

--- 617 unchanged lines hidden ---
173/*
174 * Function versions of the inlined __mtx_* macros. These are used by
175 * modules and can also be called from assembly language if needed.
176 */
177void
178_mtx_lock_flags(struct mtx *m, int opts, const char *file, int line)
179{
180

--- 617 unchanged lines hidden ---