Skip to content

mbind

Intro

mbind - binds an area of process memory to a set of CPUs in the system

Description

The mbind() system call sets the process memory policy of a given address range to a preferred list of nodes. This call is used to control the distribution of physical memory pages to nodes on a NUMA system. The main goal is to optimize the process execution speed. The policy might be applied to a specified range of virtual address space, but the underlying physical pages might be scattered across the nodes according to the underlying memory distribution of the physical system.

The efficacy of an mbind() call depends on various factors, like the underlying memory distribution of the physical system, the access pattern of the calling process, the hardware topology and the kernel scheduling algorithms. It is important to note that the mbind() call is advisory, meaning that the kernel might ignore the preferred placement of memory pages as long as it provides reasonable performance for the given workload.

Are there any edge-cases, drawbacks or advantages of using it?

The main disadvantage of using the mbind() call is that it might not provide the best possible results. To ensure optimal results, the kernel might need to be tuned for the particular task. Additionally, calls to mbind() that involve moving large amounts of memory might be expensive, as they involve page table updates, page potentially being read out of memory and distributed across nodes, and possibly need to be avoided in production scenarios.

Arguments

  • addr:void*[K] - the starting address of the memory range that should be affected by the policy.
  • len:unsigned long[K] - the length in bytes of the memory range that should be affected.
  • mode:int[K] - the memory policy that should be applied, as specified by the given constants.
  • nodemask:const unsigned long*[K] - a list of preferred nodes for the process memory pages.
  • maxnode:unsigned long[K] - the highest node number in the system that the nodemask applies to.
  • flags:unsigned int[K] - flags that might modify the default behavior of mbind(), such as MPOL_MF_STRICT, MPOL_MF_MOVE, MPOL_MF_MOVE_ALL or MPOL_MF_INTERNAL.

Available Tags

  • K - Originated from kernel-space.

Hooks

mbind

Type

Kprobe + Kretprobe

Purpose

To collect information about process memory policy.

Example Use Case

When a developer needs to profile an application across nodes to determine which nodes provide the best performance.

Issues

The mbind() system call is advisory, meaning the kernel might ignore the preferred placement of memory pages as long as it provides reasonable performance for the given workload.

get_mempolicy, set_mempolicy, move_pages.

This document was automatically generated by OpenAI and needs review. It might not be accurate and might contain errors. The authors of Tracee recommend that the user reads the "events.go" source file to understand the events and their arguments better.