Skip to content

Commit

Permalink
procstat: Include a maxprot column in "vm -v" output
Browse files Browse the repository at this point in the history
This field is unlikely to be useful most of the time, but it can be handy.
Hide it under verbose mode together with the RESERV column.
  • Loading branch information
markjdb committed Aug 14, 2024
1 parent 9dab939 commit f4b1b61
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
2 changes: 2 additions & 0 deletions usr.bin/procstat/procstat.1
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,8 @@ ending address of mapping
starting address of the reservation this entry belongs to
.It PRT
protection flags
.It MAXPRT
maximum protection flags
.It RES
resident pages
.It PRES
Expand Down
38 changes: 36 additions & 2 deletions usr.bin/procstat/procstat_vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ procstat_vm(struct procstat *procstat, struct kinfo_proc *kipp)
"PID", ptrwidth, "START", ptrwidth, "END", "PRT",
"RES", "PRES", "REF", "SHD", "FLAG", "TP", "PATH");
else
xo_emit("{T:/%5s %*s %*s %*s %-5s %4s %4s %3s %3s %-6s %-2s %-s}\n",
xo_emit("{T:/%5s %*s %*s %*s %-5s %-5s %4s %4s %3s %3s %-6s %-2s %-s}\n",

Check warning on line 63 in usr.bin/procstat/procstat_vm.c

View workflow job for this annotation

GitHub Actions / Style Checker

line over 80 characters
"PID", ptrwidth, "START", ptrwidth, "END",
ptrwidth, "RESERV", "PRT",
ptrwidth, "RESERV", "PRT", "MAXPRT",
"RES", "PRES", "REF", "SHD", "FLAG", "TP", "PATH");
}

Expand Down Expand Up @@ -109,6 +109,40 @@ procstat_vm(struct procstat *procstat, struct kinfo_proc *kipp)
xo_emit("{en:write_cap/%s}", kve->kve_protection &
KVME_PROT_WRITE_CAP ? "true" : "false");
xo_close_container("kve_protection");
if ((procstat_opts & PS_OPT_VERBOSE) != 0) {
xo_emit("{d:max_read/%s}",
kve->kve_max_protection & KVME_PROT_READ ?
"r" : "-");
xo_emit("{d:max_write/%s}",
kve->kve_max_protection & KVME_PROT_WRITE ?
"w" : "-");
xo_emit("{d:max_exec/%s}",
kve->kve_max_protection & KVME_PROT_EXEC ?
"x" : "-");
xo_emit("{d:max_read_cap/%s}",
kve->kve_max_protection & KVME_PROT_READ_CAP ?
"R" : "-");
xo_emit("{d:max_write_cap/%-2s} ",
kve->kve_max_protection & KVME_PROT_WRITE_CAP ?
"W" : "-");
xo_open_container("kve_max_protection");
xo_emit("{en:max_read/%s}",
kve->kve_max_protection & KVME_PROT_READ ?
"true" : "false");
xo_emit("{en:max_write/%s}",
kve->kve_max_protection & KVME_PROT_WRITE ?
"true" : "false");
xo_emit("{en:max_exec/%s}",
kve->kve_max_protection & KVME_PROT_EXEC ?
"true" : "false");
xo_emit("{en:max_read_cap/%s}",
kve->kve_max_protection & KVME_PROT_READ_CAP ?
"true" : "false");
xo_emit("{en:max_write_cap/%s}",
kve->kve_max_protection & KVME_PROT_WRITE_CAP ?
"true" : "false");
xo_close_container("kve_max_protection");
}
xo_emit("{:kve_resident/%4d/%d} ", kve->kve_resident);
xo_emit("{:kve_private_resident/%4d/%d} ",
kve->kve_private_resident);

Check failure on line 148 in usr.bin/procstat/procstat_vm.c

View workflow job for this annotation

GitHub Actions / Style Checker

Missing Signed-off-by: line
Expand Down

0 comments on commit f4b1b61

Please sign in to comment.