首先简单介绍下apic的destination mode:

physical mode下高32bit(destination field)是apic id

logical mode下高32bit是MDA,又分为flat和cluster两种:

flat就是一个bitmap

而cluster包含两个部分,高16bit为cluster ID,后16bit为bitmap;这里还分flat和hierarchy;这里就不深究了。

根据intel spec:Flat logicalmode is not supported in the x2APIC mode. Hence the Destination Format Register(DFR) is eliminated in x2APIC mode. 在x2apic已经没有FDR,所以在logical mode下不再支持flat mode了,只有cluster mode由于x2apic在原来apic的8bit apicid基础上扩展到32bit

所以通过ioapic发中断和发MSI(不是MSIX)中断的设备就有问题了;他们需要做IR,interrupt remapping(VT-d提供的一项能力,通过IOMMU来做)

但是,也有些例外,比如使用physical mode且cpu个数小于256时,8bit的apic id已经完全可以cover所有的cpu了,而且这8bit直接可以写入x2apic的32bit的destination field,所以这种情况下可以直接使用x2apic physical mode而无需IR能力

https://patchwork.kernel.org/patch/2826342/这个邮件内容告诉我们,使用x2apic而同时又没有IR能力的情况,只有虚拟化场景(bios不能enable VT-d这种情况好像要被禁止了,enable x2apic一定要开VT-d)

然而,虚拟化场景下为何一定要enable x2apic呢?

IBM给出了答案:Red Hat Enterprise Linux 6 implements x2APIC emulation for KVM guests. Advanced programmable interrupt controllers (APICs) are used in symmetric multiprocessor (SMP) computer systems. x2APIC is a machine state register (MSR) interface to a local APIC with performance and scalability enhancements. IBM lab tests show that enabling the x2APIC support for Red Hat Enterprise Linux 6 guests can result in 2% to 5% throughput improvement for many I/O workloads. You can enable the x2APIC support by specifying the -cpu qemu64,+x2apic option on the qemu-kvm command for a KVM guest.

然而这解释当然是隔靴搔痒,真正的解释还是要show me the patch:

diff

commit ce69a784504222c3ab6f1b3c357d09ec5772127a

Author: Gleb Natapov

Date: Mon Jul 20 15:24:17 2009 +0300

x86/apic: Enable x2APIC without interrupt remapping under KVM

KVM would like to provide x2APIC interface to a guest without emulating

interrupt remapping device. The reason KVM prefers guest to use x2APIC

is that x2APIC interface is better virtualizable and provides better

performance than mmio xAPIC interface:

- msr exits are faster than mmio (no page table walk, emulation)

- no need to read back ICR to look at the busy bit

- one 64 bit ICR write instead of two 32 bit writes

- shared code with the Hyper-V paravirt interface

Included patch changes x2APIC enabling logic to enable it even if IR

initialization failed, but kernel runs under KVM and no apic id is

greater than 255 (if there is one spec requires BIOS to move to x2apic

mode before starting an OS).

-v2: fix build

-v3: fix bug causing compiler warning

Signed-off-by: Gleb Natapov

Acked-by: Suresh Siddha

Cc: Sheng Yang

Cc: "avi@redhat.com"

LKML-Reference: <20090720122417.GR5638@redhat.com>

Signed-off-by: Ingo Molnar

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

commitce69a784504222c3ab6f1b3c357d09ec5772127a

Author:GlebNatapov

Date:MonJul2015:24:172009+0300

x86/apic: Enable x2APIC without interrupt remapping under KVM

KVM would like to provide x2APIC interface to a guest without emulating

interrupt remapping device. The reason KVM prefers guest to use x2APIC

is that x2APIC interface is better virtualizable and provides better

performance than mmio xAPIC interface:

- msr exits are faster than mmio (no page table walk, emulation)

- no need to read back ICR to look at the busy bit

- one 64 bit ICR write instead of two 32 bit writes

- shared code with the Hyper-V paravirt interface

Included patch changes x2APIC enabling logic to enable it even if IR

initialization failed, but kernel runs under KVM and no apic id is

greater than 255 (if there is one spec requires BIOS to move to x2apic

mode before starting an OS).

-v2: fix build

-v3: fix bug causing compiler warning

Signed-off-by: Gleb Natapov

Acked-by: Suresh Siddha

Cc: Sheng Yang

Cc: "avi@redhat.com"

LKML-Reference: <20090720122417.GR5638@redhat.com>

Signed-off-by: Ingo Molnar

Related

linux修改X2APIC参数,虚拟机对x2apic destination mode的选择相关推荐

  1. Linux修改内核参数

    Linux /proc/sys/kernel 和/proc/sys/vm下的文件控制内核的运行,可以通过修改参数的方式来改变内核功能(立即生效) 修改参数方法: 方法一: echo value > ...

  2. linux 修改hba参数,更改Raid卡和HBA卡在linux下的启动顺序

    更改Raid卡和HBA卡在linux下的启动顺序 发布时间:2006-01-11 10:13:07来源:红联作者:新新 当server安装好RHEL3系统以后,如果又添加了HBA卡,准备连接光纤存储的 ...

  3. linux 修改xt_recent参数 ip_list_tot ip_pkt_list_tot

    2019独角兽企业重金招聘Python工程师标准>>> 参考链接:http://bbs.chinaunix.net/forum.php?mod=viewthread&tid= ...

  4. Linux基础命令---sysctl修改内核参数

    sysctl sysctl指令用来修改正在运行的内核参数,可以修改的参数都保存在/proc/sys/目录中,修改会立即生效.Linux中的sysctl支持需要Procfs.您可以使用sysctl来读取 ...

  5. linux命令优先级设置,linux renice命令参数及用法详解(linux修改程序运行优先级命令)...

    linux renice命令参数及用法详解(linux修改程序运行优先级命令) 发布时间:2012-07-21 12:45:32   作者:佚名   我要评论 renice指令可重新调整程序执行的优先 ...

  6. linux修改端口cost值,Linux下通过修改网卡驱动的参数调整Intel网卡的性能

    =下面列出paramerter中和性能相关的几个以及他们的取值范围和默认值. InterruptThrottleRate 范围:100-100000 (0=off, 1=dynamic) 默认:0 注 ...

  7. 黑群晖 linux 修改参数,黑群晖 DS918+ 修改引导参数隐藏引导盘和数据盘

    在HPE Gen10 Plus ESXi 7.0 虚拟化安装黑群晖 DS918+这篇文章中我又提到一个引导配置文件中的一个参数 set extra_args_918='DiskIdxMap=1000 ...

  8. Linux如何修改openfile参数

    方法一:临时修改生效 修改openfile参数为100000,命令如下: ulimit -SHn 100000 只对当前session生效 方法二:修改配置文件,登录生效 修改/etc/securit ...

  9. 虚拟机Linux怎么更改语言,虚拟机的linux语言肿么修改

    使用中文安装了CentOS后提示出现乱码,据此判断为CentOS默认语言非中文所致.==================================linux修改默认语言 编辑/etc/sysco ...

最新文章

  1. python 线程安全链表_教你用 Python 实现 HashMap 数据结构
  2. 消息扩散(强连通分量)
  3. CF-1209 F. Koala and Notebook(建图BFS)
  4. lucene之Field属性的解释
  5. 如何远程连接Windows和linux服务器
  6. DBA跳槽应该去大公司还是小公司?99%的人这样说...
  7. for循环用i++和++i哪个效率高?
  8. php安装redis扩展‘checking for igbinary includes... configure: error: Cannot find igbinary.h‘解决方法
  9. 4改变顶点位置_从4种腰椎前凸临界点探寻腰椎退变过程
  10. SQL语句(九)使用特殊关系运算符查询
  11. 惠普T620瘦客户机安装Win7时AMD显卡驱动造成Aero透明效果不能使用
  12. HEVC帧内预测学习(一)CTU、CU、PU、TU单元划分的理解
  13. Codeforces 227E/226C Anniversary 斐波那契数列性质+矩阵快速幂
  14. 站长技术导航二开美化网站源码 网站提交自动秒收录
  15. 高等数学阶段复习, 函数极限, 连续, 导数,微分
  16. android 常用机型尺寸_Android中获取手机屏幕大小的方法
  17. 海南安全员A证怎么考多选题库
  18. ajax报错几种原因
  19. 会抓老鼠的猫不一定是好猫
  20. MDK5注释乱码以及解决方案

热门文章

  1. 基于php学生社团活动报名系统
  2. 虚拟机非正常关闭,里面的服务器重启报错:Error, some other host already uses address...
  3. Android okhttp3设置代理(http/https)
  4. 线性回归、逻辑回归学习笔记
  5. 鼎信通达MTG3000/MTG2000中继网关双重应用组网
  6. python软件安装教程-Python-中文版软件安装包以及安装教程
  7. 9.2.3 将警告视为错误
  8. 分享图片去水印几个工具-图片去除水印最好用的工具
  9. Java将PDF转为图片Jpg
  10. vue 项目获取QQ音乐歌单数据