xref: /freebsd/sys/contrib/openzfs/man/man4/spl.4 (revision e2257b3168fc1697518265527e5d817eca6c43b8)
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
5271171e0SMartin 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_obj_per_slab Ns = Ns Sy 8 Pq uint
353ff01b23SMartin MatuskaThe preferred number of objects per slab in the cache.
363ff01b23SMartin MatuskaIn general, a larger value will increase the caches memory footprint
373ff01b23SMartin Matuskawhile decreasing the time required to perform an allocation.
383ff01b23SMartin MatuskaConversely, a smaller value will minimize the footprint
393ff01b23SMartin Matuskaand improve cache reclaim time but individual allocations may take longer.
403ff01b23SMartin Matuska.
413ff01b23SMartin 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
423ff01b23SMartin MatuskaThe maximum size of a kmem cache slab in MiB.
433ff01b23SMartin MatuskaThis effectively limits the maximum cache object size to
443ff01b23SMartin Matuska.Sy spl_kmem_cache_max_size Ns / Ns Sy spl_kmem_cache_obj_per_slab .
453ff01b23SMartin Matuska.Pp
463ff01b23SMartin MatuskaCaches may not be created with
473ff01b23SMartin Matuskaobject sized larger than this limit.
483ff01b23SMartin Matuska.
493ff01b23SMartin Matuska.It Sy spl_kmem_cache_slab_limit Ns = Ns Sy 16384 Pq uint
503ff01b23SMartin MatuskaFor small objects the Linux slab allocator should be used to make the most
513ff01b23SMartin Matuskaefficient use of the memory.
523ff01b23SMartin MatuskaHowever, large objects are not supported by
533ff01b23SMartin Matuskathe Linux slab and therefore the SPL implementation is preferred.
543ff01b23SMartin MatuskaThis value is used to determine the cutoff between a small and large object.
553ff01b23SMartin Matuska.Pp
563ff01b23SMartin MatuskaObjects of size
573ff01b23SMartin Matuska.Sy spl_kmem_cache_slab_limit
583ff01b23SMartin Matuskaor smaller will be allocated using the Linux slab allocator,
593ff01b23SMartin Matuskalarge objects use the SPL allocator.
603ff01b23SMartin MatuskaA cutoff of 16K was determined to be optimal for architectures using 4K pages.
613ff01b23SMartin Matuska.
623ff01b23SMartin Matuska.It Sy spl_kmem_alloc_warn Ns = Ns Sy 32768 Pq uint
633ff01b23SMartin MatuskaAs a general rule
643ff01b23SMartin Matuska.Fn kmem_alloc
653ff01b23SMartin Matuskaallocations should be small,
663ff01b23SMartin Matuskapreferably just a few pages, since they must by physically contiguous.
673ff01b23SMartin MatuskaTherefore, a rate limited warning will be printed to the console for any
683ff01b23SMartin Matuska.Fn kmem_alloc
693ff01b23SMartin Matuskawhich exceeds a reasonable threshold.
703ff01b23SMartin Matuska.Pp
713ff01b23SMartin MatuskaThe default warning threshold is set to eight pages but capped at 32K to
723ff01b23SMartin Matuskaaccommodate systems using large pages.
733ff01b23SMartin MatuskaThis value was selected to be small enough to ensure
743ff01b23SMartin Matuskathe largest allocations are quickly noticed and fixed.
753ff01b23SMartin MatuskaBut large enough to avoid logging any warnings when a allocation size is
763ff01b23SMartin Matuskalarger than optimal but not a serious concern.
773ff01b23SMartin MatuskaSince this value is tunable, developers are encouraged to set it lower
783ff01b23SMartin Matuskawhen testing so any new largish allocations are quickly caught.
793ff01b23SMartin MatuskaThese warnings may be disabled by setting the threshold to zero.
803ff01b23SMartin Matuska.
813ff01b23SMartin Matuska.It Sy spl_kmem_alloc_max Ns = Ns Sy KMALLOC_MAX_SIZE Ns / Ns Sy 4 Pq uint
823ff01b23SMartin MatuskaLarge
833ff01b23SMartin Matuska.Fn kmem_alloc
843ff01b23SMartin Matuskaallocations will fail if they exceed
853ff01b23SMartin Matuska.Sy KMALLOC_MAX_SIZE .
863ff01b23SMartin MatuskaAllocations which are marginally smaller than this limit may succeed but
873ff01b23SMartin Matuskashould still be avoided due to the expense of locating a contiguous range
883ff01b23SMartin Matuskaof free pages.
893ff01b23SMartin MatuskaTherefore, a maximum kmem size with reasonable safely margin of 4x is set.
903ff01b23SMartin Matuska.Fn kmem_alloc
913ff01b23SMartin Matuskaallocations larger than this maximum will quickly fail.
923ff01b23SMartin Matuska.Fn vmem_alloc
933ff01b23SMartin Matuskaallocations less than or equal to this value will use
943ff01b23SMartin Matuska.Fn kmalloc ,
953ff01b23SMartin Matuskabut shift to
963ff01b23SMartin Matuska.Fn vmalloc
973ff01b23SMartin Matuskawhen exceeding this value.
983ff01b23SMartin Matuska.
993ff01b23SMartin Matuska.It Sy spl_kmem_cache_magazine_size Ns = Ns Sy 0 Pq uint
1003ff01b23SMartin MatuskaCache magazines are an optimization designed to minimize the cost of
1013ff01b23SMartin Matuskaallocating memory.
1023ff01b23SMartin MatuskaThey do this by keeping a per-cpu cache of recently
1033ff01b23SMartin Matuskafreed objects, which can then be reallocated without taking a lock.
1043ff01b23SMartin MatuskaThis can improve performance on highly contended caches.
1053ff01b23SMartin MatuskaHowever, because objects in magazines will prevent otherwise empty slabs
1063ff01b23SMartin Matuskafrom being immediately released this may not be ideal for low memory machines.
1073ff01b23SMartin Matuska.Pp
1083ff01b23SMartin MatuskaFor this reason,
1093ff01b23SMartin Matuska.Sy spl_kmem_cache_magazine_size
1103ff01b23SMartin Matuskacan be used to set a maximum magazine size.
1113ff01b23SMartin MatuskaWhen this value is set to 0 the magazine size will
1123ff01b23SMartin Matuskabe automatically determined based on the object size.
1133ff01b23SMartin MatuskaOtherwise magazines will be limited to 2-256 objects per magazine (i.e per cpu).
1143ff01b23SMartin MatuskaMagazines may never be entirely disabled in this implementation.
1153ff01b23SMartin Matuska.
1163ff01b23SMartin Matuska.It Sy spl_hostid Ns = Ns Sy 0 Pq ulong
1173ff01b23SMartin MatuskaThe system hostid, when set this can be used to uniquely identify a system.
1183ff01b23SMartin MatuskaBy default this value is set to zero which indicates the hostid is disabled.
1193ff01b23SMartin MatuskaIt can be explicitly enabled by placing a unique non-zero value in
1203ff01b23SMartin Matuska.Pa /etc/hostid .
1213ff01b23SMartin Matuska.
1223ff01b23SMartin Matuska.It Sy spl_hostid_path Ns = Ns Pa /etc/hostid Pq charp
1233ff01b23SMartin MatuskaThe expected path to locate the system hostid when specified.
1243ff01b23SMartin MatuskaThis value may be overridden for non-standard configurations.
1253ff01b23SMartin Matuska.
1263ff01b23SMartin Matuska.It Sy spl_panic_halt Ns = Ns Sy 0 Pq uint
1273ff01b23SMartin MatuskaCause a kernel panic on assertion failures.
1283ff01b23SMartin MatuskaWhen not enabled, the thread is halted to facilitate further debugging.
1293ff01b23SMartin Matuska.Pp
1303ff01b23SMartin MatuskaSet to a non-zero value to enable.
1313ff01b23SMartin Matuska.
1323ff01b23SMartin Matuska.It Sy spl_taskq_kick Ns = Ns Sy 0 Pq uint
1333ff01b23SMartin MatuskaKick stuck taskq to spawn threads.
1343ff01b23SMartin MatuskaWhen writing a non-zero value to it, it will scan all the taskqs.
1353ff01b23SMartin MatuskaIf any of them have a pending task more than 5 seconds old,
1363ff01b23SMartin Matuskait will kick it to spawn more threads.
1373ff01b23SMartin MatuskaThis can be used if you find a rare
1383ff01b23SMartin Matuskadeadlock occurs because one or more taskqs didn't spawn a thread when it should.
1393ff01b23SMartin Matuska.
1403ff01b23SMartin Matuska.It Sy spl_taskq_thread_bind Ns = Ns Sy 0 Pq int
1413ff01b23SMartin MatuskaBind taskq threads to specific CPUs.
1423ff01b23SMartin MatuskaWhen enabled all taskq threads will be distributed evenly
1433ff01b23SMartin Matuskaacross the available CPUs.
1443ff01b23SMartin MatuskaBy default, this behavior is disabled to allow the Linux scheduler
1453ff01b23SMartin Matuskathe maximum flexibility to determine where a thread should run.
1463ff01b23SMartin Matuska.
1473ff01b23SMartin Matuska.It Sy spl_taskq_thread_dynamic Ns = Ns Sy 1 Pq int
1483ff01b23SMartin MatuskaAllow dynamic taskqs.
1493ff01b23SMartin MatuskaWhen enabled taskqs which set the
1503ff01b23SMartin Matuska.Sy TASKQ_DYNAMIC
1513ff01b23SMartin Matuskaflag will by default create only a single thread.
1523ff01b23SMartin MatuskaNew threads will be created on demand up to a maximum allowed number
1533ff01b23SMartin Matuskato facilitate the completion of outstanding tasks.
1543ff01b23SMartin MatuskaThreads which are no longer needed will be promptly destroyed.
1553ff01b23SMartin MatuskaBy default this behavior is enabled but it can be disabled to
1563ff01b23SMartin Matuskaaid performance analysis or troubleshooting.
1573ff01b23SMartin Matuska.
1583ff01b23SMartin Matuska.It Sy spl_taskq_thread_priority Ns = Ns Sy 1 Pq int
1593ff01b23SMartin MatuskaAllow newly created taskq threads to set a non-default scheduler priority.
1603ff01b23SMartin MatuskaWhen enabled, the priority specified when a taskq is created will be applied
1613ff01b23SMartin Matuskato all threads created by that taskq.
1623ff01b23SMartin MatuskaWhen disabled all threads will use the default Linux kernel thread priority.
1633ff01b23SMartin MatuskaBy default, this behavior is enabled.
1643ff01b23SMartin Matuska.
1653ff01b23SMartin Matuska.It Sy spl_taskq_thread_sequential Ns = Ns Sy 4 Pq int
1663ff01b23SMartin MatuskaThe number of items a taskq worker thread must handle without interruption
1673ff01b23SMartin Matuskabefore requesting a new worker thread be spawned.
1683ff01b23SMartin MatuskaThis is used to control
1693ff01b23SMartin Matuskahow quickly taskqs ramp up the number of threads processing the queue.
1703ff01b23SMartin MatuskaBecause Linux thread creation and destruction are relatively inexpensive a
1713ff01b23SMartin Matuskasmall default value has been selected.
172bb2d13b6SMartin MatuskaThis means that normally threads will be created aggressively which is
173bb2d13b6SMartin Matuskadesirable.
1743ff01b23SMartin MatuskaIncreasing this value will
1753ff01b23SMartin Matuskaresult in a slower thread creation rate which may be preferable for some
1763ff01b23SMartin Matuskaconfigurations.
1773ff01b23SMartin Matuska.
1783ff01b23SMartin Matuska.It Sy spl_max_show_tasks Ns = Ns Sy 512 Pq uint
1793ff01b23SMartin MatuskaThe maximum number of tasks per pending list in each taskq shown in
1803ff01b23SMartin Matuska.Pa /proc/spl/taskq{,-all} .
1813ff01b23SMartin MatuskaWrite
1823ff01b23SMartin Matuska.Sy 0
1833ff01b23SMartin Matuskato turn off the limit.
1843ff01b23SMartin MatuskaThe proc file will walk the lists with lock held,
1853ff01b23SMartin Matuskareading it could cause a lock-up if the list grow too large
1863ff01b23SMartin Matuskawithout limiting the output.
1873ff01b23SMartin Matuska"(truncated)" will be shown if the list is larger than the limit.
1887b5e6873SMartin Matuska.
189*e2257b31SMartin Matuska.It Sy spl_taskq_thread_timeout_ms Ns = Ns Sy 5000 Pq uint
190*e2257b31SMartin MatuskaMinimum idle threads exit interval for dynamic taskqs.
191*e2257b31SMartin MatuskaSmaller values allow idle threads exit more often and potentially be
192*e2257b31SMartin Matuskarespawned again on demand, causing more churn.
1933ff01b23SMartin Matuska.El
194