Bug 259940 - [linuxulator][wine] no way to query the maximum process ki_size
Summary: [linuxulator][wine] no way to query the maximum process ki_size
Status: In Progress
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 13.0-RELEASE
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-bugs (Nobody)
Depends on:
Blocks: 247219
  Show dependency treegraph
Reported: 2021-11-20 03:17 UTC by Damjan Jovanovic
Modified: 2023-02-27 13:36 UTC (History)
3 users (show)

See Also:

proposed patch (4.77 KB, patch)
2021-11-20 18:06 UTC, Mark Johnston
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Damjan Jovanovic 2021-11-20 03:17:00 UTC
"struct kinfo_proc" lets us query the maximum RSS size ever attained using "i_rusage.ru_maxrss", but there is no similar field for the maximum "ki_size" (size of all virtual memory).

Since both Windows and Linux expect this, linuxulator's sys/compat/linprocfs/linprocfs.c function linprocfs_doprocstatus() completely omits "VmPeak", while in Wine I've had to lie that "ki_size" is both the current and maximum usage.

I wonder whether the kernel even captures that statistic?
Comment 1 Mark Johnston freebsd_committer 2021-11-20 18:06:31 UTC
Created attachment 229620 [details]
proposed patch

We don't track that value, but it is not hard to add.  See the attached patch.

One nit is that we count mappings with protection PROT_NONE, but not guard mappings, but for accounting purposes they should be treated the same.  Handling that properly would require some extra complexity that is probably not worth it.
Comment 2 Dmitry Chagin freebsd_committer 2023-02-26 14:30:37 UTC
(In reply to Mark Johnston from comment #1)
Mark, may we commit this without reporter feedback? It looks fine to me.
Comment 3 Mark Johnston freebsd_committer 2023-02-27 13:36:28 UTC
(In reply to Dmitry Chagin from comment #2)
The sys/vm portion of the patch requires some review.  I'll post it to phabricator when I get a chance.