2010-05-18 02:18:00 +04:00
|
|
|
/*****************************************************************************\
|
|
|
|
* Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
|
|
|
|
* Copyright (C) 2007 The Regents of the University of California.
|
|
|
|
* Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
|
|
|
|
* Written by Brian Behlendorf <behlendorf1@llnl.gov>.
|
2008-05-26 08:38:26 +04:00
|
|
|
* UCRL-CODE-235197
|
|
|
|
*
|
2010-05-18 02:18:00 +04:00
|
|
|
* This file is part of the SPL, Solaris Porting Layer.
|
2013-03-05 05:26:55 +04:00
|
|
|
* For details, see <http://zfsonlinux.org/>.
|
2010-05-18 02:18:00 +04:00
|
|
|
*
|
|
|
|
* The SPL is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your
|
|
|
|
* option) any later version.
|
2008-05-26 08:38:26 +04:00
|
|
|
*
|
2010-05-18 02:18:00 +04:00
|
|
|
* The SPL is distributed in the hope that it will be useful, but WITHOUT
|
2008-05-26 08:38:26 +04:00
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
2010-05-18 02:18:00 +04:00
|
|
|
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*****************************************************************************
|
|
|
|
* Solaris Porting Layer (SPL) Proc Implementation.
|
|
|
|
\*****************************************************************************/
|
2008-05-26 08:38:26 +04:00
|
|
|
|
2010-06-12 01:37:46 +04:00
|
|
|
#include <sys/systeminfo.h>
|
|
|
|
#include <sys/kstat.h>
|
|
|
|
#include <linux/kmod.h>
|
|
|
|
#include <linux/seq_file.h>
|
|
|
|
#include <linux/proc_compat.h>
|
2013-03-27 19:33:14 +04:00
|
|
|
#include <linux/version.h>
|
2010-07-20 01:16:05 +04:00
|
|
|
#include <spl-debug.h>
|
2008-04-19 03:39:58 +04:00
|
|
|
|
2010-07-20 22:55:37 +04:00
|
|
|
#ifdef SS_DEBUG_SUBSYS
|
|
|
|
#undef SS_DEBUG_SUBSYS
|
2008-04-19 03:39:58 +04:00
|
|
|
#endif
|
|
|
|
|
2010-07-20 22:55:37 +04:00
|
|
|
#define SS_DEBUG_SUBSYS SS_PROC
|
2008-04-19 03:39:58 +04:00
|
|
|
|
2013-03-27 19:33:14 +04:00
|
|
|
#if defined(CONSTIFY_PLUGIN) && LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
|
|
|
|
typedef struct ctl_table __no_const spl_ctl_table;
|
|
|
|
#else
|
|
|
|
typedef struct ctl_table spl_ctl_table;
|
|
|
|
#endif
|
|
|
|
|
2008-05-07 21:58:22 +04:00
|
|
|
#ifdef DEBUG_KMEM
|
2008-04-19 03:39:58 +04:00
|
|
|
static unsigned long table_min = 0;
|
|
|
|
static unsigned long table_max = ~0;
|
2008-05-07 21:58:22 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_SYSCTL
|
|
|
|
static struct ctl_table_header *spl_header = NULL;
|
2008-06-04 10:00:46 +04:00
|
|
|
#endif /* CONFIG_SYSCTL */
|
|
|
|
|
|
|
|
static struct proc_dir_entry *proc_spl = NULL;
|
2008-05-09 03:21:47 +04:00
|
|
|
#ifdef DEBUG_KMEM
|
2008-06-04 10:00:46 +04:00
|
|
|
static struct proc_dir_entry *proc_spl_kmem = NULL;
|
2008-06-28 01:40:11 +04:00
|
|
|
static struct proc_dir_entry *proc_spl_kmem_slab = NULL;
|
2008-06-04 10:00:46 +04:00
|
|
|
#endif /* DEBUG_KMEM */
|
|
|
|
struct proc_dir_entry *proc_spl_kstat = NULL;
|
2008-04-19 03:39:58 +04:00
|
|
|
|
2010-06-30 21:36:20 +04:00
|
|
|
#ifdef HAVE_CTL_NAME
|
2008-06-02 21:28:49 +04:00
|
|
|
#ifdef HAVE_CTL_UNNUMBERED
|
|
|
|
|
|
|
|
#define CTL_SPL CTL_UNNUMBERED
|
|
|
|
#define CTL_SPL_DEBUG CTL_UNNUMBERED
|
2009-02-05 02:15:41 +03:00
|
|
|
#define CTL_SPL_VM CTL_UNNUMBERED
|
2008-06-02 21:28:49 +04:00
|
|
|
#define CTL_SPL_MUTEX CTL_UNNUMBERED
|
|
|
|
#define CTL_SPL_KMEM CTL_UNNUMBERED
|
|
|
|
#define CTL_SPL_KSTAT CTL_UNNUMBERED
|
|
|
|
|
|
|
|
#define CTL_VERSION CTL_UNNUMBERED /* Version */
|
|
|
|
#define CTL_HOSTID CTL_UNNUMBERED /* Host id by /usr/bin/hostid */
|
2009-02-26 00:20:40 +03:00
|
|
|
#define CTL_KALLSYMS CTL_UNNUMBERED /* kallsyms_lookup_name addr */
|
2008-06-02 21:28:49 +04:00
|
|
|
|
|
|
|
#define CTL_DEBUG_SUBSYS CTL_UNNUMBERED /* Debug subsystem */
|
|
|
|
#define CTL_DEBUG_MASK CTL_UNNUMBERED /* Debug mask */
|
|
|
|
#define CTL_DEBUG_PRINTK CTL_UNNUMBERED /* All messages to console */
|
|
|
|
#define CTL_DEBUG_MB CTL_UNNUMBERED /* Debug buffer size */
|
|
|
|
#define CTL_DEBUG_BINARY CTL_UNNUMBERED /* Binary data in buffer */
|
|
|
|
#define CTL_DEBUG_CATASTROPHE CTL_UNNUMBERED /* Set if BUG'd or panic'd */
|
|
|
|
#define CTL_DEBUG_PANIC_ON_BUG CTL_UNNUMBERED /* Should panic on BUG */
|
|
|
|
#define CTL_DEBUG_PATH CTL_UNNUMBERED /* Dump log location */
|
|
|
|
#define CTL_DEBUG_DUMP CTL_UNNUMBERED /* Dump debug buffer to file */
|
|
|
|
#define CTL_DEBUG_FORCE_BUG CTL_UNNUMBERED /* Hook to force a BUG */
|
|
|
|
#define CTL_DEBUG_STACK_SIZE CTL_UNNUMBERED /* Max observed stack size */
|
|
|
|
|
|
|
|
#define CTL_CONSOLE_RATELIMIT CTL_UNNUMBERED /* Ratelimit console messages */
|
|
|
|
#define CTL_CONSOLE_MAX_DELAY_CS CTL_UNNUMBERED /* Max delay skip messages */
|
|
|
|
#define CTL_CONSOLE_MIN_DELAY_CS CTL_UNNUMBERED /* Init delay skip messages */
|
|
|
|
#define CTL_CONSOLE_BACKOFF CTL_UNNUMBERED /* Delay increase factor */
|
|
|
|
|
2009-02-05 02:15:41 +03:00
|
|
|
#define CTL_VM_MINFREE CTL_UNNUMBERED /* Minimum free memory */
|
|
|
|
#define CTL_VM_DESFREE CTL_UNNUMBERED /* Desired free memory */
|
|
|
|
#define CTL_VM_LOTSFREE CTL_UNNUMBERED /* Lots of free memory */
|
|
|
|
#define CTL_VM_NEEDFREE CTL_UNNUMBERED /* Need free memory */
|
|
|
|
#define CTL_VM_SWAPFS_MINFREE CTL_UNNUMBERED /* Minimum swapfs memory */
|
|
|
|
#define CTL_VM_SWAPFS_RESERVE CTL_UNNUMBERED /* Reserved swapfs memory */
|
2009-02-05 23:26:34 +03:00
|
|
|
#define CTL_VM_AVAILRMEM CTL_UNNUMBERED /* Easily available memory */
|
|
|
|
#define CTL_VM_FREEMEM CTL_UNNUMBERED /* Free memory */
|
|
|
|
#define CTL_VM_PHYSMEM CTL_UNNUMBERED /* Total physical memory */
|
2009-02-05 02:15:41 +03:00
|
|
|
|
2008-06-02 21:28:49 +04:00
|
|
|
#ifdef DEBUG_KMEM
|
|
|
|
#define CTL_KMEM_KMEMUSED CTL_UNNUMBERED /* Alloc'd kmem bytes */
|
|
|
|
#define CTL_KMEM_KMEMMAX CTL_UNNUMBERED /* Max alloc'd by kmem bytes */
|
|
|
|
#define CTL_KMEM_VMEMUSED CTL_UNNUMBERED /* Alloc'd vmem bytes */
|
|
|
|
#define CTL_KMEM_VMEMMAX CTL_UNNUMBERED /* Max alloc'd by vmem bytes */
|
2011-03-26 10:03:32 +03:00
|
|
|
#define CTL_KMEM_SLAB_KMEMTOTAL CTL_UNNUMBERED /* Total kmem slab size */
|
|
|
|
#define CTL_KMEM_SLAB_KMEMALLOC CTL_UNNUMBERED /* Alloc'd kmem slab size */
|
|
|
|
#define CTL_KMEM_SLAB_KMEMMAX CTL_UNNUMBERED /* Max kmem slab size */
|
|
|
|
#define CTL_KMEM_SLAB_VMEMTOTAL CTL_UNNUMBERED /* Total vmem slab size */
|
|
|
|
#define CTL_KMEM_SLAB_VMEMALLOC CTL_UNNUMBERED /* Alloc'd vmem slab size */
|
|
|
|
#define CTL_KMEM_SLAB_VMEMMAX CTL_UNNUMBERED /* Max vmem slab size */
|
2008-06-02 21:28:49 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#else /* HAVE_CTL_UNNUMBERED */
|
|
|
|
|
2009-02-05 02:15:41 +03:00
|
|
|
enum {
|
|
|
|
CTL_SPL = 0x87,
|
|
|
|
CTL_SPL_DEBUG = 0x88,
|
|
|
|
CTL_SPL_VM = 0x89,
|
|
|
|
CTL_SPL_MUTEX = 0x90,
|
|
|
|
CTL_SPL_KMEM = 0x91,
|
|
|
|
CTL_SPL_KSTAT = 0x92,
|
|
|
|
};
|
2008-05-06 00:18:49 +04:00
|
|
|
|
2008-04-19 03:39:58 +04:00
|
|
|
enum {
|
2009-02-05 02:15:41 +03:00
|
|
|
CTL_VERSION = 1, /* Version */
|
|
|
|
CTL_HOSTID, /* Host id reported by /usr/bin/hostid */
|
2009-02-26 00:20:40 +03:00
|
|
|
CTL_KALLSYMS, /* Address of kallsyms_lookup_name */
|
2009-02-05 02:15:41 +03:00
|
|
|
|
2012-01-21 04:39:12 +04:00
|
|
|
#ifdef DEBUG_LOG
|
2009-02-05 02:15:41 +03:00
|
|
|
CTL_DEBUG_SUBSYS, /* Debug subsystem */
|
|
|
|
CTL_DEBUG_MASK, /* Debug mask */
|
|
|
|
CTL_DEBUG_PRINTK, /* Force all messages to console */
|
|
|
|
CTL_DEBUG_MB, /* Debug buffer size */
|
|
|
|
CTL_DEBUG_BINARY, /* Include binary data in buffer */
|
|
|
|
CTL_DEBUG_CATASTROPHE, /* Set if we have BUG'd or panic'd */
|
|
|
|
CTL_DEBUG_PANIC_ON_BUG, /* Set if we should panic on BUG */
|
|
|
|
CTL_DEBUG_PATH, /* Dump log location */
|
|
|
|
CTL_DEBUG_DUMP, /* Dump debug buffer to file */
|
|
|
|
CTL_DEBUG_FORCE_BUG, /* Hook to force a BUG */
|
|
|
|
CTL_DEBUG_STACK_SIZE, /* Max observed stack size */
|
2012-01-21 04:39:12 +04:00
|
|
|
#endif
|
2009-02-05 02:15:41 +03:00
|
|
|
|
|
|
|
CTL_CONSOLE_RATELIMIT, /* Ratelimit console messages */
|
|
|
|
CTL_CONSOLE_MAX_DELAY_CS, /* Max delay which we skip messages */
|
|
|
|
CTL_CONSOLE_MIN_DELAY_CS, /* Init delay which we skip messages */
|
|
|
|
CTL_CONSOLE_BACKOFF, /* Delay increase factor */
|
|
|
|
|
|
|
|
CTL_VM_MINFREE, /* Minimum free memory threshold */
|
|
|
|
CTL_VM_DESFREE, /* Desired free memory threshold */
|
|
|
|
CTL_VM_LOTSFREE, /* Lots of free memory threshold */
|
|
|
|
CTL_VM_NEEDFREE, /* Need free memory deficit */
|
|
|
|
CTL_VM_SWAPFS_MINFREE, /* Minimum swapfs memory */
|
|
|
|
CTL_VM_SWAPFS_RESERVE, /* Reserved swapfs memory */
|
2009-02-05 23:26:34 +03:00
|
|
|
CTL_VM_AVAILRMEM, /* Easily available memory */
|
|
|
|
CTL_VM_FREEMEM, /* Free memory */
|
|
|
|
CTL_VM_PHYSMEM, /* Total physical memory */
|
2008-05-06 00:18:49 +04:00
|
|
|
|
2008-04-19 03:39:58 +04:00
|
|
|
#ifdef DEBUG_KMEM
|
2009-02-05 02:15:41 +03:00
|
|
|
CTL_KMEM_KMEMUSED, /* Alloc'd kmem bytes */
|
|
|
|
CTL_KMEM_KMEMMAX, /* Max alloc'd by kmem bytes */
|
|
|
|
CTL_KMEM_VMEMUSED, /* Alloc'd vmem bytes */
|
|
|
|
CTL_KMEM_VMEMMAX, /* Max alloc'd by vmem bytes */
|
2011-03-26 10:03:32 +03:00
|
|
|
CTL_KMEM_SLAB_KMEMTOTAL, /* Total kmem slab size */
|
|
|
|
CTL_KMEM_SLAB_KMEMALLOC, /* Alloc'd kmem slab size */
|
|
|
|
CTL_KMEM_SLAB_KMEMMAX, /* Max kmem slab size */
|
|
|
|
CTL_KMEM_SLAB_VMEMTOTAL, /* Total vmem slab size */
|
|
|
|
CTL_KMEM_SLAB_VMEMALLOC, /* Alloc'd vmem slab size */
|
|
|
|
CTL_KMEM_SLAB_VMEMMAX, /* Max vmem slab size */
|
2008-04-19 03:39:58 +04:00
|
|
|
#endif
|
|
|
|
};
|
2008-06-02 21:28:49 +04:00
|
|
|
#endif /* HAVE_CTL_UNNUMBERED */
|
2010-06-30 21:36:20 +04:00
|
|
|
#endif /* HAVE_CTL_NAME */
|
2008-04-19 03:39:58 +04:00
|
|
|
|
|
|
|
static int
|
|
|
|
proc_copyin_string(char *kbuffer, int kbuffer_size,
|
|
|
|
const char *ubuffer, int ubuffer_size)
|
|
|
|
{
|
|
|
|
int size;
|
|
|
|
|
|
|
|
if (ubuffer_size > kbuffer_size)
|
|
|
|
return -EOVERFLOW;
|
|
|
|
|
|
|
|
if (copy_from_user((void *)kbuffer, (void *)ubuffer, ubuffer_size))
|
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
/* strip trailing whitespace */
|
|
|
|
size = strnlen(kbuffer, ubuffer_size);
|
|
|
|
while (size-- >= 0)
|
|
|
|
if (!isspace(kbuffer[size]))
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* empty string */
|
|
|
|
if (size < 0)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/* no space to terminate */
|
|
|
|
if (size == kbuffer_size)
|
|
|
|
return -EOVERFLOW;
|
|
|
|
|
|
|
|
kbuffer[size + 1] = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
proc_copyout_string(char *ubuffer, int ubuffer_size,
|
|
|
|
const char *kbuffer, char *append)
|
|
|
|
{
|
|
|
|
/* NB if 'append' != NULL, it's a single character to append to the
|
|
|
|
* copied out string - usually "\n", for /proc entries and
|
|
|
|
* (i.e. a terminating zero byte) for sysctl entries
|
|
|
|
*/
|
|
|
|
int size = MIN(strlen(kbuffer), ubuffer_size);
|
|
|
|
|
|
|
|
if (copy_to_user(ubuffer, kbuffer, size))
|
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
if (append != NULL && size < ubuffer_size) {
|
|
|
|
if (copy_to_user(ubuffer + size, append, 1))
|
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
size++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
2012-01-21 04:39:12 +04:00
|
|
|
#ifdef DEBUG_LOG
|
2010-03-04 23:14:56 +03:00
|
|
|
SPL_PROC_HANDLER(proc_dobitmasks)
|
2008-04-19 03:39:58 +04:00
|
|
|
{
|
|
|
|
unsigned long *mask = table->data;
|
|
|
|
int is_subsys = (mask == &spl_debug_subsys) ? 1 : 0;
|
|
|
|
int is_printk = (mask == &spl_debug_printk) ? 1 : 0;
|
|
|
|
int size = 512, rc;
|
|
|
|
char *str;
|
2010-07-20 22:55:37 +04:00
|
|
|
SENTRY;
|
2008-04-19 03:39:58 +04:00
|
|
|
|
|
|
|
str = kmem_alloc(size, KM_SLEEP);
|
|
|
|
if (str == NULL)
|
2010-07-20 22:55:37 +04:00
|
|
|
SRETURN(-ENOMEM);
|
2008-04-19 03:39:58 +04:00
|
|
|
|
|
|
|
if (write) {
|
|
|
|
rc = proc_copyin_string(str, size, buffer, *lenp);
|
|
|
|
if (rc < 0)
|
2010-07-20 22:55:37 +04:00
|
|
|
SRETURN(rc);
|
2008-04-19 03:39:58 +04:00
|
|
|
|
|
|
|
rc = spl_debug_str2mask(mask, str, is_subsys);
|
|
|
|
/* Always print BUG/ASSERT to console, so keep this mask */
|
|
|
|
if (is_printk)
|
2010-07-20 22:55:37 +04:00
|
|
|
*mask |= SD_EMERG;
|
2008-04-19 03:39:58 +04:00
|
|
|
|
|
|
|
*ppos += *lenp;
|
|
|
|
} else {
|
|
|
|
rc = spl_debug_mask2str(str, size, *mask, is_subsys);
|
|
|
|
if (*ppos >= rc)
|
|
|
|
rc = 0;
|
|
|
|
else
|
|
|
|
rc = proc_copyout_string(buffer, *lenp,
|
|
|
|
str + *ppos, "\n");
|
|
|
|
if (rc >= 0) {
|
|
|
|
*lenp = rc;
|
|
|
|
*ppos += rc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
kmem_free(str, size);
|
2010-07-20 22:55:37 +04:00
|
|
|
SRETURN(rc);
|
2008-04-19 03:39:58 +04:00
|
|
|
}
|
|
|
|
|
2010-03-04 23:14:56 +03:00
|
|
|
SPL_PROC_HANDLER(proc_debug_mb)
|
2008-04-19 03:39:58 +04:00
|
|
|
{
|
|
|
|
char str[32];
|
|
|
|
int rc, len;
|
2010-07-20 22:55:37 +04:00
|
|
|
SENTRY;
|
2008-04-19 03:39:58 +04:00
|
|
|
|
|
|
|
if (write) {
|
|
|
|
rc = proc_copyin_string(str, sizeof(str), buffer, *lenp);
|
|
|
|
if (rc < 0)
|
2010-07-20 22:55:37 +04:00
|
|
|
SRETURN(rc);
|
2008-04-19 03:39:58 +04:00
|
|
|
|
|
|
|
rc = spl_debug_set_mb(simple_strtoul(str, NULL, 0));
|
|
|
|
*ppos += *lenp;
|
|
|
|
} else {
|
|
|
|
len = snprintf(str, sizeof(str), "%d", spl_debug_get_mb());
|
|
|
|
if (*ppos >= len)
|
|
|
|
rc = 0;
|
|
|
|
else
|
2010-03-04 23:14:56 +03:00
|
|
|
rc = proc_copyout_string(buffer,*lenp,str+*ppos,"\n");
|
2008-04-19 03:39:58 +04:00
|
|
|
|
|
|
|
if (rc >= 0) {
|
|
|
|
*lenp = rc;
|
|
|
|
*ppos += rc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-20 22:55:37 +04:00
|
|
|
SRETURN(rc);
|
2008-04-19 03:39:58 +04:00
|
|
|
}
|
|
|
|
|
2010-03-04 23:14:56 +03:00
|
|
|
SPL_PROC_HANDLER(proc_dump_kernel)
|
2008-04-19 03:39:58 +04:00
|
|
|
{
|
2010-07-20 22:55:37 +04:00
|
|
|
SENTRY;
|
2008-04-19 03:39:58 +04:00
|
|
|
|
|
|
|
if (write) {
|
2008-04-22 02:44:11 +04:00
|
|
|
spl_debug_dumplog(0);
|
2008-04-19 03:39:58 +04:00
|
|
|
*ppos += *lenp;
|
|
|
|
} else {
|
|
|
|
*lenp = 0;
|
|
|
|
}
|
|
|
|
|
2010-07-20 22:55:37 +04:00
|
|
|
SRETURN(0);
|
2008-04-19 03:39:58 +04:00
|
|
|
}
|
|
|
|
|
2010-03-04 23:14:56 +03:00
|
|
|
SPL_PROC_HANDLER(proc_force_bug)
|
2008-04-19 03:39:58 +04:00
|
|
|
{
|
2010-07-20 22:55:37 +04:00
|
|
|
SENTRY;
|
2008-04-19 03:39:58 +04:00
|
|
|
|
2010-07-20 01:16:05 +04:00
|
|
|
if (write)
|
|
|
|
PANIC("Crashing due to forced panic\n");
|
|
|
|
else
|
2008-04-19 03:39:58 +04:00
|
|
|
*lenp = 0;
|
|
|
|
|
2010-07-20 22:55:37 +04:00
|
|
|
SRETURN(0);
|
2008-04-19 03:39:58 +04:00
|
|
|
}
|
|
|
|
|
2010-03-04 23:14:56 +03:00
|
|
|
SPL_PROC_HANDLER(proc_console_max_delay_cs)
|
2008-04-19 03:39:58 +04:00
|
|
|
{
|
|
|
|
int rc, max_delay_cs;
|
2013-03-27 19:33:14 +04:00
|
|
|
spl_ctl_table dummy = *table;
|
2008-04-19 03:39:58 +04:00
|
|
|
long d;
|
2010-07-20 22:55:37 +04:00
|
|
|
SENTRY;
|
2008-04-19 03:39:58 +04:00
|
|
|
|
|
|
|
dummy.data = &max_delay_cs;
|
|
|
|
dummy.proc_handler = &proc_dointvec;
|
|
|
|
|
|
|
|
if (write) {
|
|
|
|
max_delay_cs = 0;
|
2010-03-04 23:14:56 +03:00
|
|
|
rc = spl_proc_dointvec(&dummy,write,filp,buffer,lenp,ppos);
|
2008-04-19 03:39:58 +04:00
|
|
|
if (rc < 0)
|
2010-07-20 22:55:37 +04:00
|
|
|
SRETURN(rc);
|
2008-04-19 03:39:58 +04:00
|
|
|
|
|
|
|
if (max_delay_cs <= 0)
|
2010-07-20 22:55:37 +04:00
|
|
|
SRETURN(-EINVAL);
|
2008-04-19 03:39:58 +04:00
|
|
|
|
|
|
|
d = (max_delay_cs * HZ) / 100;
|
|
|
|
if (d == 0 || d < spl_console_min_delay)
|
2010-07-20 22:55:37 +04:00
|
|
|
SRETURN(-EINVAL);
|
2008-04-19 03:39:58 +04:00
|
|
|
|
|
|
|
spl_console_max_delay = d;
|
|
|
|
} else {
|
|
|
|
max_delay_cs = (spl_console_max_delay * 100) / HZ;
|
2010-03-04 23:14:56 +03:00
|
|
|
rc = spl_proc_dointvec(&dummy,write,filp,buffer,lenp,ppos);
|
2008-04-19 03:39:58 +04:00
|
|
|
}
|
|
|
|
|
2010-07-20 22:55:37 +04:00
|
|
|
SRETURN(rc);
|
2008-04-19 03:39:58 +04:00
|
|
|
}
|
|
|
|
|
2010-03-04 23:14:56 +03:00
|
|
|
SPL_PROC_HANDLER(proc_console_min_delay_cs)
|
2008-04-19 03:39:58 +04:00
|
|
|
{
|
|
|
|
int rc, min_delay_cs;
|
2013-03-27 19:33:14 +04:00
|
|
|
spl_ctl_table dummy = *table;
|
2008-04-19 03:39:58 +04:00
|
|
|
long d;
|
2010-07-20 22:55:37 +04:00
|
|
|
SENTRY;
|
2008-04-19 03:39:58 +04:00
|
|
|
|
|
|
|
dummy.data = &min_delay_cs;
|
|
|
|
dummy.proc_handler = &proc_dointvec;
|
|
|
|
|
|
|
|
if (write) {
|
|
|
|
min_delay_cs = 0;
|
2010-03-04 23:14:56 +03:00
|
|
|
rc = spl_proc_dointvec(&dummy,write,filp,buffer,lenp,ppos);
|
2008-04-19 03:39:58 +04:00
|
|
|
if (rc < 0)
|
2010-07-20 22:55:37 +04:00
|
|
|
SRETURN(rc);
|
2008-04-19 03:39:58 +04:00
|
|
|
|
|
|
|
if (min_delay_cs <= 0)
|
2010-07-20 22:55:37 +04:00
|
|
|
SRETURN(-EINVAL);
|
2008-04-19 03:39:58 +04:00
|
|
|
|
|
|
|
d = (min_delay_cs * HZ) / 100;
|
|
|
|
if (d == 0 || d > spl_console_max_delay)
|
2010-07-20 22:55:37 +04:00
|
|
|
SRETURN(-EINVAL);
|
2008-04-19 03:39:58 +04:00
|
|
|
|
|
|
|
spl_console_min_delay = d;
|
|
|
|
} else {
|
|
|
|
min_delay_cs = (spl_console_min_delay * 100) / HZ;
|
2010-03-04 23:14:56 +03:00
|
|
|
rc = spl_proc_dointvec(&dummy,write,filp,buffer,lenp,ppos);
|
2008-04-19 03:39:58 +04:00
|
|
|
}
|
|
|
|
|
2010-07-20 22:55:37 +04:00
|
|
|
SRETURN(rc);
|
2008-04-19 03:39:58 +04:00
|
|
|
}
|
|
|
|
|
2010-03-04 23:14:56 +03:00
|
|
|
SPL_PROC_HANDLER(proc_console_backoff)
|
2008-04-19 03:39:58 +04:00
|
|
|
{
|
|
|
|
int rc, backoff;
|
2013-03-27 19:33:14 +04:00
|
|
|
spl_ctl_table dummy = *table;
|
2010-07-20 22:55:37 +04:00
|
|
|
SENTRY;
|
2008-04-19 03:39:58 +04:00
|
|
|
|
|
|
|
dummy.data = &backoff;
|
|
|
|
dummy.proc_handler = &proc_dointvec;
|
|
|
|
|
|
|
|
if (write) {
|
|
|
|
backoff = 0;
|
2010-03-04 23:14:56 +03:00
|
|
|
rc = spl_proc_dointvec(&dummy,write,filp,buffer,lenp,ppos);
|
2008-04-19 03:39:58 +04:00
|
|
|
if (rc < 0)
|
2010-07-20 22:55:37 +04:00
|
|
|
SRETURN(rc);
|
2008-04-19 03:39:58 +04:00
|
|
|
|
|
|
|
if (backoff <= 0)
|
2010-07-20 22:55:37 +04:00
|
|
|
SRETURN(-EINVAL);
|
2008-04-19 03:39:58 +04:00
|
|
|
|
|
|
|
spl_console_backoff = backoff;
|
|
|
|
} else {
|
|
|
|
backoff = spl_console_backoff;
|
2010-03-04 23:14:56 +03:00
|
|
|
rc = spl_proc_dointvec(&dummy,write,filp,buffer,lenp,ppos);
|
2008-04-19 03:39:58 +04:00
|
|
|
}
|
|
|
|
|
2010-07-20 22:55:37 +04:00
|
|
|
SRETURN(rc);
|
2008-04-19 03:39:58 +04:00
|
|
|
}
|
2012-01-21 04:39:12 +04:00
|
|
|
#endif /* DEBUG_LOG */
|
2008-04-19 03:39:58 +04:00
|
|
|
|
2008-05-10 02:53:20 +04:00
|
|
|
#ifdef DEBUG_KMEM
|
2010-03-04 23:14:56 +03:00
|
|
|
SPL_PROC_HANDLER(proc_domemused)
|
2008-04-19 03:39:58 +04:00
|
|
|
{
|
|
|
|
int rc = 0;
|
|
|
|
unsigned long min = 0, max = ~0, val;
|
2013-03-27 19:33:14 +04:00
|
|
|
spl_ctl_table dummy = *table;
|
2010-07-20 22:55:37 +04:00
|
|
|
SENTRY;
|
2008-04-19 03:39:58 +04:00
|
|
|
|
|
|
|
dummy.data = &val;
|
|
|
|
dummy.proc_handler = &proc_dointvec;
|
|
|
|
dummy.extra1 = &min;
|
|
|
|
dummy.extra2 = &max;
|
|
|
|
|
|
|
|
if (write) {
|
|
|
|
*ppos += *lenp;
|
|
|
|
} else {
|
2009-12-05 02:54:12 +03:00
|
|
|
# ifdef HAVE_ATOMIC64_T
|
2008-11-03 23:34:17 +03:00
|
|
|
val = atomic64_read((atomic64_t *)table->data);
|
2009-12-05 02:54:12 +03:00
|
|
|
# else
|
|
|
|
val = atomic_read((atomic_t *)table->data);
|
|
|
|
# endif /* HAVE_ATOMIC64_T */
|
2010-03-04 23:14:56 +03:00
|
|
|
rc = spl_proc_doulongvec_minmax(&dummy, write, filp,
|
|
|
|
buffer, lenp, ppos);
|
2008-04-19 03:39:58 +04:00
|
|
|
}
|
|
|
|
|
2010-07-20 22:55:37 +04:00
|
|
|
SRETURN(rc);
|
2008-04-19 03:39:58 +04:00
|
|
|
}
|
2011-03-26 10:03:32 +03:00
|
|
|
|
|
|
|
SPL_PROC_HANDLER(proc_doslab)
|
|
|
|
{
|
|
|
|
int rc = 0;
|
|
|
|
unsigned long min = 0, max = ~0, val = 0, mask;
|
2013-03-27 19:33:14 +04:00
|
|
|
spl_ctl_table dummy = *table;
|
2011-03-26 10:03:32 +03:00
|
|
|
spl_kmem_cache_t *skc;
|
|
|
|
SENTRY;
|
|
|
|
|
|
|
|
dummy.data = &val;
|
|
|
|
dummy.proc_handler = &proc_dointvec;
|
|
|
|
dummy.extra1 = &min;
|
|
|
|
dummy.extra2 = &max;
|
|
|
|
|
|
|
|
if (write) {
|
|
|
|
*ppos += *lenp;
|
|
|
|
} else {
|
|
|
|
down_read(&spl_kmem_cache_sem);
|
|
|
|
mask = (unsigned long)table->data;
|
|
|
|
|
|
|
|
list_for_each_entry(skc, &spl_kmem_cache_list, skc_list) {
|
|
|
|
|
|
|
|
/* Only use slabs of the correct kmem/vmem type */
|
|
|
|
if (!(skc->skc_flags & mask))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* Sum the specified field for selected slabs */
|
|
|
|
switch (mask & (KMC_TOTAL | KMC_ALLOC | KMC_MAX)) {
|
|
|
|
case KMC_TOTAL:
|
|
|
|
val += skc->skc_slab_size * skc->skc_slab_total;
|
|
|
|
break;
|
|
|
|
case KMC_ALLOC:
|
|
|
|
val += skc->skc_obj_size * skc->skc_obj_alloc;
|
|
|
|
break;
|
|
|
|
case KMC_MAX:
|
|
|
|
val += skc->skc_obj_size * skc->skc_obj_max;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
up_read(&spl_kmem_cache_sem);
|
|
|
|
rc = spl_proc_doulongvec_minmax(&dummy, write, filp,
|
|
|
|
buffer, lenp, ppos);
|
|
|
|
}
|
|
|
|
|
|
|
|
SRETURN(rc);
|
|
|
|
}
|
2008-05-10 02:53:20 +04:00
|
|
|
#endif /* DEBUG_KMEM */
|
2008-04-19 03:39:58 +04:00
|
|
|
|
2010-03-04 23:14:56 +03:00
|
|
|
SPL_PROC_HANDLER(proc_dohostid)
|
2008-04-19 03:39:58 +04:00
|
|
|
{
|
|
|
|
int len, rc = 0;
|
|
|
|
char *end, str[32];
|
2010-07-20 22:55:37 +04:00
|
|
|
SENTRY;
|
2008-04-19 03:39:58 +04:00
|
|
|
|
|
|
|
if (write) {
|
2010-03-04 23:14:56 +03:00
|
|
|
/* We can't use spl_proc_doulongvec_minmax() in the write
|
2011-04-25 05:48:56 +04:00
|
|
|
* case here because hostid while a hex value has no
|
2009-03-13 00:23:34 +03:00
|
|
|
* leading 0x which confuses the helper function. */
|
2008-04-19 03:39:58 +04:00
|
|
|
rc = proc_copyin_string(str, sizeof(str), buffer, *lenp);
|
|
|
|
if (rc < 0)
|
2010-07-20 22:55:37 +04:00
|
|
|
SRETURN(rc);
|
2008-04-19 03:39:58 +04:00
|
|
|
|
2011-04-11 23:49:50 +04:00
|
|
|
spl_hostid = simple_strtoul(str, &end, 16);
|
2009-03-13 00:23:34 +03:00
|
|
|
if (str == end)
|
2010-07-20 22:55:37 +04:00
|
|
|
SRETURN(-EINVAL);
|
2008-04-19 03:39:58 +04:00
|
|
|
|
|
|
|
} else {
|
2011-04-25 05:48:56 +04:00
|
|
|
len = snprintf(str, sizeof(str), "%lx", spl_hostid);
|
2008-04-19 03:39:58 +04:00
|
|
|
if (*ppos >= len)
|
|
|
|
rc = 0;
|
|
|
|
else
|
2010-03-04 23:14:56 +03:00
|
|
|
rc = proc_copyout_string(buffer,*lenp,str+*ppos,"\n");
|
2008-04-19 03:39:58 +04:00
|
|
|
|
|
|
|
if (rc >= 0) {
|
|
|
|
*lenp = rc;
|
|
|
|
*ppos += rc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-20 22:55:37 +04:00
|
|
|
SRETURN(rc);
|
2008-04-19 03:39:58 +04:00
|
|
|
}
|
|
|
|
|
2009-02-26 00:20:40 +03:00
|
|
|
#ifndef HAVE_KALLSYMS_LOOKUP_NAME
|
2010-03-04 23:14:56 +03:00
|
|
|
SPL_PROC_HANDLER(proc_dokallsyms_lookup_name)
|
|
|
|
{
|
2009-02-26 00:20:40 +03:00
|
|
|
int len, rc = 0;
|
|
|
|
char *end, str[32];
|
2010-07-20 22:55:37 +04:00
|
|
|
SENTRY;
|
2009-02-26 00:20:40 +03:00
|
|
|
|
|
|
|
if (write) {
|
|
|
|
/* This may only be set once at module load time */
|
2009-05-20 21:08:37 +04:00
|
|
|
if (spl_kallsyms_lookup_name_fn != SYMBOL_POISON)
|
2010-07-20 22:55:37 +04:00
|
|
|
SRETURN(-EEXIST);
|
2009-02-26 00:20:40 +03:00
|
|
|
|
2010-03-04 23:14:56 +03:00
|
|
|
/* We can't use spl_proc_doulongvec_minmax() in the write
|
2011-04-25 05:48:56 +04:00
|
|
|
* case here because the address while a hex value has no
|
2009-02-26 00:20:40 +03:00
|
|
|
* leading 0x which confuses the helper function. */
|
|
|
|
rc = proc_copyin_string(str, sizeof(str), buffer, *lenp);
|
|
|
|
if (rc < 0)
|
2010-07-20 22:55:37 +04:00
|
|
|
SRETURN(rc);
|
2009-02-26 00:20:40 +03:00
|
|
|
|
|
|
|
spl_kallsyms_lookup_name_fn =
|
|
|
|
(kallsyms_lookup_name_t)simple_strtoul(str, &end, 16);
|
2012-12-19 05:02:27 +04:00
|
|
|
wake_up(&spl_kallsyms_lookup_name_waitq);
|
|
|
|
|
2009-02-26 00:20:40 +03:00
|
|
|
if (str == end)
|
2010-07-20 22:55:37 +04:00
|
|
|
SRETURN(-EINVAL);
|
2009-02-26 00:20:40 +03:00
|
|
|
|
|
|
|
*ppos += *lenp;
|
|
|
|
} else {
|
|
|
|
len = snprintf(str, sizeof(str), "%lx",
|
|
|
|
(unsigned long)spl_kallsyms_lookup_name_fn);
|
|
|
|
if (*ppos >= len)
|
|
|
|
rc = 0;
|
|
|
|
else
|
|
|
|
rc = proc_copyout_string(buffer,*lenp,str+*ppos,"\n");
|
|
|
|
|
|
|
|
if (rc >= 0) {
|
|
|
|
*lenp = rc;
|
|
|
|
*ppos += rc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-20 22:55:37 +04:00
|
|
|
SRETURN(rc);
|
2009-02-26 00:20:40 +03:00
|
|
|
}
|
|
|
|
#endif /* HAVE_KALLSYMS_LOOKUP_NAME */
|
|
|
|
|
2010-03-04 23:14:56 +03:00
|
|
|
SPL_PROC_HANDLER(proc_doavailrmem)
|
2009-02-05 23:26:34 +03:00
|
|
|
{
|
|
|
|
int len, rc = 0;
|
|
|
|
char str[32];
|
2010-07-20 22:55:37 +04:00
|
|
|
SENTRY;
|
2009-02-05 23:26:34 +03:00
|
|
|
|
|
|
|
if (write) {
|
|
|
|
*ppos += *lenp;
|
|
|
|
} else {
|
2010-03-04 23:14:56 +03:00
|
|
|
len = snprintf(str, sizeof(str), "%lu",
|
|
|
|
(unsigned long)availrmem);
|
2009-02-05 23:26:34 +03:00
|
|
|
if (*ppos >= len)
|
|
|
|
rc = 0;
|
|
|
|
else
|
2010-03-04 23:14:56 +03:00
|
|
|
rc = proc_copyout_string(buffer,*lenp,str+*ppos,"\n");
|
2009-02-05 23:26:34 +03:00
|
|
|
|
|
|
|
if (rc >= 0) {
|
|
|
|
*lenp = rc;
|
|
|
|
*ppos += rc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-20 22:55:37 +04:00
|
|
|
SRETURN(rc);
|
2009-02-05 23:26:34 +03:00
|
|
|
}
|
|
|
|
|
2010-03-04 23:14:56 +03:00
|
|
|
SPL_PROC_HANDLER(proc_dofreemem)
|
2009-02-05 23:26:34 +03:00
|
|
|
{
|
|
|
|
int len, rc = 0;
|
|
|
|
char str[32];
|
2010-07-20 22:55:37 +04:00
|
|
|
SENTRY;
|
2009-02-05 23:26:34 +03:00
|
|
|
|
|
|
|
if (write) {
|
|
|
|
*ppos += *lenp;
|
|
|
|
} else {
|
|
|
|
len = snprintf(str, sizeof(str), "%lu", (unsigned long)freemem);
|
|
|
|
if (*ppos >= len)
|
|
|
|
rc = 0;
|
|
|
|
else
|
2010-03-04 23:14:56 +03:00
|
|
|
rc = proc_copyout_string(buffer,*lenp,str+*ppos,"\n");
|
2009-02-05 23:26:34 +03:00
|
|
|
|
|
|
|
if (rc >= 0) {
|
|
|
|
*lenp = rc;
|
|
|
|
*ppos += rc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-20 22:55:37 +04:00
|
|
|
SRETURN(rc);
|
2009-02-05 23:26:34 +03:00
|
|
|
}
|
|
|
|
|
2008-06-28 01:40:11 +04:00
|
|
|
#ifdef DEBUG_KMEM
|
|
|
|
static void
|
|
|
|
slab_seq_show_headers(struct seq_file *f)
|
|
|
|
{
|
2011-03-26 07:50:40 +03:00
|
|
|
seq_printf(f,
|
|
|
|
"--------------------- cache ----------"
|
|
|
|
"--------------------------------------------- "
|
|
|
|
"----- slab ------ "
|
2012-10-30 03:51:59 +04:00
|
|
|
"---- object ----- "
|
|
|
|
"--- emergency ---\n");
|
2011-03-26 07:50:40 +03:00
|
|
|
seq_printf(f,
|
|
|
|
"name "
|
|
|
|
" flags size alloc slabsize objsize "
|
|
|
|
"total alloc max "
|
2012-10-30 03:51:59 +04:00
|
|
|
"total alloc max "
|
|
|
|
"dlock alloc max\n");
|
2008-06-28 01:40:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
slab_seq_show(struct seq_file *f, void *p)
|
|
|
|
{
|
2009-12-11 22:20:08 +03:00
|
|
|
spl_kmem_cache_t *skc = p;
|
2008-06-28 01:40:11 +04:00
|
|
|
|
2009-12-11 22:20:08 +03:00
|
|
|
ASSERT(skc->skc_magic == SKC_MAGIC);
|
2008-06-28 01:40:11 +04:00
|
|
|
|
2013-12-09 02:01:45 +04:00
|
|
|
/*
|
|
|
|
* Backed by Linux slab see /proc/slabinfo.
|
|
|
|
*/
|
|
|
|
if (skc->skc_flags & KMC_SLAB)
|
|
|
|
return (0);
|
|
|
|
|
2009-12-11 22:20:08 +03:00
|
|
|
spin_lock(&skc->skc_lock);
|
2011-03-26 07:50:40 +03:00
|
|
|
seq_printf(f, "%-36s ", skc->skc_name);
|
|
|
|
seq_printf(f, "0x%05lx %9lu %9lu %8u %8u "
|
2012-10-30 03:51:59 +04:00
|
|
|
"%5lu %5lu %5lu %5lu %5lu %5lu %5lu %5lu %5lu\n",
|
2011-03-26 07:50:40 +03:00
|
|
|
(long unsigned)skc->skc_flags,
|
|
|
|
(long unsigned)(skc->skc_slab_size * skc->skc_slab_total),
|
|
|
|
(long unsigned)(skc->skc_obj_size * skc->skc_obj_alloc),
|
|
|
|
(unsigned)skc->skc_slab_size,
|
|
|
|
(unsigned)skc->skc_obj_size,
|
|
|
|
(long unsigned)skc->skc_slab_total,
|
|
|
|
(long unsigned)skc->skc_slab_alloc,
|
|
|
|
(long unsigned)skc->skc_slab_max,
|
|
|
|
(long unsigned)skc->skc_obj_total,
|
|
|
|
(long unsigned)skc->skc_obj_alloc,
|
Emergency slab objects
This patch is designed to resolve a deadlock which can occur with
__vmalloc() based slabs. The issue is that the Linux kernel does
not honor the flags passed to __vmalloc(). This makes it unsafe
to use in a writeback context. Unfortunately, this is a use case
ZFS depends on for correct operation.
Fixing this issue in the upstream kernel was pursued and patches
are available which resolve the issue.
https://bugs.gentoo.org/show_bug.cgi?id=416685
However, these changes were rejected because upstream felt that
using __vmalloc() in the context of writeback should never be done.
Their solution was for us to rewrite parts of ZFS to accomidate
the Linux VM.
While that is probably the right long term solution, and it is
something we want to pursue, it is not a trivial task and will
likely destabilize the existing code. This work has been planned
for the 0.7.0 release but in the meanwhile we want to improve the
SPL slab implementation to accomidate this expected ZFS usage.
This is accomplished by performing the __vmalloc() asynchronously
in the context of a work queue. This doesn't prevent the posibility
of the worker thread from deadlocking. However, the caller can now
safely block on a wait queue for the slab allocation to complete.
Normally this will occur in a reasonable amount of time and the
caller will be woken up when the new slab is available,. The objects
will then get cached in the per-cpu magazines and everything will
proceed as usual.
However, if the __vmalloc() deadlocks for the reasons described
above, or is just very slow, then the callers on the wait queues
will timeout out. When this rare situation occurs they will attempt
to kmalloc() a single minimally sized object using the GFP_NOIO flags.
This allocation will not deadlock because kmalloc() will honor the
passed flags and the caller will be able to make forward progress.
As long as forward progress can be maintained then even if the
worker thread is deadlocked the critical thread will make progress.
This will eventually allow the deadlocked worker thread to complete
and normal operation will resume.
These emergency allocations will likely be slow since they require
contiguous pages. However, their use should be rare so the impact
is expected to be minimal. If that turns out not to be the case in
practice further optimizations are possible.
One additional concern is if these emergency objects are long lived.
Right now they are simply tracked on a list which must be walked when
an object is freed. Is they accumulate on a system and the list
grows freeing objects will become more expensive. This could be
handled relatively easily by using a hash instead of a list, but that
optimization (if needed) is left for a follow up patch.
Additionally, these emeregency objects could be repacked in to existing
slabs as objects are freed if the kmem_cache_set_move() functionality
was implemented. See issue https://github.com/zfsonlinux/spl/issues/26
for full details. This work would also help reduce ZFS's memory
fragmentation problems.
The /proc/spl/kmem/slab file has had two new columns added at the
end. The 'emerg' column reports the current number of these emergency
objects in use for the cache, and the following 'max' column shows
the historical worst case. These value should give us a good idea
of how often these objects are needed. Based on these values under
real use cases we can tune the default behavior.
Lastly, as a side benefit using a single work queue for the slab
allocations should reduce cpu contention on the global virtual address
space lock. This should manifest itself as reduced cpu usage for
the system.
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
2012-08-08 03:59:50 +04:00
|
|
|
(long unsigned)skc->skc_obj_max,
|
2012-10-30 03:51:59 +04:00
|
|
|
(long unsigned)skc->skc_obj_deadlock,
|
Emergency slab objects
This patch is designed to resolve a deadlock which can occur with
__vmalloc() based slabs. The issue is that the Linux kernel does
not honor the flags passed to __vmalloc(). This makes it unsafe
to use in a writeback context. Unfortunately, this is a use case
ZFS depends on for correct operation.
Fixing this issue in the upstream kernel was pursued and patches
are available which resolve the issue.
https://bugs.gentoo.org/show_bug.cgi?id=416685
However, these changes were rejected because upstream felt that
using __vmalloc() in the context of writeback should never be done.
Their solution was for us to rewrite parts of ZFS to accomidate
the Linux VM.
While that is probably the right long term solution, and it is
something we want to pursue, it is not a trivial task and will
likely destabilize the existing code. This work has been planned
for the 0.7.0 release but in the meanwhile we want to improve the
SPL slab implementation to accomidate this expected ZFS usage.
This is accomplished by performing the __vmalloc() asynchronously
in the context of a work queue. This doesn't prevent the posibility
of the worker thread from deadlocking. However, the caller can now
safely block on a wait queue for the slab allocation to complete.
Normally this will occur in a reasonable amount of time and the
caller will be woken up when the new slab is available,. The objects
will then get cached in the per-cpu magazines and everything will
proceed as usual.
However, if the __vmalloc() deadlocks for the reasons described
above, or is just very slow, then the callers on the wait queues
will timeout out. When this rare situation occurs they will attempt
to kmalloc() a single minimally sized object using the GFP_NOIO flags.
This allocation will not deadlock because kmalloc() will honor the
passed flags and the caller will be able to make forward progress.
As long as forward progress can be maintained then even if the
worker thread is deadlocked the critical thread will make progress.
This will eventually allow the deadlocked worker thread to complete
and normal operation will resume.
These emergency allocations will likely be slow since they require
contiguous pages. However, their use should be rare so the impact
is expected to be minimal. If that turns out not to be the case in
practice further optimizations are possible.
One additional concern is if these emergency objects are long lived.
Right now they are simply tracked on a list which must be walked when
an object is freed. Is they accumulate on a system and the list
grows freeing objects will become more expensive. This could be
handled relatively easily by using a hash instead of a list, but that
optimization (if needed) is left for a follow up patch.
Additionally, these emeregency objects could be repacked in to existing
slabs as objects are freed if the kmem_cache_set_move() functionality
was implemented. See issue https://github.com/zfsonlinux/spl/issues/26
for full details. This work would also help reduce ZFS's memory
fragmentation problems.
The /proc/spl/kmem/slab file has had two new columns added at the
end. The 'emerg' column reports the current number of these emergency
objects in use for the cache, and the following 'max' column shows
the historical worst case. These value should give us a good idea
of how often these objects are needed. Based on these values under
real use cases we can tune the default behavior.
Lastly, as a side benefit using a single work queue for the slab
allocations should reduce cpu contention on the global virtual address
space lock. This should manifest itself as reduced cpu usage for
the system.
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
2012-08-08 03:59:50 +04:00
|
|
|
(long unsigned)skc->skc_obj_emergency,
|
|
|
|
(long unsigned)skc->skc_obj_emergency_max);
|
2009-12-11 22:20:08 +03:00
|
|
|
|
|
|
|
spin_unlock(&skc->skc_lock);
|
2008-06-28 01:40:11 +04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void *
|
|
|
|
slab_seq_start(struct seq_file *f, loff_t *pos)
|
|
|
|
{
|
|
|
|
struct list_head *p;
|
|
|
|
loff_t n = *pos;
|
2010-07-20 22:55:37 +04:00
|
|
|
SENTRY;
|
2008-06-28 01:40:11 +04:00
|
|
|
|
|
|
|
down_read(&spl_kmem_cache_sem);
|
|
|
|
if (!n)
|
|
|
|
slab_seq_show_headers(f);
|
|
|
|
|
|
|
|
p = spl_kmem_cache_list.next;
|
|
|
|
while (n--) {
|
|
|
|
p = p->next;
|
|
|
|
if (p == &spl_kmem_cache_list)
|
2010-07-20 22:55:37 +04:00
|
|
|
SRETURN(NULL);
|
2008-06-28 01:40:11 +04:00
|
|
|
}
|
|
|
|
|
2010-07-20 22:55:37 +04:00
|
|
|
SRETURN(list_entry(p, spl_kmem_cache_t, skc_list));
|
2008-06-28 01:40:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void *
|
|
|
|
slab_seq_next(struct seq_file *f, void *p, loff_t *pos)
|
|
|
|
{
|
|
|
|
spl_kmem_cache_t *skc = p;
|
2010-07-20 22:55:37 +04:00
|
|
|
SENTRY;
|
2008-06-28 01:40:11 +04:00
|
|
|
|
|
|
|
++*pos;
|
2010-07-20 22:55:37 +04:00
|
|
|
SRETURN((skc->skc_list.next == &spl_kmem_cache_list) ?
|
2010-03-04 23:14:56 +03:00
|
|
|
NULL : list_entry(skc->skc_list.next,spl_kmem_cache_t,skc_list));
|
2008-06-28 01:40:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
slab_seq_stop(struct seq_file *f, void *v)
|
|
|
|
{
|
|
|
|
up_read(&spl_kmem_cache_sem);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct seq_operations slab_seq_ops = {
|
|
|
|
.show = slab_seq_show,
|
|
|
|
.start = slab_seq_start,
|
|
|
|
.next = slab_seq_next,
|
|
|
|
.stop = slab_seq_stop,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
|
|
|
proc_slab_open(struct inode *inode, struct file *filp)
|
|
|
|
{
|
|
|
|
return seq_open(filp, &slab_seq_ops);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct file_operations proc_slab_operations = {
|
|
|
|
.open = proc_slab_open,
|
|
|
|
.read = seq_read,
|
|
|
|
.llseek = seq_lseek,
|
|
|
|
.release = seq_release,
|
|
|
|
};
|
|
|
|
#endif /* DEBUG_KMEM */
|
|
|
|
|
2012-01-21 04:39:12 +04:00
|
|
|
#ifdef DEBUG_LOG
|
2008-05-06 00:18:49 +04:00
|
|
|
static struct ctl_table spl_debug_table[] = {
|
2008-04-19 03:39:58 +04:00
|
|
|
{
|
2010-06-30 21:36:20 +04:00
|
|
|
CTL_NAME (CTL_DEBUG_SUBSYS)
|
2008-05-06 00:18:49 +04:00
|
|
|
.procname = "subsystem",
|
2008-04-19 03:39:58 +04:00
|
|
|
.data = &spl_debug_subsys,
|
|
|
|
.maxlen = sizeof(unsigned long),
|
|
|
|
.mode = 0644,
|
|
|
|
.proc_handler = &proc_dobitmasks
|
|
|
|
},
|
|
|
|
{
|
2010-06-30 21:36:20 +04:00
|
|
|
CTL_NAME (CTL_DEBUG_MASK)
|
2008-05-06 00:18:49 +04:00
|
|
|
.procname = "mask",
|
2008-04-19 03:39:58 +04:00
|
|
|
.data = &spl_debug_mask,
|
|
|
|
.maxlen = sizeof(unsigned long),
|
|
|
|
.mode = 0644,
|
|
|
|
.proc_handler = &proc_dobitmasks
|
|
|
|
},
|
|
|
|
{
|
2010-06-30 21:36:20 +04:00
|
|
|
CTL_NAME (CTL_DEBUG_PRINTK)
|
2008-05-06 00:18:49 +04:00
|
|
|
.procname = "printk",
|
2008-04-19 03:39:58 +04:00
|
|
|
.data = &spl_debug_printk,
|
|
|
|
.maxlen = sizeof(unsigned long),
|
|
|
|
.mode = 0644,
|
|
|
|
.proc_handler = &proc_dobitmasks
|
|
|
|
},
|
|
|
|
{
|
2010-06-30 21:36:20 +04:00
|
|
|
CTL_NAME (CTL_DEBUG_MB)
|
2008-05-06 00:18:49 +04:00
|
|
|
.procname = "mb",
|
2008-04-19 03:39:58 +04:00
|
|
|
.mode = 0644,
|
|
|
|
.proc_handler = &proc_debug_mb,
|
|
|
|
},
|
|
|
|
{
|
2010-06-30 21:36:20 +04:00
|
|
|
CTL_NAME (CTL_DEBUG_BINARY)
|
2008-05-06 00:18:49 +04:00
|
|
|
.procname = "binary",
|
2008-04-19 03:39:58 +04:00
|
|
|
.data = &spl_debug_binary,
|
|
|
|
.maxlen = sizeof(int),
|
|
|
|
.mode = 0644,
|
|
|
|
.proc_handler = &proc_dointvec,
|
|
|
|
},
|
|
|
|
{
|
2010-06-30 21:36:20 +04:00
|
|
|
CTL_NAME (CTL_DEBUG_CATASTROPHE)
|
2008-04-19 03:39:58 +04:00
|
|
|
.procname = "catastrophe",
|
|
|
|
.data = &spl_debug_catastrophe,
|
|
|
|
.maxlen = sizeof(int),
|
|
|
|
.mode = 0444,
|
|
|
|
.proc_handler = &proc_dointvec,
|
|
|
|
},
|
|
|
|
{
|
2010-06-30 21:36:20 +04:00
|
|
|
CTL_NAME (CTL_DEBUG_PANIC_ON_BUG)
|
2008-04-19 03:39:58 +04:00
|
|
|
.procname = "panic_on_bug",
|
|
|
|
.data = &spl_debug_panic_on_bug,
|
|
|
|
.maxlen = sizeof(int),
|
|
|
|
.mode = 0644,
|
|
|
|
.proc_handler = &proc_dointvec
|
|
|
|
},
|
|
|
|
{
|
2010-06-30 21:36:20 +04:00
|
|
|
CTL_NAME (CTL_DEBUG_PATH)
|
2008-05-06 00:18:49 +04:00
|
|
|
.procname = "path",
|
2008-04-19 03:39:58 +04:00
|
|
|
.data = spl_debug_file_path,
|
|
|
|
.maxlen = sizeof(spl_debug_file_path),
|
|
|
|
.mode = 0644,
|
|
|
|
.proc_handler = &proc_dostring,
|
|
|
|
},
|
|
|
|
{
|
2010-06-30 21:36:20 +04:00
|
|
|
CTL_NAME (CTL_DEBUG_DUMP)
|
2008-05-06 00:18:49 +04:00
|
|
|
.procname = "dump",
|
2008-04-19 03:39:58 +04:00
|
|
|
.mode = 0200,
|
|
|
|
.proc_handler = &proc_dump_kernel,
|
|
|
|
},
|
2010-06-30 21:36:20 +04:00
|
|
|
{ CTL_NAME (CTL_DEBUG_FORCE_BUG)
|
2008-04-19 03:39:58 +04:00
|
|
|
.procname = "force_bug",
|
|
|
|
.mode = 0200,
|
|
|
|
.proc_handler = &proc_force_bug,
|
|
|
|
},
|
|
|
|
{
|
2010-06-30 21:36:20 +04:00
|
|
|
CTL_NAME (CTL_CONSOLE_RATELIMIT)
|
2008-04-19 03:39:58 +04:00
|
|
|
.procname = "console_ratelimit",
|
|
|
|
.data = &spl_console_ratelimit,
|
|
|
|
.maxlen = sizeof(int),
|
|
|
|
.mode = 0644,
|
|
|
|
.proc_handler = &proc_dointvec,
|
|
|
|
},
|
|
|
|
{
|
2010-06-30 21:36:20 +04:00
|
|
|
CTL_NAME (CTL_CONSOLE_MAX_DELAY_CS)
|
2008-04-19 03:39:58 +04:00
|
|
|
.procname = "console_max_delay_centisecs",
|
|
|
|
.maxlen = sizeof(int),
|
|
|
|
.mode = 0644,
|
|
|
|
.proc_handler = &proc_console_max_delay_cs,
|
|
|
|
},
|
|
|
|
{
|
2010-06-30 21:36:20 +04:00
|
|
|
CTL_NAME (CTL_CONSOLE_MIN_DELAY_CS)
|
2008-04-19 03:39:58 +04:00
|
|
|
.procname = "console_min_delay_centisecs",
|
|
|
|
.maxlen = sizeof(int),
|
|
|
|
.mode = 0644,
|
|
|
|
.proc_handler = &proc_console_min_delay_cs,
|
|
|
|
},
|
|
|
|
{
|
2010-06-30 21:36:20 +04:00
|
|
|
CTL_NAME (CTL_CONSOLE_BACKOFF)
|
2008-04-19 03:39:58 +04:00
|
|
|
.procname = "console_backoff",
|
|
|
|
.maxlen = sizeof(int),
|
|
|
|
.mode = 0644,
|
|
|
|
.proc_handler = &proc_console_backoff,
|
|
|
|
},
|
|
|
|
{
|
2010-06-30 21:36:20 +04:00
|
|
|
CTL_NAME (CTL_DEBUG_STACK_SIZE)
|
2008-04-19 03:39:58 +04:00
|
|
|
.procname = "stack_max",
|
|
|
|
.data = &spl_debug_stack,
|
|
|
|
.maxlen = sizeof(int),
|
|
|
|
.mode = 0444,
|
|
|
|
.proc_handler = &proc_dointvec,
|
|
|
|
},
|
2008-05-06 00:18:49 +04:00
|
|
|
{0},
|
|
|
|
};
|
2012-01-21 04:39:12 +04:00
|
|
|
#endif /* DEBUG_LOG */
|
2008-05-06 00:18:49 +04:00
|
|
|
|
2009-02-05 02:15:41 +03:00
|
|
|
static struct ctl_table spl_vm_table[] = {
|
|
|
|
{
|
2010-06-30 21:36:20 +04:00
|
|
|
CTL_NAME (CTL_VM_MINFREE)
|
2009-02-05 02:15:41 +03:00
|
|
|
.procname = "minfree",
|
|
|
|
.data = &minfree,
|
|
|
|
.maxlen = sizeof(int),
|
|
|
|
.mode = 0644,
|
|
|
|
.proc_handler = &proc_dointvec,
|
|
|
|
},
|
|
|
|
{
|
2010-06-30 21:36:20 +04:00
|
|
|
CTL_NAME (CTL_VM_DESFREE)
|
2009-02-05 02:15:41 +03:00
|
|
|
.procname = "desfree",
|
|
|
|
.data = &desfree,
|
|
|
|
.maxlen = sizeof(int),
|
|
|
|
.mode = 0644,
|
|
|
|
.proc_handler = &proc_dointvec,
|
|
|
|
},
|
|
|
|
{
|
2010-06-30 21:36:20 +04:00
|
|
|
CTL_NAME (CTL_VM_LOTSFREE)
|
2009-02-05 02:15:41 +03:00
|
|
|
.procname = "lotsfree",
|
|
|
|
.data = &lotsfree,
|
|
|
|
.maxlen = sizeof(int),
|
|
|
|
.mode = 0644,
|
|
|
|
.proc_handler = &proc_dointvec,
|
|
|
|
},
|
|
|
|
{
|
2010-06-30 21:36:20 +04:00
|
|
|
CTL_NAME (CTL_VM_NEEDFREE)
|
2009-02-05 02:15:41 +03:00
|
|
|
.procname = "needfree",
|
|
|
|
.data = &needfree,
|
|
|
|
.maxlen = sizeof(int),
|
|
|
|
.mode = 0444,
|
|
|
|
.proc_handler = &proc_dointvec,
|
|
|
|
},
|
|
|
|
{
|
2010-06-30 21:36:20 +04:00
|
|
|
CTL_NAME (CTL_VM_SWAPFS_MINFREE)
|
2009-02-05 02:15:41 +03:00
|
|
|
.procname = "swapfs_minfree",
|
|
|
|
.data = &swapfs_minfree,
|
|
|
|
.maxlen = sizeof(int),
|
|
|
|
.mode = 0644,
|
|
|
|
.proc_handler = &proc_dointvec,
|
|
|
|
},
|
|
|
|
{
|
2010-06-30 21:36:20 +04:00
|
|
|
CTL_NAME (CTL_VM_SWAPFS_RESERVE)
|
2009-02-05 02:15:41 +03:00
|
|
|
.procname = "swapfs_reserve",
|
|
|
|
.data = &swapfs_reserve,
|
|
|
|
.maxlen = sizeof(int),
|
|
|
|
.mode = 0644,
|
|
|
|
.proc_handler = &proc_dointvec,
|
|
|
|
},
|
|
|
|
{
|
2010-06-30 21:36:20 +04:00
|
|
|
CTL_NAME (CTL_VM_AVAILRMEM)
|
2009-02-05 02:15:41 +03:00
|
|
|
.procname = "availrmem",
|
2009-02-05 23:26:34 +03:00
|
|
|
.mode = 0444,
|
|
|
|
.proc_handler = &proc_doavailrmem,
|
|
|
|
},
|
|
|
|
{
|
2010-06-30 21:36:20 +04:00
|
|
|
CTL_NAME (CTL_VM_FREEMEM)
|
2009-02-05 23:26:34 +03:00
|
|
|
.procname = "freemem",
|
|
|
|
.data = (void *)2,
|
|
|
|
.maxlen = sizeof(int),
|
|
|
|
.mode = 0444,
|
|
|
|
.proc_handler = &proc_dofreemem,
|
|
|
|
},
|
|
|
|
{
|
2010-06-30 21:36:20 +04:00
|
|
|
CTL_NAME (CTL_VM_PHYSMEM)
|
2009-02-05 23:26:34 +03:00
|
|
|
.procname = "physmem",
|
|
|
|
.data = &physmem,
|
2009-02-05 02:15:41 +03:00
|
|
|
.maxlen = sizeof(int),
|
|
|
|
.mode = 0444,
|
|
|
|
.proc_handler = &proc_dointvec,
|
|
|
|
},
|
|
|
|
{0},
|
|
|
|
};
|
|
|
|
|
2008-04-19 03:39:58 +04:00
|
|
|
#ifdef DEBUG_KMEM
|
2008-05-06 00:18:49 +04:00
|
|
|
static struct ctl_table spl_kmem_table[] = {
|
2008-04-19 03:39:58 +04:00
|
|
|
{
|
2010-06-30 21:36:20 +04:00
|
|
|
CTL_NAME (CTL_KMEM_KMEMUSED)
|
2008-04-19 03:39:58 +04:00
|
|
|
.procname = "kmem_used",
|
|
|
|
.data = &kmem_alloc_used,
|
2009-12-05 02:54:12 +03:00
|
|
|
# ifdef HAVE_ATOMIC64_T
|
2008-04-19 03:39:58 +04:00
|
|
|
.maxlen = sizeof(atomic64_t),
|
2009-12-05 02:54:12 +03:00
|
|
|
# else
|
|
|
|
.maxlen = sizeof(atomic_t),
|
|
|
|
# endif /* HAVE_ATOMIC64_T */
|
2008-04-19 03:39:58 +04:00
|
|
|
.mode = 0444,
|
2009-12-05 02:54:12 +03:00
|
|
|
.proc_handler = &proc_domemused,
|
2008-04-19 03:39:58 +04:00
|
|
|
},
|
|
|
|
{
|
2010-06-30 21:36:20 +04:00
|
|
|
CTL_NAME (CTL_KMEM_KMEMMAX)
|
2008-04-19 03:39:58 +04:00
|
|
|
.procname = "kmem_max",
|
|
|
|
.data = &kmem_alloc_max,
|
|
|
|
.maxlen = sizeof(unsigned long),
|
|
|
|
.extra1 = &table_min,
|
|
|
|
.extra2 = &table_max,
|
|
|
|
.mode = 0444,
|
|
|
|
.proc_handler = &proc_doulongvec_minmax,
|
|
|
|
},
|
|
|
|
{
|
2010-06-30 21:36:20 +04:00
|
|
|
CTL_NAME (CTL_KMEM_VMEMUSED)
|
2008-04-19 03:39:58 +04:00
|
|
|
.procname = "vmem_used",
|
|
|
|
.data = &vmem_alloc_used,
|
2009-12-05 02:54:12 +03:00
|
|
|
# ifdef HAVE_ATOMIC64_T
|
2008-04-19 03:39:58 +04:00
|
|
|
.maxlen = sizeof(atomic64_t),
|
2009-12-05 02:54:12 +03:00
|
|
|
# else
|
|
|
|
.maxlen = sizeof(atomic_t),
|
|
|
|
# endif /* HAVE_ATOMIC64_T */
|
2008-04-19 03:39:58 +04:00
|
|
|
.mode = 0444,
|
2009-12-05 02:54:12 +03:00
|
|
|
.proc_handler = &proc_domemused,
|
2008-04-19 03:39:58 +04:00
|
|
|
},
|
|
|
|
{
|
2010-06-30 21:36:20 +04:00
|
|
|
CTL_NAME (CTL_KMEM_VMEMMAX)
|
2008-04-19 03:39:58 +04:00
|
|
|
.procname = "vmem_max",
|
|
|
|
.data = &vmem_alloc_max,
|
|
|
|
.maxlen = sizeof(unsigned long),
|
|
|
|
.extra1 = &table_min,
|
|
|
|
.extra2 = &table_max,
|
|
|
|
.mode = 0444,
|
|
|
|
.proc_handler = &proc_doulongvec_minmax,
|
|
|
|
},
|
2011-03-26 10:03:32 +03:00
|
|
|
{
|
|
|
|
CTL_NAME (CTL_KMEM_SLAB_KMEMTOTAL)
|
|
|
|
.procname = "slab_kmem_total",
|
|
|
|
.data = (void *)(KMC_KMEM | KMC_TOTAL),
|
|
|
|
.maxlen = sizeof(unsigned long),
|
|
|
|
.extra1 = &table_min,
|
|
|
|
.extra2 = &table_max,
|
|
|
|
.mode = 0444,
|
|
|
|
.proc_handler = &proc_doslab,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
CTL_NAME (CTL_KMEM_SLAB_KMEMALLOC)
|
|
|
|
.procname = "slab_kmem_alloc",
|
|
|
|
.data = (void *)(KMC_KMEM | KMC_ALLOC),
|
|
|
|
.maxlen = sizeof(unsigned long),
|
|
|
|
.extra1 = &table_min,
|
|
|
|
.extra2 = &table_max,
|
|
|
|
.mode = 0444,
|
|
|
|
.proc_handler = &proc_doslab,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
CTL_NAME (CTL_KMEM_SLAB_KMEMMAX)
|
|
|
|
.procname = "slab_kmem_max",
|
|
|
|
.data = (void *)(KMC_KMEM | KMC_MAX),
|
|
|
|
.maxlen = sizeof(unsigned long),
|
|
|
|
.extra1 = &table_min,
|
|
|
|
.extra2 = &table_max,
|
|
|
|
.mode = 0444,
|
|
|
|
.proc_handler = &proc_doslab,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
CTL_NAME (CTL_KMEM_SLAB_VMEMTOTAL)
|
|
|
|
.procname = "slab_vmem_total",
|
|
|
|
.data = (void *)(KMC_VMEM | KMC_TOTAL),
|
|
|
|
.maxlen = sizeof(unsigned long),
|
|
|
|
.extra1 = &table_min,
|
|
|
|
.extra2 = &table_max,
|
|
|
|
.mode = 0444,
|
|
|
|
.proc_handler = &proc_doslab,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
CTL_NAME (CTL_KMEM_SLAB_VMEMALLOC)
|
|
|
|
.procname = "slab_vmem_alloc",
|
|
|
|
.data = (void *)(KMC_VMEM | KMC_ALLOC),
|
|
|
|
.maxlen = sizeof(unsigned long),
|
|
|
|
.extra1 = &table_min,
|
|
|
|
.extra2 = &table_max,
|
|
|
|
.mode = 0444,
|
|
|
|
.proc_handler = &proc_doslab,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
CTL_NAME (CTL_KMEM_SLAB_VMEMMAX)
|
|
|
|
.procname = "slab_vmem_max",
|
|
|
|
.data = (void *)(KMC_VMEM | KMC_MAX),
|
|
|
|
.maxlen = sizeof(unsigned long),
|
|
|
|
.extra1 = &table_min,
|
|
|
|
.extra2 = &table_max,
|
|
|
|
.mode = 0444,
|
|
|
|
.proc_handler = &proc_doslab,
|
|
|
|
},
|
2008-05-06 00:18:49 +04:00
|
|
|
{0},
|
|
|
|
};
|
2008-05-09 03:21:47 +04:00
|
|
|
#endif /* DEBUG_KMEM */
|
|
|
|
|
|
|
|
static struct ctl_table spl_kstat_table[] = {
|
|
|
|
{0},
|
|
|
|
};
|
2008-05-06 00:18:49 +04:00
|
|
|
|
|
|
|
static struct ctl_table spl_table[] = {
|
|
|
|
/* NB No .strategy entries have been provided since
|
|
|
|
* sysctl(8) prefers to go via /proc for portability.
|
|
|
|
*/
|
|
|
|
{
|
2010-06-30 21:36:20 +04:00
|
|
|
CTL_NAME (CTL_VERSION)
|
2008-05-06 00:18:49 +04:00
|
|
|
.procname = "version",
|
|
|
|
.data = spl_version,
|
|
|
|
.maxlen = sizeof(spl_version),
|
|
|
|
.mode = 0444,
|
|
|
|
.proc_handler = &proc_dostring,
|
|
|
|
},
|
2008-04-19 03:39:58 +04:00
|
|
|
{
|
2010-06-30 21:36:20 +04:00
|
|
|
CTL_NAME (CTL_HOSTID)
|
2008-04-19 03:39:58 +04:00
|
|
|
.procname = "hostid",
|
|
|
|
.data = &spl_hostid,
|
|
|
|
.maxlen = sizeof(unsigned long),
|
|
|
|
.mode = 0644,
|
|
|
|
.proc_handler = &proc_dohostid,
|
|
|
|
},
|
2009-02-26 00:20:40 +03:00
|
|
|
#ifndef HAVE_KALLSYMS_LOOKUP_NAME
|
|
|
|
{
|
2010-06-30 21:36:20 +04:00
|
|
|
CTL_NAME (CTL_KALLSYMS)
|
2009-02-26 00:20:40 +03:00
|
|
|
.procname = "kallsyms_lookup_name",
|
|
|
|
.data = &spl_kallsyms_lookup_name_fn,
|
|
|
|
.maxlen = sizeof(unsigned long),
|
|
|
|
.mode = 0644,
|
|
|
|
.proc_handler = &proc_dokallsyms_lookup_name,
|
|
|
|
},
|
|
|
|
#endif
|
2012-01-21 04:39:12 +04:00
|
|
|
#ifdef DEBUG_LOG
|
2008-05-06 00:18:49 +04:00
|
|
|
{
|
2010-06-30 21:36:20 +04:00
|
|
|
CTL_NAME (CTL_SPL_DEBUG)
|
2008-05-06 00:18:49 +04:00
|
|
|
.procname = "debug",
|
|
|
|
.mode = 0555,
|
|
|
|
.child = spl_debug_table,
|
|
|
|
},
|
2012-01-21 04:39:12 +04:00
|
|
|
#endif
|
2009-02-05 02:15:41 +03:00
|
|
|
{
|
2010-06-30 21:36:20 +04:00
|
|
|
CTL_NAME (CTL_SPL_VM)
|
2009-02-05 02:15:41 +03:00
|
|
|
.procname = "vm",
|
|
|
|
.mode = 0555,
|
|
|
|
.child = spl_vm_table,
|
|
|
|
},
|
2008-05-06 00:18:49 +04:00
|
|
|
#ifdef DEBUG_KMEM
|
|
|
|
{
|
2010-06-30 21:36:20 +04:00
|
|
|
CTL_NAME (CTL_SPL_KMEM)
|
2008-05-06 00:18:49 +04:00
|
|
|
.procname = "kmem",
|
|
|
|
.mode = 0555,
|
|
|
|
.child = spl_kmem_table,
|
|
|
|
},
|
2008-05-09 03:21:47 +04:00
|
|
|
#endif
|
|
|
|
{
|
2010-06-30 21:36:20 +04:00
|
|
|
CTL_NAME (CTL_SPL_KSTAT)
|
2008-05-09 03:21:47 +04:00
|
|
|
.procname = "kstat",
|
|
|
|
.mode = 0555,
|
|
|
|
.child = spl_kstat_table,
|
|
|
|
},
|
2008-04-19 03:39:58 +04:00
|
|
|
{ 0 },
|
|
|
|
};
|
|
|
|
|
2008-05-06 00:18:49 +04:00
|
|
|
static struct ctl_table spl_dir[] = {
|
2008-04-19 03:39:58 +04:00
|
|
|
{
|
2010-06-30 21:36:20 +04:00
|
|
|
CTL_NAME (CTL_SPL)
|
2008-04-19 03:39:58 +04:00
|
|
|
.procname = "spl",
|
|
|
|
.mode = 0555,
|
|
|
|
.child = spl_table,
|
|
|
|
},
|
2008-06-02 21:28:49 +04:00
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct ctl_table spl_root[] = {
|
|
|
|
{
|
2010-06-30 21:36:20 +04:00
|
|
|
CTL_NAME (CTL_KERN)
|
2008-06-02 21:28:49 +04:00
|
|
|
.procname = "kernel",
|
|
|
|
.mode = 0555,
|
|
|
|
.child = spl_dir,
|
|
|
|
},
|
|
|
|
{ 0 }
|
2008-04-19 03:39:58 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
int
|
2011-11-11 21:03:31 +04:00
|
|
|
spl_proc_init(void)
|
2008-04-19 03:39:58 +04:00
|
|
|
{
|
2008-05-07 21:58:22 +04:00
|
|
|
int rc = 0;
|
2010-07-20 22:55:37 +04:00
|
|
|
SENTRY;
|
2008-04-19 03:39:58 +04:00
|
|
|
|
|
|
|
#ifdef CONFIG_SYSCTL
|
2008-06-02 21:28:49 +04:00
|
|
|
spl_header = spl_register_sysctl_table(spl_root, 0);
|
2008-04-19 03:39:58 +04:00
|
|
|
if (spl_header == NULL)
|
2010-07-20 22:55:37 +04:00
|
|
|
SRETURN(-EUNATCH);
|
2008-06-04 10:00:46 +04:00
|
|
|
#endif /* CONFIG_SYSCTL */
|
2008-05-06 00:18:49 +04:00
|
|
|
|
2008-06-04 10:00:46 +04:00
|
|
|
proc_spl = proc_mkdir("spl", NULL);
|
|
|
|
if (proc_spl == NULL)
|
2010-07-20 22:55:37 +04:00
|
|
|
SGOTO(out, rc = -EUNATCH);
|
2008-05-07 21:58:22 +04:00
|
|
|
|
2008-05-09 03:21:47 +04:00
|
|
|
#ifdef DEBUG_KMEM
|
2008-06-04 10:00:46 +04:00
|
|
|
proc_spl_kmem = proc_mkdir("kmem", proc_spl);
|
|
|
|
if (proc_spl_kmem == NULL)
|
2010-07-20 22:55:37 +04:00
|
|
|
SGOTO(out, rc = -EUNATCH);
|
2008-06-28 01:40:11 +04:00
|
|
|
|
2013-07-04 00:34:52 +04:00
|
|
|
proc_spl_kmem_slab = proc_create_data("slab", 0444,
|
|
|
|
proc_spl_kmem, &proc_slab_operations, NULL);
|
2008-06-28 01:40:11 +04:00
|
|
|
if (proc_spl_kmem_slab == NULL)
|
2010-07-20 22:55:37 +04:00
|
|
|
SGOTO(out, rc = -EUNATCH);
|
2008-06-28 01:40:11 +04:00
|
|
|
|
2008-05-09 03:21:47 +04:00
|
|
|
#endif /* DEBUG_KMEM */
|
|
|
|
|
2008-06-04 10:00:46 +04:00
|
|
|
proc_spl_kstat = proc_mkdir("kstat", proc_spl);
|
|
|
|
if (proc_spl_kstat == NULL)
|
2010-07-20 22:55:37 +04:00
|
|
|
SGOTO(out, rc = -EUNATCH);
|
2008-05-07 21:58:22 +04:00
|
|
|
out:
|
2008-06-04 10:00:46 +04:00
|
|
|
if (rc) {
|
|
|
|
remove_proc_entry("kstat", proc_spl);
|
2008-06-28 01:40:11 +04:00
|
|
|
#ifdef DEBUG_KMEM
|
|
|
|
remove_proc_entry("slab", proc_spl_kmem);
|
2008-06-04 10:00:46 +04:00
|
|
|
remove_proc_entry("kmem", proc_spl);
|
2009-10-30 23:58:51 +03:00
|
|
|
#endif
|
2008-06-04 10:09:16 +04:00
|
|
|
remove_proc_entry("spl", NULL);
|
2008-06-04 10:00:46 +04:00
|
|
|
#ifdef CONFIG_SYSCTL
|
|
|
|
spl_unregister_sysctl_table(spl_header);
|
2008-05-07 21:58:22 +04:00
|
|
|
#endif /* CONFIG_SYSCTL */
|
2008-06-04 10:00:46 +04:00
|
|
|
}
|
|
|
|
|
2010-07-20 22:55:37 +04:00
|
|
|
SRETURN(rc);
|
2008-04-19 03:39:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-11-11 21:03:31 +04:00
|
|
|
spl_proc_fini(void)
|
2008-04-19 03:39:58 +04:00
|
|
|
{
|
2010-07-20 22:55:37 +04:00
|
|
|
SENTRY;
|
2008-04-19 03:39:58 +04:00
|
|
|
|
2008-06-04 10:00:46 +04:00
|
|
|
remove_proc_entry("kstat", proc_spl);
|
2008-06-28 01:40:11 +04:00
|
|
|
#ifdef DEBUG_KMEM
|
|
|
|
remove_proc_entry("slab", proc_spl_kmem);
|
2008-06-04 10:00:46 +04:00
|
|
|
remove_proc_entry("kmem", proc_spl);
|
2009-10-30 23:58:51 +03:00
|
|
|
#endif
|
2008-06-04 10:09:16 +04:00
|
|
|
remove_proc_entry("spl", NULL);
|
2008-06-04 10:00:46 +04:00
|
|
|
|
2008-04-19 03:39:58 +04:00
|
|
|
#ifdef CONFIG_SYSCTL
|
|
|
|
ASSERT(spl_header != NULL);
|
2008-06-02 21:28:49 +04:00
|
|
|
spl_unregister_sysctl_table(spl_header);
|
2008-06-04 10:00:46 +04:00
|
|
|
#endif /* CONFIG_SYSCTL */
|
|
|
|
|
2010-07-20 22:55:37 +04:00
|
|
|
SEXIT;
|
2008-04-19 03:39:58 +04:00
|
|
|
}
|