Page MenuHomeFreeBSD

kqueue: do not buffer the whole knote report when sizing it
ClosedPublic

Authored by seuros on Jul 29 2026, 5:07 PM.
Tags
None
Referenced Files
F174965863: D58536.id.diff
Wed, Oct 7, 6:21 AM
F174965410: D58536.diff
Wed, Oct 7, 6:16 AM
F174965400: D58536.id183170.diff
Wed, Oct 7, 6:16 AM
F174965208: D58536.id183043.diff
Wed, Oct 7, 6:15 AM
F174947803: D58536.diff
Wed, Oct 7, 3:33 AM
F174875478: D58536.diff
Tue, Oct 6, 5:15 PM
Unknown Object (File)
Tue, Sep 29, 6:41 AM
Unknown Object (File)
Sat, Sep 26, 5:11 PM
Subscribers

Details

Summary

kern_proc_kqueues_out() reported into an intermediate sbuf and copied the
result into the caller's.

A process that had leaked 468k kqueue descriptors wired 757 MB of M_SBUF
while dumping core, over roughly 9M reallocations, then copied the whole
thing again.

PR 296835: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=296835

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

markj added a subscriber: markj.

This is also bugzilla PR 296835: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=296835, please include that in the commit log message.

With the change we avoid the reallocations, but we're still potentially allocating a giant buffer when actually writing out the note, no? I don't really understand why kern_proc_kqueues_out() doesn't just use the caller-supplied sbuf.

This revision is now accepted and ready to land.Jul 31 2026, 2:12 PM
This revision now requires review to proceed.Jul 31 2026, 3:45 PM
This revision is now accepted and ready to land.Jul 31 2026, 3:45 PM