zoukankan      html  css  js  c++  java
  • xm list和xl list显示内存不一致的问题

    xm list和xl list显示内存不一致的问题

    在xen4.1.2上一台windows虚机碰到这个问题:
    # xm list test6
    Name                                        ID   Mem VCPUs      State   Time(s)
    test6                                       16  512     2     -b----    158.0
    # xl list test6
    Name                                        ID   Mem VCPUs      State   Time(s)
    test6                                       16   2048     2     -b----     158.6

    同一台虚机,用两个不同的工具查看,内存居然差了将近2GB。

    由于xm和xl的实现机制不同,所以从源码分析开始,分别查看xm list和xl list的源码

    xm list:

        前文(http://www.cnblogs.com/feisky/archive/2011/11/27/2265053.html)已经分析过xm list的源码,它得到的内存是xend和xenstore中的内存(两者总是保持一致)
        
        xenstore中的内存可以通过下面的命令读出:
        
        xenstore-read /vm/[uuid]/memory

    xl list:
        ==>  xl.c::main() --> cmdtable_lookup() --> main_list()
        ==>  xl_cmdimpl.c::main_list() 
        ==>  libxl_domain_info(&ctx, &info_buf, domid);
              ==>  xc_domain_getinfolist(ctx->xch, domid, 1, &xcinfo)
              ==>  xcinfo2xlinfo(&xcinfo, info_r)
              ==>  xlinfo->current_memkb = PAGE_TO_MEMKB(xcinfo->tot_pages);
        ==>  xc_domain_getinfolist(ctx->xch, domid, 1, &xcinfo);
             可以看到xl list最终是通过XEN_SYSCTL_getdomaininfolist超级调用实现的
        ==>  xen/common/sysctl.c::do_sysctl()
        ==>  xen/common/domctl.c::getdomaininfo(d, &info)
             info->tot_pages         = d->tot_pages;
             info->max_pages         = d->max_pages;
             info->shr_pages         = atomic_read(&d->shr_pages);
             info->shared_info_frame = mfn_to_gmfn(d, __pa(d->shared_info)>>PAGE_SHIFT);

    可以看出,xl list得到的是hypervisor为该domain分配的内存。

    通常情况下hypervisor为该domain分配的内存比xend传进去的内存多2MB(在xen3.4.3上也有同样的问题,多余的2MB应该是hypervisor占用)
    [root@localhost ~]# xm li test6
    Name                                        ID   Mem VCPUs      State   Time(s)
    test6                                       21   512     2     -b----     79.4
    [root@localhost ~]# xl list test6
    Name                                        ID   Mem VCPUs      State   Time(s)
    test6                                       21   514     2     -b----      79.4

    上面碰到的问题是由于虽然通过xm mem-set为虚机重新调整了内存,新的内存值写入到了xend和xenstore中,但hypervisor并没有立即为该虚机ballon内存。此时,如果多次执行xl list可以看到test6虚机的内存一点点减少,直至514MB。
  • 相关阅读:
    微信小程序之----加载中提示框loading
    微信小程序之----消息提示框toast
    微信小程序之----弹框组件modal
    浅析浏览器的回流与重绘 (Reflow & Repaint)
    关于input的一些问题解决方法分享
    关于js中 toFixed()的一个小坑
    浅谈js中null和undefined的区别
    浅谈JS中的闭包
    浅谈JS中的浅拷贝与深拷贝
    css设置居中的方案总结
  • 原文地址:https://www.cnblogs.com/feisky/p/2446105.html
Copyright © 2011-2022 走看看