{"id":152,"date":"2017-06-21T14:06:06","date_gmt":"2017-06-21T14:06:06","guid":{"rendered":"http:\/\/www.luo666.com\/?p=152"},"modified":"2019-01-19T04:43:02","modified_gmt":"2019-01-19T04:43:02","slug":"%e8%99%9a%e6%8b%9f%e6%9c%ba%e5%af%b9x2apic-destination-mode%e7%9a%84%e9%80%89%e6%8b%a9","status":"publish","type":"post","link":"http:\/\/www.luo666.com\/?p=152","title":{"rendered":"\u865a\u62df\u673a\u5bf9x2apic destination mode\u7684\u9009\u62e9"},"content":{"rendered":"<p>\u9996\u5148\u7b80\u5355\u4ecb\u7ecd\u4e0bapic\u7684destination mode\uff1a<a href=\"https:\/\/i0.wp.com\/www.luo666.com\/wp-content\/uploads\/2017\/06\/93E1DBA3-0FBA-48E6-A0FD-7D7C63308E73.png\"><img data-attachment-id=\"155\" data-permalink=\"http:\/\/www.luo666.com\/?attachment_id=155\" data-orig-file=\"https:\/\/i0.wp.com\/www.luo666.com\/wp-content\/uploads\/2017\/06\/93E1DBA3-0FBA-48E6-A0FD-7D7C63308E73.png?fit=590%2C325\" data-orig-size=\"590,325\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"93E1DBA3-0FBA-48E6-A0FD-7D7C63308E73\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/www.luo666.com\/wp-content\/uploads\/2017\/06\/93E1DBA3-0FBA-48E6-A0FD-7D7C63308E73.png?fit=300%2C165\" data-large-file=\"https:\/\/i0.wp.com\/www.luo666.com\/wp-content\/uploads\/2017\/06\/93E1DBA3-0FBA-48E6-A0FD-7D7C63308E73.png?fit=590%2C325\" decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-155\" src=\"https:\/\/i0.wp.com\/www.luo666.com\/wp-content\/uploads\/2017\/06\/93E1DBA3-0FBA-48E6-A0FD-7D7C63308E73.png?resize=590%2C325\" alt=\"\" width=\"590\" height=\"325\" data-recalc-dims=\"1\" \/><\/a><\/p>\n<p style=\"padding-left: 30px;\">physical mode\u4e0b\u9ad832bit\uff08destination field\uff09\u662fapic id<br \/>\nlogical mode\u4e0b\u9ad832bit\u662fMDA\uff0c\u53c8\u5206\u4e3aflat\u548ccluster\u4e24\u79cd\uff1a<br \/>\nflat\u5c31\u662f\u4e00\u4e2abitmap<br \/>\n\u800ccluster\u5305\u542b\u4e24\u4e2a\u90e8\u5206\uff0c\u9ad816bit\u4e3acluster ID\uff0c\u540e16bit\u4e3abitmap\uff1b\u8fd9\u91cc\u8fd8\u5206flat\u548chierarchy\uff1b\u8fd9\u91cc\u5c31\u4e0d\u6df1\u7a76\u4e86\u3002<\/p>\n<p style=\"padding-left: 30px;\">\u6839\u636eintel spec\uff1a<em>Flat logicalmode is not supported in the x2APIC mode. Hence the Destination Format Register(DFR) is eliminated in x2APIC mode.<\/em> \u5728x2apic\u5df2\u7ecf\u6ca1\u6709FDR\uff0c\u6240\u4ee5\u5728logical mode\u4e0b\u4e0d\u518d\u652f\u6301flat mode\u4e86\uff0c\u53ea\u6709cluster mode\u7531\u4e8ex2apic\u5728\u539f\u6765apic\u76848bit apicid\u57fa\u7840\u4e0a\u6269\u5c55\u523032bit<\/p>\n<p>\u6240\u4ee5\u901a\u8fc7ioapic\u53d1\u4e2d\u65ad\u548c\u53d1MSI\uff08\u4e0d\u662fMSIX\uff09\u4e2d\u65ad\u7684\u8bbe\u5907\u5c31\u6709\u95ee\u9898\u4e86\uff1b\u4ed6\u4eec\u9700\u8981\u505aIR\uff0cinterrupt remapping\uff08VT-d\u63d0\u4f9b\u7684\u4e00\u9879\u80fd\u529b\uff0c\u901a\u8fc7IOMMU\u6765\u505a\uff09<br \/>\n\u4f46\u662f\uff0c\u4e5f\u6709\u4e9b\u4f8b\u5916\uff0c\u6bd4\u5982\u4f7f\u7528physical mode\u4e14cpu\u4e2a\u6570\u5c0f\u4e8e256\u65f6\uff0c8bit\u7684apic id\u5df2\u7ecf\u5b8c\u5168\u53ef\u4ee5cover\u6240\u6709\u7684cpu\u4e86\uff0c\u800c\u4e14\u8fd98bit\u76f4\u63a5\u53ef\u4ee5\u5199\u5165x2apic\u768432bit\u7684destination field\uff0c\u6240\u4ee5\u8fd9\u79cd\u60c5\u51b5\u4e0b\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528x2apic physical mode\u800c\u65e0\u9700IR\u80fd\u529b<\/p>\n<p>https:\/\/patchwork.kernel.org\/patch\/2826342\/\u8fd9\u4e2a\u90ae\u4ef6\u5185\u5bb9\u544a\u8bc9\u6211\u4eec\uff0c\u4f7f\u7528x2apic\u800c\u540c\u65f6\u53c8\u6ca1\u6709IR\u80fd\u529b\u7684\u60c5\u51b5\uff0c\u53ea\u6709\u865a\u62df\u5316\u573a\u666f\uff08bios\u4e0d\u80fdenable VT-d\u8fd9\u79cd\u60c5\u51b5\u597d\u50cf\u8981\u88ab\u7981\u6b62\u4e86\uff0cenable x2apic\u4e00\u5b9a\u8981\u5f00VT-d\uff09<\/p>\n<p>\u7136\u800c\uff0c\u865a\u62df\u5316\u573a\u666f\u4e0b\u4e3a\u4f55\u4e00\u5b9a\u8981enable x2apic\u5462\uff1f<br \/>\n<a href=\"https:\/\/www.ibm.com\/support\/knowledgecenter\/en\/linuxonibm\/liaat\/liaatbpkvmasynchio.htm\">IBM\u7ed9\u51fa\u4e86\u7b54\u6848<\/a>\uff1a<em>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.<\/em><\/p>\n<p>\u7136\u800c\u8fd9\u89e3\u91ca\u5f53\u7136\u662f\u9694\u9774\u6414\u75d2\uff0c\u771f\u6b63\u7684\u89e3\u91ca\u8fd8\u662f\u8981show me the patch\uff1a<\/p>\n<pre class=\"lang:diff decode:true\">commit ce69a784504222c3ab6f1b3c357d09ec5772127a\nAuthor: Gleb Natapov &lt;gleb@redhat.com&gt;\nDate:   Mon Jul 20 15:24:17 2009 +0300\n\n    x86\/apic: Enable x2APIC without interrupt remapping under KVM\n\n    KVM would like to provide x2APIC interface to a guest without emulating\n    interrupt remapping device. The reason KVM prefers guest to use x2APIC\n    is that x2APIC interface is better virtualizable and provides better\n    performance than mmio xAPIC interface:\n\n     - msr exits are faster than mmio (no page table walk, emulation)\n     - no need to read back ICR to look at the busy bit\n     - one 64 bit ICR write instead of two 32 bit writes\n     - shared code with the Hyper-V paravirt interface\n\n    Included patch changes x2APIC enabling logic to enable it even if IR\n    initialization failed, but kernel runs under KVM and no apic id is\n    greater than 255 (if there is one spec requires BIOS to move to x2apic\n    mode before starting an OS).\n\n    -v2: fix build\n    -v3: fix bug causing compiler warning\n\n    Signed-off-by: Gleb Natapov &lt;gleb@redhat.com&gt;\n    Acked-by: Suresh Siddha &lt;suresh.b.siddha@intel.com&gt;\n    Cc: Sheng Yang &lt;sheng@linux.intel.com&gt;\n    Cc: \"avi@redhat.com\" &lt;avi@redhat.com&gt;\n    LKML-Reference: &lt;20090720122417.GR5638@redhat.com&gt;\n    Signed-off-by: Ingo Molnar &lt;mingo@elte.hu&gt;<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9996\u5148\u7b80\u5355\u4ecb\u7ecd\u4e0bapic\u7684destination mode\uff1a physical mode\u4e0b\u9ad832bit\uff08destination field\uff09\u662fapic id logical mode\u4e0b\u9ad832bit\u662fMDA\uff0c\u53c8\u5206\u4e3aflat\u548ccluster\u4e24\u79cd\uff1a flat\u5c31\u662f\u4e00\u4e2abitmap \u800ccluster\u5305\u542b\u4e24\u4e2a\u90e8\u5206\uff0c\u9ad816bit\u4e3acluster ID\uff0c\u540e16bit\u4e3abitmap\uff1b\u8fd9\u91cc\u8fd8\u5206flat\u548chierarchy\uff1b\u8fd9\u91cc\u5c31\u4e0d\u6df1\u7a76\u4e86\u3002 \u6839\u636eintel spec\uff1aFlat logicalmode is not supported in the x2APIC mode. Hence the Destination Format Register(DFR) is eliminated in x2APIC mode. \u5728x2apic\u5df2\u7ecf\u6ca1\u6709FDR\uff0c\u6240\u4ee5\u5728logical mode\u4e0b\u4e0d\u518d\u652f\u6301flat mode\u4e86\uff0c\u53ea\u6709cluster mode\u7531\u4e8ex2apic\u5728\u539f\u6765apic\u76848bit apicid\u57fa\u7840\u4e0a\u6269\u5c55\u523032bit \u6240\u4ee5\u901a\u8fc7ioapic\u53d1\u4e2d\u65ad\u548c\u53d1MSI\uff08\u4e0d\u662fMSIX\uff09\u4e2d\u65ad\u7684\u8bbe\u5907\u5c31\u6709\u95ee\u9898\u4e86\uff1b\u4ed6\u4eec\u9700\u8981\u505aIR\uff0cinterrupt remapping\uff08VT-d\u63d0\u4f9b\u7684\u4e00\u9879\u80fd\u529b\uff0c\u901a\u8fc7IOMMU\u6765\u505a\uff09 \u4f46\u662f\uff0c\u4e5f\u6709\u4e9b\u4f8b\u5916\uff0c\u6bd4\u5982\u4f7f\u7528physical mode\u4e14cpu\u4e2a\u6570\u5c0f\u4e8e256\u65f6\uff0c8bit\u7684apic id\u5df2\u7ecf\u5b8c\u5168\u53ef\u4ee5cover\u6240\u6709\u7684cpu\u4e86\uff0c\u800c\u4e14\u8fd98bit\u76f4\u63a5\u53ef\u4ee5\u5199\u5165x2apic\u768432bit\u7684destination field\uff0c\u6240\u4ee5\u8fd9\u79cd\u60c5\u51b5\u4e0b\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528x2apic physical mode\u800c\u65e0\u9700IR\u80fd\u529b https:\/\/patchwork.kernel.org\/patch\/2826342\/\u8fd9\u4e2a\u90ae\u4ef6\u5185\u5bb9\u544a\u8bc9\u6211\u4eec\uff0c\u4f7f\u7528x2apic\u800c\u540c\u65f6\u53c8\u6ca1\u6709IR\u80fd\u529b\u7684\u60c5\u51b5\uff0c\u53ea\u6709\u865a\u62df\u5316\u573a\u666f\uff08bios\u4e0d\u80fdenable VT-d\u8fd9\u79cd\u60c5\u51b5\u597d\u50cf\u8981\u88ab\u7981\u6b62\u4e86\uff0cenable x2apic\u4e00\u5b9a\u8981\u5f00VT-d\uff09 \u7136\u800c\uff0c\u865a\u62df\u5316\u573a\u666f\u4e0b\u4e3a\u4f55\u4e00\u5b9a\u8981enable x2apic\u5462\uff1f IBM\u7ed9\u51fa\u4e86\u7b54\u6848\uff1aRed Hat Enterprise Linux 6 implements &hellip; <a href=\"http:\/\/www.luo666.com\/?p=152\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;\u865a\u62df\u673a\u5bf9x2apic destination mode\u7684\u9009\u62e9&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"footnotes":"","_jetpack_memberships_contains_paid_content":false,"jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[3],"tags":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p7Dhki-2s","jetpack-related-posts":[],"_links":{"self":[{"href":"http:\/\/www.luo666.com\/index.php?rest_route=\/wp\/v2\/posts\/152"}],"collection":[{"href":"http:\/\/www.luo666.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.luo666.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.luo666.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.luo666.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=152"}],"version-history":[{"count":5,"href":"http:\/\/www.luo666.com\/index.php?rest_route=\/wp\/v2\/posts\/152\/revisions"}],"predecessor-version":[{"id":158,"href":"http:\/\/www.luo666.com\/index.php?rest_route=\/wp\/v2\/posts\/152\/revisions\/158"}],"wp:attachment":[{"href":"http:\/\/www.luo666.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=152"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.luo666.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=152"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.luo666.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=152"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}