From 5c32e9fcb228dcd1a2c91b6eff1555b7d3c02dbd Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Tue, 18 Jun 2019 21:05:10 +0000 Subject: 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. --- sys/sys/sbuf.h | 1 + 1 file changed, 1 insertion(+) (limited to 'sys/sys/sbuf.h') 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); +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 *); -- cgit v1.2.3