aboutsummaryrefslogtreecommitdiff
path: root/sys/netinet/in_pcb.c
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2023-05-30 19:11:32 +0000
committerMark Johnston <markj@FreeBSD.org>2023-05-30 19:11:32 +0000
commit4e78addbeff902aabaa87fdaafbd962f90720d69 (patch)
treee59d8edddcb04c43696c68ce0b2b43ff4ab86778 /sys/netinet/in_pcb.c
parent7a52b570e758a5f607c4071e260065633632c868 (diff)
downloadsrc-4e78addbeff902aabaa87fdaafbd962f90720d69.tar.gz
src-4e78addbeff902aabaa87fdaafbd962f90720d69.zip
buf: Make the number of pbufs slightly more dynamic
Various subsystems pre-allocate a set of pbufs, allocated to implement I/O operations. pbuf allocations are transient, unlike most buf allocations. Most subsystems preallocate nswbuf or nswbuf/2 pbufs each. The preallocation ensures that pbuf allocation will succeed in low memory conditions, which might help avoid deadlocks. Currently we initialize nswbuf = min(nbuf / 4, 256). nbuf/4 > 256 on anything but the smallest systems. For example, nswbuf is 256 in a VM with 128MB of memory. In this configuration, a firecracker VM with one CPU preallocates over 900 pbufs. This consumes 2MB of RAM and adds several milliseconds to the kernel's (very small) boot time. Scale nswbuf by ncpu in the common case. I think this makes more sense than scaling by the amount of RAM, since pbuf allocations are transient and aren't used for caching. With the change, we get nswbuf=256 with 8 CPUs. With fewer than 8 CPUs we'll preallocate fewer pbufs than before, and with more we'll preallocate more. Event: BSDCan 2023 Reported by: cperciva Reviewed by: glebius, kib MFC after: 2 months Differential Revision: https://reviews.freebsd.org/D40216
Diffstat (limited to 'sys/netinet/in_pcb.c')
0 files changed, 0 insertions, 0 deletions