Page MenuHomeFreeBSD

procstat: report vm mappings size
Needs ReviewPublic

Authored by salvopolizzi03_gmail.com on Mar 4 2026, 6:54 PM.
Tags
None
Referenced Files
F151996546: D55653.id.diff
Sun, Apr 12, 12:13 AM
Unknown Object (File)
Sun, Apr 5, 1:14 PM
Unknown Object (File)
Sun, Mar 29, 12:56 PM
Unknown Object (File)
Mon, Mar 23, 10:23 PM
Unknown Object (File)
Sun, Mar 22, 11:19 PM
Unknown Object (File)
Fri, Mar 13, 9:25 PM
Unknown Object (File)
Fri, Mar 13, 12:40 PM
Unknown Object (File)
Mar 9 2026, 7:11 AM

Details

Summary

Add a SIZE column to procstat vm output showing the size of each
virtual memory mapping (END - START).

Example output from the 'procstat -a vm':

 PID              START                END SIZE  PRT  RES PRES REF SHD   FLAG TP
1380      0x605014ce000      0x605014d9000 44K  r--   11   42   9   3 CN--- vn /bin/sh
1380      0x605014d9000      0x605014f8000 124K  r-x   31   42   9   3 CN--- vn /bin/sh
1380      0x605014f8000      0x605014f9000 4.0K  r--    1    1   1   0 CN--- sw
1380      0x605014f9000      0x605014fa000 4.0K  rw-    1    0   1   0 C---- vn /bin/sh
1380      0x605014fa000      0x605014fc000 8.0K  rw-    2    2   1   0 C---- sw
1380      0x60d02136000      0x60d22116000 512M  ---    0    0   0   0 ----- gd
1380      0x60d22116000      0x60d22136000 128K  rw-   13   13   1   0 C--D- sw
1380      0x60d225be000      0x60d225bf000 4.0K  r-x    1    1  31   0 ----- ph
1380      0x60d2358d000      0x60d235a3000 88K  r--   22   53  12   6 CN--- vn /lib/libedit.so.8

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

obiwac added a reviewer: kib.
usr.bin/procstat/procstat_vm.c
54

you didn't update the format string here, so PATH is cut off

72–77

why do we have the size here twice?

Why is this needed? Size is end-start.
Note that there are huge amount of scripts used by people who parse procstat vm output based on the text format, with the fixed assignment of the columns. The output layout for text is kind of ABI, due to this.

If you insist that it is must be added, it probably fine for structured output like json/xml, but even less useful because its parsing already requires some full language that can do end-start. For the text columnar format, the new column perhaps requires a new option to enable it.

In D55653#1273804, @kib wrote:

Why is this needed? Size is end-start.
Note that there are huge amount of scripts used by people who parse procstat vm output based on the text format, with the fixed assignment of the columns. The output layout for text is kind of ABI, due to this.

If you insist that it is must be added, it probably fine for structured output like json/xml, but even less useful because its parsing already requires some full language that can do end-start. For the text columnar format, the new column perhaps requires a new option to enable it.

In which case maybe we add size to the very end? this wasn't mentioned in the review description, but this is related to bug https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=293416 for context

In D55653#1273804, @kib wrote:

Why is this needed? Size is end-start.
Note that there are huge amount of scripts used by people who parse procstat vm output based on the text format, with the fixed assignment of the columns. The output layout for text is kind of ABI, due to this.

If you insist that it is must be added, it probably fine for structured output like json/xml, but even less useful because its parsing already requires some full language that can do end-start. For the text columnar format, the new column perhaps requires a new option to enable it.

In which case maybe we add size to the very end? this wasn't mentioned in the review description, but this is related to bug https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=293416 for context

Note that the field in the last column, which contains the path, might be empty. This makes additions after it even worse than just breaking the layout as proposed in patch.

I do suggest to add an option to enable the size column.

In D55653#1273825, @kib wrote:
In D55653#1273804, @kib wrote:

Why is this needed? Size is end-start.
Note that there are huge amount of scripts used by people who parse procstat vm output based on the text format, with the fixed assignment of the columns. The output layout for text is kind of ABI, due to this.

If you insist that it is must be added, it probably fine for structured output like json/xml, but even less useful because its parsing already requires some full language that can do end-start. For the text columnar format, the new column perhaps requires a new option to enable it.

In which case maybe we add size to the very end? this wasn't mentioned in the review description, but this is related to bug https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=293416 for context

Note that the field in the last column, which contains the path, might be empty. This makes additions after it even worse than just breaking the layout as proposed in patch.

I do suggest to add an option to enable the size column.

How do you suggest to name the option? Something like --size?

usr.bin/procstat/procstat_vm.c
72–77

The first one should display the size with the h modifier so what is displayed in the console while the e modifier should emit for encoding output styles (json, xml). Maybe i'm missing something

usr.bin/procstat/procstat_vm.c
72–77

ah yes indeed. you're not missing anything I'm just not that familiar with libxo :)

In D55653#1273825, @kib wrote:
In D55653#1273804, @kib wrote:

Why is this needed? Size is end-start.
Note that there are huge amount of scripts used by people who parse procstat vm output based on the text format, with the fixed assignment of the columns. The output layout for text is kind of ABI, due to this.

If you insist that it is must be added, it probably fine for structured output like json/xml, but even less useful because its parsing already requires some full language that can do end-start. For the text columnar format, the new column perhaps requires a new option to enable it.

In which case maybe we add size to the very end? this wasn't mentioned in the review description, but this is related to bug https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=293416 for context

Note that the field in the last column, which contains the path, might be empty. This makes additions after it even worse than just breaking the layout as proposed in patch.

I do suggest to add an option to enable the size column.

How do you suggest to name the option? Something like --size?

Does procstat support the long options?

Note that the option should be for the 'vm' command, not for procstat itself.