]> git.proxmox.com Git - mirror_spl.git/blame - module/spl/spl-mutex.c
Fix undefined reference on spl_mutex_spin_max().
[mirror_spl.git] / module / spl / spl-mutex.c
CommitLineData
716154c5
BB
1/*****************************************************************************\
2 * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
3 * Copyright (C) 2007 The Regents of the University of California.
4 * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
5 * Written by Brian Behlendorf <behlendorf1@llnl.gov>.
715f6251 6 * UCRL-CODE-235197
7 *
716154c5
BB
8 * This file is part of the SPL, Solaris Porting Layer.
9 * For details, see <http://github.com/behlendorf/spl/>.
10 *
11 * The SPL is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
715f6251 15 *
716154c5 16 * The SPL is distributed in the hope that it will be useful, but WITHOUT
715f6251 17 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19 * for more details.
20 *
21 * You should have received a copy of the GNU General Public License along
716154c5
BB
22 * with the SPL. If not, see <http://www.gnu.org/licenses/>.
23 *****************************************************************************
24 * Solaris Porting Layer (SPL) Mutex Implementation.
25\*****************************************************************************/
715f6251 26
9ab1ac14 27#include <sys/mutex.h>
28
29#ifdef DEBUG_SUBSYSTEM
30#undef DEBUG_SUBSYSTEM
31#endif
32
33#define DEBUG_SUBSYSTEM S_MUTEX
34
4d54fdee
BB
35/*
36 * While a standard mutex implementation has been available in the kernel
37 * for quite some time. It was not until 2.6.29 and latter kernels that
38 * adaptive mutexs were embraced and integrated with the scheduler. This
39 * brought a significant performance improvement, but just as importantly
40 * it added a lock owner to the generic mutex outside CONFIG_DEBUG_MUTEXES
41 * builds. This is critical for correctly supporting the mutex_owner()
42 * Solaris primitive. When the owner is available we use a pure Linux
43 * mutex implementation. When the owner is not available we still use
44 * Linux mutexs as a base but also reserve space for an owner field right
45 * after the mutex structure.
9ab1ac14 46 *
4d54fdee
BB
47 * In the case when HAVE_MUTEX_OWNER is not defined your code may
48 * still me able to leverage adaptive mutexs. As long as the task_curr()
49 * symbol is exported this code will provide a poor mans adaptive mutex
50 * implementation. However, this is not required and if the symbol is
51 * unavailable we provide a standard mutex.
9ab1ac14 52 */
53
38b5ff4d 54#if !defined(HAVE_MUTEX_OWNER) || !defined(CONFIG_SMP) || defined(CONFIG_DEBUG_MUTEXES)
4d54fdee
BB
55#ifdef HAVE_TASK_CURR
56/*
57 * mutex_spin_max = { 0, -1, 1-MAX_INT }
58 * 0: Never spin when trying to acquire lock
59 * -1: Spin until acquired or holder yields without dropping lock
9ab1ac14 60 * 1-MAX_INT: Spin for N attempts before sleeping for lock
61 */
56f92453 62int mutex_spin_max = 0;
4d54fdee
BB
63module_param(mutex_spin_max, int, 0644);
64MODULE_PARM_DESC(mutex_spin_max, "Spin a maximum of N times to acquire lock");
9ab1ac14 65
66int
4d54fdee 67spl_mutex_spin_max(void)
9ab1ac14 68{
4d54fdee 69 return mutex_spin_max;
9ab1ac14 70}
4d54fdee 71EXPORT_SYMBOL(spl_mutex_spin_max);
9ab1ac14 72
4d54fdee
BB
73#endif /* HAVE_TASK_CURR */
74#endif /* !HAVE_MUTEX_OWNER */
9ab1ac14 75
4d54fdee
BB
76int spl_mutex_init(void) { return 0; }
77void spl_mutex_fini(void) { }