{"id":208518,"date":"2021-02-13T09:26:51","date_gmt":"2021-02-13T01:26:51","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=208518"},"modified":"2021-01-29T10:39:35","modified_gmt":"2021-01-29T02:39:35","slug":"arm64-linux-doc","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/arm64-linux-doc.html","title":{"rendered":"\u4e00\u6587\u770b\u660e\u767d ARM64 Linux \u5185\u6838\u9875\u8868\u7684\u5757\u6620\u5c04"},"content":{"rendered":"
\u5bfc\u8bfb<\/td>\n | \u5185\u6838\u6587\u6863Documentation\/arm64\/memory.rst\u63cf\u8ff0\u4e86ARM64 Linux\u5185\u6838\u7a7a\u95f4\u7684\u5185\u5b58\u6620\u5c04\u60c5\u51b5\uff0c\u5e94\u8be5\u662f\u6b64\u65b9\u9762\u6700\u6743\u5a01\u6587\u6863\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n <\/p>\n \u5185\u6838\u6587\u6863Documentation\/arm64\/memory.rst\u63cf\u8ff0\u4e86ARM64 Linux\u5185\u6838\u7a7a\u95f4\u7684\u5185\u5b58\u6620\u5c04\u60c5\u51b5\uff0c\u5e94\u8be5\u662f\u6b64\u65b9\u9762\u6700\u6743\u5a01\u6587\u6863\u3002<\/p>\n \u4ee5\u5178\u578b\u76844K\u9875\u548c48\u4f4d\u865a\u62df\u5730\u5740\u4e3a\u4f8b\uff0c\u6574\u4e2a\u5185\u6838\u7a7a\u95f4\u7684\u865a\u62df\u5730\u5740\u5206\u5e03\u5982\u4e0b\uff1a<\/p>\n <\/p>\n \u4eceffff000000000000\u5230ffff7fffffffffff\u662f\u4e00\u6bb5\u9488\u5bf9\u7269\u7406\u5730\u5740\u7684\u7ebf\u6027\u6620\u5c04\u533a\uff0c\u6700\u5927\u652f\u6301128TB\u7684\u7269\u7406\u5730\u5740\u7a7a\u95f4\uff0c\u8fd9\u4e00\u6bb5\u5730\u5740\u975e\u5e38\u7c7b\u4f3cARM32\u7684low memory\u6620\u5c04\u533a\u3002<\/p>\n \u6211\u4eec\u770b\u770b\u8fd9\u79cd\u60c5\u51b5\u4e0b\u7684\u9875\u8868\uff0c\u6211\u4eec\u65e2\u53ef\u4ee5\u7528\u6700\u7ec8\u7684\u301020:12\u3011\u5bf9\u5e94\u7684PTE\u6620\u5c04\u9879\uff0c\u4ee54K\u4e3a\u5355\u4f4d\uff0c\u8fdb\u884c\u865a\u62df\u5730\u5740\u5230\u7269\u7406\u5730\u5740\u7684\u6620\u5c04;\u53c8\u53ef\u4ee5\u4ee5\u301029:21\u3011\u5bf9\u5e94\u7684PMD\u6620\u5c04\u9879\uff0c\u4ee52M\u4e3a\u5355\u4f4d\uff0c\u8fdb\u884c\u865a\u62df\u5730\u5740\u5230\u7269\u7406\u5730\u5740\u7684\u6620\u5c04\u3002<\/p>\n <\/p>\n \u5bf9\u4e8e\u7528\u6237\u7a7a\u95f4\u7684\u865a\u62df\u5730\u5740\u800c\u8a00\uff0c\u5f53\u6211\u4eec\u8fdb\u884c\u7684\u662fPMD\u6620\u5c04\u7684\u65f6\u5019\uff0c\u6211\u4eec\u5f97\u5230\u7684\u662fHuge Page\uff0cARM64\u76842MB\u7684huge page\uff0c\u5728\u865a\u62df\u548c\u7269\u7406\u4e0a\u90fd\u8fde\u7eed\uff0c\u5b83\u5728\u5b9e\u8df5\u5de5\u7a0b\u4e2d\u7684\u597d\u5904\u662f\uff0c\u53ef\u4ee5\u51cf\u5c0fTLB miss\uff0c\u56e0\u4e3a\uff0c\u5982\u679c\u8fdb\u884c\u4e862MB\u7684\u6620\u5c04\uff0c\u6574\u4e2a2MB\u4e0d\u518d\u9700\u8981PTE\uff0c\u6620\u5c04\u5173\u7cfb\u5927\u4e3a\u51cf\u5c0f\u3002<\/p>\n <\/p>\n \u5bf9\u4e8e\u5185\u6838\u7a7a\u95f4\u800c\u8a00\uff0c\u4eceffff000000000000\u5230ffff7fffffffffff\u7684\u8fd9\u6bb5\u865a\u62df\u5730\u5740\uff0c\u5982\u679c\u4e0e\u7269\u7406\u5730\u5740\u8fdb\u884c\u7684\u662f\u4e00\u79cdPMD\u6620\u5c04\u7684\u8bdd\uff0c\u663e\u7136\u4e5f\u53ef\u4ee5\u8fbe\u5230\u540c\u6837\u7684\u6548\u679c\u3002\u4f46\u662f\uff0c\u8fd9\u4e0d\u610f\u5473\u7740\u5b83\u4eec\u5c31\u662fHuge Page\u3002\u4f17\u6240\u5468\u77e5\uff0c\u5185\u6838\u5f00\u673a\u628a\u7269\u7406\u5730\u5740\u5f80\u865a\u62df\u5730\u5740\u8fdb\u884c\u7ebf\u6027\u6620\u5c04\uff0c\u5e76\u4e0d\u610f\u5473\u7740\u8fd9\u7247\u5185\u5b58\u88ab\u5185\u6838\u62ff\u8d70\u4e86\uff0c\u5b83\u53ea\u662f\u8fdb\u884c\u4e86\u4e00\u79cd\u6620\u5c04\uff0c\u4ee5\u4fbf\u65e5\u540e\u8c03\u7528kmalloc()\uff0cget_free_pages()\u7b49API\u7533\u8bf7\u7684\u5185\u5b58\u662f\u76f4\u63a5\u5df2\u7ecf\u6709\u865a\u5b9e\u6620\u5c04\u7684\u3002\u6240\u4ee5\uff0c\u5373\u4fbf\u5185\u6838\u8fdb\u884c\u7684\u5c31\u662fPMD\u6620\u5c04\uff0c\u5728\u5185\u5b58\u7684\u5206\u5272\u4e0a\uff0c\u8fd8\u662f\u53ef\u4ee5\u4ee54K\u4e3a\u5355\u4f4d\u7684\uff1a<\/p>\n <\/p>\n \u6240\u4ee5\uff0c\u5373\u4fbf\u6211\u4eec\u5728\u5185\u6838\u7a7a\u95f4\u8fdb\u884cPMD\u6620\u5c04\uff0c\u91cc\u9762\u7684\u6bcf\u4e2a\u84dd\u8272\u5706\u5708(\u4e00\u4e2a4K\u9875)\uff0c\u8fd8\u662f\u53ef\u4ee5\u88ab\u5355\u72ec\u5206\u914d\u7684\uff0c\u8fd9\u79cd\u5206\u914d\u53ef\u4ee5\u662fkmalloc\u3001vmalloc\uff0c\u7528\u6237\u6001\u7684malloc\u7b49\u3002\u5185\u6838\u6001\u8fdb\u884c\u7684PMD\u6620\u5c04\uff0c\u4e0d\u610f\u5473\u7740\u76f8\u5173\u76842MB\u6210\u4e3a\u4e86huge page\uff0c\u5b83\u7eaf\u7cb9\u53ea\u662f\u4e3a\u4e86\u670d\u52a1\u4e8e\u5f53\u5185\u6838\u4ee5\u7ebf\u6027\u6620\u5c04\u7684\u865a\u62df\u5730\u5740\u8bbf\u95ee\u8be5\u7269\u7406\u5730\u5740\u7684\u65f6\u5019(\u6211\u4eec\u8ba4\u4e3a\u5185\u6838\u5927\u591a\u6570\u65f6\u5019\u662f\u7528\u8fd9\u4e2a\u7ebf\u6027\u6620\u5c04\u7684\u865a\u62df\u5730\u5740\u7684)\uff0c\u51cf\u5c0fTLB miss\u3002<\/p>\n \u5f53\u7136\uff0c\u66f4\u725b\u903c\u7684\u60c5\u51b5\u4e0b\uff0c\u5185\u6838\u5e94\u8be5\u4e5f\u53ef\u4ee5\u76f4\u63a5\u7528\u301038:30\u3011\u4f4d\u7684PUD\u6765\u8fdb\u884c\u6620\u5c04\uff0c\u8fd9\u6837\u6620\u5c04\u5173\u7cfb\u662f1GB\u7684\uff0c\u5219\u6574\u4e2a1GB\u540e\u9762\u5360TLB\u7684\u65f6\u5019\uff0c\u53ea\u9700\u8981\u5360\u4e00\u4e2a\u5165\u53e3\u3002<\/p>\n <\/p>\n \u5f53\u7136\uff0c\u5982\u679c\u7528\u6237\u6001\u7684\u865a\u5b9e\u6620\u5c04\u662f\u8fd9\u6837\u7684\uff0c\u7528\u6237\u5b9e\u9645\u5f97\u5230\u4e86\u4e00\u4e2a1GB\u7684\u5de8\u9875\u3002\u4f46\u662f\u5bf9\u4e8e\u5185\u6838\u7684\u7ebf\u6027\u6620\u5c04\u533a\u57df\u800c\u8a00\uff0c\u5373\u4fbf\u6211\u4eec\u8fdb\u884c\u4e861GB\u7684PUD\u6620\u5c04\uff0c\u8fd91G\u5185\u90e8\u5c31\u53ef\u4ee5\u8fdb\u4e00\u6b65\u5207\u5272\u4e3a4KB\u9875\u6216\u80052MB\u7684\u5de8\u9875\u3002\u8bb0\u4f4f\uff1a\u5185\u6838\u6001\u7684\u7ebf\u6027\u6620\u5c04\u533a\u7684\u6620\u5c04\u53ea\u662f\u4e2a\u6620\u5c04\u5173\u7cfb\uff0c\u4e0d\u662f\u4e2a\u5206\u914d\u5173\u7cfb\u3002\u6bd4\u5982\u4e0b\u9762\u76841GB\u7684\u5185\u6838\u7ebf\u6027\u6620\u5c04\u76841GB\u533a\u57df\uff0c\u4ecd\u7136\u53ef\u4ee5\u88ab4K\u5206\u914d\u8d70\uff0c\u6216\u8005\u88ab\u7528\u6237\u4ee5huge page\u4ee52MB\u4e3a\u5355\u4f4d\u5206\u914d\u8d70\uff1a<\/p>\n <\/p>\n \u6211\u4eec\u9700\u8981\u4e00\u4e2a\u771f\u5b9e\u7684\u8c03\u8bd5\u624b\u6bb5\u6765\u9a8c\u8bc1\u6211\u4eec\u7684\u60f3\u6cd5\uff0c\u8fd9\u4e2a\u8c03\u8bd5\u624b\u6bb5\u5c31\u662fPTDUMP(Page Table Dump)\uff0c\u76f8\u5173\u7684\u4ee3\u7801\u5728ARM64\u5185\u6838\u7684\uff1a<\/p>\n \r\narch\/arm64\/mm\/ptdump.c\u548cptdump_debugfs.c\r\n<\/pre>\n |