PMEM2_VM_RESERVATION_MAP_FIND_FIRST(3)

πŸ’– PMEM2_VM_RESERVATION_MAP_FIND(3) πŸ’–

okay bestie, sit down, hydrate, and let me tell you about the cutest lil squad of functions in the PMDK Programmer's Manual, section 3. their whole job? finding mappings in a virtual memory reservation. searching for the mapping located at the desirable location, if you will. and honestly? they ate. 🫢


✨ NAME ✨

pmem2_vm_reservation_map_find(), pmem2_vm_reservation_map_find_prev(), pmem2_vm_reservation_map_find_next(), pmem2_vm_reservation_map_find_first() and pmem2_vm_reservation_map_find_last() β€” search for the mapping located at the desirable location πŸ”


🌸 SYNOPSIS 🌸

#include <libpmem2.h>

struct pmem2_map;
struct pmem2_vm_reservation;
int pmem2_vm_reservation_map_find(struct pmem2_vm_reservation *rsv,
        size_t reserv_offset, size_t len, struct pmem2_map **map_ptr);
int pmem2_vm_reservation_map_find_prev(struct pmem2_vm_reservation *rsv,
        struct pmem2_map *map, struct pmem2_map **prev_map);
int pmem2_vm_reservation_map_find_next(struct pmem2_vm_reservation *rsv,
        struct pmem2_map *map, struct pmem2_map **next_map);
int pmem2_vm_reservation_map_find_first(struct pmem2_vm_reservation *rsv,
        struct pmem2_map **first_map);
int pmem2_vm_reservation_map_find_last(struct pmem2_vm_reservation *rsv,
        struct pmem2_map **last_map);

like, five whole functions. a whole friend group. no cap. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the lore, bestie. mappings get inserted into the virtual memory reservation in the order of their virtual address space location. the first mapping is the earliest mapping in the virtual address space contained in a reservation, and the last mapping is, well, the last one. main character energy for the earliest one, honestly. ✨

  • pmem2_vm_reservation_map_find() β€” searches for the earliest mapping stored in the virtual memory reservation that intersects with the interval defined by the reserv_offset and len variables, and hands it back to you through the map_ptr variable. πŸŽ€
  • pmem2_vm_reservation_map_find_prev() β€” searches for the map previous to the provided map, and returns it via the provided prev_map variable. ⬅️
  • pmem2_vm_reservation_map_find_next() β€” searches for the map next after the provided map, and returns it via the next_map variable. ➑️
  • pmem2_vm_reservation_map_find_first() β€” searches for the first map in the reservation, and returns it via the provided first_map variable. πŸ‘‘
  • pmem2_vm_reservation_map_find_last() β€” searches for the last map in the reservation, and returns it via the provided last_map variable. 🏁

πŸŽ€ RETURN VALUE πŸŽ€

pmem2_vm_reservation_map_find(), pmem2_vm_reservation_map_find_prev(), pmem2_vm_reservation_map_find_next(), pmem2_vm_reservation_map_find_first() and pmem2_vm_reservation_map_find_last() return 0 on success, or a negative error on failure.

on success it passes an address to the found mapping via the user provided map pointer variable. otherwise, when no mapping was found, it passes a NULL value. it's giving "found nothing, bestie" 😭


πŸ’€ ERRORS πŸ’€

the whole squad β€” pmem2_vm_reservation_map_find(), pmem2_vm_reservation_map_find_prev(), pmem2_vm_reservation_map_find_next(), pmem2_vm_reservation_map_find_first() and pmem2_vm_reservation_map_find_last() β€” can fail with the following errors:

  • PMEM2_E_MAPPING_NOT_FOUND β€” no mapping found at the desirable location of the reservation πŸ™ˆ

🌈 SEE ALSO 🌈


reminder bestie: mappings live in address-space order inside the reservation, so "first" = earliest and "last" = latest. don't come for me, that's literally what the page says. 🧚

and that's the tea, fr fr. this iconic little page came to you from the PMDK crew, dated 2025-07-24, and it is now officially over. go find your mappings, bestie. slay. πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈπŸ’…πŸ«ΆπŸ”₯πŸ‘‘β­

πŸ“¦ where this page comes from