Page MenuHomeFreeBSD

getrlimusage(2): a syscall and a tool to query current resource usage
Needs ReviewPublic

Authored by kib on Sun, Sep 22, 1:11 PM.

Details

Summary

... which are limited by RLIMIT.

This was extremely useful for me when I looked at the pipebuf limits bugs.

[No manpages ATM, will write after feedback on the interfaces. Overall, it is trivial and clear IMO].

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

kib requested review of this revision.Sun, Sep 22, 1:11 PM

IMO it would be better to add this to procstat rlimit output, rather than adding a new utility.

Why not implement this interface with a sysctl, similar to sysctl_kern_proc_rlimit()?

IMO it would be better to add this to procstat rlimit output, rather than adding a new utility.

Why not implement this interface with a sysctl, similar to sysctl_kern_proc_rlimit()?

This is somewhat ortogonal. The syscall is supposed to be used by the process itself to query its usage of the resources. Same as getrlimit(2) queries the limit, despite the presence of sysctl.

For instance, this syscall might finally give the answer to question how much usable anon memory can be allocated, assuming the limits are enforced.

In D46747#1065718, @kib wrote:

IMO it would be better to add this to procstat rlimit output, rather than adding a new utility.

Why not implement this interface with a sysctl, similar to sysctl_kern_proc_rlimit()?

This is somewhat ortogonal. The syscall is supposed to be used by the process itself to query its usage of the resources. Same as getrlimit(2) queries the limit, despite the presence of sysctl.

But it takes a PID as a parameter. Having a simple syscall interface is nice I suppose, IMO it is nice to follow the precedent of:

  • have getrlimitusage(2) operate on the current process
  • provide a sysctl interface to let (lib)procstat etc. query the limit usage of other processes

For instance, this syscall might finally give the answer to question how much usable anon memory can be allocated, assuming the limits are enforced.

Remove pid from the syscall args.
Add sysctl.
Add libprocstat function.
Add procstat limresusage command.

Any advice how to properly use libxo would be appreciated.