mmap.c (fbc90c042cd1dc7258ebfebe6d226017e5b5ac8c) | mmap.c (9651fcedf7b92d3f7f1ab179e8ab55b85ee10fc1) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * mm/mmap.c 4 * 5 * Written by obz. 6 * 7 * Address space accounting code <alan@lxorguk.ukuu.org.uk> 8 */ --- 117 unchanged lines hidden (view full) --- 126 if (file) { 127 struct address_space *mapping = file->f_mapping; 128 i_mmap_lock_write(mapping); 129 __remove_shared_vm_struct(vma, mapping); 130 i_mmap_unlock_write(mapping); 131 } 132} 133 | 1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * mm/mmap.c 4 * 5 * Written by obz. 6 * 7 * Address space accounting code <alan@lxorguk.ukuu.org.uk> 8 */ --- 117 unchanged lines hidden (view full) --- 126 if (file) { 127 struct address_space *mapping = file->f_mapping; 128 i_mmap_lock_write(mapping); 129 __remove_shared_vm_struct(vma, mapping); 130 i_mmap_unlock_write(mapping); 131 } 132} 133 |
134void unlink_file_vma_batch_init(struct unlink_vma_file_batch *vb) 135{ 136 vb->count = 0; 137} 138 139static void unlink_file_vma_batch_process(struct unlink_vma_file_batch *vb) 140{ 141 struct address_space *mapping; 142 int i; 143 144 mapping = vb->vmas[0]->vm_file->f_mapping; 145 i_mmap_lock_write(mapping); 146 for (i = 0; i < vb->count; i++) { 147 VM_WARN_ON_ONCE(vb->vmas[i]->vm_file->f_mapping != mapping); 148 __remove_shared_vm_struct(vb->vmas[i], mapping); 149 } 150 i_mmap_unlock_write(mapping); 151 152 unlink_file_vma_batch_init(vb); 153} 154 155void unlink_file_vma_batch_add(struct unlink_vma_file_batch *vb, 156 struct vm_area_struct *vma) 157{ 158 if (vma->vm_file == NULL) 159 return; 160 161 if ((vb->count > 0 && vb->vmas[0]->vm_file != vma->vm_file) || 162 vb->count == ARRAY_SIZE(vb->vmas)) 163 unlink_file_vma_batch_process(vb); 164 165 vb->vmas[vb->count] = vma; 166 vb->count++; 167} 168 169void unlink_file_vma_batch_final(struct unlink_vma_file_batch *vb) 170{ 171 if (vb->count > 0) 172 unlink_file_vma_batch_process(vb); 173} 174 | |
175/* 176 * Close a vm structure and free it. 177 */ 178static void remove_vma(struct vm_area_struct *vma, bool unreachable) 179{ 180 might_sleep(); 181 if (vma->vm_ops && vma->vm_ops->close) 182 vma->vm_ops->close(vma); --- 1222 unchanged lines hidden (view full) --- 1405 if (vm_flags & (VM_GROWSDOWN|VM_GROWSUP)) 1406 return -EINVAL; 1407 /* 1408 * Ignore pgoff. 1409 */ 1410 pgoff = 0; 1411 vm_flags |= VM_SHARED | VM_MAYSHARE; 1412 break; | 134/* 135 * Close a vm structure and free it. 136 */ 137static void remove_vma(struct vm_area_struct *vma, bool unreachable) 138{ 139 might_sleep(); 140 if (vma->vm_ops && vma->vm_ops->close) 141 vma->vm_ops->close(vma); --- 1222 unchanged lines hidden (view full) --- 1364 if (vm_flags & (VM_GROWSDOWN|VM_GROWSUP)) 1365 return -EINVAL; 1366 /* 1367 * Ignore pgoff. 1368 */ 1369 pgoff = 0; 1370 vm_flags |= VM_SHARED | VM_MAYSHARE; 1371 break; |
1372 case MAP_DROPPABLE: 1373 if (VM_DROPPABLE == VM_NONE) 1374 return -ENOTSUPP; 1375 /* 1376 * A locked or stack area makes no sense to be droppable. 1377 * 1378 * Also, since droppable pages can just go away at any time 1379 * it makes no sense to copy them on fork or dump them. 1380 * 1381 * And don't attempt to combine with hugetlb for now. 1382 */ 1383 if (flags & (MAP_LOCKED | MAP_HUGETLB)) 1384 return -EINVAL; 1385 if (vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) 1386 return -EINVAL; 1387 1388 vm_flags |= VM_DROPPABLE; 1389 1390 /* 1391 * If the pages can be dropped, then it doesn't make 1392 * sense to reserve them. 1393 */ 1394 vm_flags |= VM_NORESERVE; 1395 1396 /* 1397 * Likewise, they're volatile enough that they 1398 * shouldn't survive forks or coredumps. 1399 */ 1400 vm_flags |= VM_WIPEONFORK | VM_DONTDUMP; 1401 fallthrough; |
|
1413 case MAP_PRIVATE: 1414 /* 1415 * Set pgoff according to addr for anon_vma. 1416 */ 1417 pgoff = addr >> PAGE_SHIFT; 1418 break; 1419 default: 1420 return -EINVAL; --- 2640 unchanged lines hidden --- | 1402 case MAP_PRIVATE: 1403 /* 1404 * Set pgoff according to addr for anon_vma. 1405 */ 1406 pgoff = addr >> PAGE_SHIFT; 1407 break; 1408 default: 1409 return -EINVAL; --- 2640 unchanged lines hidden --- |