Page MenuHomeFreeBSD

sysvshm: report mapped segments in procstat and objects in vmstat -o
ClosedPublic

Authored by kib on Oct 5 2024, 11:50 AM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Dec 20, 9:17 AM
Unknown Object (File)
Nov 23 2024, 7:37 PM
Unknown Object (File)
Nov 21 2024, 5:24 PM
Unknown Object (File)
Nov 20 2024, 11:09 AM
Unknown Object (File)
Nov 18 2024, 7:41 PM
Unknown Object (File)
Nov 18 2024, 6:06 PM
Unknown Object (File)
Nov 9 2024, 7:29 PM
Unknown Object (File)
Nov 6 2024, 7:44 PM
Subscribers

Details

Summary
vm_object: add a place for more flags, which uses a hole on 64bit systems


sysv_ipc: remove sys/cdefs.h include


vm_object: add OBJ2_SYSVSHM flag2 to indicate SysV shm backing object


sysvshm: add shmobjinfo() function to find key/seq of the segment backed by obj


kinfo_vmentry: report mappings of the SysV shm segments

Mark such mappings with the new flag KVME_FLAG_SYSVSHM.
Provide segment key in kve_vn_fileid, vnode never can back shm mapping.
Provide sequence number in kve_vn_fsid_freebsd11.


kinfo_vmobject: report backing object of the SysV shm segments

Use reserved work for kvo_flags.
Mark such object with KVMO_FLAG_SYSVSHM.
Provide segment key in kvo_vn_fileid, vnode never can back shm mapping.
Provide sequence number in kvo_vn_fsid_freebsd11.


procstat vm: report SysV shm segment mapping

Also print its key and sequence number.


vmstat -o: report objects backing SysV shm segments

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

kib requested review of this revision.Oct 5 2024, 11:50 AM
sys/kern/sysv_shm.c
1055–1056

Need to set the new hook to NULL here.

sys/vm/vm_object.h
112

I never committed D35905. :(

I would prefer that, instead of having a second flag field. Do you agree? If so, I'll push it.

usr.bin/procstat/procstat_vm.c
170

The parameters are unsigned, this looks like it should be %ju:%u.

usr.bin/vmstat/vmstat.c
1543

We want the uintmax_t cast here too, no?

kib marked 4 inline comments as done.Oct 6 2024, 3:54 AM

I will wait for your vm_object flag commit.

Use vm_object_set_flag()

sys/kern/sysv_shm.c
875

What if we don't identify the object for some reason, e.g., we're racing with destruction? Then these return values are left uninitialized. Probably we should set some default values, or use a return value to indicate whether the object was found or not.

sys/kern/sysv_shm.c
875

This is why the hook itself pre-sets the *key and *seq to zero. I do not think it is needed to do more.

sys/kern/sysv_shm.c
875

I see, I missed a layer of indirection. But the problem is still there if options SYSVSHM is defined.

markj added inline comments.
usr.bin/procstat/procstat_vm.c
173

Is the intent that we will print the sysvshm identifier, or a path, or nothing? I would put an else here to make that more clear.

This revision is now accepted and ready to land.Oct 6 2024, 11:46 PM
usr.bin/procstat/procstat_vm.c
173

I want to see how hard is to report posixshm name as the next step, then I will see how to make this block final.