# NumaTest **Repository Path**: TrueAI/NumaTest ## Basic Information - **Project Name**: NumaTest - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-09-11 - **Last Updated**: 2025-09-11 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # NUMA Memory Policy Test This project is designed to test and demonstrate NUMA (Non-Uniform Memory Access) memory policy behavior in Linux systems, particularly when using `pin_user_pages_remote` to allocate physical pages in another process's address space. ## Overview The test consists of: - A kernel module (`numa_test_mod.c`) that uses `pin_user_pages_remote` to allocate physical pages - A main test program (`numa_test.c`) that allocates virtual memory without physical pages - A trigger program (`trigger_test.c`) that triggers the kernel module to allocate physical pages ## Building To build all components: ```bash make # Build kernel module make user # Build user-space programs ``` Or build everything at once: ```bash make && make user ``` ## Usage ### Basic Usage 1. Load the kernel module: ```bash sudo insmod numa_test_mod.ko ``` 2. Run the main test program: ```bash ./numa_test ``` 3. In another terminal, trigger physical page allocation: ```bash ./trigger_test /dev/numa_test ``` 4. Check kernel logs for output: ```bash sudo dmesg | tail ``` 5. Unload the kernel module: ```bash sudo rmmod numa_test_mod ``` ### Advanced NUMA Binding Options Both `numa_test` and `trigger_test` support advanced NUMA and CPU binding options: #### Binding to Specific NUMA Nodes ```bash # Bind to a single NUMA node ./numa_test -n 0 # Bind to multiple NUMA nodes ./numa_test -n 0,1,2 # No binding (use system default) ./numa_test ``` #### Binding to Specific CPU Cores ```bash # Bind to a single CPU core ./numa_test -c 0 # Bind to multiple CPU cores ./numa_test -c 0,1,2,3 # No binding (use system default) ./numa_test ``` #### Combined Binding ```bash # Bind to specific NUMA nodes and CPU cores ./numa_test -n 0,1 -c 0,1,2,3 ``` #### Memory Policy Options ```bash # Use mbind instead of process binding for memory policy ./numa_test -n 0,1 -m ``` ### Complete Examples 1. Simple test with default policies: ```bash # Terminal 1 ./numa_test /dev/numa_test # Terminal 2 (using PID and address from Terminal 1 output) ./trigger_test /dev/numa_test 12345 0x7f8b4c000000 ``` 2. Test with specific NUMA node binding: ```bash # Terminal 1 ./numa_test -n 0 /dev/numa_test # Terminal 2 ./trigger_test -n 1 /dev/numa_test 12345 0x7f8b4c000000 ``` 3. Test with multiple NUMA nodes and CPU cores: ```bash # Terminal 1 ./numa_test -n 0,1 -c 0,1,2,3 /dev/numa_test # Terminal 2 ./trigger_test -n 0,1 -c 4,5,6,7 /dev/numa_test 12345 0x7f8b4c000000 ``` 4. Test with mbind memory policy: ```bash # Terminal 1 ./numa_test -n 0,1 -m /dev/numa_test # Terminal 2 ./trigger_test /dev/numa_test 12345 0x7f8b4c000000 ``` ## Kernel Module Output The kernel module provides detailed output showing: - VMA (Virtual Memory Area) policy information - Task policy information - Policy modes in human-readable format (BIND, PREFERRED, etc.) - NUMA node masks for policies - Physical page allocation information (PFN and node) Example output: ``` NUMA Test: VMA policy mode: BIND (2) NUMA Test: VMA policy nodes: 0,1 NUMA Test: Task policy mode: PREFERRED (1) NUMA Test: Task policy nodes: 0 NUMA Test: Page info - PFN: 0x42e90b, Node: 0 ``` ## Requirements - Linux system with NUMA support - libnuma development headers (`libnuma-dev` on Debian/Ubuntu) - Kernel headers matching your running kernel - Appropriate permissions to load kernel modules and access `/dev` files ## Troubleshooting - If you get "Permission denied" errors, make sure you have appropriate permissions or use `sudo` - If NUMA functions are not available, the program will indicate this and exit - Make sure the kernel module is loaded before running the trigger program ## License This project is released under the GPL license, similar to the Linux kernel.