Merge more updates from Andrew Morton: - MM remainders - various misc things - kcov updates * emailed patches from Andrew Morton <akpm@linux-foundation.org>: (27 commits) lib/test_printf.c: call wait_for_random_bytes() before plain %p tests hexagon: drop the unused variable zero_page_mask hexagon: fix printk format warning in setup.c mm: fix oom_kill event handling treewide: use PHYS_ADDR_MAX to avoid type casting ULLONG_MAX mm: use octal not symbolic permissions ipc: use new return type vm_fault_t sysvipc/sem: mitigate semnum index against spectre v1 fault-injection: reorder config entries arm: port KCOV to arm sched/core / kcov: avoid kcov_area during task switch kcov: prefault the kcov_area kcov: ensure irq code sees a valid area kernel/relay.c: change return type to vm_fault_t exofs: avoid VLA in structures coredump: fix spam with zero VMA process fat: use fat_fs_error() instead of BUG_ON() in __fat_get_block() proc: skip branch in /proc/*/* lookup mremap: remove LATENCY_LIMIT from mremap to reduce the number of TLB shootdowns mm/memblock: add missing include <linux/bootmem.h> ...
Unified · Split
| @@ -8,9 +8,10 @@ config ARM · 7 unmodified lines | |||
| 8 | select ARCH_HAS_DEVMEM_IS_ALLOWED | 8 | select ARCH_HAS_DEVMEM_IS_ALLOWED |
| 9 | select ARCH_HAS_ELF_RANDOMIZE | 9 | select ARCH_HAS_ELF_RANDOMIZE |
| 10 | select ARCH_HAS_FORTIFY_SOURCE | 10 | select ARCH_HAS_FORTIFY_SOURCE |
| 11 | select ARCH_HAS_KCOV | ||
| 11 | select ARCH_HAS_PTE_SPECIAL if ARM_LPAE | 12 | select ARCH_HAS_PTE_SPECIAL if ARM_LPAE |
| 12 | select ARCH_HAS_SET_MEMORY | ||
| 13 | select ARCH_HAS_PHYS_TO_DMA | 13 | select ARCH_HAS_PHYS_TO_DMA |
| 14 | select ARCH_HAS_SET_MEMORY | ||
| 14 | select ARCH_HAS_STRICT_KERNEL_RWX if MMU && !XIP_KERNEL | 15 | select ARCH_HAS_STRICT_KERNEL_RWX if MMU && !XIP_KERNEL |
| 15 | select ARCH_HAS_STRICT_MODULE_RWX if MMU | 16 | select ARCH_HAS_STRICT_MODULE_RWX if MMU |
| 16 | select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST | 17 | select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST |
| @@ -25,6 +25,9 @@ endif · 24 unmodified lines | |||
| 25 | 25 | ||
| 26 | GCOV_PROFILE := n | 26 | GCOV_PROFILE := n |
| 27 | 27 | ||
| 28 | # Prevents link failures: __sanitizer_cov_trace_pc() is not linked in. | ||
| 29 | KCOV_INSTRUMENT := n | ||
| 30 | |||
| 28 | # | 31 | # |
| 29 | # Architecture dependencies | 32 | # Architecture dependencies |
| 30 | # | 33 | # |
| @@ -23,3 +23,11 @@ obj-$(CONFIG_KVM_ARM_HOST) += hyp-entry.o · 22 unmodified lines | |||
| 23 | obj-$(CONFIG_KVM_ARM_HOST) += switch.o | 23 | obj-$(CONFIG_KVM_ARM_HOST) += switch.o |
| 24 | CFLAGS_switch.o += $(CFLAGS_ARMV7VE) | 24 | CFLAGS_switch.o += $(CFLAGS_ARMV7VE) |
| 25 | obj-$(CONFIG_KVM_ARM_HOST) += s2-setup.o | 25 | obj-$(CONFIG_KVM_ARM_HOST) += s2-setup.o |
| 26 | |||
| 27 | # KVM code is run at a different exception code with a different map, so | ||
| 28 | # compiler instrumentation that inserts callbacks or checks into the code may | ||
| 29 | # cause crashes. Just disable it. | ||
| 30 | GCOV_PROFILE := n | ||
| 31 | KASAN_SANITIZE := n | ||
| 32 | UBSAN_SANITIZE := n | ||
| 33 | KCOV_INSTRUMENT := n | ||
| @@ -30,6 +30,9 @@ CFLAGS_vgettimeofday.o = -O2 · 29 unmodified lines | |||
| 30 | # Disable gcov profiling for VDSO code | 30 | # Disable gcov profiling for VDSO code |
| 31 | GCOV_PROFILE := n | 31 | GCOV_PROFILE := n |
| 32 | 32 | ||
| 33 | # Prevents link failures: __sanitizer_cov_trace_pc() is not linked in. | ||
| 34 | KCOV_INSTRUMENT := n | ||
| 35 | |||
| 33 | # Force dependency | 36 | # Force dependency |
| 34 | $(obj)/vdso.o : $(obj)/vdso.so | 37 | $(obj)/vdso.o : $(obj)/vdso.so |
| 35 | 38 | ||
| @@ -310,7 +310,7 @@ static void __init arm64_memory_present(void) · 309 unmodified lines | |||
| 310 | } | 310 | } |
| 311 | #endif | 311 | #endif |
| 312 | 312 | ||
| 313 | static phys_addr_t memory_limit = (phys_addr_t)ULLONG_MAX; | 313 | static phys_addr_t memory_limit = PHYS_ADDR_MAX; |
| 314 | 314 | ||
| 315 | /* | 315 | /* |
| 316 | * Limit the memory size that was specified via FDT. | 316 | * Limit the memory size that was specified via FDT. |
| @@ -401,7 +401,7 @@ void __init arm64_memblock_init(void) · 84 unmodified lines | |||
| 401 | * high up in memory, add back the kernel region that must be accessible | 401 | * high up in memory, add back the kernel region that must be accessible |
| 402 | * via the linear mapping. | 402 | * via the linear mapping. |
| 403 | */ | 403 | */ |
| 404 | if (memory_limit != (phys_addr_t)ULLONG_MAX) { | 404 | if (memory_limit != PHYS_ADDR_MAX) { |
| 405 | memblock_mem_limit_remove_map(memory_limit); | 405 | memblock_mem_limit_remove_map(memory_limit); |
| 406 | memblock_add(__pa_symbol(_text), (u64)(_end - _text)); | 406 | memblock_add(__pa_symbol(_text), (u64)(_end - _text)); |
| 407 | } | 407 | } |
| @@ -666,7 +666,7 @@ __setup("keepinitrd", keepinitrd_setup); · 258 unmodified lines | |||
| 666 | */ | 666 | */ |
| 667 | static int dump_mem_limit(struct notifier_block *self, unsigned long v, void *p) | 667 | static int dump_mem_limit(struct notifier_block *self, unsigned long v, void *p) |
| 668 | { | 668 | { |
| 669 | if (memory_limit != (phys_addr_t)ULLONG_MAX) { | 669 | if (memory_limit != PHYS_ADDR_MAX) { |
| 670 | pr_emerg("Memory Limit: %llu MB\n", memory_limit >> 20); | 670 | pr_emerg("Memory Limit: %llu MB\n", memory_limit >> 20); |
| 671 | } else { | 671 | } else { |
| 672 | pr_emerg("Memory Limit: none\n"); | 672 | pr_emerg("Memory Limit: none\n"); |
| @@ -30,7 +30,6 @@ · 29 unmodified lines | |||
| 30 | 30 | ||
| 31 | /* A handy thing to have if one has the RAM. Declared in head.S */ | 31 | /* A handy thing to have if one has the RAM. Declared in head.S */ |
| 32 | extern unsigned long empty_zero_page; | 32 | extern unsigned long empty_zero_page; |
| 33 | extern unsigned long zero_page_mask; | ||
| 34 | 33 | ||
| 35 | /* | 34 | /* |
| 36 | * The PTE model described here is that of the Hexagon Virtual Machine, | 35 | * The PTE model described here is that of the Hexagon Virtual Machine, |
| @@ -66,7 +66,7 @@ void __init setup_arch(char **cmdline_p) · 65 unmodified lines | |||
| 66 | */ | 66 | */ |
| 67 | __vmsetvec(_K_VM_event_vector); | 67 | __vmsetvec(_K_VM_event_vector); |
| 68 | 68 | ||
| 69 | printk(KERN_INFO "PHYS_OFFSET=0x%08x\n", PHYS_OFFSET); | 69 | printk(KERN_INFO "PHYS_OFFSET=0x%08lx\n", PHYS_OFFSET); |
| 70 | 70 | ||
| 71 | /* | 71 | /* |
| 72 | * Simulator has a few differences from the hardware. | 72 | * Simulator has a few differences from the hardware. |
| @@ -39,9 +39,6 @@ unsigned long __phys_offset; /* physical kernel offset >> 12 */ · 38 unmodified lines | |||
| 39 | /* Set as variable to limit PMD copies */ | 39 | /* Set as variable to limit PMD copies */ |
| 40 | int max_kernel_seg = 0x303; | 40 | int max_kernel_seg = 0x303; |
| 41 | 41 | ||
| 42 | /* think this should be (page_size-1) the way it's used...*/ | ||
| 43 | unsigned long zero_page_mask; | ||
| 44 | |||
| 45 | /* indicate pfn's of high memory */ | 42 | /* indicate pfn's of high memory */ |
| 46 | unsigned long highstart_pfn, highend_pfn; | 43 | unsigned long highstart_pfn, highend_pfn; |
| 47 | 44 | ||
| @@ -93,7 +93,7 @@ void __init add_memory_region(phys_addr_t start, phys_addr_t size, long type) · 92 unmodified lines | |||
| 93 | * If the region reaches the top of the physical address space, adjust | 93 | * If the region reaches the top of the physical address space, adjust |
| 94 | * the size slightly so that (start + size) doesn't overflow | 94 | * the size slightly so that (start + size) doesn't overflow |
| 95 | */ | 95 | */ |
| 96 | if (start + size - 1 == (phys_addr_t)ULLONG_MAX) | 96 | if (start + size - 1 == PHYS_ADDR_MAX) |
| 97 | --size; | 97 | --size; |
| 98 | 98 | ||
| 99 | /* Sanity check */ | 99 | /* Sanity check */ |
| @@ -376,7 +376,7 @@ static void __init bootmem_init(void) · 276 unmodified lines | |||
| 376 | unsigned long reserved_end; | 376 | unsigned long reserved_end; |
| 377 | unsigned long mapstart = ~0UL; | 377 | unsigned long mapstart = ~0UL; |
| 378 | unsigned long bootmap_size; | 378 | unsigned long bootmap_size; |
| 379 | phys_addr_t ramstart = (phys_addr_t)ULLONG_MAX; | 379 | phys_addr_t ramstart = PHYS_ADDR_MAX; |
| 380 | bool bootmap_valid = false; | 380 | bool bootmap_valid = false; |
| 381 | int i; | 381 | int i; |
| 382 | 382 | ||
| @@ -215,7 +215,7 @@ void __init mem_topology_setup(void) · 214 unmodified lines | |||
| 215 | /* Place all memblock_regions in the same node and merge contiguous | 215 | /* Place all memblock_regions in the same node and merge contiguous |
| 216 | * memblock_regions | 216 | * memblock_regions |
| 217 | */ | 217 | */ |
| 218 | memblock_set_node(0, (phys_addr_t)ULLONG_MAX, &memblock.memory, 0); | 218 | memblock_set_node(0, PHYS_ADDR_MAX, &memblock.memory, 0); |
| 219 | } | 219 | } |
| 220 | 220 | ||
| 221 | void __init initmem_init(void) | 221 | void __init initmem_init(void) |
| @@ -1620,7 +1620,7 @@ static void __init bootmem_init_nonnuma(void) · 1619 unmodified lines | |||
| 1620 | (top_of_ram - total_ram) >> 20); | 1620 | (top_of_ram - total_ram) >> 20); |
| 1621 | 1621 | ||
| 1622 | init_node_masks_nonnuma(); | 1622 | init_node_masks_nonnuma(); |
| 1623 | memblock_set_node(0, (phys_addr_t)ULLONG_MAX, &memblock.memory, 0); | 1623 | memblock_set_node(0, PHYS_ADDR_MAX, &memblock.memory, 0); |
| 1624 | allocate_node_data(0); | 1624 | allocate_node_data(0); |
| 1625 | node_set_online(0); | 1625 | node_set_online(0); |
| 1626 | } | 1626 | } |
| @@ -706,7 +706,9 @@ void __init init_mem_mapping(void) · 705 unmodified lines | |||
| 706 | */ | 706 | */ |
| 707 | int devmem_is_allowed(unsigned long pagenr) | 707 | int devmem_is_allowed(unsigned long pagenr) |
| 708 | { | 708 | { |
| 709 | if (page_is_ram(pagenr)) { | 709 | if (region_intersects(PFN_PHYS(pagenr), PAGE_SIZE, |
| 710 | IORESOURCE_SYSTEM_RAM, IORES_DESC_NONE) | ||
| 711 | != REGION_DISJOINT) { | ||
| 710 | /* | 712 | /* |
| 711 | * For disallowed memory regions in the low 1MB range, | 713 | * For disallowed memory regions in the low 1MB range, |
| 712 | * request that the page be shown as all zeros. | 714 | * request that the page be shown as all zeros. |
| @@ -692,7 +692,7 @@ void __init initmem_init(void) · 691 unmodified lines | |||
| 692 | high_memory = (void *) __va(max_low_pfn * PAGE_SIZE - 1) + 1; | 692 | high_memory = (void *) __va(max_low_pfn * PAGE_SIZE - 1) + 1; |
| 693 | #endif | 693 | #endif |
| 694 | 694 | ||
| 695 | memblock_set_node(0, (phys_addr_t)ULLONG_MAX, &memblock.memory, 0); | 695 | memblock_set_node(0, PHYS_ADDR_MAX, &memblock.memory, 0); |
| 696 | sparse_memory_present_with_active_regions(0); | 696 | sparse_memory_present_with_active_regions(0); |
| 697 | 697 | ||
| 698 | #ifdef CONFIG_FLATMEM | 698 | #ifdef CONFIG_FLATMEM |
| @@ -742,7 +742,7 @@ kernel_physical_mapping_init(unsigned long paddr_start, · 741 unmodified lines | |||
| 742 | #ifndef CONFIG_NUMA | 742 | #ifndef CONFIG_NUMA |
| 743 | void __init initmem_init(void) | 743 | void __init initmem_init(void) |
| 744 | { | 744 | { |
| 745 | memblock_set_node(0, (phys_addr_t)ULLONG_MAX, &memblock.memory, 0); | 745 | memblock_set_node(0, PHYS_ADDR_MAX, &memblock.memory, 0); |
| 746 | } | 746 | } |
| 747 | #endif | 747 | #endif |
| 748 | 748 | ||
| @@ -193,7 +193,7 @@ static __init void reserve_regions(void) · 192 unmodified lines | |||
| 193 | * uses its own memory map instead. | 193 | * uses its own memory map instead. |
| 194 | */ | 194 | */ |
| 195 | memblock_dump_all(); | 195 | memblock_dump_all(); |
| 196 | memblock_remove(0, (phys_addr_t)ULLONG_MAX); | 196 | memblock_remove(0, PHYS_ADDR_MAX); |
| 197 | 197 | ||
| 198 | for_each_efi_memory_desc(md) { | 198 | for_each_efi_memory_desc(md) { |
| 199 | paddr = md->phys_addr; | 199 | paddr = md->phys_addr; |
| @@ -686,7 +686,7 @@ static int q6v5_mpss_load(struct q6v5 *qproc) · 685 unmodified lines | |||
| 686 | struct elf32_hdr *ehdr; | 686 | struct elf32_hdr *ehdr; |
| 687 | phys_addr_t mpss_reloc; | 687 | phys_addr_t mpss_reloc; |
| 688 | phys_addr_t boot_addr; | 688 | phys_addr_t boot_addr; |
| 689 | phys_addr_t min_addr = (phys_addr_t)ULLONG_MAX; | 689 | phys_addr_t min_addr = PHYS_ADDR_MAX; |
| 690 | phys_addr_t max_addr = 0; | 690 | phys_addr_t max_addr = 0; |
| 691 | bool relocate = false; | 691 | bool relocate = false; |
| 692 | char seg_name[10]; | 692 | char seg_name[10]; |
| @@ -50,7 +50,7 @@ ssize_t qcom_mdt_get_size(const struct firmware *fw) · 49 unmodified lines | |||
| 50 | const struct elf32_phdr *phdrs; | 50 | const struct elf32_phdr *phdrs; |
| 51 | const struct elf32_phdr *phdr; | 51 | const struct elf32_phdr *phdr; |
| 52 | const struct elf32_hdr *ehdr; | 52 | const struct elf32_hdr *ehdr; |
| 53 | phys_addr_t min_addr = (phys_addr_t)ULLONG_MAX; | 53 | phys_addr_t min_addr = PHYS_ADDR_MAX; |
| 54 | phys_addr_t max_addr = 0; | 54 | phys_addr_t max_addr = 0; |
| 55 | int i; | 55 | int i; |
| 56 | 56 | ||
| @@ -97,7 +97,7 @@ int qcom_mdt_load(struct device *dev, const struct firmware *fw, · 40 unmodified lines | |||
| 97 | const struct elf32_hdr *ehdr; | 97 | const struct elf32_hdr *ehdr; |
| 98 | const struct firmware *seg_fw; | 98 | const struct firmware *seg_fw; |
| 99 | phys_addr_t mem_reloc; | 99 | phys_addr_t mem_reloc; |
| 100 | phys_addr_t min_addr = (phys_addr_t)ULLONG_MAX; | 100 | phys_addr_t min_addr = PHYS_ADDR_MAX; |
| 101 | phys_addr_t max_addr = 0; | 101 | phys_addr_t max_addr = 0; |
| 102 | size_t fw_name_len; | 102 | size_t fw_name_len; |
| 103 | ssize_t offset; | 103 | ssize_t offset; |
| @@ -1621,8 +1621,8 @@ static int fill_files_note(struct memelfnote *note) · 1620 unmodified lines | |||
| 1621 | if (size >= MAX_FILE_NOTE_SIZE) /* paranoia check */ | 1621 | if (size >= MAX_FILE_NOTE_SIZE) /* paranoia check */ |
| 1622 | return -EINVAL; | 1622 | return -EINVAL; |
| 1623 | size = round_up(size, PAGE_SIZE); | 1623 | size = round_up(size, PAGE_SIZE); |
| 1624 | data = vmalloc(size); | 1624 | data = kvmalloc(size, GFP_KERNEL); |
| 1625 | if (!data) | 1625 | if (ZERO_OR_NULL_PTR(data)) |
| 1626 | return -ENOMEM; | 1626 | return -ENOMEM; |
| 1627 | 1627 | ||
| 1628 | start_end_ofs = data + 2; | 1628 | start_end_ofs = data + 2; |
| @@ -1639,7 +1639,7 @@ static int fill_files_note(struct memelfnote *note) · 10 unmodified lines | |||
| 1639 | filename = file_path(file, name_curpos, remaining); | 1639 | filename = file_path(file, name_curpos, remaining); |
| 1640 | if (IS_ERR(filename)) { | 1640 | if (IS_ERR(filename)) { |
| 1641 | if (PTR_ERR(filename) == -ENAMETOOLONG) { | 1641 | if (PTR_ERR(filename) == -ENAMETOOLONG) { |
| 1642 | vfree(data); | 1642 | kvfree(data); |
| 1643 | size = size * 5 / 4; | 1643 | size = size * 5 / 4; |
| 1644 | goto alloc; | 1644 | goto alloc; |
| 1645 | } | 1645 | } |
| @@ -1932,7 +1932,7 @@ static void free_note_info(struct elf_note_info *info) · 286 unmodified lines | |||
| 1932 | kfree(t); | 1932 | kfree(t); |
| 1933 | } | 1933 | } |
| 1934 | kfree(info->psinfo.data); | 1934 | kfree(info->psinfo.data); |
| 1935 | vfree(info->files.data); | 1935 | kvfree(info->files.data); |
| 1936 | } | 1936 | } |
| 1937 | 1937 | ||
| 1938 | #else | 1938 | #else |
| @@ -2148,7 +2148,7 @@ static void free_note_info(struct elf_note_info *info) · 209 unmodified lines | |||
| 2148 | 2148 | ||
| 2149 | /* Free data possibly allocated by fill_files_note(): */ | 2149 | /* Free data possibly allocated by fill_files_note(): */ |
| 2150 | if (info->notes_files) | 2150 | if (info->notes_files) |
| 2151 | vfree(info->notes_files->data); | 2151 | kvfree(info->notes_files->data); |
| 2152 | 2152 | ||
| 2153 | kfree(info->prstatus); | 2153 | kfree(info->prstatus); |
| 2154 | kfree(info->psinfo); | 2154 | kfree(info->psinfo); |
| @@ -2294,8 +2294,9 @@ static int elf_core_dump(struct coredump_params *cprm) · 139 unmodified lines | |||
| 2294 | 2294 | ||
| 2295 | if (segs - 1 > ULONG_MAX / sizeof(*vma_filesz)) | 2295 | if (segs - 1 > ULONG_MAX / sizeof(*vma_filesz)) |
| 2296 | goto end_coredump; | 2296 | goto end_coredump; |
| 2297 | vma_filesz = vmalloc(array_size(sizeof(*vma_filesz), (segs - 1))); | 2297 | vma_filesz = kvmalloc(array_size(sizeof(*vma_filesz), (segs - 1)), |
| 2298 | if (!vma_filesz) | 2298 | GFP_KERNEL); |
| 2299 | if (ZERO_OR_NULL_PTR(vma_filesz)) | ||
| 2299 | goto end_coredump; | 2300 | goto end_coredump; |
| 2300 | 2301 | ||
| 2301 | for (i = 0, vma = first_vma(current, gate_vma); vma != NULL; | 2302 | for (i = 0, vma = first_vma(current, gate_vma); vma != NULL; |
| @@ -2402,7 +2403,7 @@ end_coredump: · 100 unmodified lines | |||
| 2402 | cleanup: | 2403 | cleanup: |
| 2403 | free_note_info(&info); | 2404 | free_note_info(&info); |
| 2404 | kfree(shdr4extnum); | 2405 | kfree(shdr4extnum); |
| 2405 | vfree(vma_filesz); | 2406 | kvfree(vma_filesz); |
| 2406 | kfree(phdr4note); | 2407 | kfree(phdr4note); |
| 2407 | kfree(elf); | 2408 | kfree(elf); |
| 2408 | out: | 2409 | out: |
| @@ -146,68 +146,82 @@ int _ore_get_io_state(struct ore_layout *layout, · 145 unmodified lines | |||
| 146 | struct ore_io_state **pios) | 146 | struct ore_io_state **pios) |
| 147 | { | 147 | { |
| 148 | struct ore_io_state *ios; | 148 | struct ore_io_state *ios; |
| 149 | struct page **pages; | 149 | size_t size_ios, size_extra, size_total; |
| 150 | struct osd_sg_entry *sgilist; | 150 | void *ios_extra; |
| 151 | |||
| 152 | /* | ||
| 153 | * The desired layout looks like this, with the extra_allocation | ||
| 154 | * items pointed at from fields within ios or per_dev: | ||
| 155 | |||
| 151 | struct __alloc_all_io_state { | 156 | struct __alloc_all_io_state { |
| 152 | struct ore_io_state ios; | 157 | struct ore_io_state ios; |
| 153 | struct ore_per_dev_state per_dev[numdevs]; | 158 | struct ore_per_dev_state per_dev[numdevs]; |
| 154 | union { | 159 | union { |
| 155 | struct osd_sg_entry sglist[sgs_per_dev * numdevs]; | 160 | struct osd_sg_entry sglist[sgs_per_dev * numdevs]; |
| 156 | struct page *pages[num_par_pages]; | 161 | struct page *pages[num_par_pages]; |
| 157 | }; | 162 | } extra_allocation; |
| 158 | } *_aios; | 163 | } whole_allocation; |
| 159 | 164 | ||
| 160 | if (likely(sizeof(*_aios) <= PAGE_SIZE)) { | 165 | */ |
| 161 | _aios = kzalloc(sizeof(*_aios), GFP_KERNEL); | 166 | |
| 162 | if (unlikely(!_aios)) { | 167 | /* This should never happen, so abort early if it ever does. */ |
| 163 | ORE_DBGMSG("Failed kzalloc bytes=%zd\n", | 168 | if (sgs_per_dev && num_par_pages) { |
| 164 | sizeof(*_aios)); | 169 | ORE_DBGMSG("Tried to use both pages and sglist\n"); |
| 170 | *pios = NULL; | ||
| 171 | return -EINVAL; | ||
| 172 | } | ||
| 173 | |||
| 174 | if (numdevs > (INT_MAX - sizeof(*ios)) / | ||
| 175 | sizeof(struct ore_per_dev_state)) | ||
| 176 | return -ENOMEM; | ||
| 177 | size_ios = sizeof(*ios) + sizeof(struct ore_per_dev_state) * numdevs; | ||
| 178 | |||
| 179 | if (sgs_per_dev * numdevs > INT_MAX / sizeof(struct osd_sg_entry)) | ||
| 180 | return -ENOMEM; | ||
| 181 | if (num_par_pages > INT_MAX / sizeof(struct page *)) | ||
| 182 | return -ENOMEM; | ||
| 183 | size_extra = max(sizeof(struct osd_sg_entry) * (sgs_per_dev * numdevs), | ||
| 184 | sizeof(struct page *) * num_par_pages); | ||
| 185 | |||
| 186 | size_total = size_ios + size_extra; | ||
| 187 | |||
| 188 | if (likely(size_total <= PAGE_SIZE)) { | ||
| 189 | ios = kzalloc(size_total, GFP_KERNEL); | ||
| 190 | if (unlikely(!ios)) { | ||
| 191 | ORE_DBGMSG("Failed kzalloc bytes=%zd\n", size_total); | ||
| 165 | *pios = NULL; | 192 | *pios = NULL; |
| 166 | return -ENOMEM; | 193 | return -ENOMEM; |
| 167 | } | 194 | } |
| 168 | pages = num_par_pages ? _aios->pages : NULL; | 195 | ios_extra = (char *)ios + size_ios; |
| 169 | sgilist = sgs_per_dev ? _aios->sglist : NULL; | ||
| 170 | ios = &_aios->ios; | ||
| 171 | } else { | 196 | } else { |
| 172 | struct __alloc_small_io_state { | 197 | ios = kzalloc(size_ios, GFP_KERNEL); |
| 173 | struct ore_io_state ios; | 198 | if (unlikely(!ios)) { |
| 174 | struct ore_per_dev_state per_dev[numdevs]; | ||
| 175 | } *_aio_small; | ||
| 176 | union __extra_part { | ||
| 177 | struct osd_sg_entry sglist[sgs_per_dev * numdevs]; | ||
| 178 | struct page *pages[num_par_pages]; | ||
| 179 | } *extra_part; | ||
| 180 | |||
| 181 | _aio_small = kzalloc(sizeof(*_aio_small), GFP_KERNEL); | ||
| 182 | if (unlikely(!_aio_small)) { | ||
| 183 | ORE_DBGMSG("Failed alloc first part bytes=%zd\n", | 199 | ORE_DBGMSG("Failed alloc first part bytes=%zd\n", |
| 184 | sizeof(*_aio_small)); | 200 | size_ios); |
| 185 | *pios = NULL; | 201 | *pios = NULL; |
| 186 | return -ENOMEM; | 202 | return -ENOMEM; |
| 187 | } | 203 | } |
| 188 | extra_part = kzalloc(sizeof(*extra_part), GFP_KERNEL); | 204 | ios_extra = kzalloc(size_extra, GFP_KERNEL); |
| 189 | if (unlikely(!extra_part)) { | 205 | if (unlikely(!ios_extra)) { |
| 190 | ORE_DBGMSG("Failed alloc second part bytes=%zd\n", | 206 | ORE_DBGMSG("Failed alloc second part bytes=%zd\n", |
| 191 | sizeof(*extra_part)); | 207 | size_extra); |
| 192 | kfree(_aio_small); | 208 | kfree(ios); |
| 193 | *pios = NULL; | 209 | *pios = NULL; |
| 194 | return -ENOMEM; | 210 | return -ENOMEM; |
| 195 | } | 211 | } |
| 196 | 212 | ||
| 197 | pages = num_par_pages ? extra_part->pages : NULL; | ||
| 198 | sgilist = sgs_per_dev ? extra_part->sglist : NULL; | ||
| 199 | /* In this case the per_dev[0].sgilist holds the pointer to | 213 | /* In this case the per_dev[0].sgilist holds the pointer to |
| 200 | * be freed | 214 | * be freed |
| 201 | */ | 215 | */ |
| 202 | ios = &_aio_small->ios; | ||
| 203 | ios->extra_part_alloc = true; | 216 | ios->extra_part_alloc = true; |
| 204 | } | 217 | } |
| 205 | 218 | ||
| 206 | if (pages) { | 219 | if (num_par_pages) { |
| 207 | ios->parity_pages = pages; | 220 | ios->parity_pages = ios_extra; |
| 208 | ios->max_par_pages = num_par_pages; | 221 | ios->max_par_pages = num_par_pages; |
| 209 | } | 222 | } |
| 210 | if (sgilist) { | 223 | if (sgs_per_dev) { |
| 224 | struct osd_sg_entry *sgilist = ios_extra; | ||
| 211 | unsigned d; | 225 | unsigned d; |
| 212 | 226 | ||
| 213 | for (d = 0; d < numdevs; ++d) { | 227 | for (d = 0; d < numdevs; ++d) { |
| @@ -71,6 +71,11 @@ static int _sp2d_alloc(unsigned pages_in_unit, unsigned group_width, · 70 unmodified lines | |||
| 71 | { | 71 | { |
| 72 | struct __stripe_pages_2d *sp2d; | 72 | struct __stripe_pages_2d *sp2d; |
| 73 | unsigned data_devs = group_width - parity; | 73 | unsigned data_devs = group_width - parity; |
| 74 | |||
| 75 | /* | ||
| 76 | * Desired allocation layout is, though when larger than PAGE_SIZE, | ||
| 77 | * each struct __alloc_1p_arrays is separately allocated: | ||
| 78 | |||
| 74 | struct _alloc_all_bytes { | 79 | struct _alloc_all_bytes { |
| 75 | struct __alloc_stripe_pages_2d { | 80 | struct __alloc_stripe_pages_2d { |
| 76 | struct __stripe_pages_2d sp2d; | 81 | struct __stripe_pages_2d sp2d; |
| @@ -82,55 +87,85 @@ static int _sp2d_alloc(unsigned pages_in_unit, unsigned group_width, · 5 unmodified lines | |||
| 82 | char page_is_read[data_devs]; | 87 | char page_is_read[data_devs]; |
| 83 | } __a1pa[pages_in_unit]; | 88 | } __a1pa[pages_in_unit]; |
| 84 | } *_aab; | 89 | } *_aab; |
| 90 | |||
| 85 | struct __alloc_1p_arrays *__a1pa; | 91 | struct __alloc_1p_arrays *__a1pa; |
| 86 | struct __alloc_1p_arrays *__a1pa_end; | 92 | struct __alloc_1p_arrays *__a1pa_end; |
| 87 | const unsigned sizeof__a1pa = sizeof(_aab->__a1pa[0]); | 93 | |
| 94 | */ | ||
| 95 | |||
| 96 | char *__a1pa; | ||
| 97 | char *__a1pa_end; | ||
| 98 | |||
| 99 | const size_t sizeof_stripe_pages_2d = | ||
| 100 | sizeof(struct __stripe_pages_2d) + | ||
| 101 | sizeof(struct __1_page_stripe) * pages_in_unit; | ||
| 102 | const size_t sizeof__a1pa = | ||
| 103 | ALIGN(sizeof(struct page *) * (2 * group_width) + data_devs, | ||
| 104 | sizeof(void *)); | ||
| 105 | const size_t sizeof__a1pa_arrays = sizeof__a1pa * pages_in_unit; | ||
| 106 | const size_t alloc_total = sizeof_stripe_pages_2d + | ||
| 107 | sizeof__a1pa_arrays; | ||
| 108 | |||
| 88 | unsigned num_a1pa, alloc_size, i; | 109 | unsigned num_a1pa, alloc_size, i; |
| 89 | 110 | ||
| 90 | /* FIXME: check these numbers in ore_verify_layout */ | 111 | /* FIXME: check these numbers in ore_verify_layout */ |
| 91 | BUG_ON(sizeof(_aab->__asp2d) > PAGE_SIZE); | 112 | BUG_ON(sizeof_stripe_pages_2d > PAGE_SIZE); |
| 92 | BUG_ON(sizeof__a1pa > PAGE_SIZE); | 113 | BUG_ON(sizeof__a1pa > PAGE_SIZE); |
| 93 | 114 | ||
| 94 | if (sizeof(*_aab) > PAGE_SIZE) { | 115 | /* |
| 95 | num_a1pa = (PAGE_SIZE - sizeof(_aab->__asp2d)) / sizeof__a1pa; | 116 | * If alloc_total would be larger than PAGE_SIZE, only allocate |
| 96 | alloc_size = sizeof(_aab->__asp2d) + sizeof__a1pa * num_a1pa; | 117 | * as many a1pa items as would fill the rest of the page, instead |
| 118 | * of the full pages_in_unit count. | ||
| 119 | */ | ||
| 120 | if (alloc_total > PAGE_SIZE) { | ||
| 121 | num_a1pa = (PAGE_SIZE - sizeof_stripe_pages_2d) / sizeof__a1pa; | ||
| 122 | alloc_size = sizeof_stripe_pages_2d + sizeof__a1pa * num_a1pa; | ||
| 97 | } else { | 123 | } else { |
| 98 | num_a1pa = pages_in_unit; | 124 | num_a1pa = pages_in_unit; |
| 99 | alloc_size = sizeof(*_aab); | 125 | alloc_size = alloc_total; |
| 100 | } | 126 | } |
| 101 | 127 | ||
| 102 | _aab = kzalloc(alloc_size, GFP_KERNEL); | 128 | *psp2d = sp2d = kzalloc(alloc_size, GFP_KERNEL); |
| 103 | if (unlikely(!_aab)) { | 129 | if (unlikely(!sp2d)) { |
| 104 | ORE_DBGMSG("!! Failed to alloc sp2d size=%d\n", alloc_size); | 130 | ORE_DBGMSG("!! Failed to alloc sp2d size=%d\n", alloc_size); |
| 105 | return -ENOMEM; | 131 | return -ENOMEM; |
| 106 | } | 132 | } |
| 133 | /* From here Just call _sp2d_free */ | ||
| 107 | 134 | ||
| 108 | sp2d = &_aab->__asp2d.sp2d; | 135 | /* Find start of a1pa area. */ |
| 109 | *psp2d = sp2d; /* From here Just call _sp2d_free */ | 136 | __a1pa = (char *)sp2d + sizeof_stripe_pages_2d; |
| 110 | 137 | /* Find end of the _allocated_ a1pa area. */ | |
| 111 | __a1pa = _aab->__a1pa; | 138 | __a1pa_end = __a1pa + alloc_size; |
| 112 | __a1pa_end = __a1pa + num_a1pa; | ||
| 113 | 139 | ||
| 140 | /* Allocate additionally needed a1pa items in PAGE_SIZE chunks. */ | ||
| 114 | for (i = 0; i < pages_in_unit; ++i) { | 141 | for (i = 0; i < pages_in_unit; ++i) { |
| 142 | struct __1_page_stripe *stripe = &sp2d->_1p_stripes[i]; | ||
| 143 | |||
| 115 | if (unlikely(__a1pa >= __a1pa_end)) { | 144 | if (unlikely(__a1pa >= __a1pa_end)) { |
| 116 | num_a1pa = min_t(unsigned, PAGE_SIZE / sizeof__a1pa, | 145 | num_a1pa = min_t(unsigned, PAGE_SIZE / sizeof__a1pa, |
| 117 | pages_in_unit - i); | 146 | pages_in_unit - i); |
| 147 | alloc_size = sizeof__a1pa * num_a1pa; | ||
| 118 | 148 | ||
| 119 | __a1pa = kcalloc(num_a1pa, sizeof__a1pa, GFP_KERNEL); | 149 | __a1pa = kzalloc(alloc_size, GFP_KERNEL); |
| 120 | if (unlikely(!__a1pa)) { | 150 | if (unlikely(!__a1pa)) { |
| 121 | ORE_DBGMSG("!! Failed to _alloc_1p_arrays=%d\n", | 151 | ORE_DBGMSG("!! Failed to _alloc_1p_arrays=%d\n", |
| 122 | num_a1pa); | 152 | num_a1pa); |
| 123 | return -ENOMEM; | 153 | return -ENOMEM; |
| 124 | } | 154 | } |
| 125 | __a1pa_end = __a1pa + num_a1pa; | 155 | __a1pa_end = __a1pa + alloc_size; |
| 126 | /* First *pages is marked for kfree of the buffer */ | 156 | /* First *pages is marked for kfree of the buffer */ |
| 127 | sp2d->_1p_stripes[i].alloc = true; | 157 | stripe->alloc = true; |
| 128 | } | 158 | } |
| 129 | 159 | ||
| 130 | sp2d->_1p_stripes[i].pages = __a1pa->pages; | 160 | /* |
| 131 | sp2d->_1p_stripes[i].scribble = __a1pa->scribble ; | 161 | * Attach all _lp_stripes pointers to the allocation for |
| 132 | sp2d->_1p_stripes[i].page_is_read = __a1pa->page_is_read; | 162 | * it which was either part of the original PAGE_SIZE |
| 133 | ++__a1pa; | 163 | * allocation or the subsequent allocation in this loop. |
| 164 | */ | ||
| 165 | stripe->pages = (void *)__a1pa; | ||
| 166 | stripe->scribble = stripe->pages + group_width; | ||
| 167 | stripe->page_is_read = (char *)stripe->scribble + group_width; | ||
| 168 | __a1pa += sizeof__a1pa; | ||
| 134 | } | 169 | } |
| 135 | 170 | ||
| 136 | sp2d->parity = parity; | 171 | sp2d->parity = parity; |
| @@ -549,27 +549,26 @@ static int exofs_devs_2_odi(struct exofs_dt_device_info *dt_dev, · 548 unmodified lines | |||
| 549 | static int __alloc_dev_table(struct exofs_sb_info *sbi, unsigned numdevs, | 549 | static int __alloc_dev_table(struct exofs_sb_info *sbi, unsigned numdevs, |
| 550 | struct exofs_dev **peds) | 550 | struct exofs_dev **peds) |
| 551 | { | 551 | { |
| 552 | struct __alloc_ore_devs_and_exofs_devs { | 552 | /* Twice bigger table: See exofs_init_comps() and comment at |
| 553 | /* Twice bigger table: See exofs_init_comps() and comment at | 553 | * exofs_read_lookup_dev_table() |
| 554 | * exofs_read_lookup_dev_table() | 554 | */ |
| 555 | */ | 555 | const size_t numores = numdevs * 2 - 1; |
| 556 | struct ore_dev *oreds[numdevs * 2 - 1]; | ||
| 557 | struct exofs_dev eds[numdevs]; | ||
| 558 | } *aoded; | ||
| 559 | struct exofs_dev *eds; | 556 | struct exofs_dev *eds; |
| 560 | unsigned i; | 557 | unsigned i; |
| 561 | 558 | ||
| 562 | aoded = kzalloc(sizeof(*aoded), GFP_KERNEL); | 559 | sbi->oc.ods = kzalloc(numores * sizeof(struct ore_dev *) + |
| 563 | if (unlikely(!aoded)) { | 560 | numdevs * sizeof(struct exofs_dev), GFP_KERNEL); |
| 561 | if (unlikely(!sbi->oc.ods)) { | ||
| 564 | EXOFS_ERR("ERROR: failed allocating Device array[%d]\n", | 562 | EXOFS_ERR("ERROR: failed allocating Device array[%d]\n", |
| 565 | numdevs); | 563 | numdevs); |
| 566 | return -ENOMEM; | 564 | return -ENOMEM; |
| 567 | } | 565 | } |
| 568 | 566 | ||
| 569 | sbi->oc.ods = aoded->oreds; | 567 | /* Start of allocated struct exofs_dev entries */ |
| 570 | *peds = eds = aoded->eds; | 568 | *peds = eds = (void *)sbi->oc.ods[numores]; |
| 569 | /* Initialize pointers into struct exofs_dev */ | ||
| 571 | for (i = 0; i < numdevs; ++i) | 570 | for (i = 0; i < numdevs; ++i) |
| 572 | aoded->oreds[i] = &eds[i].ored; | 571 | sbi->oc.ods[i] = &eds[i].ored; |
| 573 | return 0; | 572 | return 0; |
| 574 | } | 573 | } |
| 575 | 574 | ||
| @@ -158,8 +158,14 @@ static inline int __fat_get_block(struct inode *inode, sector_t iblock, · 157 unmodified lines | |||
| 158 | err = fat_bmap(inode, iblock, &phys, &mapped_blocks, create, false); | 158 | err = fat_bmap(inode, iblock, &phys, &mapped_blocks, create, false); |
| 159 | if (err) | 159 | if (err) |
| 160 | return err; | 160 | return err; |
| 161 | if (!phys) { | ||
| 162 | fat_fs_error(sb, | ||
| 163 | "invalid FAT chain (i_pos %lld, last_block %llu)", | ||
| 164 | MSDOS_I(inode)->i_pos, | ||
| 165 | (unsigned long long)last_block); | ||
| 166 | return -EIO; | ||
| 167 | } | ||
| 161 | 168 | ||
| 162 | BUG_ON(!phys); | ||
| 163 | BUG_ON(*max_blocks != mapped_blocks); | 169 | BUG_ON(*max_blocks != mapped_blocks); |
| 164 | set_buffer_new(bh_result); | 170 | set_buffer_new(bh_result); |
| 165 | map_bh(bh_result, sb, phys); | 171 | map_bh(bh_result, sb, phys); |
| @@ -2439,14 +2439,11 @@ static struct dentry *proc_pident_lookup(struct inode *dir, · 2438 unmodified lines | |||
| 2439 | for (p = ents; p < last; p++) { | 2439 | for (p = ents; p < last; p++) { |
| 2440 | if (p->len != dentry->d_name.len) | 2440 | if (p->len != dentry->d_name.len) |
| 2441 | continue; | 2441 | continue; |
| 2442 | if (!memcmp(dentry->d_name.name, p->name, p->len)) | 2442 | if (!memcmp(dentry->d_name.name, p->name, p->len)) { |
| 2443 | res = proc_pident_instantiate(dentry, task, p); | ||
| 2443 | break; | 2444 | break; |
| 2445 | } | ||
| 2444 | } | 2446 | } |
| 2445 | if (p >= last) | ||
| 2446 | goto out; | ||
| 2447 | |||
| 2448 | res = proc_pident_instantiate(dentry, task, p); | ||
| 2449 | out: | ||
| 2450 | put_task_struct(task); | 2447 | put_task_struct(task); |
| 2451 | out_no_task: | 2448 | out_no_task: |
| 2452 | return res; | 2449 | return res; |
| @@ -22,13 +22,27 @@ enum kcov_mode { · 21 unmodified lines | |||
| 22 | KCOV_MODE_TRACE_CMP = 3, | 22 | KCOV_MODE_TRACE_CMP = 3, |
| 23 | }; | 23 | }; |
| 24 | 24 | ||
| 25 | #define KCOV_IN_CTXSW (1 << 30) | ||
| 26 | |||
| 25 | void kcov_task_init(struct task_struct *t); | 27 | void kcov_task_init(struct task_struct *t); |
| 26 | void kcov_task_exit(struct task_struct *t); | 28 | void kcov_task_exit(struct task_struct *t); |
| 27 | 29 | ||
| 30 | #define kcov_prepare_switch(t) \ | ||
| 31 | do { \ | ||
| 32 | (t)->kcov_mode |= KCOV_IN_CTXSW; \ | ||
| 33 | } while (0) | ||
| 34 | |||
| 35 | #define kcov_finish_switch(t) \ | ||
| 36 | do { \ | ||
| 37 | (t)->kcov_mode &= ~KCOV_IN_CTXSW; \ | ||
| 38 | } while (0) | ||
| 39 | |||
| 28 | #else | 40 | #else |
| 29 | 41 | ||
| 30 | static inline void kcov_task_init(struct task_struct *t) {} | 42 | static inline void kcov_task_init(struct task_struct *t) {} |
| 31 | static inline void kcov_task_exit(struct task_struct *t) {} | 43 | static inline void kcov_task_exit(struct task_struct *t) {} |
| 44 | static inline void kcov_prepare_switch(struct task_struct *t) {} | ||
| 45 | static inline void kcov_finish_switch(struct task_struct *t) {} | ||
| 32 | 46 | ||
| 33 | #endif /* CONFIG_KCOV */ | 47 | #endif /* CONFIG_KCOV */ |
| 34 | #endif /* _LINUX_KCOV_H */ | 48 | #endif /* _LINUX_KCOV_H */ |
| @@ -53,6 +53,7 @@ enum memcg_memory_event { · 52 unmodified lines | |||
| 53 | MEMCG_HIGH, | 53 | MEMCG_HIGH, |
| 54 | MEMCG_MAX, | 54 | MEMCG_MAX, |
| 55 | MEMCG_OOM, | 55 | MEMCG_OOM, |
| 56 | MEMCG_OOM_KILL, | ||
| 56 | MEMCG_SWAP_MAX, | 57 | MEMCG_SWAP_MAX, |
| 57 | MEMCG_SWAP_FAIL, | 58 | MEMCG_SWAP_FAIL, |
| 58 | MEMCG_NR_MEMORY_EVENTS, | 59 | MEMCG_NR_MEMORY_EVENTS, |
| @@ -720,11 +721,8 @@ static inline void count_memcg_event_mm(struct mm_struct *mm, · 661 unmodified lines | |||
| 720 | 721 | ||
| 721 | rcu_read_lock(); | 722 | rcu_read_lock(); |
| 722 | memcg = mem_cgroup_from_task(rcu_dereference(mm->owner)); | 723 | memcg = mem_cgroup_from_task(rcu_dereference(mm->owner)); |
| 723 | if (likely(memcg)) { | 724 | if (likely(memcg)) |
| 724 | count_memcg_events(memcg, idx, 1); | 725 | count_memcg_events(memcg, idx, 1); |
| 725 | if (idx == OOM_KILL) | ||
| 726 | cgroup_file_notify(&memcg->events_file); | ||
| 727 | } | ||
| 728 | rcu_read_unlock(); | 726 | rcu_read_unlock(); |
| 729 | } | 727 | } |
| 730 | 728 | ||
| @@ -735,6 +733,21 @@ static inline void memcg_memory_event(struct mem_cgroup *memcg, · 4 unmodified lines | |||
| 735 | cgroup_file_notify(&memcg->events_file); | 733 | cgroup_file_notify(&memcg->events_file); |
| 736 | } | 734 | } |
| 737 | 735 | ||
| 736 | static inline void memcg_memory_event_mm(struct mm_struct *mm, | ||
| 737 | enum memcg_memory_event event) | ||
| 738 | { | ||
| 739 | struct mem_cgroup *memcg; | ||
| 740 | |||
| 741 | if (mem_cgroup_disabled()) | ||
| 742 | return; | ||
| 743 | |||
| 744 | rcu_read_lock(); | ||
| 745 | memcg = mem_cgroup_from_task(rcu_dereference(mm->owner)); | ||
| 746 | if (likely(memcg)) | ||
| 747 | memcg_memory_event(memcg, event); | ||
| 748 | rcu_read_unlock(); | ||
| 749 | } | ||
| 750 | |||
| 738 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE | 751 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE |
| 739 | void mem_cgroup_split_huge_fixup(struct page *head); | 752 | void mem_cgroup_split_huge_fixup(struct page *head); |
| 740 | #endif | 753 | #endif |
| @@ -756,6 +769,11 @@ static inline void memcg_memory_event(struct mem_cgroup *memcg, · 15 unmodified lines | |||
| 756 | { | 769 | { |
| 757 | } | 770 | } |
| 758 | 771 | ||
| 772 | static inline void memcg_memory_event_mm(struct mm_struct *mm, | ||
| 773 | enum memcg_memory_event event) | ||
| 774 | { | ||
| 775 | } | ||
| 776 | |||
| 759 | static inline enum mem_cgroup_protection mem_cgroup_protected( | 777 | static inline enum mem_cgroup_protection mem_cgroup_protected( |
| 760 | struct mem_cgroup *root, struct mem_cgroup *memcg) | 778 | struct mem_cgroup *root, struct mem_cgroup *memcg) |
| 761 | { | 779 | { |
| @@ -1130,7 +1130,7 @@ struct task_struct { · 1129 unmodified lines | |||
| 1130 | 1130 | ||
| 1131 | #ifdef CONFIG_KCOV | 1131 | #ifdef CONFIG_KCOV |
| 1132 | /* Coverage collection mode enabled for this task (0 if disabled): */ | 1132 | /* Coverage collection mode enabled for this task (0 if disabled): */ |
| 1133 | enum kcov_mode kcov_mode; | 1133 | unsigned int kcov_mode; |
| 1134 | 1134 | ||
| 1135 | /* Size of the kcov_area: */ | 1135 | /* Size of the kcov_area: */ |
| 1136 | unsigned int kcov_size; | 1136 | unsigned int kcov_size; |
| @@ -600,6 +600,7 @@ struct memcg_cache_params { · 599 unmodified lines | |||
| 600 | struct memcg_cache_array __rcu *memcg_caches; | 600 | struct memcg_cache_array __rcu *memcg_caches; |
| 601 | struct list_head __root_caches_node; | 601 | struct list_head __root_caches_node; |
| 602 | struct list_head children; | 602 | struct list_head children; |
| 603 | bool dying; | ||
| 603 | }; | 604 | }; |
| 604 | struct { | 605 | struct { |
| 605 | struct mem_cgroup *memcg; | 606 | struct mem_cgroup *memcg; |
| @@ -85,6 +85,7 @@ · 84 unmodified lines | |||
| 85 | #include <linux/nsproxy.h> | 85 | #include <linux/nsproxy.h> |
| 86 | #include <linux/ipc_namespace.h> | 86 | #include <linux/ipc_namespace.h> |
| 87 | #include <linux/sched/wake_q.h> | 87 | #include <linux/sched/wake_q.h> |
| 88 | #include <linux/nospec.h> | ||
| 88 | 89 | ||
| 89 | #include <linux/uaccess.h> | 90 | #include <linux/uaccess.h> |
| 90 | #include "util.h" | 91 | #include "util.h" |
| @@ -368,6 +369,7 @@ static inline int sem_lock(struct sem_array *sma, struct sembuf *sops, · 277 unmodified lines | |||
| 368 | int nsops) | 369 | int nsops) |
| 369 | { | 370 | { |
| 370 | struct sem *sem; | 371 | struct sem *sem; |
| 372 | int idx; | ||
| 371 | 373 | ||
| 372 | if (nsops != 1) { | 374 | if (nsops != 1) { |
| 373 | /* Complex operation - acquire a full lock */ | 375 | /* Complex operation - acquire a full lock */ |
| @@ -385,7 +387,8 @@ static inline int sem_lock(struct sem_array *sma, struct sembuf *sops, · 11 unmodified lines | |||
| 385 | * | 387 | * |
| 386 | * Both facts are tracked by use_global_mode. | 388 | * Both facts are tracked by use_global_mode. |
| 387 | */ | 389 | */ |
| 388 | sem = &sma->sems[sops->sem_num]; | 390 | idx = array_index_nospec(sops->sem_num, sma->sem_nsems); |
| 391 | sem = &sma->sems[idx]; | ||
| 389 | 392 | ||
| 390 | /* | 393 | /* |
| 391 | * Initial check for use_global_lock. Just an optimization, | 394 | * Initial check for use_global_lock. Just an optimization, |
| @@ -638,7 +641,8 @@ static int perform_atomic_semop_slow(struct sem_array *sma, struct sem_queue *q) · 246 unmodified lines | |||
| 638 | un = q->undo; | 641 | un = q->undo; |
| 639 | 642 | ||
| 640 | for (sop = sops; sop < sops + nsops; sop++) { | 643 | for (sop = sops; sop < sops + nsops; sop++) { |
| 641 | curr = &sma->sems[sop->sem_num]; | 644 | int idx = array_index_nospec(sop->sem_num, sma->sem_nsems); |
| 645 | curr = &sma->sems[idx]; | ||
| 642 | sem_op = sop->sem_op; | 646 | sem_op = sop->sem_op; |
| 643 | result = curr->semval; | 647 | result = curr->semval; |
| 644 | 648 | ||
| @@ -718,7 +722,9 @@ static int perform_atomic_semop(struct sem_array *sma, struct sem_queue *q) · 73 unmodified lines | |||
| 718 | * until the operations can go through. | 722 | * until the operations can go through. |
| 719 | */ | 723 | */ |
| 720 | for (sop = sops; sop < sops + nsops; sop++) { | 724 | for (sop = sops; sop < sops + nsops; sop++) { |
| 721 | curr = &sma->sems[sop->sem_num]; | 725 | int idx = array_index_nospec(sop->sem_num, sma->sem_nsems); |
| 726 | |||
| 727 | curr = &sma->sems[idx]; | ||
| 722 | sem_op = sop->sem_op; | 728 | sem_op = sop->sem_op; |
| 723 | result = curr->semval; | 729 | result = curr->semval; |
| 724 | 730 | ||
| @@ -1356,6 +1362,7 @@ static int semctl_setval(struct ipc_namespace *ns, int semid, int semnum, · 631 unmodified lines | |||
| 1356 | return -EIDRM; | 1362 | return -EIDRM; |
| 1357 | } | 1363 | } |
| 1358 | 1364 | ||
| 1365 | semnum = array_index_nospec(semnum, sma->sem_nsems); | ||
| 1359 | curr = &sma->sems[semnum]; | 1366 | curr = &sma->sems[semnum]; |
| 1360 | 1367 | ||
| 1361 | ipc_assert_locked_object(&sma->sem_perm); | 1368 | ipc_assert_locked_object(&sma->sem_perm); |
| @@ -1509,6 +1516,8 @@ static int semctl_main(struct ipc_namespace *ns, int semid, int semnum, · 147 unmodified lines | |||
| 1509 | err = -EIDRM; | 1516 | err = -EIDRM; |
| 1510 | goto out_unlock; | 1517 | goto out_unlock; |
| 1511 | } | 1518 | } |
| 1519 | |||
| 1520 | semnum = array_index_nospec(semnum, nsems); | ||
| 1512 | curr = &sma->sems[semnum]; | 1521 | curr = &sma->sems[semnum]; |
| 1513 | 1522 | ||
| 1514 | switch (cmd) { | 1523 | switch (cmd) { |
| @@ -2081,7 +2090,8 @@ static long do_semtimedop(int semid, struct sembuf __user *tsops, · 566 unmodified lines | |||
| 2081 | */ | 2090 | */ |
| 2082 | if (nsops == 1) { | 2091 | if (nsops == 1) { |
| 2083 | struct sem *curr; | 2092 | struct sem *curr; |
| 2084 | curr = &sma->sems[sops->sem_num]; | 2093 | int idx = array_index_nospec(sops->sem_num, sma->sem_nsems); |
| 2094 | curr = &sma->sems[idx]; | ||
| 2085 | 2095 | ||
| 2086 | if (alter) { | 2096 | if (alter) { |
| 2087 | if (sma->complex_count) { | 2097 | if (sma->complex_count) { |
| @@ -408,7 +408,7 @@ void exit_shm(struct task_struct *task) · 407 unmodified lines | |||
| 408 | up_write(&shm_ids(ns).rwsem); | 408 | up_write(&shm_ids(ns).rwsem); |
| 409 | } | 409 | } |
| 410 | 410 | ||
| 411 | static int shm_fault(struct vm_fault *vmf) | 411 | static vm_fault_t shm_fault(struct vm_fault *vmf) |
| 412 | { | 412 | { |
| 413 | struct file *file = vmf->vma->vm_file; | 413 | struct file *file = vmf->vma->vm_file; |
| 414 | struct shm_file_data *sfd = shm_file_data(file); | 414 | struct shm_file_data *sfd = shm_file_data(file); |
| @@ -440,6 +440,14 @@ static __latent_entropy int dup_mmap(struct mm_struct *mm, · 439 unmodified lines | |||
| 440 | continue; | 440 | continue; |
| 441 | } | 441 | } |
| 442 | charge = 0; | 442 | charge = 0; |
| 443 | /* | ||
| 444 | * Don't duplicate many vmas if we've been oom-killed (for | ||
| 445 | * example) | ||
| 446 | */ | ||
| 447 | if (fatal_signal_pending(current)) { | ||
| 448 | retval = -EINTR; | ||
| 449 | goto out; | ||
| 450 | } | ||
| 443 | if (mpnt->vm_flags & VM_ACCOUNT) { | 451 | if (mpnt->vm_flags & VM_ACCOUNT) { |
| 444 | unsigned long len = vma_pages(mpnt); | 452 | unsigned long len = vma_pages(mpnt); |
| 445 | 453 | ||
| @@ -58,7 +58,7 @@ struct kcov { · 57 unmodified lines | |||
| 58 | 58 | ||
| 59 | static bool check_kcov_mode(enum kcov_mode needed_mode, struct task_struct *t) | 59 | static bool check_kcov_mode(enum kcov_mode needed_mode, struct task_struct *t) |
| 60 | { | 60 | { |
| 61 | enum kcov_mode mode; | 61 | unsigned int mode; |
| 62 | 62 | ||
| 63 | /* | 63 | /* |
| 64 | * We are interested in code coverage as a function of a syscall inputs, | 64 | * We are interested in code coverage as a function of a syscall inputs, |
| @@ -241,7 +241,8 @@ static void kcov_put(struct kcov *kcov) · 176 unmodified lines | |||
| 241 | 241 | ||
| 242 | void kcov_task_init(struct task_struct *t) | 242 | void kcov_task_init(struct task_struct *t) |
| 243 | { | 243 | { |
| 244 | t->kcov_mode = KCOV_MODE_DISABLED; | 244 | WRITE_ONCE(t->kcov_mode, KCOV_MODE_DISABLED); |
| 245 | barrier(); | ||
| 245 | t->kcov_size = 0; | 246 | t->kcov_size = 0; |
| 246 | t->kcov_area = NULL; | 247 | t->kcov_area = NULL; |
| 247 | t->kcov = NULL; | 248 | t->kcov = NULL; |
| @@ -323,6 +324,21 @@ static int kcov_close(struct inode *inode, struct file *filep) · 75 unmodified lines | |||
| 323 | return 0; | 324 | return 0; |
| 324 | } | 325 | } |
| 325 | 326 | ||
| 327 | /* | ||
| 328 | * Fault in a lazily-faulted vmalloc area before it can be used by | ||
| 329 | * __santizer_cov_trace_pc(), to avoid recursion issues if any code on the | ||
| 330 | * vmalloc fault handling path is instrumented. | ||
| 331 | */ | ||
| 332 | static void kcov_fault_in_area(struct kcov *kcov) | ||
| 333 | { | ||
| 334 | unsigned long stride = PAGE_SIZE / sizeof(unsigned long); | ||
| 335 | unsigned long *area = kcov->area; | ||
| 336 | unsigned long offset; | ||
| 337 | |||
| 338 | for (offset = 0; offset < kcov->size; offset += stride) | ||
| 339 | READ_ONCE(area[offset]); | ||
| 340 | } | ||
| 341 | |||
| 326 | static int kcov_ioctl_locked(struct kcov *kcov, unsigned int cmd, | 342 | static int kcov_ioctl_locked(struct kcov *kcov, unsigned int cmd, |
| 327 | unsigned long arg) | 343 | unsigned long arg) |
| 328 | { | 344 | { |
| @@ -371,6 +387,7 @@ static int kcov_ioctl_locked(struct kcov *kcov, unsigned int cmd, · 42 unmodified lines | |||
| 371 | #endif | 387 | #endif |
| 372 | else | 388 | else |
| 373 | return -EINVAL; | 389 | return -EINVAL; |
| 390 | kcov_fault_in_area(kcov); | ||
| 374 | /* Cache in task struct for performance. */ | 391 | /* Cache in task struct for performance. */ |
| 375 | t->kcov_size = kcov->size; | 392 | t->kcov_size = kcov->size; |
| 376 | t->kcov_area = kcov->area; | 393 | t->kcov_area = kcov->area; |
| @@ -829,6 +829,8 @@ static int kimage_load_normal_segment(struct kimage *image, · 828 unmodified lines | |||
| 829 | else | 829 | else |
| 830 | buf += mchunk; | 830 | buf += mchunk; |
| 831 | mbytes -= mchunk; | 831 | mbytes -= mchunk; |
| 832 | |||
| 833 | cond_resched(); | ||
| 832 | } | 834 | } |
| 833 | out: | 835 | out: |
| 834 | return result; | 836 | return result; |
| @@ -893,6 +895,8 @@ static int kimage_load_crash_segment(struct kimage *image, · 58 unmodified lines | |||
| 893 | else | 895 | else |
| 894 | buf += mchunk; | 896 | buf += mchunk; |
| 895 | mbytes -= mchunk; | 897 | mbytes -= mchunk; |
| 898 | |||
| 899 | cond_resched(); | ||
| 896 | } | 900 | } |
| 897 | out: | 901 | out: |
| 898 | return result; | 902 | return result; |
| @@ -39,7 +39,7 @@ static void relay_file_mmap_close(struct vm_area_struct *vma) · 38 unmodified lines | |||
| 39 | /* | 39 | /* |
| 40 | * fault() vm_op implementation for relay file mapping. | 40 | * fault() vm_op implementation for relay file mapping. |
| 41 | */ | 41 | */ |
| 42 | static int relay_buf_fault(struct vm_fault *vmf) | 42 | static vm_fault_t relay_buf_fault(struct vm_fault *vmf) |
| 43 | { | 43 | { |
| 44 | struct page *page; | 44 | struct page *page; |
| 45 | struct rchan_buf *buf = vmf->vma->vm_private_data; | 45 | struct rchan_buf *buf = vmf->vma->vm_private_data; |
| @@ -10,6 +10,8 @@ · 9 unmodified lines | |||
| 10 | #include <linux/kthread.h> | 10 | #include <linux/kthread.h> |
| 11 | #include <linux/nospec.h> | 11 | #include <linux/nospec.h> |
| 12 | 12 | ||
| 13 | #include <linux/kcov.h> | ||
| 14 | |||
| 13 | #include <asm/switch_to.h> | 15 | #include <asm/switch_to.h> |
| 14 | #include <asm/tlb.h> | 16 | #include <asm/tlb.h> |
| 15 | 17 | ||
| @@ -2633,6 +2635,7 @@ static inline void · 2617 unmodified lines | |||
| 2633 | prepare_task_switch(struct rq *rq, struct task_struct *prev, | 2635 | prepare_task_switch(struct rq *rq, struct task_struct *prev, |
| 2634 | struct task_struct *next) | 2636 | struct task_struct *next) |
| 2635 | { | 2637 | { |
| 2638 | kcov_prepare_switch(prev); | ||
| 2636 | sched_info_switch(rq, prev, next); | 2639 | sched_info_switch(rq, prev, next); |
| 2637 | perf_event_task_sched_out(prev, next); | 2640 | perf_event_task_sched_out(prev, next); |
| 2638 | rseq_preempt(prev); | 2641 | rseq_preempt(prev); |
| @@ -2702,6 +2705,7 @@ static struct rq *finish_task_switch(struct task_struct *prev) · 63 unmodified lines | |||
| 2702 | finish_task(prev); | 2705 | finish_task(prev); |
| 2703 | finish_lock_switch(rq); | 2706 | finish_lock_switch(rq); |
| 2704 | finish_arch_post_lock_switch(); | 2707 | finish_arch_post_lock_switch(); |
| 2708 | kcov_finish_switch(current); | ||
| 2705 | 2709 | ||
| 2706 | fire_sched_in_preempt_notifiers(current); | 2710 | fire_sched_in_preempt_notifiers(current); |
| 2707 | /* | 2711 | /* |
| @@ -1506,6 +1506,10 @@ config NETDEV_NOTIFIER_ERROR_INJECT · 1505 unmodified lines | |||
| 1506 | 1506 | ||
| 1507 | If unsure, say N. | 1507 | If unsure, say N. |
| 1508 | 1508 | ||
| 1509 | config FUNCTION_ERROR_INJECTION | ||
| 1510 | def_bool y | ||
| 1511 | depends on HAVE_FUNCTION_ERROR_INJECTION && KPROBES | ||
| 1512 | |||
| 1509 | config FAULT_INJECTION | 1513 | config FAULT_INJECTION |
| 1510 | bool "Fault-injection framework" | 1514 | bool "Fault-injection framework" |
| 1511 | depends on DEBUG_KERNEL | 1515 | depends on DEBUG_KERNEL |
| @@ -1513,10 +1517,6 @@ config FAULT_INJECTION · 1 unmodified line | |||
| 1513 | Provide fault-injection framework. | 1517 | Provide fault-injection framework. |
| 1514 | For more details, see Documentation/fault-injection/. | 1518 | For more details, see Documentation/fault-injection/. |
| 1515 | 1519 | ||
| 1516 | config FUNCTION_ERROR_INJECTION | ||
| 1517 | def_bool y | ||
| 1518 | depends on HAVE_FUNCTION_ERROR_INJECTION && KPROBES | ||
| 1519 | |||
| 1520 | config FAILSLAB | 1520 | config FAILSLAB |
| 1521 | bool "Fault-injection capability for kmalloc" | 1521 | bool "Fault-injection capability for kmalloc" |
| 1522 | depends on FAULT_INJECTION | 1522 | depends on FAULT_INJECTION |
| @@ -1547,16 +1547,6 @@ config FAIL_IO_TIMEOUT · 24 unmodified lines | |||
| 1547 | Only works with drivers that use the generic timeout handling, | 1547 | Only works with drivers that use the generic timeout handling, |
| 1548 | for others it wont do anything. | 1548 | for others it wont do anything. |
| 1549 | 1549 | ||
| 1550 | config FAIL_MMC_REQUEST | ||
| 1551 | bool "Fault-injection capability for MMC IO" | ||
| 1552 | depends on FAULT_INJECTION_DEBUG_FS && MMC | ||
| 1553 | help | ||
| 1554 | Provide fault-injection capability for MMC IO. | ||
| 1555 | This will make the mmc core return data errors. This is | ||
| 1556 | useful to test the error handling in the mmc block device | ||
| 1557 | and to test how the mmc host driver handles retries from | ||
| 1558 | the block device. | ||
| 1559 | |||
| 1560 | config FAIL_FUTEX | 1550 | config FAIL_FUTEX |
| 1561 | bool "Fault-injection capability for futexes" | 1551 | bool "Fault-injection capability for futexes" |
| 1562 | select DEBUG_FS | 1552 | select DEBUG_FS |
| @@ -1564,6 +1554,12 @@ config FAIL_FUTEX · 1 unmodified line | |||
| 1564 | help | 1554 | help |
| 1565 | Provide fault-injection capability for futexes. | 1555 | Provide fault-injection capability for futexes. |
| 1566 | 1556 | ||
| 1557 | config FAULT_INJECTION_DEBUG_FS | ||
| 1558 | bool "Debugfs entries for fault-injection capabilities" | ||
| 1559 | depends on FAULT_INJECTION && SYSFS && DEBUG_FS | ||
| 1560 | help | ||
| 1561 | Enable configuration of fault-injection capabilities via debugfs. | ||
| 1562 | |||
| 1567 | config FAIL_FUNCTION | 1563 | config FAIL_FUNCTION |
| 1568 | bool "Fault-injection capability for functions" | 1564 | bool "Fault-injection capability for functions" |
| 1569 | depends on FAULT_INJECTION_DEBUG_FS && FUNCTION_ERROR_INJECTION | 1565 | depends on FAULT_INJECTION_DEBUG_FS && FUNCTION_ERROR_INJECTION |
| @@ -1574,11 +1570,15 @@ config FAIL_FUNCTION · 4 unmodified lines | |||
| 1574 | an error value and have to handle it. This is useful to test the | 1570 | an error value and have to handle it. This is useful to test the |
| 1575 | error handling in various subsystems. | 1571 | error handling in various subsystems. |
| 1576 | 1572 | ||
| 1577 | config FAULT_INJECTION_DEBUG_FS | 1573 | config FAIL_MMC_REQUEST |
| 1578 | bool "Debugfs entries for fault-injection capabilities" | 1574 | bool "Fault-injection capability for MMC IO" |
| 1579 | depends on FAULT_INJECTION && SYSFS && DEBUG_FS | 1575 | depends on FAULT_INJECTION_DEBUG_FS && MMC |
| 1580 | help | 1576 | help |
| 1581 | Enable configuration of fault-injection capabilities via debugfs. | 1577 | Provide fault-injection capability for MMC IO. |
| 1578 | This will make the mmc core return data errors. This is | ||
| 1579 | useful to test the error handling in the mmc block device | ||
| 1580 | and to test how the mmc host driver handles retries from | ||
| 1581 | the block device. | ||
| 1582 | 1582 | ||
| 1583 | config FAULT_INJECTION_STACKTRACE_FILTER | 1583 | config FAULT_INJECTION_STACKTRACE_FILTER |
| 1584 | bool "stacktrace filter for fault-injection capabilities" | 1584 | bool "stacktrace filter for fault-injection capabilities" |
| @@ -260,6 +260,13 @@ plain(void) · 259 unmodified lines | |||
| 260 | { | 260 | { |
| 261 | int err; | 261 | int err; |
| 262 | 262 | ||
| 263 | /* | ||
| 264 | * Make sure crng is ready. Otherwise we get "(ptrval)" instead | ||
| 265 | * of a hashed address when printing '%p' in plain_hash() and | ||
| 266 | * plain_format(). | ||
| 267 | */ | ||
| 268 | wait_for_random_bytes(); | ||
| 269 | |||
| 263 | err = plain_hash(); | 270 | err = plain_hash(); |
| 264 | if (err) { | 271 | if (err) { |
| 265 | pr_warn("plain 'p' does not appear to be hashed\n"); | 272 | pr_warn("plain 'p' does not appear to be hashed\n"); |
| @@ -307,12 +307,10 @@ static int __init init_cleancache(void) · 306 unmodified lines | |||
| 307 | struct dentry *root = debugfs_create_dir("cleancache", NULL); | 307 | struct dentry *root = debugfs_create_dir("cleancache", NULL); |
| 308 | if (root == NULL) | 308 | if (root == NULL) |
| 309 | return -ENXIO; | 309 | return -ENXIO; |
| 310 | debugfs_create_u64("succ_gets", S_IRUGO, root, &cleancache_succ_gets); | 310 | debugfs_create_u64("succ_gets", 0444, root, &cleancache_succ_gets); |
| 311 | debugfs_create_u64("failed_gets", S_IRUGO, | 311 | debugfs_create_u64("failed_gets", 0444, root, &cleancache_failed_gets); |
| 312 | root, &cleancache_failed_gets); | 312 | debugfs_create_u64("puts", 0444, root, &cleancache_puts); |
| 313 | debugfs_create_u64("puts", S_IRUGO, root, &cleancache_puts); | 313 | debugfs_create_u64("invalidates", 0444, root, &cleancache_invalidates); |
| 314 | debugfs_create_u64("invalidates", S_IRUGO, | ||
| 315 | root, &cleancache_invalidates); | ||
| 316 | #endif | 314 | #endif |
| 317 | return 0; | 315 | return 0; |
| 318 | } | 316 | } |
| @@ -172,23 +172,18 @@ static void cma_debugfs_add_one(struct cma *cma, int idx) · 171 unmodified lines | |||
| 172 | 172 | ||
| 173 | tmp = debugfs_create_dir(name, cma_debugfs_root); | 173 | tmp = debugfs_create_dir(name, cma_debugfs_root); |
| 174 | 174 | ||
| 175 | debugfs_create_file("alloc", S_IWUSR, tmp, cma, | 175 | debugfs_create_file("alloc", 0200, tmp, cma, &cma_alloc_fops); |
| 176 | &cma_alloc_fops); | 176 | debugfs_create_file("free", 0200, tmp, cma, &cma_free_fops); |
| 177 | 177 | debugfs_create_file("base_pfn", 0444, tmp, | |
| 178 | debugfs_create_file("free", S_IWUSR, tmp, cma, | 178 | &cma->base_pfn, &cma_debugfs_fops); |
| 179 | &cma_free_fops); | 179 | debugfs_create_file("count", 0444, tmp, &cma->count, &cma_debugfs_fops); |
| 180 | 180 | debugfs_create_file("order_per_bit", 0444, tmp, | |
| 181 | debugfs_create_file("base_pfn", S_IRUGO, tmp, | 181 | &cma->order_per_bit, &cma_debugfs_fops); |
| 182 | &cma->base_pfn, &cma_debugfs_fops); | 182 | debugfs_create_file("used", 0444, tmp, cma, &cma_used_fops); |
| 183 | debugfs_create_file("count", S_IRUGO, tmp, | 183 | debugfs_create_file("maxchunk", 0444, tmp, cma, &cma_maxchunk_fops); |
| 184 | &cma->count, &cma_debugfs_fops); | ||
| 185 | debugfs_create_file("order_per_bit", S_IRUGO, tmp, | ||
| 186 | &cma->order_per_bit, &cma_debugfs_fops); | ||
| 187 | debugfs_create_file("used", S_IRUGO, tmp, cma, &cma_used_fops); | ||
| 188 | debugfs_create_file("maxchunk", S_IRUGO, tmp, cma, &cma_maxchunk_fops); | ||
| 189 | 184 | ||
| 190 | u32s = DIV_ROUND_UP(cma_bitmap_maxno(cma), BITS_PER_BYTE * sizeof(u32)); | 185 | u32s = DIV_ROUND_UP(cma_bitmap_maxno(cma), BITS_PER_BYTE * sizeof(u32)); |
| 191 | debugfs_create_u32_array("bitmap", S_IRUGO, tmp, (u32*)cma->bitmap, u32s); | 186 | debugfs_create_u32_array("bitmap", 0444, tmp, (u32 *)cma->bitmap, u32s); |
| 192 | } | 187 | } |
| 193 | 188 | ||
| 194 | static int __init cma_debugfs_init(void) | 189 | static int __init cma_debugfs_init(void) |
| @@ -1899,7 +1899,7 @@ static ssize_t sysfs_compact_node(struct device *dev, · 1898 unmodified lines | |||
| 1899 | 1899 | ||
| 1900 | return count; | 1900 | return count; |
| 1901 | } | 1901 | } |
| 1902 | static DEVICE_ATTR(compact, S_IWUSR, NULL, sysfs_compact_node); | 1902 | static DEVICE_ATTR(compact, 0200, NULL, sysfs_compact_node); |
| 1903 | 1903 | ||
| 1904 | int compaction_register_node(struct node *node) | 1904 | int compaction_register_node(struct node *node) |
| 1905 | { | 1905 | { |
| @@ -105,7 +105,7 @@ show_pools(struct device *dev, struct device_attribute *attr, char *buf) · 104 unmodified lines | |||
| 105 | return PAGE_SIZE - size; | 105 | return PAGE_SIZE - size; |
| 106 | } | 106 | } |
| 107 | 107 | ||
| 108 | static DEVICE_ATTR(pools, S_IRUGO, show_pools, NULL); | 108 | static DEVICE_ATTR(pools, 0444, show_pools, NULL); |
| 109 | 109 | ||
| 110 | /** | 110 | /** |
| 111 | * dma_pool_create - Creates a pool of consistent memory blocks, for dma. | 111 | * dma_pool_create - Creates a pool of consistent memory blocks, for dma. |
| @@ -42,7 +42,7 @@ __setup("failslab=", setup_failslab); · 41 unmodified lines | |||
| 42 | static int __init failslab_debugfs_init(void) | 42 | static int __init failslab_debugfs_init(void) |
| 43 | { | 43 | { |
| 44 | struct dentry *dir; | 44 | struct dentry *dir; |
| 45 | umode_t mode = S_IFREG | S_IRUSR | S_IWUSR; | 45 | umode_t mode = S_IFREG | 0600; |
| 46 | 46 | ||
| 47 | dir = fault_create_debugfs_attr("failslab", NULL, &failslab.attr); | 47 | dir = fault_create_debugfs_attr("failslab", NULL, &failslab.attr); |
| 48 | if (IS_ERR(dir)) | 48 | if (IS_ERR(dir)) |
| @@ -486,12 +486,11 @@ static int __init init_frontswap(void) · 485 unmodified lines | |||
| 486 | struct dentry *root = debugfs_create_dir("frontswap", NULL); | 486 | struct dentry *root = debugfs_create_dir("frontswap", NULL); |
| 487 | if (root == NULL) | 487 | if (root == NULL) |
| 488 | return -ENXIO; | 488 | return -ENXIO; |
| 489 | debugfs_create_u64("loads", S_IRUGO, root, &frontswap_loads); | 489 | debugfs_create_u64("loads", 0444, root, &frontswap_loads); |
| 490 | debugfs_create_u64("succ_stores", S_IRUGO, root, &frontswap_succ_stores); | 490 | debugfs_create_u64("succ_stores", 0444, root, &frontswap_succ_stores); |
| 491 | debugfs_create_u64("failed_stores", S_IRUGO, root, | 491 | debugfs_create_u64("failed_stores", 0444, root, |
| 492 | &frontswap_failed_stores); | 492 | &frontswap_failed_stores); |
| 493 | debugfs_create_u64("invalidates", S_IRUGO, | 493 | debugfs_create_u64("invalidates", 0444, root, &frontswap_invalidates); |
| 494 | root, &frontswap_invalidates); | ||
| 495 | #endif | 494 | #endif |
| 496 | return 0; | 495 | return 0; |
| 497 | } | 496 | } |
| @@ -216,6 +216,8 @@ struct rmap_item { · 215 unmodified lines | |||
| 216 | #define SEQNR_MASK 0x0ff /* low bits of unstable tree seqnr */ | 216 | #define SEQNR_MASK 0x0ff /* low bits of unstable tree seqnr */ |
| 217 | #define UNSTABLE_FLAG 0x100 /* is a node of the unstable tree */ | 217 | #define UNSTABLE_FLAG 0x100 /* is a node of the unstable tree */ |
| 218 | #define STABLE_FLAG 0x200 /* is listed from the stable tree */ | 218 | #define STABLE_FLAG 0x200 /* is listed from the stable tree */ |
| 219 | #define KSM_FLAG_MASK (SEQNR_MASK|UNSTABLE_FLAG|STABLE_FLAG) | ||
| 220 | /* to mask all the flags */ | ||
| 219 | 221 | ||
| 220 | /* The stable and unstable tree heads */ | 222 | /* The stable and unstable tree heads */ |
| 221 | static struct rb_root one_stable_tree[1] = { RB_ROOT }; | 223 | static struct rb_root one_stable_tree[1] = { RB_ROOT }; |
| @@ -2598,10 +2600,15 @@ again: · 2376 unmodified lines | |||
| 2598 | anon_vma_lock_read(anon_vma); | 2600 | anon_vma_lock_read(anon_vma); |
| 2599 | anon_vma_interval_tree_foreach(vmac, &anon_vma->rb_root, | 2601 | anon_vma_interval_tree_foreach(vmac, &anon_vma->rb_root, |
| 2600 | 0, ULONG_MAX) { | 2602 | 0, ULONG_MAX) { |
| 2603 | unsigned long addr; | ||
| 2604 | |||
| 2601 | cond_resched(); | 2605 | cond_resched(); |
| 2602 | vma = vmac->vma; | 2606 | vma = vmac->vma; |
| 2603 | if (rmap_item->address < vma->vm_start || | 2607 | |
| 2604 | rmap_item->address >= vma->vm_end) | 2608 | /* Ignore the stable/unstable/sqnr flags */ |
| 2609 | addr = rmap_item->address & ~KSM_FLAG_MASK; | ||
| 2610 | |||
| 2611 | if (addr < vma->vm_start || addr >= vma->vm_end) | ||
| 2605 | continue; | 2612 | continue; |
| 2606 | /* | 2613 | /* |
| 2607 | * Initially we examine only the vma which covers this | 2614 | * Initially we examine only the vma which covers this |
| @@ -2615,8 +2622,7 @@ again: · 7 unmodified lines | |||
| 2615 | if (rwc->invalid_vma && rwc->invalid_vma(vma, rwc->arg)) | 2622 | if (rwc->invalid_vma && rwc->invalid_vma(vma, rwc->arg)) |
| 2616 | continue; | 2623 | continue; |
| 2617 | 2624 | ||
| 2618 | if (!rwc->rmap_one(page, vma, | 2625 | if (!rwc->rmap_one(page, vma, addr, rwc->arg)) { |
| 2619 | rmap_item->address, rwc->arg)) { | ||
| 2620 | anon_vma_unlock_read(anon_vma); | 2626 | anon_vma_unlock_read(anon_vma); |
| 2621 | return; | 2627 | return; |
| 2622 | } | 2628 | } |
| @@ -20,6 +20,7 @@ · 19 unmodified lines | |||
| 20 | #include <linux/kmemleak.h> | 20 | #include <linux/kmemleak.h> |
| 21 | #include <linux/seq_file.h> | 21 | #include <linux/seq_file.h> |
| 22 | #include <linux/memblock.h> | 22 | #include <linux/memblock.h> |
| 23 | #include <linux/bootmem.h> | ||
| 23 | 24 | ||
| 24 | #include <asm/sections.h> | 25 | #include <asm/sections.h> |
| 25 | #include <linux/io.h> | 26 | #include <linux/io.h> |
| @@ -1808,10 +1809,13 @@ static int __init memblock_init_debugfs(void) · 1782 unmodified lines | |||
| 1808 | struct dentry *root = debugfs_create_dir("memblock", NULL); | 1809 | struct dentry *root = debugfs_create_dir("memblock", NULL); |
| 1809 | if (!root) | 1810 | if (!root) |
| 1810 | return -ENXIO; | 1811 | return -ENXIO; |
| 1811 | debugfs_create_file("memory", S_IRUGO, root, &memblock.memory, &memblock_debug_fops); | 1812 | debugfs_create_file("memory", 0444, root, |
| 1812 | debugfs_create_file("reserved", S_IRUGO, root, &memblock.reserved, &memblock_debug_fops); | 1813 | &memblock.memory, &memblock_debug_fops); |
| 1814 | debugfs_create_file("reserved", 0444, root, | ||
| 1815 | &memblock.reserved, &memblock_debug_fops); | ||
| 1813 | #ifdef CONFIG_HAVE_MEMBLOCK_PHYS_MAP | 1816 | #ifdef CONFIG_HAVE_MEMBLOCK_PHYS_MAP |
| 1814 | debugfs_create_file("physmem", S_IRUGO, root, &memblock.physmem, &memblock_debug_fops); | 1817 | debugfs_create_file("physmem", 0444, root, |
| 1818 | &memblock.physmem, &memblock_debug_fops); | ||
| 1815 | #endif | 1819 | #endif |
| 1816 | 1820 | ||
| 1817 | return 0; | 1821 | return 0; |
| @@ -3550,7 +3550,8 @@ static int mem_cgroup_oom_control_read(struct seq_file *sf, void *v) · 3549 unmodified lines | |||
| 3550 | 3550 | ||
| 3551 | seq_printf(sf, "oom_kill_disable %d\n", memcg->oom_kill_disable); | 3551 | seq_printf(sf, "oom_kill_disable %d\n", memcg->oom_kill_disable); |
| 3552 | seq_printf(sf, "under_oom %d\n", (bool)memcg->under_oom); | 3552 | seq_printf(sf, "under_oom %d\n", (bool)memcg->under_oom); |
| 3553 | seq_printf(sf, "oom_kill %lu\n", memcg_sum_events(memcg, OOM_KILL)); | 3553 | seq_printf(sf, "oom_kill %lu\n", |
| 3554 | atomic_long_read(&memcg->memory_events[MEMCG_OOM_KILL])); | ||
| 3554 | return 0; | 3555 | return 0; |
| 3555 | } | 3556 | } |
| 3556 | 3557 | ||
| @@ -5239,7 +5240,8 @@ static int memory_events_show(struct seq_file *m, void *v) · 1682 unmodified lines | |||
| 5239 | atomic_long_read(&memcg->memory_events[MEMCG_MAX])); | 5240 | atomic_long_read(&memcg->memory_events[MEMCG_MAX])); |
| 5240 | seq_printf(m, "oom %lu\n", | 5241 | seq_printf(m, "oom %lu\n", |
| 5241 | atomic_long_read(&memcg->memory_events[MEMCG_OOM])); | 5242 | atomic_long_read(&memcg->memory_events[MEMCG_OOM])); |
| 5242 | seq_printf(m, "oom_kill %lu\n", memcg_sum_events(memcg, OOM_KILL)); | 5243 | seq_printf(m, "oom_kill %lu\n", |
| 5244 | atomic_long_read(&memcg->memory_events[MEMCG_OOM_KILL])); | ||
| 5243 | 5245 | ||
| 5244 | return 0; | 5246 | return 0; |
| 5245 | } | 5247 | } |
| @@ -5480,6 +5482,10 @@ enum mem_cgroup_protection mem_cgroup_protected(struct mem_cgroup *root, · 234 unmodified lines | |||
| 5480 | elow = memcg->memory.low; | 5482 | elow = memcg->memory.low; |
| 5481 | 5483 | ||
| 5482 | parent = parent_mem_cgroup(memcg); | 5484 | parent = parent_mem_cgroup(memcg); |
| 5485 | /* No parent means a non-hierarchical mode on v1 memcg */ | ||
| 5486 | if (!parent) | ||
| 5487 | return MEMCG_PROT_NONE; | ||
| 5488 | |||
| 5483 | if (parent == root) | 5489 | if (parent == root) |
| 5484 | goto exit; | 5490 | goto exit; |
| 5485 | 5491 | ||
| @@ -191,8 +191,6 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd, · 190 unmodified lines | |||
| 191 | drop_rmap_locks(vma); | 191 | drop_rmap_locks(vma); |
| 192 | } | 192 | } |
| 193 | 193 | ||
| 194 | #define LATENCY_LIMIT (64 * PAGE_SIZE) | ||
| 195 | |||
| 196 | unsigned long move_page_tables(struct vm_area_struct *vma, | 194 | unsigned long move_page_tables(struct vm_area_struct *vma, |
| 197 | unsigned long old_addr, struct vm_area_struct *new_vma, | 195 | unsigned long old_addr, struct vm_area_struct *new_vma, |
| 198 | unsigned long new_addr, unsigned long len, | 196 | unsigned long new_addr, unsigned long len, |
| @@ -247,8 +245,6 @@ unsigned long move_page_tables(struct vm_area_struct *vma, · 48 unmodified lines | |||
| 247 | next = (new_addr + PMD_SIZE) & PMD_MASK; | 245 | next = (new_addr + PMD_SIZE) & PMD_MASK; |
| 248 | if (extent > next - new_addr) | 246 | if (extent > next - new_addr) |
| 249 | extent = next - new_addr; | 247 | extent = next - new_addr; |
| 250 | if (extent > LATENCY_LIMIT) | ||
| 251 | extent = LATENCY_LIMIT; | ||
| 252 | move_ptes(vma, old_pmd, old_addr, old_addr + extent, new_vma, | 248 | move_ptes(vma, old_pmd, old_addr, old_addr + extent, new_vma, |
| 253 | new_pmd, new_addr, need_rmap_locks, &need_flush); | 249 | new_pmd, new_addr, need_rmap_locks, &need_flush); |
| 254 | } | 250 | } |
| @@ -913,7 +913,7 @@ static void oom_kill_process(struct oom_control *oc, const char *message) · 912 unmodified lines | |||
| 913 | 913 | ||
| 914 | /* Raise event before sending signal: task reaper must see this */ | 914 | /* Raise event before sending signal: task reaper must see this */ |
| 915 | count_vm_event(OOM_KILL); | 915 | count_vm_event(OOM_KILL); |
| 916 | count_memcg_event_mm(mm, OOM_KILL); | 916 | memcg_memory_event_mm(mm, MEMCG_OOM_KILL); |
| 917 | 917 | ||
| 918 | /* | 918 | /* |
| 919 | * We should send SIGKILL before granting access to memory reserves | 919 | * We should send SIGKILL before granting access to memory reserves |
| @@ -3061,7 +3061,7 @@ static bool should_fail_alloc_page(gfp_t gfp_mask, unsigned int order) · 3060 unmodified lines | |||
| 3061 | 3061 | ||
| 3062 | static int __init fail_page_alloc_debugfs(void) | 3062 | static int __init fail_page_alloc_debugfs(void) |
| 3063 | { | 3063 | { |
| 3064 | umode_t mode = S_IFREG | S_IRUSR | S_IWUSR; | 3064 | umode_t mode = S_IFREG | 0600; |
| 3065 | struct dentry *dir; | 3065 | struct dentry *dir; |
| 3066 | 3066 | ||
| 3067 | dir = fault_create_debugfs_attr("fail_page_alloc", NULL, | 3067 | dir = fault_create_debugfs_attr("fail_page_alloc", NULL, |
| @@ -201,7 +201,7 @@ static ssize_t page_idle_bitmap_write(struct file *file, struct kobject *kobj, · 200 unmodified lines | |||
| 201 | } | 201 | } |
| 202 | 202 | ||
| 203 | static struct bin_attribute page_idle_bitmap_attr = | 203 | static struct bin_attribute page_idle_bitmap_attr = |
| 204 | __BIN_ATTR(bitmap, S_IRUSR | S_IWUSR, | 204 | __BIN_ATTR(bitmap, 0600, |
| 205 | page_idle_bitmap_read, page_idle_bitmap_write, 0); | 205 | page_idle_bitmap_read, page_idle_bitmap_write, 0); |
| 206 | 206 | ||
| 207 | static struct bin_attribute *page_idle_bin_attrs[] = { | 207 | static struct bin_attribute *page_idle_bin_attrs[] = { |
| @@ -631,8 +631,8 @@ static int __init pageowner_init(void) · 630 unmodified lines | |||
| 631 | return 0; | 631 | return 0; |
| 632 | } | 632 | } |
| 633 | 633 | ||
| 634 | dentry = debugfs_create_file("page_owner", S_IRUSR, NULL, | 634 | dentry = debugfs_create_file("page_owner", 0400, NULL, |
| 635 | NULL, &proc_page_owner_operations); | 635 | NULL, &proc_page_owner_operations); |
| 636 | 636 | ||
| 637 | return PTR_ERR_OR_ZERO(dentry); | 637 | return PTR_ERR_OR_ZERO(dentry); |
| 638 | } | 638 | } |
| @@ -3013,7 +3013,8 @@ static int shmem_symlink(struct inode *dir, struct dentry *dentry, const char *s · 3012 unmodified lines | |||
| 3013 | if (len > PAGE_SIZE) | 3013 | if (len > PAGE_SIZE) |
| 3014 | return -ENAMETOOLONG; | 3014 | return -ENAMETOOLONG; |
| 3015 | 3015 | ||
| 3016 | inode = shmem_get_inode(dir->i_sb, dir, S_IFLNK|S_IRWXUGO, 0, VM_NORESERVE); | 3016 | inode = shmem_get_inode(dir->i_sb, dir, S_IFLNK | 0777, 0, |
| 3017 | VM_NORESERVE); | ||
| 3017 | if (!inode) | 3018 | if (!inode) |
| 3018 | return -ENOSPC; | 3019 | return -ENOSPC; |
| 3019 | 3020 | ||
| @@ -3445,7 +3446,7 @@ static int shmem_show_options(struct seq_file *seq, struct dentry *root) · 425 unmodified lines | |||
| 3445 | sbinfo->max_blocks << (PAGE_SHIFT - 10)); | 3446 | sbinfo->max_blocks << (PAGE_SHIFT - 10)); |
| 3446 | if (sbinfo->max_inodes != shmem_default_max_inodes()) | 3447 | if (sbinfo->max_inodes != shmem_default_max_inodes()) |
| 3447 | seq_printf(seq, ",nr_inodes=%lu", sbinfo->max_inodes); | 3448 | seq_printf(seq, ",nr_inodes=%lu", sbinfo->max_inodes); |
| 3448 | if (sbinfo->mode != (S_IRWXUGO | S_ISVTX)) | 3449 | if (sbinfo->mode != (0777 | S_ISVTX)) |
| 3449 | seq_printf(seq, ",mode=%03ho", sbinfo->mode); | 3450 | seq_printf(seq, ",mode=%03ho", sbinfo->mode); |
| 3450 | if (!uid_eq(sbinfo->uid, GLOBAL_ROOT_UID)) | 3451 | if (!uid_eq(sbinfo->uid, GLOBAL_ROOT_UID)) |
| 3451 | seq_printf(seq, ",uid=%u", | 3452 | seq_printf(seq, ",uid=%u", |
| @@ -3486,7 +3487,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent) · 34 unmodified lines | |||
| 3486 | if (!sbinfo) | 3487 | if (!sbinfo) |
| 3487 | return -ENOMEM; | 3488 | return -ENOMEM; |
| 3488 | 3489 | ||
| 3489 | sbinfo->mode = S_IRWXUGO | S_ISVTX; | 3490 | sbinfo->mode = 0777 | S_ISVTX; |
| 3490 | sbinfo->uid = current_fsuid(); | 3491 | sbinfo->uid = current_fsuid(); |
| 3491 | sbinfo->gid = current_fsgid(); | 3492 | sbinfo->gid = current_fsgid(); |
| 3492 | sb->s_fs_info = sbinfo; | 3493 | sb->s_fs_info = sbinfo; |
| @@ -3929,7 +3930,7 @@ static struct file *__shmem_file_setup(struct vfsmount *mnt, const char *name, l · 436 unmodified lines | |||
| 3929 | d_set_d_op(path.dentry, &anon_ops); | 3930 | d_set_d_op(path.dentry, &anon_ops); |
| 3930 | 3931 | ||
| 3931 | res = ERR_PTR(-ENOSPC); | 3932 | res = ERR_PTR(-ENOSPC); |
| 3932 | inode = shmem_get_inode(sb, NULL, S_IFREG | S_IRWXUGO, 0, flags); | 3933 | inode = shmem_get_inode(sb, NULL, S_IFREG | 0777, 0, flags); |
| 3933 | if (!inode) | 3934 | if (!inode) |
| 3934 | goto put_memory; | 3935 | goto put_memory; |
| 3935 | 3936 | ||
| @@ -136,6 +136,7 @@ void slab_init_memcg_params(struct kmem_cache *s) · 135 unmodified lines | |||
| 136 | s->memcg_params.root_cache = NULL; | 136 | s->memcg_params.root_cache = NULL; |
| 137 | RCU_INIT_POINTER(s->memcg_params.memcg_caches, NULL); | 137 | RCU_INIT_POINTER(s->memcg_params.memcg_caches, NULL); |
| 138 | INIT_LIST_HEAD(&s->memcg_params.children); | 138 | INIT_LIST_HEAD(&s->memcg_params.children); |
| 139 | s->memcg_params.dying = false; | ||
| 139 | } | 140 | } |
| 140 | 141 | ||
| 141 | static int init_memcg_params(struct kmem_cache *s, | 142 | static int init_memcg_params(struct kmem_cache *s, |
| @@ -608,7 +609,7 @@ void memcg_create_kmem_cache(struct mem_cgroup *memcg, · 466 unmodified lines | |||
| 608 | * The memory cgroup could have been offlined while the cache | 609 | * The memory cgroup could have been offlined while the cache |
| 609 | * creation work was pending. | 610 | * creation work was pending. |
| 610 | */ | 611 | */ |
| 611 | if (memcg->kmem_state != KMEM_ONLINE) | 612 | if (memcg->kmem_state != KMEM_ONLINE || root_cache->memcg_params.dying) |
| 612 | goto out_unlock; | 613 | goto out_unlock; |
| 613 | 614 | ||
| 614 | idx = memcg_cache_id(memcg); | 615 | idx = memcg_cache_id(memcg); |
| @@ -712,6 +713,9 @@ void slab_deactivate_memcg_cache_rcu_sched(struct kmem_cache *s, · 97 unmodified lines | |||
| 712 | WARN_ON_ONCE(s->memcg_params.deact_fn)) | 713 | WARN_ON_ONCE(s->memcg_params.deact_fn)) |
| 713 | return; | 714 | return; |
| 714 | 715 | ||
| 716 | if (s->memcg_params.root_cache->memcg_params.dying) | ||
| 717 | return; | ||
| 718 | |||
| 715 | /* pin memcg so that @s doesn't get destroyed in the middle */ | 719 | /* pin memcg so that @s doesn't get destroyed in the middle */ |
| 716 | css_get(&s->memcg_params.memcg->css); | 720 | css_get(&s->memcg_params.memcg->css); |
| 717 | 721 | ||
| @@ -823,11 +827,36 @@ static int shutdown_memcg_caches(struct kmem_cache *s) · 105 unmodified lines | |||
| 823 | return -EBUSY; | 827 | return -EBUSY; |
| 824 | return 0; | 828 | return 0; |
| 825 | } | 829 | } |
| 830 | |||
| 831 | static void flush_memcg_workqueue(struct kmem_cache *s) | ||
| 832 | { | ||
| 833 | mutex_lock(&slab_mutex); | ||
| 834 | s->memcg_params.dying = true; | ||
| 835 | mutex_unlock(&slab_mutex); | ||
| 836 | |||
| 837 | /* | ||
| 838 | * SLUB deactivates the kmem_caches through call_rcu_sched. Make | ||
| 839 | * sure all registered rcu callbacks have been invoked. | ||
| 840 | */ | ||
| 841 | if (IS_ENABLED(CONFIG_SLUB)) | ||
| 842 | rcu_barrier_sched(); | ||
| 843 | |||
| 844 | /* | ||
| 845 | * SLAB and SLUB create memcg kmem_caches through workqueue and SLUB | ||
| 846 | * deactivates the memcg kmem_caches through workqueue. Make sure all | ||
| 847 | * previous workitems on workqueue are processed. | ||
| 848 | */ | ||
| 849 | flush_workqueue(memcg_kmem_cache_wq); | ||
| 850 | } | ||
| 826 | #else | 851 | #else |
| 827 | static inline int shutdown_memcg_caches(struct kmem_cache *s) | 852 | static inline int shutdown_memcg_caches(struct kmem_cache *s) |
| 828 | { | 853 | { |
| 829 | return 0; | 854 | return 0; |
| 830 | } | 855 | } |
| 856 | |||
| 857 | static inline void flush_memcg_workqueue(struct kmem_cache *s) | ||
| 858 | { | ||
| 859 | } | ||
| 831 | #endif /* CONFIG_MEMCG && !CONFIG_SLOB */ | 860 | #endif /* CONFIG_MEMCG && !CONFIG_SLOB */ |
| 832 | 861 | ||
| 833 | void slab_kmem_cache_release(struct kmem_cache *s) | 862 | void slab_kmem_cache_release(struct kmem_cache *s) |
| @@ -845,6 +874,8 @@ void kmem_cache_destroy(struct kmem_cache *s) · 11 unmodified lines | |||
| 845 | if (unlikely(!s)) | 874 | if (unlikely(!s)) |
| 846 | return; | 875 | return; |
| 847 | 876 | ||
| 877 | flush_memcg_workqueue(s); | ||
| 878 | |||
| 848 | get_online_cpus(); | 879 | get_online_cpus(); |
| 849 | get_online_mems(); | 880 | get_online_mems(); |
| 850 | 881 | ||
| @@ -1212,9 +1243,9 @@ void cache_random_seq_destroy(struct kmem_cache *cachep) · 361 unmodified lines | |||
| 1212 | 1243 | ||
| 1213 | #if defined(CONFIG_SLAB) || defined(CONFIG_SLUB_DEBUG) | 1244 | #if defined(CONFIG_SLAB) || defined(CONFIG_SLUB_DEBUG) |
| 1214 | #ifdef CONFIG_SLAB | 1245 | #ifdef CONFIG_SLAB |
| 1215 | #define SLABINFO_RIGHTS (S_IWUSR | S_IRUSR) | 1246 | #define SLABINFO_RIGHTS (0600) |
| 1216 | #else | 1247 | #else |
| 1217 | #define SLABINFO_RIGHTS S_IRUSR | 1248 | #define SLABINFO_RIGHTS (0400) |
| 1218 | #endif | 1249 | #endif |
| 1219 | 1250 | ||
| 1220 | static void print_slabinfo_header(struct seq_file *m) | 1251 | static void print_slabinfo_header(struct seq_file *m) |
| @@ -100,7 +100,7 @@ atomic_t nr_rotate_swap = ATOMIC_INIT(0); · 99 unmodified lines | |||
| 100 | 100 | ||
| 101 | static inline unsigned char swap_count(unsigned char ent) | 101 | static inline unsigned char swap_count(unsigned char ent) |
| 102 | { | 102 | { |
| 103 | return ent & ~SWAP_HAS_CACHE; /* may include SWAP_HAS_CONT flag */ | 103 | return ent & ~SWAP_HAS_CACHE; /* may include COUNT_CONTINUED flag */ |
| 104 | } | 104 | } |
| 105 | 105 | ||
| 106 | /* returns 1 if swap entry is freed */ | 106 | /* returns 1 if swap entry is freed */ |
| @@ -2741,11 +2741,11 @@ static const struct seq_operations vmalloc_op = { · 2740 unmodified lines | |||
| 2741 | static int __init proc_vmalloc_init(void) | 2741 | static int __init proc_vmalloc_init(void) |
| 2742 | { | 2742 | { |
| 2743 | if (IS_ENABLED(CONFIG_NUMA)) | 2743 | if (IS_ENABLED(CONFIG_NUMA)) |
| 2744 | proc_create_seq_private("vmallocinfo", S_IRUSR, NULL, | 2744 | proc_create_seq_private("vmallocinfo", 0400, NULL, |
| 2745 | &vmalloc_op, | 2745 | &vmalloc_op, |
| 2746 | nr_node_ids * sizeof(unsigned int), NULL); | 2746 | nr_node_ids * sizeof(unsigned int), NULL); |
| 2747 | else | 2747 | else |
| 2748 | proc_create_seq("vmallocinfo", S_IRUSR, NULL, &vmalloc_op); | 2748 | proc_create_seq("vmallocinfo", 0400, NULL, &vmalloc_op); |
| 2749 | return 0; | 2749 | return 0; |
| 2750 | } | 2750 | } |
| 2751 | module_init(proc_vmalloc_init); | 2751 | module_init(proc_vmalloc_init); |
| @@ -661,8 +661,9 @@ static void zs_pool_stat_create(struct zs_pool *pool, const char *name) · 660 unmodified lines | |||
| 661 | } | 661 | } |
| 662 | pool->stat_dentry = entry; | 662 | pool->stat_dentry = entry; |
| 663 | 663 | ||
| 664 | entry = debugfs_create_file("classes", S_IFREG | S_IRUGO, | 664 | entry = debugfs_create_file("classes", S_IFREG | 0444, |
| 665 | pool->stat_dentry, pool, &zs_stats_size_fops); | 665 | pool->stat_dentry, pool, |
| 666 | &zs_stats_size_fops); | ||
| 666 | if (!entry) { | 667 | if (!entry) { |
| 667 | pr_warn("%s: debugfs file entry <%s> creation failed\n", | 668 | pr_warn("%s: debugfs file entry <%s> creation failed\n", |
| 668 | name, "classes"); | 669 | name, "classes"); |
| @@ -1256,26 +1256,26 @@ static int __init zswap_debugfs_init(void) · 1255 unmodified lines | |||
| 1256 | if (!zswap_debugfs_root) | 1256 | if (!zswap_debugfs_root) |
| 1257 | return -ENOMEM; | 1257 | return -ENOMEM; |
| 1258 | 1258 | ||
| 1259 | debugfs_create_u64("pool_limit_hit", S_IRUGO, | 1259 | debugfs_create_u64("pool_limit_hit", 0444, |
| 1260 | zswap_debugfs_root, &zswap_pool_limit_hit); | 1260 | zswap_debugfs_root, &zswap_pool_limit_hit); |
| 1261 | debugfs_create_u64("reject_reclaim_fail", S_IRUGO, | 1261 | debugfs_create_u64("reject_reclaim_fail", 0444, |
| 1262 | zswap_debugfs_root, &zswap_reject_reclaim_fail); | 1262 | zswap_debugfs_root, &zswap_reject_reclaim_fail); |
| 1263 | debugfs_create_u64("reject_alloc_fail", S_IRUGO, | 1263 | debugfs_create_u64("reject_alloc_fail", 0444, |
| 1264 | zswap_debugfs_root, &zswap_reject_alloc_fail); | 1264 | zswap_debugfs_root, &zswap_reject_alloc_fail); |
| 1265 | debugfs_create_u64("reject_kmemcache_fail", S_IRUGO, | 1265 | debugfs_create_u64("reject_kmemcache_fail", 0444, |
| 1266 | zswap_debugfs_root, &zswap_reject_kmemcache_fail); | 1266 | zswap_debugfs_root, &zswap_reject_kmemcache_fail); |
| 1267 | debugfs_create_u64("reject_compress_poor", S_IRUGO, | 1267 | debugfs_create_u64("reject_compress_poor", 0444, |
| 1268 | zswap_debugfs_root, &zswap_reject_compress_poor); | 1268 | zswap_debugfs_root, &zswap_reject_compress_poor); |
| 1269 | debugfs_create_u64("written_back_pages", S_IRUGO, | 1269 | debugfs_create_u64("written_back_pages", 0444, |
| 1270 | zswap_debugfs_root, &zswap_written_back_pages); | 1270 | zswap_debugfs_root, &zswap_written_back_pages); |
| 1271 | debugfs_create_u64("duplicate_entry", S_IRUGO, | 1271 | debugfs_create_u64("duplicate_entry", 0444, |
| 1272 | zswap_debugfs_root, &zswap_duplicate_entry); | 1272 | zswap_debugfs_root, &zswap_duplicate_entry); |
| 1273 | debugfs_create_u64("pool_total_size", S_IRUGO, | 1273 | debugfs_create_u64("pool_total_size", 0444, |
| 1274 | zswap_debugfs_root, &zswap_pool_total_size); | 1274 | zswap_debugfs_root, &zswap_pool_total_size); |
| 1275 | debugfs_create_atomic_t("stored_pages", S_IRUGO, | 1275 | debugfs_create_atomic_t("stored_pages", 0444, |
| 1276 | zswap_debugfs_root, &zswap_stored_pages); | 1276 | zswap_debugfs_root, &zswap_stored_pages); |
| 1277 | debugfs_create_atomic_t("same_filled_pages", 0444, | 1277 | debugfs_create_atomic_t("same_filled_pages", 0444, |
| 1278 | zswap_debugfs_root, &zswap_same_filled_pages); | 1278 | zswap_debugfs_root, &zswap_same_filled_pages); |
| 1279 | 1279 | ||
| 1280 | return 0; | 1280 | return 0; |
| 1281 | } | 1281 | } |