Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'mm-hotfixes-stable-2022-12-22-14-34' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

Pull hotfixes from Andrew Morton:
"Eight fixes, all cc:stable. One is for gcov and the remainder are MM"

* tag 'mm-hotfixes-stable-2022-12-22-14-34' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm:
gcov: add support for checksum field
test_maple_tree: add test for mas_spanning_rebalance() on insufficient data
maple_tree: fix mas_spanning_rebalance() on insufficient data
hugetlb: really allocate vma lock for all sharable vmas
kmsan: export kmsan_handle_urb
kmsan: include linux/vmalloc.h
mm/mempolicy: fix memory leak in set_mempolicy_home_node system call
mm, mremap: fix mremap() expanding vma with addr inside vma

+184 -187
+5
kernel/gcov/gcc_4_7.c
··· 82 82 * @version: gcov version magic indicating the gcc version used for compilation 83 83 * @next: list head for a singly-linked list 84 84 * @stamp: uniquifying time stamp 85 + * @checksum: unique object checksum 85 86 * @filename: name of the associated gcov data file 86 87 * @merge: merge functions (null for unused counter type) 87 88 * @n_functions: number of instrumented functions ··· 95 94 unsigned int version; 96 95 struct gcov_info *next; 97 96 unsigned int stamp; 97 + /* Since GCC 12.1 a checksum field is added. */ 98 + #if (__GNUC__ >= 12) 99 + unsigned int checksum; 100 + #endif 98 101 const char *filename; 99 102 void (*merge[GCOV_COUNTERS])(gcov_type *, unsigned int); 100 103 unsigned int n_functions;
+3 -1
lib/maple_tree.c
··· 2994 2994 mast->free = &free; 2995 2995 mast->destroy = &destroy; 2996 2996 l_mas.node = r_mas.node = m_mas.node = MAS_NONE; 2997 - if (!(mast->orig_l->min && mast->orig_r->max == ULONG_MAX) && 2997 + 2998 + /* Check if this is not root and has sufficient data. */ 2999 + if (((mast->orig_l->min != 0) || (mast->orig_r->max != ULONG_MAX)) && 2998 3000 unlikely(mast->bn->b_end <= mt_min_slots[mast->bn->type])) 2999 3001 mast_spanning_rebalance(mast); 3000 3002
+23
lib/test_maple_tree.c
··· 2498 2498 } 2499 2499 } 2500 2500 2501 + static noinline void check_bnode_min_spanning(struct maple_tree *mt) 2502 + { 2503 + int i = 50; 2504 + MA_STATE(mas, mt, 0, 0); 2505 + 2506 + mt_set_non_kernel(9999); 2507 + mas_lock(&mas); 2508 + do { 2509 + mas_set_range(&mas, i*10, i*10+9); 2510 + mas_store(&mas, check_bnode_min_spanning); 2511 + } while (i--); 2512 + 2513 + mas_set_range(&mas, 240, 509); 2514 + mas_store(&mas, NULL); 2515 + mas_unlock(&mas); 2516 + mas_destroy(&mas); 2517 + mt_set_non_kernel(0); 2518 + } 2519 + 2501 2520 static DEFINE_MTREE(tree); 2502 2521 static int maple_tree_seed(void) 2503 2522 { ··· 2759 2740 2760 2741 mt_init_flags(&tree, MT_FLAGS_ALLOC_RANGE); 2761 2742 check_dup(&tree); 2743 + mtree_destroy(&tree); 2744 + 2745 + mt_init_flags(&tree, MT_FLAGS_ALLOC_RANGE); 2746 + check_bnode_min_spanning(&tree); 2762 2747 mtree_destroy(&tree); 2763 2748 2764 2749 #if defined(BENCH)
+148 -185
mm/hugetlb.c
··· 255 255 return subpool_inode(file_inode(vma->vm_file)); 256 256 } 257 257 258 + /* 259 + * hugetlb vma_lock helper routines 260 + */ 261 + static bool __vma_shareable_lock(struct vm_area_struct *vma) 262 + { 263 + return vma->vm_flags & (VM_MAYSHARE | VM_SHARED) && 264 + vma->vm_private_data; 265 + } 266 + 267 + void hugetlb_vma_lock_read(struct vm_area_struct *vma) 268 + { 269 + if (__vma_shareable_lock(vma)) { 270 + struct hugetlb_vma_lock *vma_lock = vma->vm_private_data; 271 + 272 + down_read(&vma_lock->rw_sema); 273 + } 274 + } 275 + 276 + void hugetlb_vma_unlock_read(struct vm_area_struct *vma) 277 + { 278 + if (__vma_shareable_lock(vma)) { 279 + struct hugetlb_vma_lock *vma_lock = vma->vm_private_data; 280 + 281 + up_read(&vma_lock->rw_sema); 282 + } 283 + } 284 + 285 + void hugetlb_vma_lock_write(struct vm_area_struct *vma) 286 + { 287 + if (__vma_shareable_lock(vma)) { 288 + struct hugetlb_vma_lock *vma_lock = vma->vm_private_data; 289 + 290 + down_write(&vma_lock->rw_sema); 291 + } 292 + } 293 + 294 + void hugetlb_vma_unlock_write(struct vm_area_struct *vma) 295 + { 296 + if (__vma_shareable_lock(vma)) { 297 + struct hugetlb_vma_lock *vma_lock = vma->vm_private_data; 298 + 299 + up_write(&vma_lock->rw_sema); 300 + } 301 + } 302 + 303 + int hugetlb_vma_trylock_write(struct vm_area_struct *vma) 304 + { 305 + struct hugetlb_vma_lock *vma_lock = vma->vm_private_data; 306 + 307 + if (!__vma_shareable_lock(vma)) 308 + return 1; 309 + 310 + return down_write_trylock(&vma_lock->rw_sema); 311 + } 312 + 313 + void hugetlb_vma_assert_locked(struct vm_area_struct *vma) 314 + { 315 + if (__vma_shareable_lock(vma)) { 316 + struct hugetlb_vma_lock *vma_lock = vma->vm_private_data; 317 + 318 + lockdep_assert_held(&vma_lock->rw_sema); 319 + } 320 + } 321 + 322 + void hugetlb_vma_lock_release(struct kref *kref) 323 + { 324 + struct hugetlb_vma_lock *vma_lock = container_of(kref, 325 + struct hugetlb_vma_lock, refs); 326 + 327 + kfree(vma_lock); 328 + } 329 + 330 + static void __hugetlb_vma_unlock_write_put(struct hugetlb_vma_lock *vma_lock) 331 + { 332 + struct vm_area_struct *vma = vma_lock->vma; 333 + 334 + /* 335 + * vma_lock structure may or not be released as a result of put, 336 + * it certainly will no longer be attached to vma so clear pointer. 337 + * Semaphore synchronizes access to vma_lock->vma field. 338 + */ 339 + vma_lock->vma = NULL; 340 + vma->vm_private_data = NULL; 341 + up_write(&vma_lock->rw_sema); 342 + kref_put(&vma_lock->refs, hugetlb_vma_lock_release); 343 + } 344 + 345 + static void __hugetlb_vma_unlock_write_free(struct vm_area_struct *vma) 346 + { 347 + if (__vma_shareable_lock(vma)) { 348 + struct hugetlb_vma_lock *vma_lock = vma->vm_private_data; 349 + 350 + __hugetlb_vma_unlock_write_put(vma_lock); 351 + } 352 + } 353 + 354 + static void hugetlb_vma_lock_free(struct vm_area_struct *vma) 355 + { 356 + /* 357 + * Only present in sharable vmas. 358 + */ 359 + if (!vma || !__vma_shareable_lock(vma)) 360 + return; 361 + 362 + if (vma->vm_private_data) { 363 + struct hugetlb_vma_lock *vma_lock = vma->vm_private_data; 364 + 365 + down_write(&vma_lock->rw_sema); 366 + __hugetlb_vma_unlock_write_put(vma_lock); 367 + } 368 + } 369 + 370 + static void hugetlb_vma_lock_alloc(struct vm_area_struct *vma) 371 + { 372 + struct hugetlb_vma_lock *vma_lock; 373 + 374 + /* Only establish in (flags) sharable vmas */ 375 + if (!vma || !(vma->vm_flags & VM_MAYSHARE)) 376 + return; 377 + 378 + /* Should never get here with non-NULL vm_private_data */ 379 + if (vma->vm_private_data) 380 + return; 381 + 382 + vma_lock = kmalloc(sizeof(*vma_lock), GFP_KERNEL); 383 + if (!vma_lock) { 384 + /* 385 + * If we can not allocate structure, then vma can not 386 + * participate in pmd sharing. This is only a possible 387 + * performance enhancement and memory saving issue. 388 + * However, the lock is also used to synchronize page 389 + * faults with truncation. If the lock is not present, 390 + * unlikely races could leave pages in a file past i_size 391 + * until the file is removed. Warn in the unlikely case of 392 + * allocation failure. 393 + */ 394 + pr_warn_once("HugeTLB: unable to allocate vma specific lock\n"); 395 + return; 396 + } 397 + 398 + kref_init(&vma_lock->refs); 399 + init_rwsem(&vma_lock->rw_sema); 400 + vma_lock->vma = vma; 401 + vma->vm_private_data = vma_lock; 402 + } 403 + 258 404 /* Helper that removes a struct file_region from the resv_map cache and returns 259 405 * it for use. 260 406 */ ··· 6759 6613 } 6760 6614 6761 6615 /* 6762 - * vma specific semaphore used for pmd sharing synchronization 6616 + * vma specific semaphore used for pmd sharing and fault/truncation 6617 + * synchronization 6763 6618 */ 6764 6619 hugetlb_vma_lock_alloc(vma); 6765 6620 ··· 7016 6869 *end = ALIGN(*end, PUD_SIZE); 7017 6870 } 7018 6871 7019 - static bool __vma_shareable_flags_pmd(struct vm_area_struct *vma) 7020 - { 7021 - return vma->vm_flags & (VM_MAYSHARE | VM_SHARED) && 7022 - vma->vm_private_data; 7023 - } 7024 - 7025 - void hugetlb_vma_lock_read(struct vm_area_struct *vma) 7026 - { 7027 - if (__vma_shareable_flags_pmd(vma)) { 7028 - struct hugetlb_vma_lock *vma_lock = vma->vm_private_data; 7029 - 7030 - down_read(&vma_lock->rw_sema); 7031 - } 7032 - } 7033 - 7034 - void hugetlb_vma_unlock_read(struct vm_area_struct *vma) 7035 - { 7036 - if (__vma_shareable_flags_pmd(vma)) { 7037 - struct hugetlb_vma_lock *vma_lock = vma->vm_private_data; 7038 - 7039 - up_read(&vma_lock->rw_sema); 7040 - } 7041 - } 7042 - 7043 - void hugetlb_vma_lock_write(struct vm_area_struct *vma) 7044 - { 7045 - if (__vma_shareable_flags_pmd(vma)) { 7046 - struct hugetlb_vma_lock *vma_lock = vma->vm_private_data; 7047 - 7048 - down_write(&vma_lock->rw_sema); 7049 - } 7050 - } 7051 - 7052 - void hugetlb_vma_unlock_write(struct vm_area_struct *vma) 7053 - { 7054 - if (__vma_shareable_flags_pmd(vma)) { 7055 - struct hugetlb_vma_lock *vma_lock = vma->vm_private_data; 7056 - 7057 - up_write(&vma_lock->rw_sema); 7058 - } 7059 - } 7060 - 7061 - int hugetlb_vma_trylock_write(struct vm_area_struct *vma) 7062 - { 7063 - struct hugetlb_vma_lock *vma_lock = vma->vm_private_data; 7064 - 7065 - if (!__vma_shareable_flags_pmd(vma)) 7066 - return 1; 7067 - 7068 - return down_write_trylock(&vma_lock->rw_sema); 7069 - } 7070 - 7071 - void hugetlb_vma_assert_locked(struct vm_area_struct *vma) 7072 - { 7073 - if (__vma_shareable_flags_pmd(vma)) { 7074 - struct hugetlb_vma_lock *vma_lock = vma->vm_private_data; 7075 - 7076 - lockdep_assert_held(&vma_lock->rw_sema); 7077 - } 7078 - } 7079 - 7080 - void hugetlb_vma_lock_release(struct kref *kref) 7081 - { 7082 - struct hugetlb_vma_lock *vma_lock = container_of(kref, 7083 - struct hugetlb_vma_lock, refs); 7084 - 7085 - kfree(vma_lock); 7086 - } 7087 - 7088 - static void __hugetlb_vma_unlock_write_put(struct hugetlb_vma_lock *vma_lock) 7089 - { 7090 - struct vm_area_struct *vma = vma_lock->vma; 7091 - 7092 - /* 7093 - * vma_lock structure may or not be released as a result of put, 7094 - * it certainly will no longer be attached to vma so clear pointer. 7095 - * Semaphore synchronizes access to vma_lock->vma field. 7096 - */ 7097 - vma_lock->vma = NULL; 7098 - vma->vm_private_data = NULL; 7099 - up_write(&vma_lock->rw_sema); 7100 - kref_put(&vma_lock->refs, hugetlb_vma_lock_release); 7101 - } 7102 - 7103 - static void __hugetlb_vma_unlock_write_free(struct vm_area_struct *vma) 7104 - { 7105 - if (__vma_shareable_flags_pmd(vma)) { 7106 - struct hugetlb_vma_lock *vma_lock = vma->vm_private_data; 7107 - 7108 - __hugetlb_vma_unlock_write_put(vma_lock); 7109 - } 7110 - } 7111 - 7112 - static void hugetlb_vma_lock_free(struct vm_area_struct *vma) 7113 - { 7114 - /* 7115 - * Only present in sharable vmas. 7116 - */ 7117 - if (!vma || !__vma_shareable_flags_pmd(vma)) 7118 - return; 7119 - 7120 - if (vma->vm_private_data) { 7121 - struct hugetlb_vma_lock *vma_lock = vma->vm_private_data; 7122 - 7123 - down_write(&vma_lock->rw_sema); 7124 - __hugetlb_vma_unlock_write_put(vma_lock); 7125 - } 7126 - } 7127 - 7128 - static void hugetlb_vma_lock_alloc(struct vm_area_struct *vma) 7129 - { 7130 - struct hugetlb_vma_lock *vma_lock; 7131 - 7132 - /* Only establish in (flags) sharable vmas */ 7133 - if (!vma || !(vma->vm_flags & VM_MAYSHARE)) 7134 - return; 7135 - 7136 - /* Should never get here with non-NULL vm_private_data */ 7137 - if (vma->vm_private_data) 7138 - return; 7139 - 7140 - vma_lock = kmalloc(sizeof(*vma_lock), GFP_KERNEL); 7141 - if (!vma_lock) { 7142 - /* 7143 - * If we can not allocate structure, then vma can not 7144 - * participate in pmd sharing. This is only a possible 7145 - * performance enhancement and memory saving issue. 7146 - * However, the lock is also used to synchronize page 7147 - * faults with truncation. If the lock is not present, 7148 - * unlikely races could leave pages in a file past i_size 7149 - * until the file is removed. Warn in the unlikely case of 7150 - * allocation failure. 7151 - */ 7152 - pr_warn_once("HugeTLB: unable to allocate vma specific lock\n"); 7153 - return; 7154 - } 7155 - 7156 - kref_init(&vma_lock->refs); 7157 - init_rwsem(&vma_lock->rw_sema); 7158 - vma_lock->vma = vma; 7159 - vma->vm_private_data = vma_lock; 7160 - } 7161 - 7162 6872 /* 7163 6873 * Search for a shareable pmd page for hugetlb. In any case calls pmd_alloc() 7164 6874 * and returns the corresponding pte. While this is not necessary for the ··· 7103 7099 } 7104 7100 7105 7101 #else /* !CONFIG_ARCH_WANT_HUGE_PMD_SHARE */ 7106 - 7107 - void hugetlb_vma_lock_read(struct vm_area_struct *vma) 7108 - { 7109 - } 7110 - 7111 - void hugetlb_vma_unlock_read(struct vm_area_struct *vma) 7112 - { 7113 - } 7114 - 7115 - void hugetlb_vma_lock_write(struct vm_area_struct *vma) 7116 - { 7117 - } 7118 - 7119 - void hugetlb_vma_unlock_write(struct vm_area_struct *vma) 7120 - { 7121 - } 7122 - 7123 - int hugetlb_vma_trylock_write(struct vm_area_struct *vma) 7124 - { 7125 - return 1; 7126 - } 7127 - 7128 - void hugetlb_vma_assert_locked(struct vm_area_struct *vma) 7129 - { 7130 - } 7131 - 7132 - void hugetlb_vma_lock_release(struct kref *kref) 7133 - { 7134 - } 7135 - 7136 - static void __hugetlb_vma_unlock_write_free(struct vm_area_struct *vma) 7137 - { 7138 - } 7139 - 7140 - static void hugetlb_vma_lock_free(struct vm_area_struct *vma) 7141 - { 7142 - } 7143 - 7144 - static void hugetlb_vma_lock_alloc(struct vm_area_struct *vma) 7145 - { 7146 - } 7147 7102 7148 7103 pte_t *huge_pmd_share(struct mm_struct *mm, struct vm_area_struct *vma, 7149 7104 unsigned long addr, pud_t *pud)
+1
mm/kmsan/hooks.c
··· 260 260 urb->transfer_buffer_length, 261 261 /*checked*/ false); 262 262 } 263 + EXPORT_SYMBOL_GPL(kmsan_handle_urb); 263 264 264 265 static void kmsan_handle_dma_page(const void *addr, size_t size, 265 266 enum dma_data_direction dir)
+1
mm/kmsan/kmsan_test.c
··· 22 22 #include <linux/spinlock.h> 23 23 #include <linux/string.h> 24 24 #include <linux/tracepoint.h> 25 + #include <linux/vmalloc.h> 25 26 #include <trace/events/printk.h> 26 27 27 28 static DEFINE_PER_CPU(int, per_cpu_var);
+1
mm/mempolicy.c
··· 1540 1540 * the home node for vmas we already updated before. 1541 1541 */ 1542 1542 if (new->mode != MPOL_BIND && new->mode != MPOL_PREFERRED_MANY) { 1543 + mpol_put(new); 1543 1544 err = -EOPNOTSUPP; 1544 1545 break; 1545 1546 }
+2 -1
mm/mremap.c
··· 1016 1016 long pages = (new_len - old_len) >> PAGE_SHIFT; 1017 1017 unsigned long extension_start = addr + old_len; 1018 1018 unsigned long extension_end = addr + new_len; 1019 - pgoff_t extension_pgoff = vma->vm_pgoff + (old_len >> PAGE_SHIFT); 1019 + pgoff_t extension_pgoff = vma->vm_pgoff + 1020 + ((extension_start - vma->vm_start) >> PAGE_SHIFT); 1020 1021 1021 1022 if (vma->vm_flags & VM_ACCOUNT) { 1022 1023 if (security_vm_enough_memory_mm(mm, pages)) {