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
Unknown Object (File)
Tue, Sep 15, 12:10 AM
Unknown Object (File)
Mon, Sep 14, 3:33 PM
Unknown Object (File)
Fri, Sep 11, 6:29 PM
Unknown Object (File)
Wed, Sep 9, 3:33 PM
Unknown Object (File)
Wed, Sep 9, 12:00 AM
Unknown Object (File)
Tue, Sep 8, 12:32 AM
Unknown Object (File)
Mon, Sep 7, 1:28 AM
Unknown Object (File)
Sun, Sep 6, 11:03 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