{"id":3586,"date":"2011-12-16T20:09:35","date_gmt":"2011-12-16T12:09:35","guid":{"rendered":"http:\/\/edsionte.com\/techblog\/?p=3586"},"modified":"2012-03-27T19:21:56","modified_gmt":"2012-03-27T11:21:56","slug":"%e4%b8%8e%e8%99%9a%e6%8b%9f%e5%86%85%e5%ad%98%e5%8c%ba%e5%9f%9f%e6%9c%89%e5%85%b3%e7%9a%84%e6%93%8d%e4%bd%9c%e4%b9%8b%e4%ba%8c-%e5%90%88%e5%b9%b6%e5%92%8c%e6%8f%92%e5%85%a5","status":"publish","type":"post","link":"http:\/\/edsionte.com\/techblog\/archives\/3586","title":{"rendered":"\u4e0e\u865a\u62df\u5185\u5b58\u533a\u57df\u6709\u5173\u7684\u64cd\u4f5c\uff082\uff09-\u5408\u5e76\u5185\u5b58\u533a\u57df"},"content":{"rendered":"<h3>\u5408\u5e76\u5185\u5b58\u533a\u57df<\/h3>\n<p>Linux\u7684\u5185\u5b58\u7ba1\u7406\u6a21\u5757\u4ee5\u865a\u62df\u5185\u5b58\u533a\u57df\u4e3a\u5355\u4f4d\u7ba1\u7406\u8fdb\u7a0b\u7684\u865a\u62df\u5185\u5b58\uff0c\u4e00\u4e2a\u8fdb\u7a0b\u7684\u6240\u6709\u5185\u5b58\u533a\u57df\u5206\u522b\u4ee5\u94fe\u8868\u548c\u6811\u5f62\u7ed3\u6784\u8fdb\u884c\u7ec4\u7ec7\u3002\u5f53\u4e00\u4e2a\u65b0\u5efa\u7684\u533a\u57df\u52a0\u5165\u8fdb\u7a0b\u65f6\uff0c\u5185\u6838\u4f1a\u8bd5\u56fe\u5c06\u8fd9\u4e2a\u65b0\u533a\u57df\u4e0e\u5df2\u5b58\u5728\u7684\u533a\u57df\u8fdb\u884c\u5408\u5e76\u3002\u533a\u57df\u5408\u5e76\u7684\u9996\u8981\u6761\u4ef6\u5c31\u662f\u68c0\u67e5\u65b0\u533a\u57df\u4e4b\u524d\u7684prve\u533a\u57df\u7ec8\u6b62\u5730\u5740\u662f\u5426\u4e0e\u65b0\u533a\u57df\u8d77\u59cb\u5730\u5740\u91cd\u5408\uff0c\u6216\u65b0\u533a\u57df\u7684\u7ed3\u675f\u5730\u5740\u662f\u5426\u4e0e\u5176\u4e4b\u540e\u7684next\u533a\u57df\u8d77\u59cb\u5730\u5740\u91cd\u5408\uff1b\u63a5\u7740\u518d\u68c0\u67e5\u5c06\u8981\u5408\u5e76\u7684\u533a\u57df\u662f\u5426\u6709\u76f8\u540c\u7684\u6807\u5fd7\u3002\u5982\u679c\u5408\u5e76\u533a\u57df\u5747\u6620\u5c04\u4e86\u78c1\u76d8\u6587\u4ef6\uff0c\u5219\u8fd8\u8981\u68c0\u67e5\u5176\u6620\u5c04\u6587\u4ef6\u662f\u5426\u76f8\u540c\uff0c\u4ee5\u53ca\u6587\u4ef6\u5185\u7684\u504f\u79fb\u91cf\u662f\u5426\u8fde\u7eed\u3002<\/p>\n<p>\u4e0a\u8ff0\u63d0\u53ca\u7684\u4e00\u7cfb\u5217\u6761\u4ef6\u68c0\u67e5\u662f\u5728vma_merge()\u4e2d\u5b8c\u6210\u7684\uff0c\u6839\u636e\u65b0\u533a\u57df\u548c\u5b83\u524d\u540e\u4e24\u4e2a\u5185\u5b58\u533a\u57df\u4e4b\u95f4\u7684\u4f4d\u7f6e\u5173\u7cfb\uff0c\u533a\u57df\u5408\u5e76\u5206\u4e3a8\u79cd\u60c5\u51b5\u3002\u7531\u4e8e\u5408\u5e76\u6761\u4ef6\u7684\u590d\u6742\u6027\uff0c\u8be5\u51fd\u6570\u5305\u542b\u597d\u51e0\u4e2a\u53c2\u6570\uff0c\u5206\u522b\u5bf9\u4e0a\u8ff0\u8bf4\u660e\u7684\u5408\u5e76\u6761\u4ef6\u8fdb\u884c\u68c0\u6d4b\u3002<\/p>\n<p>mm\u63cf\u8ff0\u8981\u6dfb\u52a0\u65b0\u533a\u57df\u8fdb\u7a0b\u7684\u5185\u5b58\u7a7a\u95f4\uff0cprev\u6307\u5411\u5f53\u524d\u533a\u57df\u4e4b\u524d\u7684\u4e00\u4e2a\u5185\u5b58\u533a\u57df\uff0caddr\u8868\u793a\u65b0\u533a\u57df\u7684\u8d77\u59cb\u5730\u5740\uff0cend\u4e3a\u65b0\u533a\u57df\u7684\u7ed3\u675f\u5730\u5740\uff0cvm_flags\u8868\u793a\u8be5\u533a\u57df\u7684\u6807\u5fd7\u3002\u5982\u679c\u8be5\u65b0\u533a\u57df\u6620\u5c04\u4e86\u4e00\u4e2a\u78c1\u76d8\u6587\u4ef6\uff0c\u5219file\u7ed3\u6784\u8868\u793a\u8be5\u6587\u4ef6\uff0cpgoff\u8868\u793a\u8be5\u6587\u4ef6\u6620\u5c04\u7684\u504f\u79fb\u91cf\u3002<\/p>\n<pre class=\"brush:c\">struct vm_area_struct *vma_merge(struct mm_struct *mm,\r\n                        struct vm_area_struct *prev, unsigned long addr,\r\n                        unsigned long end, unsigned long vm_flags,\r\n                        struct anon_vma *anon_vma, struct file *file,\r\n                        pgoff_t pgoff, struct mempolicy *policy)<\/pre>\n<p>\u5408\u5e76\u51fd\u6570\u9996\u5148\u901a\u8fc7\u8d77\u59cb\u5730\u5740\u548c\u7ec8\u6b62\u5730\u5740\u8ba1\u7b97\u65b0\u533a\u57df\u7684\u957f\u5ea6\uff0c\u63a5\u4e0b\u6765\u5224\u65ad\u65b0\u533a\u57df\u662f\u5426\u8bbe\u7f6e\u4e86VM_SPECIAL\uff0c\u8fd9\u4e2a\u6807\u5fd7\u6307\u5b9a\u4e86\u8be5\u533a\u57df\u4e0d\u80fd\u548c\u5176\u4ed6\u533a\u57df\u5408\u5e76\uff0c\u56e0\u6b64\u7acb\u5373\u8fd4\u56deNULL\u3002<\/p>\n<pre class=\"brush:c\">        pgoff_t pglen = (end - addr) &gt;&gt; PAGE_SHIFT;\r\n        struct vm_area_struct *area, *next;\r\n        int err;\r\n\r\n        if (vm_flags &amp; VM_SPECIAL)\r\n                return NULL;\r\n\r\n        if (prev)\r\n                next = prev-&gt;vm_next;\r\n        else\r\n                next = mm-&gt;mmap;\r\n        area = next;\r\n        if (next &amp;&amp; next-&gt;vm_end == end)                \/* cases 6, 7, 8 *\/\r\n                next = next-&gt;vm_next;<\/pre>\n<p>\u63a5\u7740\uff0c\u901a\u8fc7prev\u83b7\u5f97\u4e0b\u4e00\u4e2a\u5185\u5b58\u533a\u57df\u7684\u63cf\u8ff0\u7b26next\uff0c\u5982\u56fe1\u3002\u5982\u679c\u65b0\u533a\u57df\u7684\u7ec8\u6b62\u5730\u5740\u4e0enext\u533a\u57df\u7684\u7ec8\u6b62\u5730\u5740\u91cd\u5408\uff0c\u5219next\u518d\u5411\u524d\u79fb\u52a8\u4e00\u4e2a\u533a\u57df\uff0c\u5982\u56fe2\u3002\u4e3a\u4e86\u4fbf\u4e8e\u8bf4\u660e\uff0c\u5728\u56fe2\u6240\u793a\u7684\u60c5\u51b5\u4e0b\uff0cnext\u2018\u8868\u793a\u7d27\u90bbprev\u7684\u90a3\u4e2a\u533a\u57df\uff0c\u800cnext\u8868\u793a\u7d27\u90bbnext\u2018\u7684\u533a\u57df\u3002\u56fe\u4e2d\u6bcf\u4e2a\u4e0d\u540c\u7684\u5185\u5b58\u533a\u57df\u90fd\u4f7f\u7528\u4e0d\u540c\u7684\u989c\u8272\u6807\u793a\u3002<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/edsionte.com\/techblog\/archives\/3586\/case678\" rel=\"attachment wp-att-3624\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter  wp-image-3624\" title=\"case678\" src=\"http:\/\/edsionte.com\/techblog\/wordpress\/wp-content\/uploads\/2011\/12\/case678.jpeg\" alt=\"\" width=\"456\" height=\"270\" srcset=\"http:\/\/edsionte.com\/techblog\/wordpress\/wp-content\/uploads\/2011\/12\/case678.jpeg 652w, http:\/\/edsionte.com\/techblog\/wordpress\/wp-content\/uploads\/2011\/12\/case678-300x177.jpg 300w\" sizes=\"auto, (max-width: 456px) 100vw, 456px\" \/><\/a><\/p>\n<p>\u63a5\u4e0b\u6765\u5f00\u59cb\u771f\u6b63\u7684\u5408\u5e76\u5de5\u4f5c\uff0c\u5408\u5e76\u5206\u4e3a\u4e24\u5927\u7c7b\uff0c\u7b2c\u4e00\u5927\u7c7b\u4e3a\u65b0\u533a\u57df\u7684\u8d77\u59cb\u5730\u5740\u548cprev\u533a\u57df\u7684\u7ec8\u6b62\u5730\u5740\u91cd\u5408\uff0c\u7b2c\u4e8c\u79cd\u60c5\u51b5\u4e3a\u65b0\u533a\u57df\u7684\u7ec8\u6b62\u5730\u5740\u548cnext\u533a\u57df\u7684\u8d77\u59cb\u5730\u5740\u91cd\u5408\u3002<\/p>\n<p>\u6211\u4eec\u9996\u5148\u5206\u6790\u7b2c\u4e00\u79cd\u60c5\u51b5\uff0c\u5373\u4fbfaddr\u548cprev\u7684\u7ec8\u6b62\u5730\u5740\u91cd\u5408\u8fd8\u4e0d\u8db3\u4ee5\u5c06\u5176\u5408\u5e76\uff0c\u8fd8\u5e94\u901a\u8fc7can_vma_merge_after()\u5224\u65ad\u4e24\u8005\u7684\u6807\u5fd7\u548c\u6620\u5c04\u6587\u4ef6\u7b49\u662f\u5426\u76f8\u540c\u3002\u5982\u679c\u90fd\u6ee1\u8db3\u6761\u4ef6\uff0c\u90a3\u4e48\u5408\u5e76\u6b64\u65f6\u5c31\u5e94\u8be5\u53ef\u4ee5\u5f00\u59cb\u4e86\u3002\u4e0d\u8fc7\u5408\u5e76\u51fd\u6570\u529b\u6c42\u6bcf\u6b21\u5408\u5e76\u7a0b\u5ea6\u8fbe\u5230\u6700\u5927\u5316\uff0c\u5b83\u518d\u7ee7\u7eed\u68c0\u67e5end\u662f\u5426\u6070\u597d\u4e0enext\u533a\u57df\u7684\u8d77\u59cb\u5730\u5740\u91cd\u5408\u3002<\/p>\n<p>\u5728\u8fd9\u6837\u7684\u5224\u65ad\u6761\u4ef6\u4e0b\uff0c\u4f1a\u51fa\u73b05\u79cd\u4e0d\u540c\u7684\u5408\u5e76\u60c5\u51b5(\u5206\u522b\u4e3acase1\uff0c6\uff0c2\uff0c5\uff0c7)\u3002\u6bcf\u79cd\u5408\u5e76\u60c5\u51b5\u6700\u7ec8\u90fd\u4f1a\u8c03\u7528vma_adjust\uff08\uff09\uff0c\u5b83\u901a\u8fc7\u4fee\u6539vma\u7ed3\u6784\u4e2d\u7684\u5b57\u6bb5\u5bf9\u533a\u57df\u8fdb\u884c\u9002\u5f53\u8c03\u6574\uff0c\u4e5f\u5c31\u662f\u8bf4\u771f\u6b63\u7684\u5408\u5e76\u662f\u5728\u8fd9\u4e2a\u51fd\u6570\u4e2d\u5b8c\u6210\u7684\u3002\u53ef\u4ee5\u770b\u51favma_merge()\u672c\u8d28\u4e0a\u662f\u4e00\u4e2a\u201c\u5206\u6d41\u201d\u51fd\u6570\uff0c\u5b83\u5c06\u533a\u57df\u5408\u5e76\u7ec6\u5316\uff0c\u6839\u636e\u4e0d\u540c\u7684\u5408\u5e76\u60c5\u51b5\u5411vma_adjust()\u4f20\u9012\u4e0d\u540c\u7684\u53c2\u6570\u3002<\/p>\n<pre class=\"brush:c\">        if (prev &amp;&amp; prev-&gt;vm_end == addr &amp;&amp;\r\n                        mpol_equal(vma_policy(prev), policy) &amp;&amp;\r\n                        can_vma_merge_after(prev, vm_flags,\r\n                                                anon_vma, file, pgoff)) {\r\n                if (next &amp;&amp; end == next-&gt;vm_start &amp;&amp;\r\n                                mpol_equal(policy, vma_policy(next)) &amp;&amp;\r\n                                can_vma_merge_before(next, vm_flags,\r\n                                        anon_vma, file, pgoff+pglen) &amp;&amp;\r\n                                is_mergeable_anon_vma(prev-&gt;anon_vma,\r\n                                                      next-&gt;anon_vma)) {\r\n                                                        \/* cases 1, 6 *\/\r\n                        err = vma_adjust(prev, prev-&gt;vm_start,\r\n                                next-&gt;vm_end, prev-&gt;vm_pgoff, NULL);\r\n                } else                                  \/* cases 2, 5, 7 *\/\r\n                        err = vma_adjust(prev, prev-&gt;vm_start,\r\n                                end, prev-&gt;vm_pgoff, NULL);\r\n                if (err)\r\n                        return NULL;\r\n                return prev;\r\n        }<\/pre>\n<p>\u4ece\u4e0a\u9762\u7684\u5206\u6790\u4ee5\u53ca\u6e90\u7801\u53ef\u4ee5\u770b\u51fa\uff0ccase1\u548ccase6\u65e2\u6ee1\u8db3addr\u4e0eprev\u7ec8\u6b62\u5730\u5740\u91cd\u5408\uff0c\u53c8\u6ee1\u8db3end\u4e0enext\u8d77\u59cb\u5730\u5740\u91cd\u5408\uff0c\u4f46\u662f\u4ed6\u4eec\u7684next(\u5982\u56fe1\uff0c2)\u5374\u6307\u5411\u4e0d\u540c\u7684\u533a\u57df\u3002case1\u53ef\u53c2\u8003\u4e0b\u56fe\uff0c\u5b83\u5b9e\u9645\u4e0a\u662f\u586b\u5145\u4e86prev\u548cnext\u4e4b\u95f4\u7684\u201c\u7a7a\u6d1e\u201d\uff0c\u4e5f\u5c31\u662f\u8bf4\u4e09\u4e2a\u533a\u57df\u5408\u4e3a\u4e00\u4e2a\u533a\u57df\uff0cvma_adjust()\u4f1a\u5220\u9664next\u533a\u57df\u540c\u65f6\u6269\u5927prev\u533a\u57df\u3002<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/edsionte.com\/techblog\/archives\/3586\/case1\" rel=\"attachment wp-att-3616\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter  wp-image-3616\" title=\"case1\" src=\"http:\/\/edsionte.com\/techblog\/wordpress\/wp-content\/uploads\/2011\/12\/case1.jpeg\" alt=\"\" width=\"329\" height=\"300\" srcset=\"http:\/\/edsionte.com\/techblog\/wordpress\/wp-content\/uploads\/2011\/12\/case1.jpeg 470w, http:\/\/edsionte.com\/techblog\/wordpress\/wp-content\/uploads\/2011\/12\/case1-300x273.jpg 300w\" sizes=\"auto, (max-width: 329px) 100vw, 329px\" \/><\/a><\/p>\n<p>case6\u4e5f\u53ef\u4ee5\u770b\u4f5c\u662f\u586b\u5145prev\u548cnext\u533a\u57df\u4e4b\u95f4\u7684\u7a7a\u6d1e\uff0c\u4e0d\u8fc7\u5b83\u4f1a\u5c06next\u2018\u533a\u57df\u8fdb\u884c\u201c\u8986\u76d6\u201d\u3002\u901a\u8fc7\u4ee3\u7801\u53ef\u4ee5\u53d1\u73b0\uff0cnext\u2018\u548cnext\u533a\u57df\u4e8b\u5b9e\u4e0a\u662f\u8fde\u7eed\u7684\uff0c\u4e0d\u8fc7\u7531\u4e8e\u5176\u4ed6\u539f\u56e0\uff0c\u6bd4\u5982\u6807\u5fd7\u4e0d\u540c\uff0c\u9020\u6210\u5b83\u4eec\u662f\u4e24\u4e2a\u4e0d\u540c\u7684\u533a\u57df\u3002\u5c3d\u7ba1\u5730\u5740\u8fde\u7eed\uff0c\u4f46\u662f\u7ec4\u7ec7\u7684\u65f6\u5019\u4ecd\u7136\u901a\u8fc7\u94fe\u8868\u94fe\u63a5\u3002\u8fd9\u91cc\u4e3a\u4e86\u5b9a\u91cf\u7684\u8868\u793a\u533a\u57df\u4e4b\u95f4\u7684\u5173\u7cfb\uff0c\u7701\u53bb\u4e86next\u2018\u548cnext\u4e4b\u95f4\u7684\u94fe\u63a5\u7bad\u5934\u3002<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/edsionte.com\/techblog\/archives\/3586\/case6\" rel=\"attachment wp-att-3621\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter  wp-image-3621\" title=\"case6\" src=\"http:\/\/edsionte.com\/techblog\/wordpress\/wp-content\/uploads\/2011\/12\/case6.jpeg\" alt=\"\" width=\"461\" height=\"301\" srcset=\"http:\/\/edsionte.com\/techblog\/wordpress\/wp-content\/uploads\/2011\/12\/case6.jpeg 658w, http:\/\/edsionte.com\/techblog\/wordpress\/wp-content\/uploads\/2011\/12\/case6-300x196.jpg 300w\" sizes=\"auto, (max-width: 461px) 100vw, 461px\" \/><\/a><\/p>\n<p>\u5982\u679cend\u4e0enext\u7684\u8d77\u59cb\u5730\u5740\u4e0d\u91cd\u5408\uff0c\u90a3\u4e48\u4f1a\u51fa\u73b0case2\uff0ccase5\uff0ccase7\u4e09\u79cd\u60c5\u51b5\u3002\u8fd9\u4e09\u79cd\u60c5\u51b5\u7684\u5dee\u5f02\u4f1a\u5728vma_adjust()\u4e2d\u88ab\u8fdb\u4e00\u6b65\u533a\u5206\uff0c\u800c\u5728\u5f53\u524d\u51fd\u6570\u4e2d\uff0c\u5b83\u4eec\u88ab\u770b\u4f5c\u662f\u4e00\u79cd\u60c5\u51b5\uff0c\u5373addr\u4e0eprev\u7ec8\u6b62\u5730\u5740\u91cd\u5408\u800cend\u4e0enext\u8d77\u59cb\u5730\u5740\u4e0d\u91cd\u5408\u3002<\/p>\n<p>\u5982\u679cend\u5c0f\u4e8enext\u533a\u57df\u7684\u8d77\u59cb\u5730\u5740\uff0c\u5219\u4e3acase2\u3002<\/p>\n<p style=\"text-align: center;\">\u00a0<a href=\"http:\/\/edsionte.com\/techblog\/archives\/3586\/case2\" rel=\"attachment wp-att-3617\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter  wp-image-3617\" title=\"case2\" src=\"http:\/\/edsionte.com\/techblog\/wordpress\/wp-content\/uploads\/2011\/12\/case2.jpeg\" alt=\"\" width=\"385\" height=\"308\" srcset=\"http:\/\/edsionte.com\/techblog\/wordpress\/wp-content\/uploads\/2011\/12\/case2.jpeg 550w, http:\/\/edsionte.com\/techblog\/wordpress\/wp-content\/uploads\/2011\/12\/case2-300x239.jpg 300w\" sizes=\"auto, (max-width: 385px) 100vw, 385px\" \/><\/a><\/p>\n<p>\u5982\u679cend\u5927\u4e8enext\u533a\u57df\u7684\u8d77\u59cb\u5730\u5740\uff0c\u5219\u4e3acase5\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0cnext\u4f1a\u88ab\u4e00\u5206\u4e3a\u4e8c\uff0c\u4e00\u90e8\u5206\u52a0\u5165prev\uff0c\u800c\u53e6\u4e00\u90e8\u5206\u5219\u7ee7\u7eed\u4fdd\u7559\u5728\u539f\u59cb\u533a\u57df\u4e2d\u3002<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/edsionte.com\/techblog\/archives\/3586\/case5\" rel=\"attachment wp-att-3620\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter  wp-image-3620\" title=\"case5\" src=\"http:\/\/edsionte.com\/techblog\/wordpress\/wp-content\/uploads\/2011\/12\/case5.jpeg\" alt=\"\" width=\"429\" height=\"308\" srcset=\"http:\/\/edsionte.com\/techblog\/wordpress\/wp-content\/uploads\/2011\/12\/case5.jpeg 613w, http:\/\/edsionte.com\/techblog\/wordpress\/wp-content\/uploads\/2011\/12\/case5-300x215.jpg 300w\" sizes=\"auto, (max-width: 429px) 100vw, 429px\" \/><\/a><\/p>\n<p>case7\u4e5f\u662f\u4e00\u79cd\u6269\u5927prev\u7684\u60c5\u51b5\uff0c\u5b83\u4f1a\u5c06next\u2018\u8986\u76d6\uff0c\u800cnext\u5219\u4fdd\u6301\u4e0d\u53d8\u3002<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/edsionte.com\/techblog\/archives\/3586\/case7\" rel=\"attachment wp-att-3622\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter  wp-image-3622\" title=\"case7\" src=\"http:\/\/edsionte.com\/techblog\/wordpress\/wp-content\/uploads\/2011\/12\/case7.jpeg\" alt=\"\" width=\"461\" height=\"301\" srcset=\"http:\/\/edsionte.com\/techblog\/wordpress\/wp-content\/uploads\/2011\/12\/case7.jpeg 658w, http:\/\/edsionte.com\/techblog\/wordpress\/wp-content\/uploads\/2011\/12\/case7-300x196.jpg 300w\" sizes=\"auto, (max-width: 461px) 100vw, 461px\" \/><\/a><\/p>\n<p>\u5f53\u4e0a\u8ff0\u60c5\u51b5\u90fd\u4e0d\u7b26\u5408\u65f6\uff0c\u8fdb\u5165\u7b2c\u4e8c\u5927\u7c7b\u5408\u5e76\uff0c\u5373end\u4e0enext\u7684\u8d77\u59cb\u5730\u5740\u91cd\u5408\u3002\u5728\u8fd9\u79cd\u60c5\u5f62\u4e0b\u6d89\u53ca\u4e09\u79cd\u5408\u5e76\u6a21\u578b\uff0c\u5b83\u4eec\u7684\u56fe\u793a\u5206\u522b\u5982\u4e0b\u6240\u793a\u3002<\/p>\n<pre class=\"brush:c\">        if (next &amp;&amp; end == next-&gt;vm_start &amp;&amp;\r\n                        mpol_equal(policy, vma_policy(next)) &amp;&amp;\r\n                        can_vma_merge_before(next, vm_flags,\r\n                                        anon_vma, file, pgoff+pglen)) {\r\n                if (prev &amp;&amp; addr &lt; prev-&gt;vm_end)        \/* case 4 *\/\r\n                        err = vma_adjust(prev, prev-&gt;vm_start,\r\n                                addr, prev-&gt;vm_pgoff, NULL);\r\n                else                                    \/* cases 3, 8 *\/\r\n                        err = vma_adjust(area, addr, next-&gt;vm_end,\r\n                                next-&gt;vm_pgoff - pglen, NULL);\r\n                if (err)\r\n                        return NULL;\r\n                return area;\r\n        }\r\n\r\n        return NULL;<\/pre>\n<p>\u5982\u679caddr\u5927\u4e8eprev\u7684\u7ec8\u6b62\u5730\u5740\uff0c\u5219\u5c5e\u4e8ecase4\u3002\u8fd9\u79cd\u60c5\u51b5\u4e0b\u7f29\u5c0fprev\uff0c\u6269\u5145next\u3002<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/edsionte.com\/techblog\/archives\/3586\/case4\" rel=\"attachment wp-att-3619\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter  wp-image-3619\" title=\"case4\" src=\"http:\/\/edsionte.com\/techblog\/wordpress\/wp-content\/uploads\/2011\/12\/case4.jpeg\" alt=\"\" width=\"422\" height=\"309\" srcset=\"http:\/\/edsionte.com\/techblog\/wordpress\/wp-content\/uploads\/2011\/12\/case4.jpeg 603w, http:\/\/edsionte.com\/techblog\/wordpress\/wp-content\/uploads\/2011\/12\/case4-300x219.jpg 300w\" sizes=\"auto, (max-width: 422px) 100vw, 422px\" \/><\/a><\/p>\n<p>\u5982\u679caddr\u5c0f\u4e8eprev\u533a\u57df\u7684\u7ec8\u6b62\u5730\u5740\uff0c\u5219\u5c5e\u4e8ecase3\u3002\u8fd9\u79cd\u60c5\u51b5\u4e0bprev\u4e0d\u505a\u6539\u53d8\uff0c\u6269\u5145next\u3002<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/edsionte.com\/techblog\/archives\/3586\/case3\" rel=\"attachment wp-att-3618\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter  wp-image-3618\" title=\"case3\" src=\"http:\/\/edsionte.com\/techblog\/wordpress\/wp-content\/uploads\/2011\/12\/case3.jpeg\" alt=\"\" width=\"385\" height=\"302\" srcset=\"http:\/\/edsionte.com\/techblog\/wordpress\/wp-content\/uploads\/2011\/12\/case3.jpeg 550w, http:\/\/edsionte.com\/techblog\/wordpress\/wp-content\/uploads\/2011\/12\/case3-300x235.jpg 300w\" sizes=\"auto, (max-width: 385px) 100vw, 385px\" \/><\/a><\/p>\n<p>case8\u4e0ecase3\u6bd4\u8f83\u7c7b\u4f3c\uff0c\u4e0d\u8fc7\u5b83\u4f1a\u8986\u76d6\u5df2\u5b58\u5728\u7684next\u2018\u3002<br \/>\n<a href=\"http:\/\/edsionte.com\/techblog\/archives\/3586\/case8\" rel=\"attachment wp-att-3623\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter  wp-image-3623\" title=\"case8\" src=\"http:\/\/edsionte.com\/techblog\/wordpress\/wp-content\/uploads\/2011\/12\/case8.jpeg\" alt=\"\" width=\"459\" height=\"313\" srcset=\"http:\/\/edsionte.com\/techblog\/wordpress\/wp-content\/uploads\/2011\/12\/case8.jpeg 656w, http:\/\/edsionte.com\/techblog\/wordpress\/wp-content\/uploads\/2011\/12\/case8-300x204.jpg 300w\" sizes=\"auto, (max-width: 459px) 100vw, 459px\" \/><\/a><br \/>\n\u4ece\u6e90\u7801\u7684\u6761\u4ef6\u5224\u65ad\u8bed\u53e5\u53ef\u4ee5\u770b\u51fa\uff0c\u4e0a\u8ff08\u79cd\u5408\u5e76\u60c5\u51b5\u53ef\u4ee5\u89c4\u5212\u4e3a\u56db\u7c7b\uff0c\u901a\u8fc7\u5411vma_adjust()\u4f20\u9012\u4e0d\u540c\u7684\u53c2\u6570\u53ef\u4ee5\u4e3a\u6bcf\u79cd\u60c5\u51b5\u8c03\u8282\u5185\u5b58\u533a\u57df\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5408\u5e76\u5185\u5b58\u533a\u57df Linux\u7684\u5185\u5b58\u7ba1\u7406\u6a21\u5757\u4ee5\u865a\u62df\u5185\u5b58\u533a\u57df\u4e3a\u5355\u4f4d\u7ba1\u7406\u8fdb\u7a0b\u7684\u865a\u62df\u5185\u5b58\uff0c\u4e00\u4e2a\u8fdb\u7a0b\u7684\u6240\u6709\u5185\u5b58\u533a\u57df\u5206\u522b\u4ee5\u94fe\u8868 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[266],"tags":[264,296,407,295],"class_list":["post-3586","post","type-post","status-publish","format-standard","hentry","category-266","tag-mmap","tag-vma","tag-407","tag-295"],"views":12375,"_links":{"self":[{"href":"http:\/\/edsionte.com\/techblog\/wp-json\/wp\/v2\/posts\/3586","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/edsionte.com\/techblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/edsionte.com\/techblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/edsionte.com\/techblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/edsionte.com\/techblog\/wp-json\/wp\/v2\/comments?post=3586"}],"version-history":[{"count":0,"href":"http:\/\/edsionte.com\/techblog\/wp-json\/wp\/v2\/posts\/3586\/revisions"}],"wp:attachment":[{"href":"http:\/\/edsionte.com\/techblog\/wp-json\/wp\/v2\/media?parent=3586"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/edsionte.com\/techblog\/wp-json\/wp\/v2\/categories?post=3586"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/edsionte.com\/techblog\/wp-json\/wp\/v2\/tags?post=3586"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}