1 编写代码pslist.c

   1: #include<linux/init.h>
   2: #include<linux/module.h>
   3: #include<linux/list.h>
   4: #include<linux/sched.h>
   5: #include<linux/proc_fs.h>
   6: #include<linux/mm_types.h>
   7: #include<linux/fs.h>
   8: #include<linux/path.h>
   9: #include<linux/dcache.h>
  10: #include<linux/mm.h>
  11: #include<linux/mmzone.h>
  12: #include<linux/vmalloc.h>
  13:  
);
  15:  
int analyzeUMANode()
  17: {
int i,j;
long node_present_pages;
long node_spanned_pages;
struct pglist_data* node_0;
  22:     
struct zone* pzone;
long start_pfn;
long present_pages;
long spanned_pages;
struct free_area* pfreearea;
  28:     
);
  30:  
  31:     node_0 = NODE_DATA(0);
, node_0);
if (node_0 == NULL)
return 0;
  35:         
  36:     node_present_pages = node_0->node_present_pages;
  37:     node_spanned_pages = node_0->node_spanned_pages;
, node_present_pages);
, node_spanned_pages);
  40:     
for (i = 0; i < MAX_NR_ZONES; ++i)
  42:     {
  43:         pzone = &node_0->node_zones[i];
if (pzone == NULL)
continue;
, i, pzone->name);
  47:         start_pfn = pzone->zone_start_pfn;
, start_pfn);
  49:         present_pages = pzone->present_pages;
, present_pages);
  51:         spanned_pages = pzone->spanned_pages;
, spanned_pages);
, start_pfn * PAGE_SIZE / 1024 / 1024, (start_pfn + spanned_pages) * PAGE_SIZE / 1024 / 1024);
  54:         pfreearea = &pzone->free_area;
if (pfreearea == NULL)
continue;
for (j = 0; j < MAX_ORDER; ++j)
  58:         {
, (pfreearea + j)->nr_free);    
  60:         }
);
  62:     }    
return 0;
  64: }
  65:  
int pslist_init()
  67: {
  68:     analyzeUMANode();
  69:         
  70: }
  71:  
void pslist_exit()
  73: {
);
  75: }
  76:  
  77: module_init(pslist_init);
  78: module_exit(pslist_exit);

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-23
  • 2022-12-23
  • 2021-04-24
  • 2021-09-29
  • 2022-02-11
  • 2022-01-17
猜你喜欢
  • 2022-02-14
  • 2021-05-05
  • 2021-10-28
  • 2021-12-04
  • 2022-12-23
  • 2022-01-30
  • 2022-12-23
相关资源
相似解决方案