{"id":196038,"date":"2020-07-22T08:39:19","date_gmt":"2020-07-22T00:39:19","guid":{"rendered":"https:\/\/gulass.cn\/?p=196038"},"modified":"2020-07-15T13:39:49","modified_gmt":"2020-07-15T05:39:49","slug":"linux-memory-fragmentation","status":"publish","type":"post","link":"https:\/\/gulass.cn\/linux-memory-fragmentation.html","title":{"rendered":"Linux \u7269\u7406\u5185\u5b58\u5916\u788e\u7247\u4f60\u77e5\u9053\u662f\u5565\u5417\uff1f"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u9610\u8ff0\u7269\u7406\u5185\u5b58\u5916\u788e\u7247\u5316\u7684\u6765\u9f99\u53bb\u8109\u524d\uff0c\u5148\u5f97\u660e\u767dLinux\u662f\u5982\u4f55\u7ba1\u7406\u7269\u7406\u5185\u5b58\u7684?Linux\u5185\u6838\u91c7\u7528\u7684\u662fbuddy system allocation\uff0c\u5373\u8457\u540d\u7684\u4f19\u4f34\u7cfb\u7edf\u5206\u914d\u5668\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\"\"<\/p>\n

\u4e00\u3001Linux\u7269\u7406\u5185\u5b58\u5916\u788e\u7247\u5316\u6982\u8ff0<\/strong><\/div>\n

\u4ec0\u4e48\u662fLinux\u7269\u7406\u5185\u5b58\u788e\u7247\u5316?Linux\u7269\u7406\u5185\u5b58\u788e\u7247\u5316\u5305\u62ec\u4e24\u79cd\uff1a<\/p>\n

\u7269\u7406\u5185\u5b58\u5185\u788e\u7247\uff1a\u6307\u5206\u914d\u7ed9\u7528\u6237\u7684\u5185\u5b58\u7a7a\u95f4\u4e2d\u672a\u88ab\u4f7f\u7528\u7684\u90e8\u5206<\/strong><\/span><\/div>\n

\u4f8b\u5982\u8fdb\u7a0b\u9700\u8981\u4f7f\u75283K bytes\u7269\u7406\u5185\u5b58\uff0c\u4e8e\u662f\u5411\u7cfb\u7edf\u7533\u8bf7\u4e86\u5927\u5c0f\u7b49\u4e8e3Kbytes\u7684\u5185\u5b58\uff0c\u4f46\u662f\u7531\u4e8eLinux\u5185\u6838\u4f19\u4f34\u7cfb\u7edf\u7b97\u6cd5\u6700\u5c0f\u9897\u7c92\u662f4K bytes\uff0c\u6240\u4ee5\u5206\u914d\u7684\u662f4Kbytes\u5185\u5b58\uff0c\u90a3\u4e48\u5176\u4e2d1K bytes\u672a\u88ab\u4f7f\u7528\u7684\u5185\u5b58\u5c31\u662f\u5185\u5b58\u5185\u788e\u7247\u3002<\/p>\n

\"\"<\/p>\n

\u7269\u7406\u5185\u5b58\u5916\u788e\u7247\u5316\uff1a\u6307\u7cfb\u7edf\u4e2d\u65e0\u6cd5\u5229\u7528\u7684\u5c0f\u5185\u5b58\u5757<\/strong><\/span><\/div>\n

\u4f8b\u5982\u7cfb\u7edf\u5269\u4f59\u5185\u5b58\u4e3a16K bytes\uff0c\u4f46\u662f\u8fd916K bytes\u5185\u5b58\u662f\u75314\u4e2a4K bytes\u7684\u9875\u9762\u7ec4\u6210\uff0c\u537316K\u5185\u5b58\u7269\u7406\u9875\u5e27\u53f7#1\u4e0d\u8fde\u7eed\u3002\u5728\u7cfb\u7edf\u5269\u4f5916K bytes\u5185\u5b58\u7684\u60c5\u51b5\u4e0b\uff0c\u7cfb\u7edf\u5374\u65e0\u6cd5\u6210\u529f\u5206\u914d\u5927\u4e8e4K\u7684\u8fde\u7eed\u7269\u7406\u5185\u5b58\uff0c\u8be5\u60c5\u51b5\u5c31\u662f\u5185\u5b58\u5916\u788e\u7247\u5bfc\u81f4\uff0c\u672c\u6587\u4e2d\u9610\u8ff0\u7684\u5c31\u662f\u7269\u7406\u5185\u5b58\u5916\u788e\u7247\u5316\u3002<\/p>\n

\u6ce8\uff1a#1\u7269\u7406\u9875\u5e27\u53f7\uff1aLinux\u7269\u7406\u5185\u5b58\u662f\u901a\u8fc7\u9875\u9762\u8fdb\u884c\u7ba1\u7406\uff0c\u5e76\u5bf9\u6bcf\u4e2a\u9875\u9762\u8fdb\u884c\u7f16\u53f7\uff0c\u79f0\u4e3a\u9875\u5e27\u53f7\uff0c\u5982\u679c\u662f\u8fde\u7eed\u7684\u4e24\u4e2a\u7269\u7406\u9875\u9762\uff0c\u5176\u9875\u5e27\u53f7\u662f\u8fde\u7eed\u7684\u3002<\/p>\n

\"\"<\/p>\n

\u4e8c\u3001Linux\u7269\u7406\u5185\u5b58\u7ba1\u7406\u6846\u67b6<\/strong><\/div>\n

\u9610\u8ff0\u7269\u7406\u5185\u5b58\u5916\u788e\u7247\u5316\u7684\u6765\u9f99\u53bb\u8109\u524d\uff0c\u5148\u5f97\u660e\u767dLinux\u662f\u5982\u4f55\u7ba1\u7406\u7269\u7406\u5185\u5b58\u7684?Linux\u5185\u6838\u91c7\u7528\u7684\u662fbuddy system allocation\uff0c\u5373\u8457\u540d\u7684\u4f19\u4f34\u7cfb\u7edf\u5206\u914d\u5668\u3002<\/p>\n

\u8bbe\u8ba1\u601d\u8def<\/strong><\/span><\/div>\n

\u4f19\u4f34\u7cfb\u7edf\u5206\u914d\u5668\u7684\u6838\u5fc3\u601d\u8def\uff1a\u5c06\u7cfb\u7edf\u7684\u7a7a\u95f2\u9875\u9762\u5206\u4e3a11\u4e2a\u5757\u94fe\u8868\uff0c\u6bcf\u4e2a\u5757\u94fe\u8868\u5206\u522b\u7ba1\u7406\u77401,2,4,8,16,32,64,128,256,512\u548c1024\u4e2a\u7269\u7406\u9875\u5e27\u53f7\u8fde\u7eed\u7684\u9875\u9762\u3002\u6bcf\u4e2a\u9875\u9762\u5927\u5c0f\u4e3a4K bytes\uff0cbuddy\u7ba1\u7406\u7684\u5757\u5927\u5c0f\u8303\u56f4\u4ece4K bytes\u52304M bytes\uff0c\u4ee52\u7684\u500d\u6570\u9012\u589e\u3002<\/p>\n

\"\"<\/p>\n

\u7ba1\u7406\u903b\u8f91<\/strong><\/span><\/div>\n

Linux\u5bf9\u7269\u7406\u9875\u9762\u7ba1\u7406\u7684\u6846\u67b6\u5982\u4e0a\u56fe\uff0c\u7531\u4e8e\u672c\u6587\u9610\u8ff0\u7684\u662f\u7269\u7406\u5185\u5b58\u5916\u788e\u7247\uff0c\u6240\u4ee5\u5173\u4e8e\u4f19\u4f34\u7cfb\u7edf\u672c\u6587\u53ea\u505a\u7b80\u5355\u5206\u6790\uff0c\u4e0d\u6d89\u53ca\u5177\u4f53\u7684\u7ec6\u8282\u5e76\u4e0d\u9610\u8ff0\u5173\u4e8eper cpu pageset\u7b49\u5185\u5bb9\uff0c\u5982\u679c\u8bfb\u8005\u6709\u5174\u8da3\uff0c\u53ef\u4ee5\u53c2\u8003\u5185\u6838\u6e90\u7801\u3002<\/p>\n

Linux\u5c06\u7269\u7406\u5185\u5b58\u5206\u4e3a\u4e0d\u540c\u7684node\u548czone\u6765\u7ba1\u7406\uff1a<\/p>\n

    \n
  • node\uff1a\u4e3a\u4e86\u652f\u6301NUMA\u7ed3\u6784\uff0c\u5373CPU\u5bf9\u4e0d\u540c\u5185\u5b58\u7c07\u7684\u8bbf\u95ee\u901f\u5ea6\u4e0d\u540c\uff0cLinux\u8bbe\u8ba1\u4e86node\u7ed3\u6784\uff0c\u5c06\u7269\u7406\u5185\u5b58\u5206\u4e3a\u591a\u4e2a\u5185\u5b58\u8282\u70b9\u7ba1\u7406;\u5bf9\u4e8eUMA\u7ed3\u6784\uff0c\u53ea\u6709\u4e00\u4e2anode\u8282\u70b9\u3002<\/li>\n
  • zone\uff1a\u4e3a\u517c\u5bb9\u4e0d\u540c\u7684\u5e73\u53f0\u7684\u786c\u4ef6\u9650\u5236\uff0c\u4f8b\u598280x86\u7684\u4f53\u7cfb\u7ed3\u6784\u7684\u786c\u4ef6\u603b\u7ebf\u8bbf\u95ee\u7b49\u95ee\u9898\uff0cLinux\u5c06node\u8282\u70b9\u4e0b\u7684\u5185\u5b58\u5206\u4e3a\u591a\u4e2azone;\u76ee\u524d\u5728ARM\u5e73\u53f0\uff0c\u591a\u4e2azone\u7ba1\u7406\u5df2\u975e\u5fc5\u8981\u3002<\/li>\n<\/ul>\n

    zone\u7ba1\u7406\u5355\u5143\u4e0b\u7684\u5185\u5b58\u901a\u8fc7free_area\u6570\u7ec4\u5c06\u5185\u5b58\u5206\u621011\u4e2a\u5757\u94fe\u8868\u8fdb\u884c\u7ba1\u7406\uff1a<\/p>\n

    \"\"<\/p>\n

      \n
    • free_area\u6570\u7ec4\u603b\u5171\u670911\u4e2a\u7d22\u5f15\uff0c\u6bcf\u4e2a\u7d22\u5f15\u7ba1\u7406\u7740\u4e0d\u540c\u5927\u5c0f\u7684\u5757\u94fe\u8868\u3002<\/li>\n
    • free_area[0]\u7ba1\u7406\u7684\u5185\u5b58\u5355\u4f4d\u4e3a2^0\u9875\u9762\uff0c\u53734K byte\u5185\u5b58;<\/li>\n
    • free_area[1]\u7ba1\u7406\u7684\u5185\u5b58\u5355\u4f4d\u4e3a2^1\u7684\u7269\u7406\u9875\u5e27\u53f7\u8fde\u7eed\u9875\u9762\uff0c\u53738K bytes\u5185\u5b58;<\/li>\n<\/ul>\n

      \u4ee5\u6b64\u7c7b\u63a8;<\/p>\n

      free_area\u7ba1\u7406\u7684\u5185\u5b58\u8fd8\u7ec6\u5206\u4e3a\u5404\u79cd\u7c7b\u578b\uff0c\u4f8b\u5982\u4e0d\u53ef\u79fb\u52a8\u9875\u9762\u548c\u53ef\u79fb\u52a8\u9875\u9762\u7b49\uff0c\u6bcf\u79cd\u7c7b\u578b\u7684\u9875\u9762\u7c7b\u578b\u5bf9\u5e94\u4e00\u4e2afree_list\u94fe\u8868\uff0c\u8be5\u94fe\u8868\u5c31\u94fe\u63a5\u7740\u9875\u9762\u7ed3\u6784\u4f53\u3002<\/p>\n

      \"\"<\/p>\n

        \n
      • \u6839\u636e\u5206\u914d\u9875\u9762\u7c7b\u578b\uff0c\u627e\u5230\u5bf9\u5e94\u7684\u5185\u5b58\u8282\u70b9node\u548c\u5185\u5b58\u7ba1\u7406\u5355\u5143zone;<\/li>\n
      • \u6839\u636e\u5206\u914d\u9875\u9762\u5927\u5c0f\uff0c\u627e\u5230\u7684\u5bf9\u5e94\u5927\u5c0f\u7684free_area\u7ed3\u6784\u4f53;<\/li>\n
      • \u6839\u636e\u5206\u914d\u9875\u9762\u7c7b\u578b\uff0c\u627e\u5230\u5bf9\u5e94\u7684free_list\u94fe\u8868\uff0c\u5206\u914d\u9875\u9762;<\/li>\n<\/ul>\n

        \u5f53\u5411\u4f19\u4f34\u7cfb\u7edf\u91ca\u653e\u9875\u9762\u65f6\uff0cbuddy\u91ca\u653e\u9875\u9762\u7684\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n

          \n
        1. \u6839\u636e\u5206\u914d\u9875\u9762\u7c7b\u578b\uff0c\u627e\u5230\u5bf9\u5e94\u7684\u5185\u5b58\u8282\u70b9node\u548c\u5185\u5b58\u7ba1\u7406\u5355\u5143zone;<\/li>\n
        2. \u5224\u65ad\u662f\u5426\u6709\u7269\u7406\u9875\u5e27\u53f7\u76f8\u8fde\u7684\u7a7a\u95f2\u5185\u5b58\u5757\uff0c\u53ef\u4ee5\u8ddf\u88ab\u91ca\u653e\u7684\u5185\u5b58\u5757\u5408\u5e76\u6210\u66f4\u5927\u7684\u5757\u5185\u5b58\uff0c\u5408\u5e76\u7684\u6761\u4ef6\uff1a<\/li>\n
        3. \u7269\u7406\u5e27\u5fc5\u987b\u90fd\u662f\u8fde\u7eed\u7684;<\/li>\n
        4. \u76f8\u540c\u7684\u7c7b\u578b\u548c\u76f8\u540c\u7684\u5927\u5c0f;<\/li>\n
        5. \u5408\u5e76\u540e\u5757\u5185\u5b58\u7684\u7b2c\u4e00\u4e2a\u9875\u9762\u7684\u7269\u7406\u5730\u5740\u6ee1\u8db3\u201d2*\u5757\u5927\u5c0f*4K\u201d\u7684\u500d\u6570\u3002<\/li>\n
        6. \u6839\u636e\u91ca\u653e\u9875\u9762\u7684\u5927\u5c0f\u6216\u8005\u5408\u5e76\u7684\u5927\u5c0f\uff0c\u627e\u5230\u7684\u5bf9\u5e94\u5927\u5c0f\u7684free_area\u7ed3\u6784\u4f53;<\/li>\n
        7. \u6839\u636e\u91ca\u653e\u9875\u9762\u7684\u7c7b\u578b\uff0c\u627e\u5230\u5bf9\u5e94\u7684free_list\u94fe\u8868\uff0c\u91ca\u653e\u9875\u9762;<\/li>\n<\/ol>\n
          \u4e09\u3001Linux\u9488\u5bf9\u7269\u7406\u5185\u5b58\u5916\u788e\u7247\u5316\u7684\u63aa\u65bd<\/strong><\/div>\n

          \u4ece\u201c\u4e8c\u3001Linux\u7269\u7406\u5185\u5b58\u7ba1\u7406\u67b6\u6784\u201d\uff0c\u53ef\u4ee5\u53d1\u73b0\u4f19\u4f34\u7cfb\u7edf\u5185\u5b58\u7ba1\u7406\u6846\u67b6\u662f\u53ef\u4ee5\u6709\u6548\u6539\u5584\u7269\u7406\u5185\u5b58\u5916\u788e\u7247\u7684\uff0c\u56e0\u4e3a\u4f19\u4f34\u7cfb\u7edf\u6709\u5982\u4e0b\u4e24\u4e2a\u7ba1\u7406\u903b\u8f91\uff0c\u53ef\u4ee5\u51cf\u5c11\u4e86\u5916\u788e\u7247\u5316\u7684\u4ea7\u751f\uff1a<\/p>\n

            \n
          • \u5c0f\u5757\u5185\u5b58\u5728\u5c0f\u5757\u94fe\u8868\u5206\u914d\uff0c\u51cf\u5c11\u5927\u5757\u94fe\u8868\u88ab\u6c61\u67d3\u7684\u6982\u7387;<\/li>\n
          • \u5185\u5b58\u91ca\u653e\u65f6\u4f1a\u5c1d\u8bd5\u6574\u5408\u6210\u5927\u5757\u5185\u5b58\u7684\u903b\u8f91\uff0c\u6709\u52a9\u4e8e\u5927\u5757\u5185\u5b58\u7684\u5408\u6210;<\/li>\n<\/ul>\n

            \u9664\u6b64\u4e4b\u5916\uff0c\u5185\u6838\u8fd8\u652f\u6301\u4ee5\u4e0b\u63aa\u65bd\u6539\u5584\u7269\u7406\u5185\u5b58\u5916\u788e\u7247\u5316(\u53ea\u5217\u4e3e\u4e3b\u8981\u7684\u673a\u5236)\uff1a<\/p>\n

            memory compaction<\/strong><\/span><\/div>\n

            (1)\u5185\u5b58\u89c4\u6574\u539f\u7406<\/strong><\/p>\n

            Linux\u7269\u7406\u9875\u9762\u89c4\u6574\u673a\u5236\uff0c\u7c7b\u4f3c\u4e8e\u78c1\u76d8\u6574\u7406\uff0c\u4e3b\u8981\u662f\u5e94\u7528\u4e86\u5185\u6838\u7684\u9875\u9762\u8fc1\u79fb\u673a\u5236\uff0c\u662f\u4e00\u79cd\u5c06\u53ef\u79fb\u52a8\u9875\u9762\u8fdb\u884c\u8fc1\u79fb\u540e\u817e\u51fa\u8fde\u7eed\u7269\u7406\u5185\u5b58\u7684\u65b9\u6cd5\u3002<\/p>\n

            \u5047\u8bbe\u5b58\u5728\u4e00\u4e2a\u975e\u5e38\u5c0f\u7684\u5185\u5b58\u57df\u5982\u4e0b\uff1a<\/p>\n

            \"\"<\/p>\n

            \u84dd\u8272\u8868\u793a\u7a7a\u95f2\u7684\u9875\u9762\uff0c\u767d\u8272\u8868\u793a\u5df2\u7ecf\u88ab\u5206\u914d\u7684\u9875\u9762\uff0c\u53ef\u4ee5\u770b\u5230\u5982\u4e0a\u5185\u5b58\u57df\u7684\u7a7a\u95f2\u9875\u9762(\u84dd\u8272)\u975e\u5e38\u96f6\u6563\uff0c\u65e0\u6cd5\u5206\u914d\u5927\u4e8e\u4e24\u9875\u7684\u8fde\u7eed\u7269\u7406\u5185\u5b58\u3002<\/p>\n

            \u4e0b\u9762\u6f14\u793a\u4e00\u4e0b\u5185\u5b58\u89c4\u6574\u7684\u7b80\u5316\u5de5\u4f5c\u539f\u7406\uff0c\u5185\u6838\u4f1a\u8fd0\u884c\u4e24\u4e2a\u72ec\u7acb\u7684\u626b\u63cf\u52a8\u4f5c\uff1a\u7b2c\u4e00\u4e2a\u626b\u63cf\u4ece\u5185\u5b58\u57df\u7684\u5e95\u90e8\u5f00\u59cb\uff0c\u4e00\u8fb9\u626b\u63cf\u4e00\u8fb9\u5c06\u5df2\u5206\u914d\u7684\u53ef\u79fb\u52a8(MOVABLE)\u9875\u9762\u8bb0\u5f55\u5230\u4e00\u4e2a\u5217\u8868\u4e2d\uff1a<\/p>\n

            \"\"<\/p>\n

            \u53e6\u5916\u7b2c\u4e8c\u626b\u63cf\u662f\u4ece\u5185\u5b58\u57df\u7684\u9876\u90e8\u5f00\u59cb\uff0c\u626b\u63cf\u53ef\u4ee5\u4f5c\u4e3a\u9875\u9762\u8fc1\u79fb\u76ee\u6807\u7684\u7a7a\u95f2\u9875\u9762\u4f4d\u7f6e\uff0c\u7136\u540e\u4e5f\u8bb0\u5f55\u5230\u4e00\u4e2a\u5217\u8868\u91cc\u9762\uff1a<\/p>\n

            \"\"<\/p>\n

            \u7b49\u4e24\u4e2a\u626b\u63cf\u5728\u57df\u4e2d\u95f4\u76f8\u9047\uff0c\u610f\u5473\u7740\u626b\u63cf\u7ed3\u675f\uff0c\u7136\u540e\u5c06\u5de6\u8fb9\u626b\u63cf\u5f97\u5230\u7684\u5df2\u5206\u914d\u7684\u9875\u9762\u8fc1\u79fb\u5230\u53f3\u8fb9\u7a7a\u95f2\u7684\u9875\u9762\u4e2d\uff0c\u5de6\u8fb9\u5c31\u5f62\u6210\u4e86\u4e00\u6bb5\u8fde\u7eed\u7684\u7269\u7406\u5185\u5b58\uff0c\u5b8c\u6210\u9875\u9762\u89c4\u6574\u3002<\/p>\n

            \"\"<\/p>\n

            (2)\u4f7f\u7528\u65b9\u6cd5<\/strong><\/p>\n

            \u5982\u679c\u60f3\u6253\u5f00\u5185\u5b58\u89c4\u6574\uff0c\u5185\u6838\u9700\u8981\u6253\u5f00\u76f8\u5173\u7684\u914d\u7f6e(\u9ed8\u8ba4\u4e3ay)<\/p>\n

            \"\"<\/p>\n

            \u6253\u5f00\u5982\u4e0a\u914d\u7f6e\u540e\uff0c\u5185\u5b58\u89c4\u6574\u7684\u89e6\u53d1\u662f\u81ea\u52a8\u7684\uff0c\u89e6\u53d1\u5185\u5b58\u89c4\u6574\u7684\u9014\u5f84\u5982\u4e0b\uff1a\u5f53\u8fdb\u7a0b\u5c1d\u8bd5\u5206\u914d\u9ad8\u9636\u5185\u5b58\u65e0\u6cd5\u6ee1\u8db3\u5e76\u4e14\u5b8c\u6210direct_reclaim#1(\u6682\u4e0d\u5206\u6790costly_order\u60c5\u51b5)\u540e\uff0c\u7cfb\u7edf\u4f1a\u6839\u636e\u5185\u5b58\u5269\u4f59\u5224\u65ad\u662f\u5426\u89e6\u53d1\u5185\u5b58\u89c4\u6574;<\/p>\n

            \u6ce8\uff1a#1direct_reclaim\uff1a\u8fdb\u7a0b\u5206\u914d\u5185\u5b58\u65f6\u53d1\u73b0\u5185\u5b58\u4e0d\u8db3\u4ece\u800c\u542f\u52a8\u76f4\u63a5\u56de\u6536\u5185\u5b58\u64cd\u4f5c\uff0c\u8fd9\u79cd\u6a21\u5f0f\u4e0b\u5206\u914d\u548c\u56de\u6536\u662f\u540c\u6b65\u7684\u5173\u7cfb\uff0c\u4e5f\u5c31\u662f\u8bf4\u5206\u914d\u5185\u5b58\u7684\u8fdb\u7a0b\u4f1a\u56e0\u4e3a\u7b49\u5f85\u5185\u5b58\u56de\u6536\u800c\u88ab\u963b\u585e\u3002<\/p>\n

            \"\"<\/p>\n

            \u5185\u6838\u4e5f\u63d0\u4f9b\u4e86\u63a5\u53e3\u7ed9\u7528\u6237\u89e6\u53d1\u89c4\u6574\u52a8\u4f5c\uff0c\u63a5\u53e3\u5982\u4e0b\uff1a<\/p>\n

            \/proc\/sys\/vm\/compact_memory<\/p>\n

            \u53ea\u8981\u5f80\u8fd9\u4e2a\u8282\u70b9\u5199\u503c\u5373\u53ef\u89e6\u53d1\u5bf9\u7cfb\u7edf\u6240\u6709node\u7ba1\u7406\u7684\u5185\u5b58\u505a\u5185\u5b58\u89c4\u6574\u3002<\/p>\n

            kcompactd<\/strong><\/span><\/div>\n

            (1)kcompact\u8bbe\u8ba1\u539f\u7406<\/strong><\/p>\n

            kcompactd\u662f\u4e00\u4e2a\u5185\u6838\u89c4\u6574\u7684\u540e\u53f0\u8fdb\u7a0b\uff0c\u5b83\u8ddfmemory compaction\u7684\u533a\u522b\u5728\u4e8e\uff1a<\/p>\n

            memory compaction\u7684\u89e6\u53d1\u9014\u5f84\u662f\u5185\u5b58\u5206\u914d\u8fdb\u5165direct_reclaim(\u6682\u4e0d\u5206\u6790costly_order\u60c5\u51b5)\u540e\u7cfb\u7edf\u4f1a\u6839\u636e\u5185\u5b58\u5269\u4f59\u5224\u65ad\u662f\u5426\u89e6\u53d1\u5185\u5b58\u89c4\u6574\uff0c\u6216\u8005\u7528\u6237\u624b\u52a8\u89e6\u53d1;<\/p>\n

            kcompactd\u5728\u5524\u9192kswapd\u6216\u8005kswapd\u8fdb\u5165\u4f11\u7720\u65f6\uff0c\u4e3b\u52a8\u89e6\u53d1\u5185\u5b58\u89c4\u6574\u3002<\/p>\n

            kcompactd\u7684\u89e6\u53d1\u8def\u5f84\u5982\u4e0b\uff1a\u4e3b\u8981\u6709\u5982\u4e0b\u4e24\u4e2a\u9014\u5f84\uff1a<\/p>\n

            \u5524\u9192kswapd\u4e4b\u524d\u89e6\u53d1\u89c4\u6574\uff0c\u89e6\u53d1\u7684\u6761\u4ef6\u662f\uff1a\u672c\u6b21\u5206\u914d\u4e0d\u652f\u6301direct_reclaim\uff0cnode\u5185\u5b58\u8282\u70b9\u662f\u5e73\u8861\u7684\uff0c\u5e76\u4e14kswapd\u5931\u8d25\u7684\u6b21\u6570\u5927\u4e8eMAX_RECLAIM_RETRIES(\u9ed8\u8ba416)\u3002<\/p>\n

            \"\"<\/p>\n

            kswapd\u5373\u5c06\u8fdb\u5165\u7761\u7720\u65f6\uff1a<\/p>\n

            \"\"<\/p>\n

            (2)\u4f7f\u7528\u65b9\u6cd5<\/strong><\/p>\n

            \u5982\u679c\u60f3\u6253\u5f00\u5185\u5b58\u89c4\u6574\uff0c\u5185\u6838\u9700\u8981\u6253\u5f00\u76f8\u5173\u7684\u914d\u7f6e(\u9ed8\u8ba4\u4e3ay)<\/p>\n

            \"\"<\/p>\n

            \u5176\u4ed6\u4f18\u5316\u7684\u601d\u8def<\/strong><\/span><\/div>\n

            \u5185\u6838\u7ecf\u8fc7\u4e0d\u65ad\u7684\u4f18\u5316\uff0c\u90a3\u4e3a\u4f55Linux\u4e3a\u4f55\u8fd8\u6709\u7269\u7406\u5185\u5b58\u5916\u788e\u7247\u5316\u5462?\u90a3\u662f\u56e0\u4e3a\u7269\u7406\u5185\u5b58\u5916\u788e\u7247\u5316\u867d\u7136\u662f\u53ef\u4ee5\u4e0d\u65ad\u4f18\u5316\u7684\uff0c\u4f46\u5374\u65e0\u6cd5\u5f97\u5230\u6839\u9664\u3002\u76ee\u524d\u7684\u5185\u6838\uff0c\u6211\u89c9\u5f97\u5bfc\u81f4\u7269\u7406\u5916\u788e\u7247\u5316\u8fd8\u6709\u4ee5\u4e0b\u4e24\u4e2a\u4e3b\u8981\u539f\u56e0\uff1a<\/p>\n

            \u4e0d\u53ef\u79fb\u52a8\u9875\u9762\u6c61\u67d3\u4e86\u5185\u5b58\u73af\u5883\uff0c\u5bfc\u81f4\u9875\u9762\u89c4\u6574\u5931\u8d25;<\/p>\n

            \u968f\u7740\u7cfb\u7edf\u4e0d\u65ad\u7533\u8bf7\u548c\u91ca\u653e\u7684\u9875\u9762\uff0c\u5bfc\u81f4\u4f19\u4f34\u7cfb\u7edf\u5206\u914d\u7684\u7269\u7406\u5185\u5b58\u9875\u5e27\u53f7\u8d8a\u53d1\u968f\u673a\uff0c\u4ece\u800c\u5bfc\u81f4\u5185\u5b58\u88ab\u9694\u65ad\u7684\u6982\u7387\u8d8a\u9ad8\uff0c\u788e\u7247\u5316\u7684\u7a0b\u5ea6\u8d8a\u9ad8\uff0c\u57283.2\u9610\u8ff0\u3002<\/p>\n

            \u9488\u5bf9\u4ee5\u4e0a\u4e24\u4e2a\u539f\u56e0\uff0c\u4ee5\u4e0b\u7684\u4f18\u5316\u63aa\u65bd\u53ef\u80fd\u8fbe\u5230\u4e00\u5b9a\u7684\u4f18\u5316\u6548\u679c\uff1a<\/p>\n

            (1)\u51cf\u5c11UNMOVABLE\u9875\u9762\u6c61\u67d3\u5185\u5b58\u73af\u5883<\/strong><\/p>\n

              \n
            • \u9650\u5236\u4e0d\u53ef\u4ee5\u79fb\u52a8\u9875\u9762\u5077\u9875\u884c\u4e3a<\/li>\n<\/ul>\n

              Linux\u5185\u5b58\u5206\u914d\u4e2d\u652f\u6301fallback\u673a\u5236\uff0c\u53c8\u53eb\u5077\u9875\u673a\u5236\u3002\u8be5\u673a\u5236\u662f\u4e3a\u4e86\u89c4\u907f\u540c\u4e2azone\u7ba1\u7406\u5355\u4f4d\u9875\u9762\u7c7b\u578b\u5269\u4f59\u4e0d\u5e73\u8861\u7684\u95ee\u9898\uff0c\u4f8b\u5982\u540c\u4e2azone\uff0cA\u9875\u9762\u7c7b\u578b\u7a7a\u95f2\u5185\u5b58\u8f83\u591a\uff0cB\u9875\u9762\u7c7b\u578b\u7a7a\u95f2\u5185\u5b58\u5374\u975e\u5e38\u7d27\u7f3a\uff0c\u5982\u679c\u6ca1\u6709\u5077\u9875\u673a\u5236\uff0c\u5206\u914dB\u9875\u9762\u7c7b\u578b\u5c31\u4f1a\u8fdb\u5165\u5185\u5b58\u5206\u914d\u6162\u901f\u8def\u5f84\u3002\u6709\u4e86\u5077\u9875\u673a\u5236\uff0c\u5728\u540c\u4e2azone\u7ba1\u7406\u5355\u4f4d\uff0c\u5982\u679cUNMOVABLE\u7c7b\u578b\u65e0\u7a7a\u95f2\u9875\u9762\uff0c\u4f46\u662fMOVABLE\u7c7b\u578b\u9875\u9762\u8fd8\u6709\u7a7a\u95f2\u9875\u9762\uff0c\u5077\u9875\u673a\u5236\u652f\u6301\u5728list_head[UNMOVABLE]\u5206\u914d\u4e0d\u5230\u9875\u9762\u7684\u60c5\u51b5\u4e0b\uff0c\u5411list_head[MOVABLE]\u5206\u914d\u9875\u9762\u3002<\/p>\n

              \u4ee5\u4e0b\u6570\u7ec4\u660e\u786e\u4e86\u5404\u79cd\u9875\u9762\u7c7b\u578b\u53ef\u5077\u7684\u9875\u9762\u7c7b\u578b\uff0c\u4f8b\u5982\u7b2c\u4e00\u884c\u8868\u793aUNMOVABLE\u9875\u9762\u53ef\u4ee5\u5077RECLAIMABLE\u548cMOVABLE\u7c7b\u578b\u7684\u9875\u9762\uff0c\u5176\u4ed6\u7c7b\u4f3c\u3002<\/p>\n

              \"\"<\/p>\n

              \u5982\u679c\u4e0d\u53ef\u79fb\u52a8\u9875\u9762\u9891\u7e41\u7684\u5077\u9875\u4f1a\u5bfc\u81f4\u4e0d\u53ef\u79fb\u52a8\u9875\u9762\u5f88\u5feb\u6c61\u67d3\u4e86\u5185\u5b58\u73af\u5883\uff0c\u7279\u522b\u6c61\u67d3\u4e86\u53ef\u79fb\u52a8\u9875\u9762\u7684\u5185\u5b58\uff0c\u5bf9\u5185\u5b58\u89c4\u6574\u6210\u529f\u7387\u7684\u5f71\u54cd\u6bd4\u8f83\u5927\u3002\u57fa\u4e8e\u4ee5\u4e0a\u60c5\u51b5\uff0c\u53ef\u4ee5\u5728\u5077\u9875\u7684\u673a\u5236\u4e0a\u52a0\u4e0a\u5206\u914d\u5927\u5c0f\u9650\u5236\u7684\u5224\u65ad\uff0c\u4e0d\u53ef\u79fb\u52a8\u9875\u9762\u53ea\u6709\u5927\u5757\u5185\u5b58\u5206\u914d\u624d\u5141\u8bb8\u5077\u9875\uff0c\u4ee5\u6b64\u51cf\u5c11\u4e0d\u53ef\u79fb\u52a8\u9875\u9762\u5bf9\u5185\u5b58\u73af\u5883\u7684\u6c61\u67d3\u3002<\/p>\n

              \u4e0d\u53ef\u79fb\u52a8\u7c7b\u578b\u9875\u9762\u5077\u9875\u540e\u4e3b\u52a8\u507f\u8fd8<\/p>\n

              \u8be5\u65b9\u6cd5\u4e3b\u8981\u662f\u4e0d\u53ef\u79fb\u52a8\u9875\u9762\u5077\u9875\u540e\u7684\u4e00\u79cd\u8865\u507f\u65b9\u6cd5\u3002\u5982\u679c\u53d1\u751f\u4e0d\u53ef\u79fb\u52a8\u9875\u9762\u5077\u9875\u540e\uff0c\u6211\u4eec\u5c06\u8be5\u9875\u9762\u8bb0\u5f55\u5230\u4e00\u4e2a\u5217\u8868\uff0c\u7b49\u540e\u7eed\u4e0d\u53ef\u79fb\u52a8\u9875\u9762\u7c7b\u578b\u5b58\u5728\u7a7a\u95f2\u9875\u9762\u65f6\uff0c\u5c06\u6240\u5077\u7684\u9875\u9762\u8fc1\u79fb\u56de\u4e0d\u53ef\u79fb\u52a8\u9875\u9762\u4e2d\uff0c\u4ece\u800c\u964d\u4f4e\u4e0d\u53ef\u79fb\u52a8\u9875\u9762\u7684\u6c61\u67d3\u3002<\/p>\n

              (2)\u964d\u4f4e\u5206\u914d\u9875\u5e27\u53f7\u7684\u968f\u673a\u6027<\/strong><\/p>\n

              \u5047\u8bbe\u6709\u4e00\u5757\u5c0f\u5185\u5b58\u57df\u5982\u4e0b\uff0c\u4ee5\u4e0b\u4e24\u79cd\u5185\u5b58\u5206\u914d\u65b9\u5f0f\u54ea\u79cd\u4f1a\u5bfc\u81f4\u4e25\u91cd\u7684\u5185\u5b58\u788e\u7247\u5316?<\/p>\n

                \n
              1. \u9875\u9762\u4ece\u5934\u90e8\u5f00\u59cb\u5206\u914d\uff0c\u76f4\u5230\u5c3e\u90e8;<\/li>\n
              2. \u9875\u9762\u968f\u673a\u4ece\u4efb\u4f55\u4f4d\u7f6e\u5206\u914d\u3002<\/li>\n<\/ol>\n

                \"\"<\/p>\n

                \u660e\u663e\u662f\u7b2c\u4e8c\u79cd\u5185\u5b58\u5206\u914d\u65b9\u5f0f\u7684\u5bf9\u5185\u5b58\u5916\u788e\u7247\u5316\u66f4\u4e0d\u53cb\u597d\uff0c\u800c\u8fd9\u70b9\u4e5f\u662f\u4f19\u4f34\u7cfb\u7edf\u76ee\u524d\u6ca1\u6709\u89e3\u51b3\u7684\u95ee\u9898\u3002\u4f19\u4f34\u7cfb\u7edf\u867d\u7136\u5c06\u5185\u5b58\u89c4\u5212\u6210\u5404\u79cd\u5927\u5c0f\u7684\u5185\u5b58\u5757\uff0c\u4ee5\u8ba9\u5c0f\u5185\u5b58\u5206\u914d\u5728\u5c0f\u5757\u94fe\u8868\u5206\u914d\uff0c\u5c3d\u91cf\u4e0d\u6c61\u67d3\u5927\u5757\u5185\u5b58\u94fe\u8868\uff0c\u4f46\u662f\u5374\u6ca1\u529e\u6cd5\u4fdd\u8bc1\u5c0f\u5757\u5185\u5b58\u5177\u4f53\u662f\u5728\u7269\u7406\u5185\u5b58\u7684\u54ea\u4e2a\u9875\u5e27\u8303\u56f4\u5206\u914d\u3002\u968f\u7740\u7cfb\u7edf\u7684\u8fd0\u884c\u8d8a\u4e45\uff0c\u5c0f\u5757\u5185\u5b58\u7684\u5206\u914d\u7684\u7269\u7406\u9875\u5e27\u53f7\u8d8a\u53d1\u968f\u673a\uff0c\u90a3\u4e48\u5176\u5bfc\u81f4\u788e\u7247\u5316\u7684\u6982\u7387\u5c31\u4f1a\u8d8a\u9ad8\u3002<\/p>\n

                  \n
                • \u9884\u7559\u6cd5<\/li>\n<\/ul>\n

                  \u6839\u636e\u8fd9\u79cd\u60c5\u51b5\uff0c\u53ef\u4ee5\u901a\u8fc7\u9884\u7559\u7684\u65b9\u5f0f\u8fdb\u884c\u76f8\u5e94\u7684\u4f18\u5316\u3002<\/p>\n

                  \u9884\u7559\u4e00\u5b9a\u7684\u5185\u5b58\u4e13\u95e8\u7528\u4e8e\u5c0f\u5757\u5185\u5b58\u5206\u914d\uff0c\u7ecf\u8fc7\u8fd9\u4e2a\u4f18\u5316\u63aa\u65bd\u540e\uff0c\u53ef\u4ee5\u6709\u6548\u964d\u4f4e\u5c0f\u5757\u5185\u5b58\u5206\u914d\u7684\u7269\u7406\u9875\u5e27\u53f7\u7684\u968f\u673a\u6027\uff0c\u4ece\u800c\u964d\u4f4e\u5c0f\u5757\u5185\u5b58\u6c61\u67d3\u5185\u5b58\u73af\u5883\u7684\u6982\u7387\u3002<\/p>\n

                  \u9884\u7559\u4e00\u5b9a\u7684\u5185\u5b58\u4e13\u95e8\u7528\u4e8e\u5927\u5757\u5185\u5b58\u5206\u914d\uff0c\u7ecf\u8fc7\u8be5\u4f18\u5316\u63aa\u65bd\u540e\uff0c\u9884\u7559\u7684\u5185\u5b58\u88ab\u5c0f\u5757\u5185\u5b58\u6c61\u67d3\u7684\u6982\u7387\u5c31\u4f1a\u964d\u4f4e\uff0c\u53ef\u4ee5\u63d0\u5347\u9884\u7559\u5185\u5b58\u5206\u914d\u5927\u5757\u5185\u5b58\u7684\u6210\u529f\u7387\u3002<\/p>\n

                  \u53e6\u5916\u5173\u4e8e\u964d\u4f4e\u4f19\u4f34\u7cfb\u7edf\u5206\u914d\u9875\u5e27\u53f7\u968f\u673a\u6027\uff0c\u8fd8\u662f\u5b58\u5728\u5f88\u591a\u4f18\u5316\u7684\u63aa\u65bd\uff0c\u540e\u7eed\u6839\u636e\u9700\u8981\u4f1a\u4e13\u95e8\u5f00\u5c55\u4e00\u7bc7\u9610\u8ff0\u8be5\u90e8\u5206\u4f18\u5316\u7684\u6587\u7ae0\uff0c\u5982\u679c\u8bfb\u8005\u6709\u5174\u8da3\uff0c\u5230\u65f6\u53ef\u4ee5\u67e5\u9605\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

                  \u4ec0\u4e48\u662fLinux\u7269\u7406\u5185\u5b58\u788e\u7247\u5316?Linux\u7269\u7406\u5185\u5b58\u788e\u7247\u5316\u5305\u62ec\u4e24\u79cd\uff1a \u4f8b\u5982\u8fdb\u7a0b\u9700\u8981\u4f7f\u75283K bytes\u7269\u7406\u5185\u5b58\uff0c […]<\/p>\n","protected":false},"author":317,"featured_media":5592,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-196038","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/196038","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/users\/317"}],"replies":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/comments?post=196038"}],"version-history":[{"count":2,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/196038\/revisions"}],"predecessor-version":[{"id":196057,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/196038\/revisions\/196057"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media\/5592"}],"wp:attachment":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media?parent=196038"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/categories?post=196038"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/tags?post=196038"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}