Page MenuHomeFreeBSD

More work on kq introspection: NT_PROCSTAT_KQUEUE and compat32
Needs ReviewPublic

Authored by kib on Sat, Mar 15, 4:34 AM.
Tags
None
Referenced Files
F112521089: D49372.diff
Wed, Mar 19, 6:43 AM
Unknown Object (File)
Sun, Mar 16, 11:22 PM
Unknown Object (File)
Sun, Mar 16, 1:11 AM
Unknown Object (File)
Sun, Mar 16, 12:57 AM
Unknown Object (File)
Sat, Mar 15, 7:57 PM
Unknown Object (File)
Sat, Mar 15, 6:49 PM
Subscribers

Details

Reviewers
jhb
markj
Summary
filedesc: export fdhold() and fddrop() functions


sysctl_kern_proc_kqueue(): convert to use sbuf


kinfo_knote: add knt_kq_fd member

Note: this breaks kinfo_knote ABI


FREEBSD_COMPAT32: add freebsd32_kevent_to_kevent32() helper

converting struct kevent to struct kevent32


sysctl KERN_PROC_KQUEUE: implement compat32


Add NT_PROCSTAT_KQUEUES core note

Suggested by:   jhb


sysctl KERN_PROC_KQUEUE: treat omitted kqfd as request to dump all kqueues


libprocstat: change psc_type_info array to use designated initializers


libprocstat: add knowledge about NT_PROCSTAT_KQUEUES core file section


gcore(1): dump NT_PROCSTAT_KQUEUES section
Test Plan

I dumped core with gcore, and then read kqueues events with procstat kqueues core.pid.
For compat32, I manually verified layouts of 32bit-compiled struct kinfo_knote vs. kinfo_knote32 using gdb ptype/o pahole command.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

kib requested review of this revision.Sat, Mar 15, 4:34 AM
kib retitled this revision from More work on kq introspection: NT__PROCSTAT_KQUEUE and compat32 to More work on kq introspection: NT_PROCSTAT_KQUEUE and compat32.Sat, Mar 15, 4:37 AM
kib edited the test plan for this revision. (Show Details)

Break ABI even more, by adding scratch fields before type-specific union.
Limit the size of copying by maxlen.

lib/libprocstat/core.c
60

Can this be const too?

sys/kern/kern_event.c
2986

Rather than exporting fdhold() and allowing implementation details from kern_descrip.c to leak out, can we add a callback interface to kern_descrip.c? Something like

int fget_remote_all(struct proc *p, void (*cb)(int, struct file *, void *), void *arg);

Then, invoke the callback on each file in the table, and here the callback is just

if (fp->f_type == DTYPE_KQUEUE) {
    kq = fp->f_data;
    error = kern_proc_kqueue_report(...);
}

with s and compat32 passed via an opaque structure.

3000

imin() is wrong for size_t-sized parameters.

kib marked 3 inline comments as done.

fget_remote_foreach()
constify array in libprocstat/core.c
Use MIN() instead of imin() for size_t.