path: root/sys/sys/sbuf.h
diff options
authorAlexander Motin <mav@FreeBSD.org>2019-06-18 21:05:10 +0000
committerAlexander Motin <mav@FreeBSD.org>2019-06-18 21:05:10 +0000
commit5c32e9fcb228dcd1a2c91b6eff1555b7d3c02dbd (patch)
tree9046c84b21d2628c4e3f76aa90a0279410a92e9b /sys/sys/sbuf.h
parentcfdcc8c7fab08427f28c59f49a9a8c6f8db51cea (diff)
Optimize kern.geom.conf* sysctls.
On large systems those sysctls may generate megabytes of output. Before this change sbuf(9) code was resizing buffer by 4KB each time many times, generating tons of TLB shootdowns. Unfortunately in this case existing sbuf_new_for_sysctl() mechanism, supposed to help with this issue, is not applicable, since all the sbuf writes are done in different kernel thread. This change improves situation in two ways: - on first sysctl call, not providing any output buffer, it sets special sbuf drain function, just counting the data and so not needing big buffer; - on second sysctl call it uses as initial buffer size value saved on previous call, so that in most cases there will be no reallocation, unless GEOM topology changed significantly. MFC after: 1 week Sponsored by: iXsystems, Inc.
Notes: svn path=/head/; revision=349178
Diffstat (limited to 'sys/sys/sbuf.h')
1 files changed, 1 insertions, 0 deletions
diff --git a/sys/sys/sbuf.h b/sys/sys/sbuf.h
index b4d274158ab0..4010f3b7d31c 100644
--- a/sys/sys/sbuf.h
+++ b/sys/sys/sbuf.h
@@ -103,6 +103,7 @@ void sbuf_start_section(struct sbuf *, ssize_t *);
ssize_t sbuf_end_section(struct sbuf *, ssize_t, size_t, int);
void sbuf_hexdump(struct sbuf *, const void *, int, const char *,
+int sbuf_count_drain(void *arg, const char *data, int len);
int sbuf_printf_drain(void *arg, const char *data, int len);
void sbuf_putbuf(struct sbuf *);