Messages in this thread Patch in this message | | | Date | Tue, 30 Mar 2004 23:48:19 +0100 (BST) | From | Hugh Dickins <> | Subject | [PATCH 5/6] mremap check map_count |
| |
mremap's move_vma should think ahead to lessen the chance of failure during its rewind on failure: running out of memory always possible, but it's silly for it to embark when it's near the map_count limit.
Note: -mm tree needs sysctl_max_map_count in place of MAX_MAP_COUNT.
--- mremap4/mm/mremap.c 2004-03-30 21:25:00.136666640 +0100 +++ mremap5/mm/mremap.c 2004-03-30 21:25:11.549931560 +0100 @@ -176,6 +176,13 @@ static unsigned long move_vma(struct vm_ unsigned long excess = 0; int split = 0; + /* + * We'd prefer to avoid failure later on in do_munmap: + * which may split one vma into three before unmapping. + */ + if (mm->map_count >= MAX_MAP_COUNT - 3) + return -ENOMEM; + new_pgoff = vma->vm_pgoff + ((old_addr - vma->vm_start) >> PAGE_SHIFT); new_vma = copy_vma(vma, new_addr, new_len, new_pgoff); if (!new_vma) - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |