shm.c (a23e1966932464e1c5226cb9ac4ce1d5fc10ba22) shm.c (63fc66f5b6b18f39269a66cf34d8cb7a24fbfe88)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * linux/ipc/shm.c
4 * Copyright (C) 1992, 1993 Krishna Balasubramanian
5 * Many improvements/fixes by Bruno Haible.
6 * Replaced `struct shm_desc' by `struct vm_area_struct', July 1994.
7 * Fixed the shm swap deallocation (shm_unuse()), August 1998 Andrea Arcangeli.
8 *

--- 648 unchanged lines hidden (view full) ---

657 .fsync = shm_fsync,
658 .release = shm_release,
659 .get_unmapped_area = shm_get_unmapped_area,
660 .llseek = noop_llseek,
661 .fallocate = shm_fallocate,
662};
663
664/*
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * linux/ipc/shm.c
4 * Copyright (C) 1992, 1993 Krishna Balasubramanian
5 * Many improvements/fixes by Bruno Haible.
6 * Replaced `struct shm_desc' by `struct vm_area_struct', July 1994.
7 * Fixed the shm swap deallocation (shm_unuse()), August 1998 Andrea Arcangeli.
8 *

--- 648 unchanged lines hidden (view full) ---

657 .fsync = shm_fsync,
658 .release = shm_release,
659 .get_unmapped_area = shm_get_unmapped_area,
660 .llseek = noop_llseek,
661 .fallocate = shm_fallocate,
662};
663
664/*
665 * shm_file_operations_huge is now identical to shm_file_operations,
666 * but we keep it distinct for the sake of is_file_shm_hugepages().
665 * shm_file_operations_huge is now identical to shm_file_operations
666 * except for fop_flags
667 */
668static const struct file_operations shm_file_operations_huge = {
669 .mmap = shm_mmap,
670 .fsync = shm_fsync,
671 .release = shm_release,
672 .get_unmapped_area = shm_get_unmapped_area,
673 .llseek = noop_llseek,
674 .fallocate = shm_fallocate,
667 */
668static const struct file_operations shm_file_operations_huge = {
669 .mmap = shm_mmap,
670 .fsync = shm_fsync,
671 .release = shm_release,
672 .get_unmapped_area = shm_get_unmapped_area,
673 .llseek = noop_llseek,
674 .fallocate = shm_fallocate,
675 .fop_flags = FOP_HUGE_PAGES,
675};
676
676};
677
677bool is_file_shm_hugepages(struct file *file)
678{
679 return file->f_op == &shm_file_operations_huge;
680}
681
682static const struct vm_operations_struct shm_vm_ops = {
683 .open = shm_open, /* callback for a new vm-area open */
684 .close = shm_close, /* callback for when the vm-area is released */
685 .fault = shm_fault,
686 .may_split = shm_may_split,
687 .pagesize = shm_pagesize,
688#if defined(CONFIG_NUMA)
689 .set_policy = shm_set_policy,

--- 1087 unchanged lines hidden (view full) ---

1777 /*
1778 * Record the file of the shm segment being
1779 * unmapped. With mremap(), someone could place
1780 * page from another segment but with equal offsets
1781 * in the range we are unmapping.
1782 */
1783 file = vma->vm_file;
1784 size = i_size_read(file_inode(vma->vm_file));
678static const struct vm_operations_struct shm_vm_ops = {
679 .open = shm_open, /* callback for a new vm-area open */
680 .close = shm_close, /* callback for when the vm-area is released */
681 .fault = shm_fault,
682 .may_split = shm_may_split,
683 .pagesize = shm_pagesize,
684#if defined(CONFIG_NUMA)
685 .set_policy = shm_set_policy,

--- 1087 unchanged lines hidden (view full) ---

1773 /*
1774 * Record the file of the shm segment being
1775 * unmapped. With mremap(), someone could place
1776 * page from another segment but with equal offsets
1777 * in the range we are unmapping.
1778 */
1779 file = vma->vm_file;
1780 size = i_size_read(file_inode(vma->vm_file));
1785 do_vma_munmap(&vmi, vma, vma->vm_start, vma->vm_end,
1786 NULL, false);
1781 do_vmi_align_munmap(&vmi, vma, mm, vma->vm_start,
1782 vma->vm_end, NULL, false);
1787 /*
1788 * We discovered the size of the shm segment, so
1789 * break out of here and fall through to the next
1790 * loop that uses the size information to stop
1791 * searching for matching vma's.
1792 */
1793 retval = 0;
1794 vma = vma_next(&vmi);

--- 7 unchanged lines hidden (view full) ---

1802 * prevent overflows and make comparisons vs. equal-width types.
1803 */
1804 size = PAGE_ALIGN(size);
1805 while (vma && (loff_t)(vma->vm_end - addr) <= size) {
1806 /* finding a matching vma now does not alter retval */
1807 if ((vma->vm_ops == &shm_vm_ops) &&
1808 ((vma->vm_start - addr)/PAGE_SIZE == vma->vm_pgoff) &&
1809 (vma->vm_file == file)) {
1783 /*
1784 * We discovered the size of the shm segment, so
1785 * break out of here and fall through to the next
1786 * loop that uses the size information to stop
1787 * searching for matching vma's.
1788 */
1789 retval = 0;
1790 vma = vma_next(&vmi);

--- 7 unchanged lines hidden (view full) ---

1798 * prevent overflows and make comparisons vs. equal-width types.
1799 */
1800 size = PAGE_ALIGN(size);
1801 while (vma && (loff_t)(vma->vm_end - addr) <= size) {
1802 /* finding a matching vma now does not alter retval */
1803 if ((vma->vm_ops == &shm_vm_ops) &&
1804 ((vma->vm_start - addr)/PAGE_SIZE == vma->vm_pgoff) &&
1805 (vma->vm_file == file)) {
1810 do_vma_munmap(&vmi, vma, vma->vm_start, vma->vm_end,
1811 NULL, false);
1806 do_vmi_align_munmap(&vmi, vma, mm, vma->vm_start,
1807 vma->vm_end, NULL, false);
1812 }
1813
1814 vma = vma_next(&vmi);
1815 }
1816
1817#else /* CONFIG_MMU */
1818 vma = vma_lookup(mm, addr);
1819 /* under NOMMU conditions, the exact address to be destroyed must be

--- 60 unchanged lines hidden ---
1808 }
1809
1810 vma = vma_next(&vmi);
1811 }
1812
1813#else /* CONFIG_MMU */
1814 vma = vma_lookup(mm, addr);
1815 /* under NOMMU conditions, the exact address to be destroyed must be

--- 60 unchanged lines hidden ---