xref: /freebsd/sys/contrib/openzfs/man/man4/spl.4 (revision 271171e0d97b88ba2a7c3bf750c9672b484c1c13)
13ff01b23SMartin Matuska.\"
23ff01b23SMartin Matuska.\" The contents of this file are subject to the terms of the Common Development
33ff01b23SMartin Matuska.\" and Distribution License (the "License").  You may not use this file except
43ff01b23SMartin Matuska.\" in compliance with the License. You can obtain a copy of the license at
5*271171e0SMartin Matuska.\" usr/src/OPENSOLARIS.LICENSE or https://opensource.org/licenses/CDDL-1.0.
63ff01b23SMartin Matuska.\"
73ff01b23SMartin Matuska.\" See the License for the specific language governing permissions and
83ff01b23SMartin Matuska.\" limitations under the License. When distributing Covered Code, include this
93ff01b23SMartin Matuska.\" CDDL HEADER in each file and include the License file at
103ff01b23SMartin Matuska.\" usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this
113ff01b23SMartin Matuska.\" CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your
123ff01b23SMartin Matuska.\" own identifying information:
133ff01b23SMartin Matuska.\" Portions Copyright [yyyy] [name of copyright owner]
143ff01b23SMartin Matuska.\"
153ff01b23SMartin Matuska.\" Copyright 2013 Turbo Fredriksson <turbo@bayour.com>. All rights reserved.
163ff01b23SMartin Matuska.\"
173ff01b23SMartin Matuska.Dd August 24, 2020
183ff01b23SMartin Matuska.Dt SPL 4
193ff01b23SMartin Matuska.Os
203ff01b23SMartin Matuska.
213ff01b23SMartin Matuska.Sh NAME
223ff01b23SMartin Matuska.Nm spl
233ff01b23SMartin Matuska.Nd parameters of the SPL kernel module
243ff01b23SMartin Matuska.
253ff01b23SMartin Matuska.Sh DESCRIPTION
263ff01b23SMartin Matuska.Bl -tag -width Ds
273ff01b23SMartin Matuska.It Sy spl_kmem_cache_kmem_threads Ns = Ns Sy 4 Pq uint
283ff01b23SMartin MatuskaThe number of threads created for the spl_kmem_cache task queue.
293ff01b23SMartin MatuskaThis task queue is responsible for allocating new slabs
303ff01b23SMartin Matuskafor use by the kmem caches.
313ff01b23SMartin MatuskaFor the majority of systems and workloads only a small number of threads are
323ff01b23SMartin Matuskarequired.
333ff01b23SMartin Matuska.
343ff01b23SMartin Matuska.It Sy spl_kmem_cache_reclaim Ns = Ns Sy 0 Pq uint
353ff01b23SMartin MatuskaWhen this is set it prevents Linux from being able to rapidly reclaim all the
363ff01b23SMartin Matuskamemory held by the kmem caches.
373ff01b23SMartin MatuskaThis may be useful in circumstances where it's preferable that Linux
383ff01b23SMartin Matuskareclaim memory from some other subsystem first.
393ff01b23SMartin MatuskaSetting this will increase the likelihood out of memory events on a memory
403ff01b23SMartin Matuskaconstrained system.
413ff01b23SMartin Matuska.
423ff01b23SMartin Matuska.It Sy spl_kmem_cache_obj_per_slab Ns = Ns Sy 8 Pq uint
433ff01b23SMartin MatuskaThe preferred number of objects per slab in the cache.
443ff01b23SMartin MatuskaIn general, a larger value will increase the caches memory footprint
453ff01b23SMartin Matuskawhile decreasing the time required to perform an allocation.
463ff01b23SMartin MatuskaConversely, a smaller value will minimize the footprint
473ff01b23SMartin Matuskaand improve cache reclaim time but individual allocations may take longer.
483ff01b23SMartin Matuska.
493ff01b23SMartin Matuska.It Sy spl_kmem_cache_max_size Ns = Ns Sy 32 Po 64-bit Pc or Sy 4 Po 32-bit Pc Pq uint
503ff01b23SMartin MatuskaThe maximum size of a kmem cache slab in MiB.
513ff01b23SMartin MatuskaThis effectively limits the maximum cache object size to
523ff01b23SMartin Matuska.Sy spl_kmem_cache_max_size Ns / Ns Sy spl_kmem_cache_obj_per_slab .
533ff01b23SMartin Matuska.Pp
543ff01b23SMartin MatuskaCaches may not be created with
553ff01b23SMartin Matuskaobject sized larger than this limit.
563ff01b23SMartin Matuska.
573ff01b23SMartin Matuska.It Sy spl_kmem_cache_slab_limit Ns = Ns Sy 16384 Pq uint
583ff01b23SMartin MatuskaFor small objects the Linux slab allocator should be used to make the most
593ff01b23SMartin Matuskaefficient use of the memory.
603ff01b23SMartin MatuskaHowever, large objects are not supported by
613ff01b23SMartin Matuskathe Linux slab and therefore the SPL implementation is preferred.
623ff01b23SMartin MatuskaThis value is used to determine the cutoff between a small and large object.
633ff01b23SMartin Matuska.Pp
643ff01b23SMartin MatuskaObjects of size
653ff01b23SMartin Matuska.Sy spl_kmem_cache_slab_limit
663ff01b23SMartin Matuskaor smaller will be allocated using the Linux slab allocator,
673ff01b23SMartin Matuskalarge objects use the SPL allocator.
683ff01b23SMartin MatuskaA cutoff of 16K was determined to be optimal for architectures using 4K pages.
693ff01b23SMartin Matuska.
703ff01b23SMartin Matuska.It Sy spl_kmem_alloc_warn Ns = Ns Sy 32768 Pq uint
713ff01b23SMartin MatuskaAs a general rule
723ff01b23SMartin Matuska.Fn kmem_alloc
733ff01b23SMartin Matuskaallocations should be small,
743ff01b23SMartin Matuskapreferably just a few pages, since they must by physically contiguous.
753ff01b23SMartin MatuskaTherefore, a rate limited warning will be printed to the console for any
763ff01b23SMartin Matuska.Fn kmem_alloc
773ff01b23SMartin Matuskawhich exceeds a reasonable threshold.
783ff01b23SMartin Matuska.Pp
793ff01b23SMartin MatuskaThe default warning threshold is set to eight pages but capped at 32K to
803ff01b23SMartin Matuskaaccommodate systems using large pages.
813ff01b23SMartin MatuskaThis value was selected to be small enough to ensure
823ff01b23SMartin Matuskathe largest allocations are quickly noticed and fixed.
833ff01b23SMartin MatuskaBut large enough to avoid logging any warnings when a allocation size is
843ff01b23SMartin Matuskalarger than optimal but not a serious concern.
853ff01b23SMartin MatuskaSince this value is tunable, developers are encouraged to set it lower
863ff01b23SMartin Matuskawhen testing so any new largish allocations are quickly caught.
873ff01b23SMartin MatuskaThese warnings may be disabled by setting the threshold to zero.
883ff01b23SMartin Matuska.
893ff01b23SMartin Matuska.It Sy spl_kmem_alloc_max Ns = Ns Sy KMALLOC_MAX_SIZE Ns / Ns Sy 4 Pq uint
903ff01b23SMartin MatuskaLarge
913ff01b23SMartin Matuska.Fn kmem_alloc
923ff01b23SMartin Matuskaallocations will fail if they exceed
933ff01b23SMartin Matuska.Sy KMALLOC_MAX_SIZE .
943ff01b23SMartin MatuskaAllocations which are marginally smaller than this limit may succeed but
953ff01b23SMartin Matuskashould still be avoided due to the expense of locating a contiguous range
963ff01b23SMartin Matuskaof free pages.
973ff01b23SMartin MatuskaTherefore, a maximum kmem size with reasonable safely margin of 4x is set.
983ff01b23SMartin Matuska.Fn kmem_alloc
993ff01b23SMartin Matuskaallocations larger than this maximum will quickly fail.
1003ff01b23SMartin Matuska.Fn vmem_alloc
1013ff01b23SMartin Matuskaallocations less than or equal to this value will use
1023ff01b23SMartin Matuska.Fn kmalloc ,
1033ff01b23SMartin Matuskabut shift to
1043ff01b23SMartin Matuska.Fn vmalloc
1053ff01b23SMartin Matuskawhen exceeding this value.
1063ff01b23SMartin Matuska.
1073ff01b23SMartin Matuska.It Sy spl_kmem_cache_magazine_size Ns = Ns Sy 0 Pq uint
1083ff01b23SMartin MatuskaCache magazines are an optimization designed to minimize the cost of
1093ff01b23SMartin Matuskaallocating memory.
1103ff01b23SMartin MatuskaThey do this by keeping a per-cpu cache of recently
1113ff01b23SMartin Matuskafreed objects, which can then be reallocated without taking a lock.
1123ff01b23SMartin MatuskaThis can improve performance on highly contended caches.
1133ff01b23SMartin MatuskaHowever, because objects in magazines will prevent otherwise empty slabs
1143ff01b23SMartin Matuskafrom being immediately released this may not be ideal for low memory machines.
1153ff01b23SMartin Matuska.Pp
1163ff01b23SMartin MatuskaFor this reason,
1173ff01b23SMartin Matuska.Sy spl_kmem_cache_magazine_size
1183ff01b23SMartin Matuskacan be used to set a maximum magazine size.
1193ff01b23SMartin MatuskaWhen this value is set to 0 the magazine size will
1203ff01b23SMartin Matuskabe automatically determined based on the object size.
1213ff01b23SMartin MatuskaOtherwise magazines will be limited to 2-256 objects per magazine (i.e per cpu).
1223ff01b23SMartin MatuskaMagazines may never be entirely disabled in this implementation.
1233ff01b23SMartin Matuska.
1243ff01b23SMartin Matuska.It Sy spl_hostid Ns = Ns Sy 0 Pq ulong
1253ff01b23SMartin MatuskaThe system hostid, when set this can be used to uniquely identify a system.
1263ff01b23SMartin MatuskaBy default this value is set to zero which indicates the hostid is disabled.
1273ff01b23SMartin MatuskaIt can be explicitly enabled by placing a unique non-zero value in
1283ff01b23SMartin Matuska.Pa /etc/hostid .
1293ff01b23SMartin Matuska.
1303ff01b23SMartin Matuska.It Sy spl_hostid_path Ns = Ns Pa /etc/hostid Pq charp
1313ff01b23SMartin MatuskaThe expected path to locate the system hostid when specified.
1323ff01b23SMartin MatuskaThis value may be overridden for non-standard configurations.
1333ff01b23SMartin Matuska.
1343ff01b23SMartin Matuska.It Sy spl_panic_halt Ns = Ns Sy 0 Pq uint
1353ff01b23SMartin MatuskaCause a kernel panic on assertion failures.
1363ff01b23SMartin MatuskaWhen not enabled, the thread is halted to facilitate further debugging.
1373ff01b23SMartin Matuska.Pp
1383ff01b23SMartin MatuskaSet to a non-zero value to enable.
1393ff01b23SMartin Matuska.
1403ff01b23SMartin Matuska.It Sy spl_taskq_kick Ns = Ns Sy 0 Pq uint
1413ff01b23SMartin MatuskaKick stuck taskq to spawn threads.
1423ff01b23SMartin MatuskaWhen writing a non-zero value to it, it will scan all the taskqs.
1433ff01b23SMartin MatuskaIf any of them have a pending task more than 5 seconds old,
1443ff01b23SMartin Matuskait will kick it to spawn more threads.
1453ff01b23SMartin MatuskaThis can be used if you find a rare
1463ff01b23SMartin Matuskadeadlock occurs because one or more taskqs didn't spawn a thread when it should.
1473ff01b23SMartin Matuska.
1483ff01b23SMartin Matuska.It Sy spl_taskq_thread_bind Ns = Ns Sy 0 Pq int
1493ff01b23SMartin MatuskaBind taskq threads to specific CPUs.
1503ff01b23SMartin MatuskaWhen enabled all taskq threads will be distributed evenly
1513ff01b23SMartin Matuskaacross the available CPUs.
1523ff01b23SMartin MatuskaBy default, this behavior is disabled to allow the Linux scheduler
1533ff01b23SMartin Matuskathe maximum flexibility to determine where a thread should run.
1543ff01b23SMartin Matuska.
1553ff01b23SMartin Matuska.It Sy spl_taskq_thread_dynamic Ns = Ns Sy 1 Pq int
1563ff01b23SMartin MatuskaAllow dynamic taskqs.
1573ff01b23SMartin MatuskaWhen enabled taskqs which set the
1583ff01b23SMartin Matuska.Sy TASKQ_DYNAMIC
1593ff01b23SMartin Matuskaflag will by default create only a single thread.
1603ff01b23SMartin MatuskaNew threads will be created on demand up to a maximum allowed number
1613ff01b23SMartin Matuskato facilitate the completion of outstanding tasks.
1623ff01b23SMartin MatuskaThreads which are no longer needed will be promptly destroyed.
1633ff01b23SMartin MatuskaBy default this behavior is enabled but it can be disabled to
1643ff01b23SMartin Matuskaaid performance analysis or troubleshooting.
1653ff01b23SMartin Matuska.
1663ff01b23SMartin Matuska.It Sy spl_taskq_thread_priority Ns = Ns Sy 1 Pq int
1673ff01b23SMartin MatuskaAllow newly created taskq threads to set a non-default scheduler priority.
1683ff01b23SMartin MatuskaWhen enabled, the priority specified when a taskq is created will be applied
1693ff01b23SMartin Matuskato all threads created by that taskq.
1703ff01b23SMartin MatuskaWhen disabled all threads will use the default Linux kernel thread priority.
1713ff01b23SMartin MatuskaBy default, this behavior is enabled.
1723ff01b23SMartin Matuska.
1733ff01b23SMartin Matuska.It Sy spl_taskq_thread_sequential Ns = Ns Sy 4 Pq int
1743ff01b23SMartin MatuskaThe number of items a taskq worker thread must handle without interruption
1753ff01b23SMartin Matuskabefore requesting a new worker thread be spawned.
1763ff01b23SMartin MatuskaThis is used to control
1773ff01b23SMartin Matuskahow quickly taskqs ramp up the number of threads processing the queue.
1783ff01b23SMartin MatuskaBecause Linux thread creation and destruction are relatively inexpensive a
1793ff01b23SMartin Matuskasmall default value has been selected.
1803ff01b23SMartin MatuskaThis means that normally threads will be created aggressively which is desirable.
1813ff01b23SMartin MatuskaIncreasing this value will
1823ff01b23SMartin Matuskaresult in a slower thread creation rate which may be preferable for some
1833ff01b23SMartin Matuskaconfigurations.
1843ff01b23SMartin Matuska.
1853ff01b23SMartin Matuska.It Sy spl_max_show_tasks Ns = Ns Sy 512 Pq uint
1863ff01b23SMartin MatuskaThe maximum number of tasks per pending list in each taskq shown in
1873ff01b23SMartin Matuska.Pa /proc/spl/taskq{,-all} .
1883ff01b23SMartin MatuskaWrite
1893ff01b23SMartin Matuska.Sy 0
1903ff01b23SMartin Matuskato turn off the limit.
1913ff01b23SMartin MatuskaThe proc file will walk the lists with lock held,
1923ff01b23SMartin Matuskareading it could cause a lock-up if the list grow too large
1933ff01b23SMartin Matuskawithout limiting the output.
1943ff01b23SMartin Matuska"(truncated)" will be shown if the list is larger than the limit.
1953ff01b23SMartin Matuska.El
196