Bug 495488 - Add FreeBSD getrlimitusage syscall wrapper
Summary: Add FreeBSD getrlimitusage syscall wrapper
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (show other bugs)
Version: 3.24 GIT
Platform: Other Other
: NOR normal
Target Milestone: ---
Assignee: Paul Floyd
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-10-28 14:58 UTC by Paul Floyd
Modified: 2024-11-03 11:02 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Floyd 2024-10-28 14:58:05 UTC
This was added 2024-09-27.

It isn't going to be straightforward. It should be fairly similar to getrlimit, with the additional requirement that it needs to get the current guest file/data/stack usage.
Comment 1 Paul Floyd 2024-11-01 20:44:17 UTC
If I compile and run the exe at the end of this page https://reviews.freebsd.org/D46747?id=143605 then I get

cpu (0):        0
fsize (1):      -1
data (2):       4096
stack (3):      131072
core (4):       -1
rss (5):        2547712
memlock (6):    0
nproc (7):      6
nofile (8):     3
sbsize (9):     0
vmem (10):      14397440
npts (11):      0
swap (12):      17977
kqueues (13):   0
umtx (14):      0
pipebuf (15):   0

data and stack look like the most complicated ones

The kernel code is

	case RLIMIT_DATA:
		if (vm == NULL)
			error = ENXIO;
		else
			*res = vm->vm_dsize * PAGE_SIZE;
		break;
	case RLIMIT_STACK:
		if (vm == NULL)
			error = ENXIO;
		else
			*res = vm->vm_ssize * PAGE_SIZE;
		break;
Comment 2 Paul Floyd 2024-11-03 11:02:33 UTC
commit 0b6c1515d158745e97ad206bf1cd3caceb8ed4dd
Author: Paul Floyd <pjfloyd@wanadoo.fr>
Date:   Sun Nov 3 10:17:17 2024 +0100

    Bug 495488 - Add FreeBSD getrlimitusage syscall wrapper