{"id":372,"date":"2010-09-14T01:00:14","date_gmt":"2010-09-14T09:00:14","guid":{"rendered":"http:\/\/www.pagetable.com\/?p=372"},"modified":"2010-09-14T01:00:14","modified_gmt":"2010-09-14T09:00:14","slug":"cpuid-on-all-cpus-hownotto","status":"publish","type":"post","link":"https:\/\/www.pagetable.com\/?p=372","title":{"rendered":"CPUID on all CPUs (HOWNOTTO)"},"content":{"rendered":"<p>A while ago, an engineer from a respectable company for low-level solutions (no names without necessity!) claimed that a certain company&#8217;s new 4-way SMP system had broken CPUs or at least broken firmware that didn&#8217;t set up some CPU features correctly: While on the older 2-way system, all CPUs returned the same features (using CPUID), on the 4-way system, two of the CPUs would return bogus data.<\/p>\n<p>I asked for his test code. It ran in kernel mode and looked roughly like this:<\/p>\n<pre>\n    int cpu_features[4];\n\n    for (int i = 0; i < 100000; i++) {\n        cpu_features[get_cur_cpu_number()] = cpuid_get_features();\n        usleep(100);\n    }\n\n    for (int j = 0; j < 4; j++)\n        printf(\"CPU %d features: %xn\", j, cpu_features[j]);\n<\/pre>\n<p>Questions to the reader:<\/p>\n<ol>\n<li>What was the original idea, what is the algorithm?<\/li>\n<li>Why did this work on a 2-way system, but not on a 4-way system?<\/li>\n<li>Which two changes would at least make this code correct (albeit still horrible)?<\/li>\n<li>How would you do it correctly?<\/li>\n<li>Would you buy software from this company?<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>A while ago, an engineer from a respectable company for low-level solutions (no names without necessity!) claimed that a certain company&#8217;s new 4-way SMP system had broken CPUs or at least broken firmware that didn&#8217;t set up some CPU features correctly: While on the older 2-way system, all CPUs returned the same features (using CPUID), &#8230; <a title=\"CPUID on all CPUs (HOWNOTTO)\" class=\"read-more\" href=\"https:\/\/www.pagetable.com\/?p=372\" aria-label=\"Read more about CPUID on all CPUs (HOWNOTTO)\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26,36,38],"tags":[],"class_list":["post-372","post","type-post","status-publish","format-standard","hentry","category-puzzle","category-whines","category-x86"],"_links":{"self":[{"href":"https:\/\/www.pagetable.com\/index.php?rest_route=\/wp\/v2\/posts\/372","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pagetable.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.pagetable.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.pagetable.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pagetable.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=372"}],"version-history":[{"count":0,"href":"https:\/\/www.pagetable.com\/index.php?rest_route=\/wp\/v2\/posts\/372\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.pagetable.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=372"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pagetable.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=372"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pagetable.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=372"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}