zos: use CVTRLSTG to get total memory accurately

The previous implementation using rcepool would return a value that is
slightly off from the true value of the system's total memory. So use
CVTRLSTG to get total memory instead, which is more accurate. For more
information on CVTRLSTG, see MVS Data Areas Volumes 1 and 3.

Co-authored-by: Gaby Baghdadi <49249542+gabylb@users.noreply.github.com>
PR-URL: https://github.com/libuv/libuv/pull/3141
Reviewed-By: Richard Lau <rlau@redhat.com>
This commit is contained in:
Shuowang (Wayne) Zhang 2021-03-25 19:53:53 -04:00 committed by Santiago Gimeno
parent f15216e9dd
commit 47e0c5c575
No known key found for this signature in database
GPG Key ID: F28C3C8DA33C03BE

View File

@ -63,12 +63,6 @@
/* Address of the rsm control and enumeration area. */
#define CVTRCEP_OFFSET 0x490
/*
Number of frames currently available to system.
Excluded are frames backing perm storage, frames offline, and bad frames.
*/
#define RCEPOOL_OFFSET 0x004
/* Total number of frames currently on all available frame queues. */
#define RCEAFC_OFFSET 0x088
@ -188,14 +182,8 @@ uint64_t uv_get_free_memory(void) {
uint64_t uv_get_total_memory(void) {
uint64_t totalram;
data_area_ptr cvt = {0};
data_area_ptr rcep = {0};
cvt.assign = *(data_area_ptr_assign_type*)(CVT_PTR);
rcep.assign = *(data_area_ptr_assign_type*)(cvt.deref + CVTRCEP_OFFSET);
totalram = *((uint64_t*)(rcep.deref + RCEPOOL_OFFSET)) * 4;
return totalram;
/* Use CVTRLSTG to get the size of actual real storage online at IPL in K. */
return (uint64_t)((int)((char *__ptr32 *__ptr32 *)0)[4][214]) * 1024;
}