2017-10-04 16:33:43 +00:00
|
|
|
/*
|
2010-05-17 22:18:00 +00: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 04:38:26 +00:00
|
|
|
* UCRL-CODE-235197
|
|
|
|
*
|
2010-05-17 22:18:00 +00:00
|
|
|
* This file is part of the SPL, Solaris Porting Layer.
|
|
|
|
*
|
|
|
|
* 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 04:38:26 +00:00
|
|
|
*
|
2010-05-17 22:18:00 +00:00
|
|
|
* The SPL is distributed in the hope that it will be useful, but WITHOUT
|
2008-05-26 04:38:26 +00: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-17 22:18:00 +00:00
|
|
|
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
|
2018-02-07 19:49:38 +00:00
|
|
|
*
|
2010-05-17 22:18:00 +00:00
|
|
|
* Solaris Porting Layer (SPL) Proc Implementation.
|
2017-10-04 16:33:43 +00:00
|
|
|
*/
|
2008-05-26 04:38:26 +00:00
|
|
|
|
2010-06-11 21:37:46 +00:00
|
|
|
#include <sys/systeminfo.h>
|
|
|
|
#include <sys/kstat.h>
|
2014-12-08 18:04:42 +00:00
|
|
|
#include <sys/kmem.h>
|
|
|
|
#include <sys/kmem_cache.h>
|
|
|
|
#include <sys/vmem.h>
|
2015-10-19 12:47:52 +00:00
|
|
|
#include <sys/taskq.h>
|
2018-02-15 01:01:15 +00:00
|
|
|
#include <sys/proc.h>
|
2014-12-08 18:04:42 +00:00
|
|
|
#include <linux/ctype.h>
|
2010-06-11 21:37:46 +00:00
|
|
|
#include <linux/kmod.h>
|
|
|
|
#include <linux/seq_file.h>
|
2014-12-08 18:04:42 +00:00
|
|
|
#include <linux/uaccess.h>
|
2013-03-27 15:33:14 +00:00
|
|
|
#include <linux/version.h>
|
2022-01-14 23:37:55 +00:00
|
|
|
#include "zfs_gitrev.h"
|
2008-04-18 23:39:58 +00:00
|
|
|
|
2018-02-07 19:49:38 +00:00
|
|
|
#if defined(CONSTIFY_PLUGIN) && LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0)
|
2013-03-27 15:33:14 +00:00
|
|
|
typedef struct ctl_table __no_const spl_ctl_table;
|
|
|
|
#else
|
|
|
|
typedef struct ctl_table spl_ctl_table;
|
|
|
|
#endif
|
|
|
|
|
2008-04-18 23:39:58 +00:00
|
|
|
static unsigned long table_min = 0;
|
|
|
|
static unsigned long table_max = ~0;
|
2008-05-07 17:58:22 +00:00
|
|
|
|
|
|
|
static struct ctl_table_header *spl_header = NULL;
|
2008-06-04 06:00:46 +00:00
|
|
|
static struct proc_dir_entry *proc_spl = NULL;
|
|
|
|
static struct proc_dir_entry *proc_spl_kmem = NULL;
|
2008-06-27 21:40:11 +00:00
|
|
|
static struct proc_dir_entry *proc_spl_kmem_slab = NULL;
|
2015-10-19 12:47:52 +00:00
|
|
|
static struct proc_dir_entry *proc_spl_taskq_all = NULL;
|
|
|
|
static struct proc_dir_entry *proc_spl_taskq = NULL;
|
2008-06-04 06:00:46 +00:00
|
|
|
struct proc_dir_entry *proc_spl_kstat = NULL;
|
2008-04-18 23:39:58 +00:00
|
|
|
|
2008-05-09 22:53:20 +00:00
|
|
|
#ifdef DEBUG_KMEM
|
2014-10-02 18:15:19 +00:00
|
|
|
static int
|
|
|
|
proc_domemused(struct ctl_table *table, int write,
|
|
|
|
void __user *buffer, size_t *lenp, loff_t *ppos)
|
2008-04-18 23:39:58 +00:00
|
|
|
{
|
2018-02-07 19:49:38 +00:00
|
|
|
int rc = 0;
|
2021-04-11 14:29:00 +00:00
|
|
|
unsigned long val;
|
2018-02-07 19:49:38 +00:00
|
|
|
spl_ctl_table dummy = *table;
|
|
|
|
|
|
|
|
dummy.data = &val;
|
|
|
|
dummy.proc_handler = &proc_dointvec;
|
2021-04-11 14:29:00 +00:00
|
|
|
dummy.extra1 = &table_min;
|
|
|
|
dummy.extra2 = &table_max;
|
2018-02-07 19:49:38 +00:00
|
|
|
|
|
|
|
if (write) {
|
|
|
|
*ppos += *lenp;
|
|
|
|
} else {
|
|
|
|
#ifdef HAVE_ATOMIC64_T
|
|
|
|
val = atomic64_read((atomic64_t *)table->data);
|
|
|
|
#else
|
|
|
|
val = atomic_read((atomic_t *)table->data);
|
|
|
|
#endif /* HAVE_ATOMIC64_T */
|
|
|
|
rc = proc_doulongvec_minmax(&dummy, write, buffer, lenp, ppos);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (rc);
|
2008-04-18 23:39:58 +00:00
|
|
|
}
|
2015-07-20 19:18:56 +00:00
|
|
|
#endif /* DEBUG_KMEM */
|
2011-03-26 07:03:32 +00:00
|
|
|
|
2014-10-02 18:15:19 +00:00
|
|
|
static int
|
|
|
|
proc_doslab(struct ctl_table *table, int write,
|
|
|
|
void __user *buffer, size_t *lenp, loff_t *ppos)
|
2011-03-26 07:03:32 +00:00
|
|
|
{
|
2018-02-07 19:49:38 +00:00
|
|
|
int rc = 0;
|
2021-04-11 14:29:00 +00:00
|
|
|
unsigned long val = 0, mask;
|
2018-02-07 19:49:38 +00:00
|
|
|
spl_ctl_table dummy = *table;
|
2019-12-14 00:07:48 +00:00
|
|
|
spl_kmem_cache_t *skc = NULL;
|
2011-03-26 07:03:32 +00:00
|
|
|
|
2018-02-07 19:49:38 +00:00
|
|
|
dummy.data = &val;
|
|
|
|
dummy.proc_handler = &proc_dointvec;
|
2021-04-11 14:29:00 +00:00
|
|
|
dummy.extra1 = &table_min;
|
|
|
|
dummy.extra2 = &table_max;
|
2011-03-26 07:03:32 +00:00
|
|
|
|
2018-02-07 19:49:38 +00:00
|
|
|
if (write) {
|
|
|
|
*ppos += *lenp;
|
|
|
|
} else {
|
|
|
|
down_read(&spl_kmem_cache_sem);
|
|
|
|
mask = (unsigned long)table->data;
|
2011-03-26 07:03:32 +00:00
|
|
|
|
2018-02-07 19:49:38 +00:00
|
|
|
list_for_each_entry(skc, &spl_kmem_cache_list, skc_list) {
|
2011-03-26 07:03:32 +00:00
|
|
|
|
|
|
|
/* 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:
|
2018-02-07 19:49:38 +00:00
|
|
|
val += skc->skc_slab_size * skc->skc_slab_total;
|
2011-03-26 07:03:32 +00:00
|
|
|
break;
|
|
|
|
case KMC_ALLOC:
|
2018-02-07 19:49:38 +00:00
|
|
|
val += skc->skc_obj_size * skc->skc_obj_alloc;
|
2011-03-26 07:03:32 +00:00
|
|
|
break;
|
|
|
|
case KMC_MAX:
|
2018-02-07 19:49:38 +00:00
|
|
|
val += skc->skc_obj_size * skc->skc_obj_max;
|
2011-03-26 07:03:32 +00:00
|
|
|
break;
|
|
|
|
}
|
2018-02-07 19:49:38 +00:00
|
|
|
}
|
2011-03-26 07:03:32 +00:00
|
|
|
|
2018-02-07 19:49:38 +00:00
|
|
|
up_read(&spl_kmem_cache_sem);
|
|
|
|
rc = proc_doulongvec_minmax(&dummy, write, buffer, lenp, ppos);
|
|
|
|
}
|
2011-03-26 07:03:32 +00:00
|
|
|
|
2018-02-07 19:49:38 +00:00
|
|
|
return (rc);
|
2011-03-26 07:03:32 +00:00
|
|
|
}
|
2008-04-18 23:39:58 +00:00
|
|
|
|
2014-10-02 18:15:19 +00:00
|
|
|
static int
|
|
|
|
proc_dohostid(struct ctl_table *table, int write,
|
|
|
|
void __user *buffer, size_t *lenp, loff_t *ppos)
|
2008-04-18 23:39:58 +00:00
|
|
|
{
|
2018-02-07 19:49:38 +00:00
|
|
|
char *end, str[32];
|
2021-04-10 23:18:40 +00:00
|
|
|
unsigned long hid;
|
|
|
|
spl_ctl_table dummy = *table;
|
|
|
|
|
|
|
|
dummy.data = str;
|
|
|
|
dummy.maxlen = sizeof (str) - 1;
|
|
|
|
|
|
|
|
if (!write)
|
|
|
|
snprintf(str, sizeof (str), "%lx",
|
|
|
|
(unsigned long) zone_get_hostid(NULL));
|
|
|
|
|
|
|
|
/* always returns 0 */
|
|
|
|
proc_dostring(&dummy, write, buffer, lenp, ppos);
|
2018-02-07 19:49:38 +00:00
|
|
|
|
|
|
|
if (write) {
|
|
|
|
/*
|
|
|
|
* We can't use proc_doulongvec_minmax() in the write
|
2021-04-10 23:18:40 +00:00
|
|
|
* case here because hostid, while a hex value, has no
|
|
|
|
* leading 0x, which confuses the helper function.
|
2018-02-07 19:49:38 +00:00
|
|
|
*/
|
|
|
|
|
2021-04-10 23:18:40 +00:00
|
|
|
hid = simple_strtoul(str, &end, 16);
|
2018-02-07 19:49:38 +00:00
|
|
|
if (str == end)
|
|
|
|
return (-EINVAL);
|
2021-04-10 23:18:40 +00:00
|
|
|
spl_hostid = hid;
|
2018-02-07 19:49:38 +00:00
|
|
|
}
|
|
|
|
|
2021-04-10 23:18:40 +00:00
|
|
|
return (0);
|
2008-04-18 23:39:58 +00:00
|
|
|
}
|
|
|
|
|
2015-10-19 12:47:52 +00:00
|
|
|
static void
|
|
|
|
taskq_seq_show_headers(struct seq_file *f)
|
|
|
|
{
|
|
|
|
seq_printf(f, "%-25s %5s %5s %5s %5s %5s %5s %12s %5s %10s\n",
|
|
|
|
"taskq", "act", "nthr", "spwn", "maxt", "pri",
|
|
|
|
"mina", "maxa", "cura", "flags");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* indices into the lheads array below */
|
|
|
|
#define LHEAD_PEND 0
|
2018-02-07 19:49:38 +00:00
|
|
|
#define LHEAD_PRIO 1
|
|
|
|
#define LHEAD_DELAY 2
|
|
|
|
#define LHEAD_WAIT 3
|
|
|
|
#define LHEAD_ACTIVE 4
|
|
|
|
#define LHEAD_SIZE 5
|
2015-10-19 12:47:52 +00:00
|
|
|
|
2016-12-01 18:06:27 +00:00
|
|
|
static unsigned int spl_max_show_tasks = 512;
|
2022-01-21 16:07:15 +00:00
|
|
|
/* CSTYLED */
|
2016-12-01 18:06:27 +00:00
|
|
|
module_param(spl_max_show_tasks, uint, 0644);
|
|
|
|
MODULE_PARM_DESC(spl_max_show_tasks, "Max number of tasks shown in taskq proc");
|
|
|
|
|
2015-10-19 12:47:52 +00:00
|
|
|
static int
|
|
|
|
taskq_seq_show_impl(struct seq_file *f, void *p, boolean_t allflag)
|
|
|
|
{
|
|
|
|
taskq_t *tq = p;
|
2019-12-14 00:07:48 +00:00
|
|
|
taskq_thread_t *tqt = NULL;
|
2017-07-24 02:32:14 +00:00
|
|
|
spl_wait_queue_entry_t *wq;
|
2015-10-19 12:47:52 +00:00
|
|
|
struct task_struct *tsk;
|
|
|
|
taskq_ent_t *tqe;
|
|
|
|
char name[100];
|
|
|
|
struct list_head *lheads[LHEAD_SIZE], *lh;
|
|
|
|
static char *list_names[LHEAD_SIZE] =
|
|
|
|
{"pend", "prio", "delay", "wait", "active" };
|
|
|
|
int i, j, have_lheads = 0;
|
|
|
|
unsigned long wflags, flags;
|
|
|
|
|
|
|
|
spin_lock_irqsave_nested(&tq->tq_lock, flags, tq->tq_lock_class);
|
|
|
|
spin_lock_irqsave(&tq->tq_wait_waitq.lock, wflags);
|
|
|
|
|
|
|
|
/* get the various lists and check whether they're empty */
|
|
|
|
lheads[LHEAD_PEND] = &tq->tq_pend_list;
|
|
|
|
lheads[LHEAD_PRIO] = &tq->tq_prio_list;
|
|
|
|
lheads[LHEAD_DELAY] = &tq->tq_delay_list;
|
2017-07-24 02:32:14 +00:00
|
|
|
#ifdef HAVE_WAIT_QUEUE_HEAD_ENTRY
|
|
|
|
lheads[LHEAD_WAIT] = &tq->tq_wait_waitq.head;
|
|
|
|
#else
|
2015-10-19 12:47:52 +00:00
|
|
|
lheads[LHEAD_WAIT] = &tq->tq_wait_waitq.task_list;
|
2017-07-24 02:32:14 +00:00
|
|
|
#endif
|
2015-10-19 12:47:52 +00:00
|
|
|
lheads[LHEAD_ACTIVE] = &tq->tq_active_list;
|
|
|
|
|
|
|
|
for (i = 0; i < LHEAD_SIZE; ++i) {
|
|
|
|
if (list_empty(lheads[i]))
|
|
|
|
lheads[i] = NULL;
|
|
|
|
else
|
|
|
|
++have_lheads;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* early return in non-"all" mode if lists are all empty */
|
|
|
|
if (!allflag && !have_lheads) {
|
|
|
|
spin_unlock_irqrestore(&tq->tq_wait_waitq.lock, wflags);
|
|
|
|
spin_unlock_irqrestore(&tq->tq_lock, flags);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* unlock the waitq quickly */
|
|
|
|
if (!lheads[LHEAD_WAIT])
|
|
|
|
spin_unlock_irqrestore(&tq->tq_wait_waitq.lock, wflags);
|
|
|
|
|
|
|
|
/* show the base taskq contents */
|
2018-02-07 19:49:38 +00:00
|
|
|
snprintf(name, sizeof (name), "%s/%d", tq->tq_name, tq->tq_instance);
|
2015-10-19 12:47:52 +00:00
|
|
|
seq_printf(f, "%-25s ", name);
|
|
|
|
seq_printf(f, "%5d %5d %5d %5d %5d %5d %12d %5d %10x\n",
|
|
|
|
tq->tq_nactive, tq->tq_nthreads, tq->tq_nspawn,
|
|
|
|
tq->tq_maxthreads, tq->tq_pri, tq->tq_minalloc, tq->tq_maxalloc,
|
|
|
|
tq->tq_nalloc, tq->tq_flags);
|
|
|
|
|
|
|
|
/* show the active list */
|
|
|
|
if (lheads[LHEAD_ACTIVE]) {
|
|
|
|
j = 0;
|
|
|
|
list_for_each_entry(tqt, &tq->tq_active_list, tqt_active_list) {
|
|
|
|
if (j == 0)
|
2018-02-07 19:49:38 +00:00
|
|
|
seq_printf(f, "\t%s:",
|
|
|
|
list_names[LHEAD_ACTIVE]);
|
2015-10-19 12:47:52 +00:00
|
|
|
else if (j == 2) {
|
|
|
|
seq_printf(f, "\n\t ");
|
|
|
|
j = 0;
|
|
|
|
}
|
|
|
|
seq_printf(f, " [%d]%pf(%ps)",
|
|
|
|
tqt->tqt_thread->pid,
|
|
|
|
tqt->tqt_task->tqent_func,
|
|
|
|
tqt->tqt_task->tqent_arg);
|
|
|
|
++j;
|
|
|
|
}
|
|
|
|
seq_printf(f, "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = LHEAD_PEND; i <= LHEAD_WAIT; ++i)
|
|
|
|
if (lheads[i]) {
|
|
|
|
j = 0;
|
|
|
|
list_for_each(lh, lheads[i]) {
|
2016-12-01 18:06:27 +00:00
|
|
|
if (spl_max_show_tasks != 0 &&
|
|
|
|
j >= spl_max_show_tasks) {
|
|
|
|
seq_printf(f, "\n\t(truncated)");
|
|
|
|
break;
|
|
|
|
}
|
2015-10-19 12:47:52 +00:00
|
|
|
/* show the wait waitq list */
|
|
|
|
if (i == LHEAD_WAIT) {
|
2017-07-24 02:32:14 +00:00
|
|
|
#ifdef HAVE_WAIT_QUEUE_HEAD_ENTRY
|
|
|
|
wq = list_entry(lh,
|
|
|
|
spl_wait_queue_entry_t, entry);
|
|
|
|
#else
|
|
|
|
wq = list_entry(lh,
|
|
|
|
spl_wait_queue_entry_t, task_list);
|
|
|
|
#endif
|
2015-10-19 12:47:52 +00:00
|
|
|
if (j == 0)
|
|
|
|
seq_printf(f, "\t%s:",
|
|
|
|
list_names[i]);
|
2016-12-01 18:06:27 +00:00
|
|
|
else if (j % 8 == 0)
|
2015-10-19 12:47:52 +00:00
|
|
|
seq_printf(f, "\n\t ");
|
2016-12-01 18:06:27 +00:00
|
|
|
|
2015-10-19 12:47:52 +00:00
|
|
|
tsk = wq->private;
|
|
|
|
seq_printf(f, " %d", tsk->pid);
|
|
|
|
/* pend, prio and delay lists */
|
|
|
|
} else {
|
|
|
|
tqe = list_entry(lh, taskq_ent_t,
|
|
|
|
tqent_list);
|
|
|
|
if (j == 0)
|
|
|
|
seq_printf(f, "\t%s:",
|
|
|
|
list_names[i]);
|
2016-12-01 18:06:27 +00:00
|
|
|
else if (j % 2 == 0)
|
2015-10-19 12:47:52 +00:00
|
|
|
seq_printf(f, "\n\t ");
|
2016-12-01 18:06:27 +00:00
|
|
|
|
2015-10-19 12:47:52 +00:00
|
|
|
seq_printf(f, " %pf(%ps)",
|
|
|
|
tqe->tqent_func,
|
|
|
|
tqe->tqent_arg);
|
|
|
|
}
|
|
|
|
++j;
|
|
|
|
}
|
|
|
|
seq_printf(f, "\n");
|
|
|
|
}
|
|
|
|
if (lheads[LHEAD_WAIT])
|
|
|
|
spin_unlock_irqrestore(&tq->tq_wait_waitq.lock, wflags);
|
|
|
|
spin_unlock_irqrestore(&tq->tq_lock, flags);
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
taskq_all_seq_show(struct seq_file *f, void *p)
|
|
|
|
{
|
|
|
|
return (taskq_seq_show_impl(f, p, B_TRUE));
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
taskq_seq_show(struct seq_file *f, void *p)
|
|
|
|
{
|
|
|
|
return (taskq_seq_show_impl(f, p, B_FALSE));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void *
|
|
|
|
taskq_seq_start(struct seq_file *f, loff_t *pos)
|
|
|
|
{
|
|
|
|
struct list_head *p;
|
|
|
|
loff_t n = *pos;
|
|
|
|
|
|
|
|
down_read(&tq_list_sem);
|
|
|
|
if (!n)
|
|
|
|
taskq_seq_show_headers(f);
|
|
|
|
|
|
|
|
p = tq_list.next;
|
|
|
|
while (n--) {
|
|
|
|
p = p->next;
|
|
|
|
if (p == &tq_list)
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (list_entry(p, taskq_t, tq_taskqs));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void *
|
|
|
|
taskq_seq_next(struct seq_file *f, void *p, loff_t *pos)
|
|
|
|
{
|
|
|
|
taskq_t *tq = p;
|
|
|
|
|
|
|
|
++*pos;
|
|
|
|
return ((tq->tq_taskqs.next == &tq_list) ?
|
2018-02-07 19:49:38 +00:00
|
|
|
NULL : list_entry(tq->tq_taskqs.next, taskq_t, tq_taskqs));
|
2015-10-19 12:47:52 +00:00
|
|
|
}
|
|
|
|
|
2008-06-27 21:40:11 +00:00
|
|
|
static void
|
|
|
|
slab_seq_show_headers(struct seq_file *f)
|
|
|
|
{
|
2018-02-07 19:49:38 +00:00
|
|
|
seq_printf(f,
|
|
|
|
"--------------------- cache ----------"
|
|
|
|
"--------------------------------------------- "
|
|
|
|
"----- slab ------ "
|
|
|
|
"---- object ----- "
|
|
|
|
"--- emergency ---\n");
|
|
|
|
seq_printf(f,
|
|
|
|
"name "
|
|
|
|
" flags size alloc slabsize objsize "
|
|
|
|
"total alloc max "
|
|
|
|
"total alloc max "
|
|
|
|
"dlock alloc max\n");
|
2008-06-27 21:40:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
slab_seq_show(struct seq_file *f, void *p)
|
|
|
|
{
|
2018-02-07 19:49:38 +00:00
|
|
|
spl_kmem_cache_t *skc = p;
|
2008-06-27 21:40:11 +00:00
|
|
|
|
2018-02-07 19:49:38 +00:00
|
|
|
ASSERT(skc->skc_magic == SKC_MAGIC);
|
2008-06-27 21:40:11 +00:00
|
|
|
|
2019-10-18 17:24:28 +00:00
|
|
|
if (skc->skc_flags & KMC_SLAB) {
|
|
|
|
/*
|
|
|
|
* This cache is backed by a generic Linux kmem cache which
|
|
|
|
* has its own accounting. For these caches we only track
|
|
|
|
* the number of active allocated objects that exist within
|
|
|
|
* the underlying Linux slabs. For the overall statistics of
|
|
|
|
* the underlying Linux cache please refer to /proc/slabinfo.
|
|
|
|
*/
|
|
|
|
spin_lock(&skc->skc_lock);
|
2020-06-27 01:06:50 +00:00
|
|
|
uint64_t objs_allocated =
|
|
|
|
percpu_counter_sum(&skc->skc_linux_alloc);
|
2019-10-18 17:24:28 +00:00
|
|
|
seq_printf(f, "%-36s ", skc->skc_name);
|
|
|
|
seq_printf(f, "0x%05lx %9s %9lu %8s %8u "
|
|
|
|
"%5s %5s %5s %5s %5lu %5s %5s %5s %5s\n",
|
|
|
|
(long unsigned)skc->skc_flags,
|
|
|
|
"-",
|
2020-06-27 01:06:50 +00:00
|
|
|
(long unsigned)(skc->skc_obj_size * objs_allocated),
|
2019-10-18 17:24:28 +00:00
|
|
|
"-",
|
|
|
|
(unsigned)skc->skc_obj_size,
|
|
|
|
"-", "-", "-", "-",
|
2020-06-27 01:06:50 +00:00
|
|
|
(long unsigned)objs_allocated,
|
2019-10-18 17:24:28 +00:00
|
|
|
"-", "-", "-", "-");
|
|
|
|
spin_unlock(&skc->skc_lock);
|
2013-12-08 22:01:45 +00:00
|
|
|
return (0);
|
2019-10-18 17:24:28 +00:00
|
|
|
}
|
2013-12-08 22:01:45 +00:00
|
|
|
|
2018-02-07 19:49:38 +00:00
|
|
|
spin_lock(&skc->skc_lock);
|
|
|
|
seq_printf(f, "%-36s ", skc->skc_name);
|
|
|
|
seq_printf(f, "0x%05lx %9lu %9lu %8u %8u "
|
|
|
|
"%5lu %5lu %5lu %5lu %5lu %5lu %5lu %5lu %5lu\n",
|
|
|
|
(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,
|
|
|
|
(long unsigned)skc->skc_obj_max,
|
|
|
|
(long unsigned)skc->skc_obj_deadlock,
|
|
|
|
(long unsigned)skc->skc_obj_emergency,
|
|
|
|
(long unsigned)skc->skc_obj_emergency_max);
|
|
|
|
spin_unlock(&skc->skc_lock);
|
|
|
|
return (0);
|
2008-06-27 21:40:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void *
|
|
|
|
slab_seq_start(struct seq_file *f, loff_t *pos)
|
|
|
|
{
|
2018-02-07 19:49:38 +00:00
|
|
|
struct list_head *p;
|
|
|
|
loff_t n = *pos;
|
2008-06-27 21:40:11 +00:00
|
|
|
|
|
|
|
down_read(&spl_kmem_cache_sem);
|
2018-02-07 19:49:38 +00:00
|
|
|
if (!n)
|
|
|
|
slab_seq_show_headers(f);
|
2008-06-27 21:40:11 +00:00
|
|
|
|
2018-02-07 19:49:38 +00:00
|
|
|
p = spl_kmem_cache_list.next;
|
|
|
|
while (n--) {
|
|
|
|
p = p->next;
|
|
|
|
if (p == &spl_kmem_cache_list)
|
|
|
|
return (NULL);
|
|
|
|
}
|
2008-06-27 21:40:11 +00:00
|
|
|
|
2018-02-07 19:49:38 +00:00
|
|
|
return (list_entry(p, spl_kmem_cache_t, skc_list));
|
2008-06-27 21:40:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void *
|
|
|
|
slab_seq_next(struct seq_file *f, void *p, loff_t *pos)
|
|
|
|
{
|
|
|
|
spl_kmem_cache_t *skc = p;
|
|
|
|
|
2018-02-07 19:49:38 +00:00
|
|
|
++*pos;
|
|
|
|
return ((skc->skc_list.next == &spl_kmem_cache_list) ?
|
|
|
|
NULL : list_entry(skc->skc_list.next, spl_kmem_cache_t, skc_list));
|
2008-06-27 21:40:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
slab_seq_stop(struct seq_file *f, void *v)
|
|
|
|
{
|
|
|
|
up_read(&spl_kmem_cache_sem);
|
|
|
|
}
|
|
|
|
|
2022-01-14 23:37:55 +00:00
|
|
|
static const struct seq_operations slab_seq_ops = {
|
2018-02-07 19:49:38 +00:00
|
|
|
.show = slab_seq_show,
|
|
|
|
.start = slab_seq_start,
|
|
|
|
.next = slab_seq_next,
|
|
|
|
.stop = slab_seq_stop,
|
2008-06-27 21:40:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
|
|
|
proc_slab_open(struct inode *inode, struct file *filp)
|
|
|
|
{
|
2018-02-07 19:49:38 +00:00
|
|
|
return (seq_open(filp, &slab_seq_ops));
|
2008-06-27 21:40:11 +00:00
|
|
|
}
|
|
|
|
|
2020-02-06 18:30:41 +00:00
|
|
|
static const kstat_proc_op_t proc_slab_operations = {
|
|
|
|
#ifdef HAVE_PROC_OPS_STRUCT
|
|
|
|
.proc_open = proc_slab_open,
|
|
|
|
.proc_read = seq_read,
|
|
|
|
.proc_lseek = seq_lseek,
|
|
|
|
.proc_release = seq_release,
|
|
|
|
#else
|
|
|
|
.open = proc_slab_open,
|
|
|
|
.read = seq_read,
|
|
|
|
.llseek = seq_lseek,
|
2018-02-07 19:49:38 +00:00
|
|
|
.release = seq_release,
|
2020-02-06 18:30:41 +00:00
|
|
|
#endif
|
2008-06-27 21:40:11 +00:00
|
|
|
};
|
|
|
|
|
2015-10-19 12:47:52 +00:00
|
|
|
static void
|
|
|
|
taskq_seq_stop(struct seq_file *f, void *v)
|
|
|
|
{
|
|
|
|
up_read(&tq_list_sem);
|
|
|
|
}
|
|
|
|
|
2022-01-14 23:37:55 +00:00
|
|
|
static const struct seq_operations taskq_all_seq_ops = {
|
2018-02-07 19:49:38 +00:00
|
|
|
.show = taskq_all_seq_show,
|
|
|
|
.start = taskq_seq_start,
|
|
|
|
.next = taskq_seq_next,
|
|
|
|
.stop = taskq_seq_stop,
|
2015-10-19 12:47:52 +00:00
|
|
|
};
|
|
|
|
|
2022-01-14 23:37:55 +00:00
|
|
|
static const struct seq_operations taskq_seq_ops = {
|
2018-02-07 19:49:38 +00:00
|
|
|
.show = taskq_seq_show,
|
|
|
|
.start = taskq_seq_start,
|
|
|
|
.next = taskq_seq_next,
|
|
|
|
.stop = taskq_seq_stop,
|
2015-10-19 12:47:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
|
|
|
proc_taskq_all_open(struct inode *inode, struct file *filp)
|
|
|
|
{
|
2018-02-07 19:49:38 +00:00
|
|
|
return (seq_open(filp, &taskq_all_seq_ops));
|
2015-10-19 12:47:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
proc_taskq_open(struct inode *inode, struct file *filp)
|
|
|
|
{
|
2018-02-07 19:49:38 +00:00
|
|
|
return (seq_open(filp, &taskq_seq_ops));
|
2015-10-19 12:47:52 +00:00
|
|
|
}
|
|
|
|
|
2020-02-06 18:30:41 +00:00
|
|
|
static const kstat_proc_op_t proc_taskq_all_operations = {
|
|
|
|
#ifdef HAVE_PROC_OPS_STRUCT
|
|
|
|
.proc_open = proc_taskq_all_open,
|
|
|
|
.proc_read = seq_read,
|
|
|
|
.proc_lseek = seq_lseek,
|
|
|
|
.proc_release = seq_release,
|
|
|
|
#else
|
2018-02-07 19:49:38 +00:00
|
|
|
.open = proc_taskq_all_open,
|
|
|
|
.read = seq_read,
|
|
|
|
.llseek = seq_lseek,
|
|
|
|
.release = seq_release,
|
2020-02-06 18:30:41 +00:00
|
|
|
#endif
|
2015-10-19 12:47:52 +00:00
|
|
|
};
|
|
|
|
|
2020-02-06 18:30:41 +00:00
|
|
|
static const kstat_proc_op_t proc_taskq_operations = {
|
|
|
|
#ifdef HAVE_PROC_OPS_STRUCT
|
|
|
|
.proc_open = proc_taskq_open,
|
|
|
|
.proc_read = seq_read,
|
|
|
|
.proc_lseek = seq_lseek,
|
|
|
|
.proc_release = seq_release,
|
|
|
|
#else
|
2018-02-07 19:49:38 +00:00
|
|
|
.open = proc_taskq_open,
|
|
|
|
.read = seq_read,
|
|
|
|
.llseek = seq_lseek,
|
|
|
|
.release = seq_release,
|
2020-02-06 18:30:41 +00:00
|
|
|
#endif
|
2015-10-19 12:47:52 +00:00
|
|
|
};
|
|
|
|
|
2008-05-05 20:18:49 +00:00
|
|
|
static struct ctl_table spl_kmem_table[] = {
|
2015-07-20 19:18:56 +00:00
|
|
|
#ifdef DEBUG_KMEM
|
2018-02-07 19:49:38 +00:00
|
|
|
{
|
|
|
|
.procname = "kmem_used",
|
|
|
|
.data = &kmem_alloc_used,
|
|
|
|
#ifdef HAVE_ATOMIC64_T
|
|
|
|
.maxlen = sizeof (atomic64_t),
|
|
|
|
#else
|
|
|
|
.maxlen = sizeof (atomic_t),
|
|
|
|
#endif /* HAVE_ATOMIC64_T */
|
|
|
|
.mode = 0444,
|
|
|
|
.proc_handler = &proc_domemused,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.procname = "kmem_max",
|
|
|
|
.data = &kmem_alloc_max,
|
|
|
|
.maxlen = sizeof (unsigned long),
|
|
|
|
.extra1 = &table_min,
|
|
|
|
.extra2 = &table_max,
|
|
|
|
.mode = 0444,
|
|
|
|
.proc_handler = &proc_doulongvec_minmax,
|
|
|
|
},
|
2015-07-20 19:18:56 +00:00
|
|
|
#endif /* DEBUG_KMEM */
|
2019-07-21 17:34:10 +00:00
|
|
|
{
|
|
|
|
.procname = "slab_kvmem_total",
|
|
|
|
.data = (void *)(KMC_KVMEM | KMC_TOTAL),
|
|
|
|
.maxlen = sizeof (unsigned long),
|
|
|
|
.extra1 = &table_min,
|
|
|
|
.extra2 = &table_max,
|
|
|
|
.mode = 0444,
|
|
|
|
.proc_handler = &proc_doslab,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.procname = "slab_kvmem_alloc",
|
|
|
|
.data = (void *)(KMC_KVMEM | KMC_ALLOC),
|
|
|
|
.maxlen = sizeof (unsigned long),
|
|
|
|
.extra1 = &table_min,
|
|
|
|
.extra2 = &table_max,
|
|
|
|
.mode = 0444,
|
|
|
|
.proc_handler = &proc_doslab,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.procname = "slab_kvmem_max",
|
|
|
|
.data = (void *)(KMC_KVMEM | KMC_MAX),
|
|
|
|
.maxlen = sizeof (unsigned long),
|
|
|
|
.extra1 = &table_min,
|
|
|
|
.extra2 = &table_max,
|
|
|
|
.mode = 0444,
|
|
|
|
.proc_handler = &proc_doslab,
|
|
|
|
},
|
2017-01-13 22:12:42 +00:00
|
|
|
{},
|
2008-05-05 20:18:49 +00:00
|
|
|
};
|
2008-05-08 23:21:47 +00:00
|
|
|
|
|
|
|
static struct ctl_table spl_kstat_table[] = {
|
2017-01-13 22:12:42 +00:00
|
|
|
{},
|
2008-05-08 23:21:47 +00:00
|
|
|
};
|
2008-05-05 20:18:49 +00:00
|
|
|
|
|
|
|
static struct ctl_table spl_table[] = {
|
2018-02-07 19:49:38 +00:00
|
|
|
/*
|
|
|
|
* NB No .strategy entries have been provided since
|
|
|
|
* sysctl(8) prefers to go via /proc for portability.
|
|
|
|
*/
|
|
|
|
{
|
2018-10-09 04:57:02 +00:00
|
|
|
.procname = "gitrev",
|
2022-01-14 23:37:55 +00:00
|
|
|
.data = (char *)ZFS_META_GITREV,
|
|
|
|
.maxlen = sizeof (ZFS_META_GITREV),
|
2018-02-07 19:49:38 +00:00
|
|
|
.mode = 0444,
|
|
|
|
.proc_handler = &proc_dostring,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.procname = "hostid",
|
|
|
|
.data = &spl_hostid,
|
|
|
|
.maxlen = sizeof (unsigned long),
|
|
|
|
.mode = 0644,
|
|
|
|
.proc_handler = &proc_dohostid,
|
|
|
|
},
|
2023-08-02 21:05:46 +00:00
|
|
|
#ifdef HAVE_REGISTER_SYSCTL_TABLE
|
2008-05-05 20:18:49 +00:00
|
|
|
{
|
2018-02-07 19:49:38 +00:00
|
|
|
.procname = "kmem",
|
|
|
|
.mode = 0555,
|
|
|
|
.child = spl_kmem_table,
|
2008-05-05 20:18:49 +00:00
|
|
|
},
|
2008-05-08 23:21:47 +00:00
|
|
|
{
|
2018-02-07 19:49:38 +00:00
|
|
|
.procname = "kstat",
|
|
|
|
.mode = 0555,
|
|
|
|
.child = spl_kstat_table,
|
2008-05-08 23:21:47 +00:00
|
|
|
},
|
2023-08-02 21:05:46 +00:00
|
|
|
#endif
|
2018-02-07 19:49:38 +00:00
|
|
|
{},
|
2008-04-18 23:39:58 +00:00
|
|
|
};
|
|
|
|
|
2023-08-02 21:05:46 +00:00
|
|
|
#ifdef HAVE_REGISTER_SYSCTL_TABLE
|
2008-05-05 20:18:49 +00:00
|
|
|
static struct ctl_table spl_dir[] = {
|
2018-02-07 19:49:38 +00:00
|
|
|
{
|
|
|
|
.procname = "spl",
|
|
|
|
.mode = 0555,
|
|
|
|
.child = spl_table,
|
|
|
|
},
|
|
|
|
{}
|
2008-06-02 17:28:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct ctl_table spl_root[] = {
|
|
|
|
{
|
2023-08-02 21:05:46 +00:00
|
|
|
.procname = "kernel",
|
|
|
|
.mode = 0555,
|
|
|
|
.child = spl_dir,
|
2008-06-02 17:28:49 +00:00
|
|
|
},
|
2017-01-13 22:12:42 +00:00
|
|
|
{}
|
2008-04-18 23:39:58 +00:00
|
|
|
};
|
2023-08-02 21:05:46 +00:00
|
|
|
#endif
|
2008-04-18 23:39:58 +00:00
|
|
|
|
|
|
|
int
|
2011-11-11 17:03:31 +00:00
|
|
|
spl_proc_init(void)
|
2008-04-18 23:39:58 +00:00
|
|
|
{
|
2008-05-07 17:58:22 +00:00
|
|
|
int rc = 0;
|
2008-04-18 23:39:58 +00:00
|
|
|
|
2023-08-02 21:05:46 +00:00
|
|
|
#ifdef HAVE_REGISTER_SYSCTL_TABLE
|
2018-02-07 19:49:38 +00:00
|
|
|
spl_header = register_sysctl_table(spl_root);
|
2008-04-18 23:39:58 +00:00
|
|
|
if (spl_header == NULL)
|
2014-11-05 22:30:35 +00:00
|
|
|
return (-EUNATCH);
|
2023-08-02 21:05:46 +00:00
|
|
|
#else
|
|
|
|
spl_header = register_sysctl("kernel/spl", spl_table);
|
|
|
|
if (spl_header == NULL)
|
|
|
|
return (-EUNATCH);
|
|
|
|
|
|
|
|
if (register_sysctl("kernel/spl/kmem", spl_kmem_table) == NULL) {
|
|
|
|
rc = -EUNATCH;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (register_sysctl("kernel/spl/kstat", spl_kstat_table) == NULL) {
|
|
|
|
rc = -EUNATCH;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
#endif
|
2008-05-05 20:18:49 +00:00
|
|
|
|
2008-06-04 06:00:46 +00:00
|
|
|
proc_spl = proc_mkdir("spl", NULL);
|
2014-11-05 22:30:35 +00:00
|
|
|
if (proc_spl == NULL) {
|
|
|
|
rc = -EUNATCH;
|
|
|
|
goto out;
|
|
|
|
}
|
2008-05-07 17:58:22 +00:00
|
|
|
|
2018-02-24 18:05:37 +00:00
|
|
|
proc_spl_taskq_all = proc_create_data("taskq-all", 0444, proc_spl,
|
|
|
|
&proc_taskq_all_operations, NULL);
|
2015-10-19 12:47:52 +00:00
|
|
|
if (proc_spl_taskq_all == NULL) {
|
|
|
|
rc = -EUNATCH;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2018-02-24 18:05:37 +00:00
|
|
|
proc_spl_taskq = proc_create_data("taskq", 0444, proc_spl,
|
|
|
|
&proc_taskq_operations, NULL);
|
2015-10-19 12:47:52 +00:00
|
|
|
if (proc_spl_taskq == NULL) {
|
|
|
|
rc = -EUNATCH;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2018-02-07 19:49:38 +00:00
|
|
|
proc_spl_kmem = proc_mkdir("kmem", proc_spl);
|
|
|
|
if (proc_spl_kmem == NULL) {
|
|
|
|
rc = -EUNATCH;
|
2014-11-05 22:30:35 +00:00
|
|
|
goto out;
|
|
|
|
}
|
2008-06-27 21:40:11 +00:00
|
|
|
|
2018-02-24 18:05:37 +00:00
|
|
|
proc_spl_kmem_slab = proc_create_data("slab", 0444, proc_spl_kmem,
|
|
|
|
&proc_slab_operations, NULL);
|
2018-02-07 19:49:38 +00:00
|
|
|
if (proc_spl_kmem_slab == NULL) {
|
2014-11-05 22:30:35 +00:00
|
|
|
rc = -EUNATCH;
|
|
|
|
goto out;
|
|
|
|
}
|
2008-06-27 21:40:11 +00:00
|
|
|
|
2018-02-07 19:49:38 +00:00
|
|
|
proc_spl_kstat = proc_mkdir("kstat", proc_spl);
|
|
|
|
if (proc_spl_kstat == NULL) {
|
|
|
|
rc = -EUNATCH;
|
2014-11-05 22:30:35 +00:00
|
|
|
goto out;
|
|
|
|
}
|
2008-05-07 17:58:22 +00:00
|
|
|
out:
|
2008-06-04 06:00:46 +00:00
|
|
|
if (rc) {
|
|
|
|
remove_proc_entry("kstat", proc_spl);
|
2018-02-07 19:49:38 +00:00
|
|
|
remove_proc_entry("slab", proc_spl_kmem);
|
2008-06-04 06:00:46 +00:00
|
|
|
remove_proc_entry("kmem", proc_spl);
|
2015-10-19 12:47:52 +00:00
|
|
|
remove_proc_entry("taskq-all", proc_spl);
|
|
|
|
remove_proc_entry("taskq", proc_spl);
|
2008-06-04 06:09:16 +00:00
|
|
|
remove_proc_entry("spl", NULL);
|
2018-02-07 19:49:38 +00:00
|
|
|
unregister_sysctl_table(spl_header);
|
2008-06-04 06:00:46 +00:00
|
|
|
}
|
|
|
|
|
2018-02-07 19:49:38 +00:00
|
|
|
return (rc);
|
2008-04-18 23:39:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-11-11 17:03:31 +00:00
|
|
|
spl_proc_fini(void)
|
2008-04-18 23:39:58 +00:00
|
|
|
{
|
2008-06-04 06:00:46 +00:00
|
|
|
remove_proc_entry("kstat", proc_spl);
|
2018-02-07 19:49:38 +00:00
|
|
|
remove_proc_entry("slab", proc_spl_kmem);
|
2008-06-04 06:00:46 +00:00
|
|
|
remove_proc_entry("kmem", proc_spl);
|
2015-10-19 12:47:52 +00:00
|
|
|
remove_proc_entry("taskq-all", proc_spl);
|
|
|
|
remove_proc_entry("taskq", proc_spl);
|
2008-06-04 06:09:16 +00:00
|
|
|
remove_proc_entry("spl", NULL);
|
2008-06-04 06:00:46 +00:00
|
|
|
|
2018-02-07 19:49:38 +00:00
|
|
|
ASSERT(spl_header != NULL);
|
|
|
|
unregister_sysctl_table(spl_header);
|
2008-04-18 23:39:58 +00:00
|
|
|
}
|