linux – NUMA内存页面迁移开销

linux – NUMA内存页面迁移开销,第1张

概述我必须在 Linux下找到与NUMA内存迁移相关的开销. 你能告诉我哪些工具可以使用吗? 如果可能,你能展示一个例子. 如果您想了解您的系统是否正在进行过多的远程节点内存访问并且您正在使用intel CPU, Intel’s PMU有一个名为vtbwrun的实用程序来报告QPI /非核心活动. 如果要查看执行页面迁移所需的时间,可以测量对numa_move_pages的调用持续时间(由numac 我必须在 Linux下找到与NUMA内存页迁移相关的开销.

你能告诉我哪些工具可以使用吗?

如果可能,你能展示一个例子.

解决方法 如果您想了解您的系统是否正在进行过多的远程节点内存访问并且您正在使用intel cpu,Intel’s PMU有一个名为vtbwrun的实用程序来报告QPI /非核心活动.

如果要查看执行页面迁移所需的时间,可以测量对numa_move_pages的调用持续时间(由numactl包提供).

这是an example:

/* * Test program to test the moving of a processes pages. * * (C) 2006 Silicon Graphics,Inc. *          Christoph Lameter <[email protected]> */#include <stdio.h>#include <stdlib.h>#include "../numa.h"#include <unistd.h>#include <errno.h>unsigned int pagesize;unsigned int page_count = 32;char *page_base;char *pages;voID **addr;int *status;int *nodes;int errors;int nr_nodes;struct bitmask *old_nodes;struct bitmask *new_nodes;int main(int argc,char **argv){      int i,rc;      pagesize = getpagesize();      nr_nodes = numa_max_node()+1;      old_nodes = numa_bitmask_alloc(nr_nodes);        new_nodes = numa_bitmask_alloc(nr_nodes);        numa_bitmask_setbit(old_nodes,1);        numa_bitmask_setbit(new_nodes,0);      if (nr_nodes < 2) {            printf("A minimum of 2 nodes is required for this test.\n");            exit(1);      }      setbuf(stdout,NulL);      printf("migrate_pages() test ......\n");      if (argc > 1)            sscanf(argv[1],"%d",&page_count);      page_base = malloc((pagesize + 1) * page_count);      addr = malloc(sizeof(char *) * page_count);      status = malloc(sizeof(int *) * page_count);      nodes = malloc(sizeof(int *) * page_count);      if (!page_base || !addr || !status || !nodes) {            printf("Unable to allocate memory\n");            exit(1);      }      pages = (voID *) ((((long)page_base) & ~((long)(pagesize - 1))) + pagesize);      for (i = 0; i < page_count; i++) {            if (i != 2)                  /* We leave page 2 unallocated */                  pages[ i * pagesize ] = (char) i;            addr[i] = pages + i * pagesize;            nodes[i] = 1;            status[i] = -123;      }      /* Move to starting node */      rc = numa_move_pages(0,page_count,addr,nodes,status,0);      if (rc < 0 && errno != ENOENT) {            perror("move_pages");            exit(1);      }      /* Verify correct startup locations */      printf("Page location at the beginning of the test\n");      printf("------------------------------------------\n");      numa_move_pages(0,NulL,0);      for (i = 0; i < page_count; i++) {            printf("Page %d vaddr=%p node=%d\n",i,pages + i * pagesize,status[i]);            if (i != 2 && status[i] != 1) {                  printf("Bad page state before migrate_pages. Page %d status %d\n",status[i]);                  exit(1);            }      }      /* Move to node zero */      numa_move_pages(0,0);      printf("\nMigrating the current processes pages ...\n");      rc = numa_migrate_pages(0,old_nodes,new_nodes);      if (rc < 0) {            perror("numa_migrate_pages Failed");            errors++;      }      /* Get page state after migration */      numa_move_pages(0,0);      for (i = 0; i < page_count; i++) {            printf("Page %d vaddr=%lx node=%d\n",(unsigned long)(pages + i * pagesize),status[i]);            if (i != 2) {                  if (pages[ i* pagesize ] != (char) i) {                        printf("*** Page contents corrupted.\n");                        errors++;                  } else if (status[i]) {                        printf("*** Page on the wrong node\n");                        errors++;                  }            }      }      if (!errors)            printf("Test successful.\n");      else            printf("%d errors.\n",errors);      return errors > 0 ? 1 : 0;}
总结

以上是内存溢出为你收集整理的linux – NUMA内存页面迁移开销全部内容,希望文章能够帮你解决linux – NUMA内存页面迁移开销所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/1032370.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-24
下一篇 2022-05-24

发表评论

登录后才能评论

评论列表(0条)

保存