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 branch 'akpm' (patches from Andrew)

Merge misc fixes from Andrew Morton:
"7 fixes"

* emailed patches from Andrew Morton <akpm@linux-foundation.org>:
mm, swap: fix race between swap count continuation operations
mm/huge_memory.c: deposit page table when copying a PMD migration entry
initramfs: fix initramfs rebuilds w/ compression after disabling
fs/hugetlbfs/inode.c: fix hwpoison reserve accounting
ocfs2: fstrim: Fix start offset of first cluster group during fstrim
mm, /proc/pid/pagemap: fix soft dirty marking for PMD migration entry
userfaultfd: hugetlbfs: prevent UFFDIO_COPY to fill beyond the end of i_size

+86 -20
+4 -1
fs/hugetlbfs/inode.c
··· 842 842 struct page *page) 843 843 { 844 844 struct inode *inode = mapping->host; 845 + pgoff_t index = page->index; 845 846 846 847 remove_huge_page(page); 847 - hugetlb_fix_reserve_counts(inode); 848 + if (unlikely(hugetlb_unreserve_pages(inode, index, index + 1, 1))) 849 + hugetlb_fix_reserve_counts(inode); 850 + 848 851 return 0; 849 852 } 850 853
+18 -6
fs/ocfs2/alloc.c
··· 7304 7304 7305 7305 static int ocfs2_trim_extent(struct super_block *sb, 7306 7306 struct ocfs2_group_desc *gd, 7307 - u32 start, u32 count) 7307 + u64 group, u32 start, u32 count) 7308 7308 { 7309 7309 u64 discard, bcount; 7310 + struct ocfs2_super *osb = OCFS2_SB(sb); 7310 7311 7311 7312 bcount = ocfs2_clusters_to_blocks(sb, count); 7312 - discard = le64_to_cpu(gd->bg_blkno) + 7313 - ocfs2_clusters_to_blocks(sb, start); 7313 + discard = ocfs2_clusters_to_blocks(sb, start); 7314 + 7315 + /* 7316 + * For the first cluster group, the gd->bg_blkno is not at the start 7317 + * of the group, but at an offset from the start. If we add it while 7318 + * calculating discard for first group, we will wrongly start fstrim a 7319 + * few blocks after the desried start block and the range can cross 7320 + * over into the next cluster group. So, add it only if this is not 7321 + * the first cluster group. 7322 + */ 7323 + if (group != osb->first_cluster_group_blkno) 7324 + discard += le64_to_cpu(gd->bg_blkno); 7314 7325 7315 7326 trace_ocfs2_trim_extent(sb, (unsigned long long)discard, bcount); 7316 7327 ··· 7329 7318 } 7330 7319 7331 7320 static int ocfs2_trim_group(struct super_block *sb, 7332 - struct ocfs2_group_desc *gd, 7321 + struct ocfs2_group_desc *gd, u64 group, 7333 7322 u32 start, u32 max, u32 minbits) 7334 7323 { 7335 7324 int ret = 0, count = 0, next; ··· 7348 7337 next = ocfs2_find_next_bit(bitmap, max, start); 7349 7338 7350 7339 if ((next - start) >= minbits) { 7351 - ret = ocfs2_trim_extent(sb, gd, 7340 + ret = ocfs2_trim_extent(sb, gd, group, 7352 7341 start, next - start); 7353 7342 if (ret < 0) { 7354 7343 mlog_errno(ret); ··· 7446 7435 } 7447 7436 7448 7437 gd = (struct ocfs2_group_desc *)gd_bh->b_data; 7449 - cnt = ocfs2_trim_group(sb, gd, first_bit, last_bit, minlen); 7438 + cnt = ocfs2_trim_group(sb, gd, group, 7439 + first_bit, last_bit, minlen); 7450 7440 brelse(gd_bh); 7451 7441 gd_bh = NULL; 7452 7442 if (cnt < 0) {
+5 -1
fs/proc/task_mmu.c
··· 1311 1311 pmd_t pmd = *pmdp; 1312 1312 struct page *page = NULL; 1313 1313 1314 - if ((vma->vm_flags & VM_SOFTDIRTY) || pmd_soft_dirty(pmd)) 1314 + if (vma->vm_flags & VM_SOFTDIRTY) 1315 1315 flags |= PM_SOFT_DIRTY; 1316 1316 1317 1317 if (pmd_present(pmd)) { 1318 1318 page = pmd_page(pmd); 1319 1319 1320 1320 flags |= PM_PRESENT; 1321 + if (pmd_soft_dirty(pmd)) 1322 + flags |= PM_SOFT_DIRTY; 1321 1323 if (pm->show_pfn) 1322 1324 frame = pmd_pfn(pmd) + 1323 1325 ((addr & ~PMD_MASK) >> PAGE_SHIFT); ··· 1331 1329 frame = swp_type(entry) | 1332 1330 (swp_offset(entry) << MAX_SWAPFILES_SHIFT); 1333 1331 flags |= PM_SWAP; 1332 + if (pmd_swp_soft_dirty(pmd)) 1333 + flags |= PM_SOFT_DIRTY; 1334 1334 VM_BUG_ON(!is_pmd_migration_entry(pmd)); 1335 1335 page = migration_entry_to_page(entry); 1336 1336 }
+4
include/linux/swap.h
··· 266 266 * both locks need hold, hold swap_lock 267 267 * first. 268 268 */ 269 + spinlock_t cont_lock; /* 270 + * protect swap count continuation page 271 + * list. 272 + */ 269 273 struct work_struct discard_work; /* discard worker */ 270 274 struct swap_cluster_list discard_clusters; /* discard clusters list */ 271 275 };
+3
mm/huge_memory.c
··· 941 941 pmd = pmd_swp_mksoft_dirty(pmd); 942 942 set_pmd_at(src_mm, addr, src_pmd, pmd); 943 943 } 944 + add_mm_counter(dst_mm, MM_ANONPAGES, HPAGE_PMD_NR); 945 + atomic_long_inc(&dst_mm->nr_ptes); 946 + pgtable_trans_huge_deposit(dst_mm, dst_pmd, pgtable); 944 947 set_pmd_at(dst_mm, addr, dst_pmd, pmd); 945 948 ret = 0; 946 949 goto out_unlock;
+30 -2
mm/hugetlb.c
··· 3984 3984 unsigned long src_addr, 3985 3985 struct page **pagep) 3986 3986 { 3987 + struct address_space *mapping; 3988 + pgoff_t idx; 3989 + unsigned long size; 3987 3990 int vm_shared = dst_vma->vm_flags & VM_SHARED; 3988 3991 struct hstate *h = hstate_vma(dst_vma); 3989 3992 pte_t _dst_pte; ··· 4024 4021 __SetPageUptodate(page); 4025 4022 set_page_huge_active(page); 4026 4023 4024 + mapping = dst_vma->vm_file->f_mapping; 4025 + idx = vma_hugecache_offset(h, dst_vma, dst_addr); 4026 + 4027 4027 /* 4028 4028 * If shared, add to page cache 4029 4029 */ 4030 4030 if (vm_shared) { 4031 - struct address_space *mapping = dst_vma->vm_file->f_mapping; 4032 - pgoff_t idx = vma_hugecache_offset(h, dst_vma, dst_addr); 4031 + size = i_size_read(mapping->host) >> huge_page_shift(h); 4032 + ret = -EFAULT; 4033 + if (idx >= size) 4034 + goto out_release_nounlock; 4033 4035 4036 + /* 4037 + * Serialization between remove_inode_hugepages() and 4038 + * huge_add_to_page_cache() below happens through the 4039 + * hugetlb_fault_mutex_table that here must be hold by 4040 + * the caller. 4041 + */ 4034 4042 ret = huge_add_to_page_cache(page, mapping, idx); 4035 4043 if (ret) 4036 4044 goto out_release_nounlock; ··· 4049 4035 4050 4036 ptl = huge_pte_lockptr(h, dst_mm, dst_pte); 4051 4037 spin_lock(ptl); 4038 + 4039 + /* 4040 + * Recheck the i_size after holding PT lock to make sure not 4041 + * to leave any page mapped (as page_mapped()) beyond the end 4042 + * of the i_size (remove_inode_hugepages() is strict about 4043 + * enforcing that). If we bail out here, we'll also leave a 4044 + * page in the radix tree in the vm_shared case beyond the end 4045 + * of the i_size, but remove_inode_hugepages() will take care 4046 + * of it as soon as we drop the hugetlb_fault_mutex_table. 4047 + */ 4048 + size = i_size_read(mapping->host) >> huge_page_shift(h); 4049 + ret = -EFAULT; 4050 + if (idx >= size) 4051 + goto out_release_unlock; 4052 4052 4053 4053 ret = -EEXIST; 4054 4054 if (!huge_pte_none(huge_ptep_get(dst_pte)))
+17 -6
mm/swapfile.c
··· 2869 2869 p->flags = SWP_USED; 2870 2870 spin_unlock(&swap_lock); 2871 2871 spin_lock_init(&p->lock); 2872 + spin_lock_init(&p->cont_lock); 2872 2873 2873 2874 return p; 2874 2875 } ··· 3546 3545 head = vmalloc_to_page(si->swap_map + offset); 3547 3546 offset &= ~PAGE_MASK; 3548 3547 3548 + spin_lock(&si->cont_lock); 3549 3549 /* 3550 3550 * Page allocation does not initialize the page's lru field, 3551 3551 * but it does always reset its private field. ··· 3566 3564 * a continuation page, free our allocation and use this one. 3567 3565 */ 3568 3566 if (!(count & COUNT_CONTINUED)) 3569 - goto out; 3567 + goto out_unlock_cont; 3570 3568 3571 3569 map = kmap_atomic(list_page) + offset; 3572 3570 count = *map; ··· 3577 3575 * free our allocation and use this one. 3578 3576 */ 3579 3577 if ((count & ~COUNT_CONTINUED) != SWAP_CONT_MAX) 3580 - goto out; 3578 + goto out_unlock_cont; 3581 3579 } 3582 3580 3583 3581 list_add_tail(&page->lru, &head->lru); 3584 3582 page = NULL; /* now it's attached, don't free it */ 3583 + out_unlock_cont: 3584 + spin_unlock(&si->cont_lock); 3585 3585 out: 3586 3586 unlock_cluster(ci); 3587 3587 spin_unlock(&si->lock); ··· 3608 3604 struct page *head; 3609 3605 struct page *page; 3610 3606 unsigned char *map; 3607 + bool ret; 3611 3608 3612 3609 head = vmalloc_to_page(si->swap_map + offset); 3613 3610 if (page_private(head) != SWP_CONTINUED) { ··· 3616 3611 return false; /* need to add count continuation */ 3617 3612 } 3618 3613 3614 + spin_lock(&si->cont_lock); 3619 3615 offset &= ~PAGE_MASK; 3620 3616 page = list_entry(head->lru.next, struct page, lru); 3621 3617 map = kmap_atomic(page) + offset; ··· 3637 3631 if (*map == SWAP_CONT_MAX) { 3638 3632 kunmap_atomic(map); 3639 3633 page = list_entry(page->lru.next, struct page, lru); 3640 - if (page == head) 3641 - return false; /* add count continuation */ 3634 + if (page == head) { 3635 + ret = false; /* add count continuation */ 3636 + goto out; 3637 + } 3642 3638 map = kmap_atomic(page) + offset; 3643 3639 init_map: *map = 0; /* we didn't zero the page */ 3644 3640 } ··· 3653 3645 kunmap_atomic(map); 3654 3646 page = list_entry(page->lru.prev, struct page, lru); 3655 3647 } 3656 - return true; /* incremented */ 3648 + ret = true; /* incremented */ 3657 3649 3658 3650 } else { /* decrementing */ 3659 3651 /* ··· 3679 3671 kunmap_atomic(map); 3680 3672 page = list_entry(page->lru.prev, struct page, lru); 3681 3673 } 3682 - return count == COUNT_CONTINUED; 3674 + ret = count == COUNT_CONTINUED; 3683 3675 } 3676 + out: 3677 + spin_unlock(&si->cont_lock); 3678 + return ret; 3684 3679 } 3685 3680 3686 3681 /*
+5 -4
usr/Makefile
··· 8 8 9 9 suffix_y = $(subst $\",,$(CONFIG_INITRAMFS_COMPRESSION)) 10 10 datafile_y = initramfs_data.cpio$(suffix_y) 11 + datafile_d_y = .$(datafile_y).d 11 12 AFLAGS_initramfs_data.o += -DINITRAMFS_IMAGE="usr/$(datafile_y)" 12 13 13 14 ··· 31 30 $(if $(CONFIG_INITRAMFS_ROOT_UID), -u $(CONFIG_INITRAMFS_ROOT_UID)) \ 32 31 $(if $(CONFIG_INITRAMFS_ROOT_GID), -g $(CONFIG_INITRAMFS_ROOT_GID)) 33 32 34 - # .initramfs_data.cpio.d is used to identify all files included 33 + # $(datafile_d_y) is used to identify all files included 35 34 # in initramfs and to detect if any files are added/removed. 36 35 # Removed files are identified by directory timestamp being updated 37 36 # The dependency list is generated by gen_initramfs.sh -l 38 - ifneq ($(wildcard $(obj)/.initramfs_data.cpio.d),) 39 - include $(obj)/.initramfs_data.cpio.d 37 + ifneq ($(wildcard $(obj)/$(datafile_d_y)),) 38 + include $(obj)/$(datafile_d_y) 40 39 endif 41 40 42 41 quiet_cmd_initfs = GEN $@ ··· 54 53 # 3) If gen_init_cpio are newer than initramfs_data.cpio 55 54 # 4) arguments to gen_initramfs.sh changes 56 55 $(obj)/$(datafile_y): $(obj)/gen_init_cpio $(deps_initramfs) klibcdirs 57 - $(Q)$(initramfs) -l $(ramfs-input) > $(obj)/.initramfs_data.cpio.d 56 + $(Q)$(initramfs) -l $(ramfs-input) > $(obj)/$(datafile_d_y) 58 57 $(call if_changed,initfs)