Bug 495488

Summary: Add FreeBSD getrlimitusage syscall wrapper
Product: [Developer tools] valgrind Reporter: Paul Floyd <pjfloyd>
Component: generalAssignee: Paul Floyd <pjfloyd>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version First Reported In: 3.24 GIT   
Target Milestone: ---   
Platform: Other   
OS: Other   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

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