Skip to content

macos: update vm_statistics64 to latest sdk#5253

Merged
tgross35 merged 2 commits into
rust-lang:mainfrom
elihwyma:main
Jul 9, 2026
Merged

macos: update vm_statistics64 to latest sdk#5253
tgross35 merged 2 commits into
rust-lang:mainfrom
elihwyma:main

Conversation

@elihwyma

@elihwyma elihwyma commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Description

Updates vm_statistics64 to include the new values added in more recent MacOS SDK versions.

Sources

Relevant header snippet from MacOS27.sdk

struct vm_statistics64 {
	natural_t       free_count;             /* # of pages free */
	natural_t       active_count;           /* # of pages active */
	natural_t       inactive_count;         /* # of pages inactive */
	natural_t       wire_count;             /* # of pages wired down */
	uint64_t        zero_fill_count;        /* # of zero fill pages */
	uint64_t        reactivations;          /* # of pages reactivated */
	uint64_t        pageins;                /* # of pageins (lifetime) */
	uint64_t        pageouts;               /* # of pageouts */
	uint64_t        faults;                 /* # of faults */
	uint64_t        cow_faults;             /* # of copy-on-writes */
	uint64_t        lookups;                /* object cache lookups */
	uint64_t        hits;                   /* object cache hits */
	uint64_t        purges;                 /* # of pages purged */
	natural_t       purgeable_count;        /* # of pages purgeable */
	/*
	 * NB: speculative pages are already accounted for in "free_count",
	 * so "speculative_count" is the number of "free" pages that are
	 * used to hold data that was read speculatively from disk but
	 * haven't actually been used by anyone so far.
	 */
	natural_t       speculative_count;      /* # of pages speculative */

	/* added for rev1 */
	uint64_t        decompressions;         /* # of pages decompressed (lifetime) */
	uint64_t        compressions;           /* # of pages compressed (lifetime) */
	uint64_t        swapins;                /* # of pages swapped in via compressor segments (lifetime) */
	uint64_t        swapouts;               /* # of pages swapped out via compressor segments (lifetime) */
	natural_t       compressor_page_count;  /* # of pages used by the compressed pager to hold all the compressed data */
	natural_t       throttled_count;        /* # of pages throttled */
	natural_t       external_page_count;    /* # of pages that are file-backed (non-swap) */
	natural_t       internal_page_count;    /* # of pages that are anonymous */
	uint64_t        total_uncompressed_pages_in_compressor; /* # of pages (uncompressed) held within the compressor. */
	/* added for rev2 */
	uint64_t        swapped_count;          /* # of compressor-stored pages currently stored in swap */
	/* Added in rev3 */
	/* The total number of physical pages in the tag storage region */
	uint64_t total_tag_storage_pages;
	/*
	 * The number of tag storage pages which hold non-tag data and are pageable
	 */
	uint64_t nontag_pageable_tag_storage_pages;
	/* The number of tag storage pages which hold non-tag data and are wired */
	uint64_t nontag_wired_tag_storage_pages;
	/*
	 * The number of tag storage pages which are being used for neither tags nor
	 * regular memory
	 */
	uint64_t free_tag_storage_pages;
	/* The number of tag storage pages which currently hold tags */
	uint64_t tag_storing_tag_storage_pages;

	/* The total number of virtual pages which are tagged */
	uint64_t total_tagged_pages;
	/* The number of resident, physical pages which are tagged */
	uint64_t resident_tagged_pages;
	/*
	 * The outstanding number of virtual tagged pages whose contents reside in the
	 * compressor
	 */
	uint64_t compressed_tagged_pages;

	/* The number of tagged pages which have been compressed since boot */
	uint64_t tagged_compressions;
	/* The number of tagged pages which have been decompressed since boot */
	uint64_t tagged_decompressions;
	/* The current number of bytes consumed by compressed tag storage data */
	uint64_t compressed_tag_storage_bytes;
	/* added for rev4 */
	/* The number of pages created due to speculative prefetch since boot */
	uint64_t speculative_pages_created;
	/* The number speculative pages that have been activated since boot */
	uint64_t speculative_pages_activated;

	/* Added for rev4 */
	/* The number of pages currently populated in the swapfile */
	uint64_t swap_count;

	/* Added for rev5 */
	/*
	 * The number of tag storage pages which are reserved for storing tags but
	 * don't currently hold any
	 */
	uint64_t empty_tag_storing_tag_storage_pages;
	/*
	 * The number of resident, file-backed (i.e. excluding JIT) pages which are
	 * mapped as executable
	 */
	uint64_t executable_count;
	/* The number of resident pages which are part of a shared region */
	uint64_t shared_region_count;
	/* The number of pages stolen by the booter */
	uint64_t boot_stolen_count;
	/* The number of file-backed pages which are secluded */
	uint64_t secluded_count;
	/* The number of internal pageable pages which are active */
	uint64_t active_internal_count;
	/* The number of internal pageable pages which are inactive */
	uint64_t inactive_internal_count;
	/* The number of external pageable pages which are active */
	uint64_t active_external_count;
	/* The number of external pageable pages which are inactive */
	uint64_t inactive_external_count;
	/* The number of purgeable volatile pages which are pageable */
	uint64_t purgeable_pageable_count;
	/* The number of purgeable-volatile pages which are wired */
	uint64_t purgeable_wired_count;
	/* The number of anonymous pages which are backgrounded */
	uint64_t background_internal_count;
	/* The number of file-backed pages which are backgrounded */
	uint64_t background_external_count;
	/* The number of anonymous pages which are queued for self-donation (App Swap) */
	uint64_t donated_count;
	/* The number of anonymous pages which are marked as real-time */
	uint64_t realtime_count;
	/* The size of physical memory in pages */
	uint64_t max_mem_count;
	/* The number of phantom file-cache ghosts which were re-paged-in */
	uint64_t phantom_ghosts_found;
	/* The number of phantom file-cache ghosts created by pageout */
	uint64_t phantom_ghosts_added;
} __attribute__((aligned(8)));

Checklist

  • Relevant tests in libc-test/semver have been updated
  • No placeholder or unstable values like *LAST or *MAX are
    included (see #3131)
  • Tested locally (cd libc-test && cargo test --target mytarget);
    especially relevant for platforms that may not be checked in CI

@rustbot label +stable-nominated

@rustbot rustbot added S-waiting-on-review stable-nominated This PR should be considered for cherry-pick to libc's stable release branch labels Jul 5, 2026
@elihwyma elihwyma changed the title feat: update vm_statistics64 to latest sdk macos: update vm_statistics64 to latest sdk Jul 5, 2026
@rustbot

This comment has been minimized.

@rustbot

rustbot commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

⚠️ Warning ⚠️

  • The following commits have merge commits (commits with multiple parents) in your changes. We have a no merge policy so these commits will need to be removed for this pull request to be merged.

    You can start a rebase with the following commands:

    $ # rebase
    $ git pull --rebase https://github.com/rust-lang/libc.git main
    $ git push --force-with-lease
    

@rustbot

rustbot commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@tgross35 tgross35 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you remove the skip at

libc/libc-test/build.rs

Lines 353 to 354 in 5848d31

// FIXME(macos): The size is changed in macOS 26.
"vm_statistics64" => true,
since this should be up to date now?

Please also add a link to https://github.com/apple-oss-distributions/xnu/blob/f6217f891ac0bb64f3d375211650a4c1ff8ca1ea/osfmk/mach/vm_statistics.h#L142-L177 in your commit message, just saying that xnu hasn't yet been updated.

View changes since this review

@rustbot

rustbot commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@elihwyma

elihwyma commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

@tgross35 the change is present in macOS 27, not 26. Removing the skip will temporarily break CI
@rustbot ready

@tgross35

tgross35 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

In that case, could you update test_apple to:

// existing
let x86_64 = target.contains("x86_64");
let i686 = target.contains("i686");
// new
let macos = VERSIONS.macos;

// ...
match ... {
    "vm_statistics64" => macos.unwrap() < (27, 0),
}

and make sure it tests locally?

@elihwyma

elihwyma commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

@tgross35 made these changes and it tests locally. Additionally, I spotted that AIO_LISTIO_MAX got bumped from 16 to 32 in the new 27 SDK, causing the test to fail. I made the same change in the test configs and tested it on macOS 27b2

Additional permalink that will be updated: https://github.com/apple-oss-distributions/xnu/blob/f6217f891ac0bb64f3d375211650a4c1ff8ca1ea/bsd/sys/aio.h#L165

@tgross35 tgross35 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks for the updates!

View changes since this review

@tgross35
tgross35 enabled auto-merge July 9, 2026 11:13
@tgross35

tgross35 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

For future reference, we usually shouldn't take PRs updating to API for not-yet-released platform versions, they tend to change. This is fine since you've already gone through the work here, but if you were planning on more you should hold off until xnu is updated (ideally also GitHub actions so we don't have to rely on local tests).

@tgross35
tgross35 added this pull request to the merge queue Jul 9, 2026
@elihwyma

elihwyma commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

@tgross35 my main motivation was trying to fix a program I use on the beta, it lead me down this rabbit hole to finding out the declaration had been updated. Thanks for taking a look at it.

Merged via the queue into rust-lang:main with commit 328f309 Jul 9, 2026
57 checks passed
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Jul 20, 2026
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Jul 20, 2026
This was referenced Jul 20, 2026
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Jul 20, 2026
@tgross35 tgross35 added stable-applied This PR has been cherry-picked to libc's stable release branch and removed stable-nominated This PR should be considered for cherry-pick to libc's stable release branch labels Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stable-applied This PR has been cherry-picked to libc's stable release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants