Page MenuHomeFreeBSD

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

Authored by guest-seuros on Wed, Jul 29, 5:07 PM.

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.Fri, Jul 31, 2:12 PM
This revision now requires review to proceed.Fri, Jul 31, 3:45 PM
This revision is now accepted and ready to land.Fri, Jul 31, 3:45 PM