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:
"16 fixes"

* emailed patches from Andrew Morton <akpm@linux-foundation.org>:
mm/memblock.c: fix a typo in __next_mem_pfn_range() comments
mm, page_alloc: check for max order in hot path
scripts/spdxcheck.py: make python3 compliant
tmpfs: make lseek(SEEK_DATA/SEK_HOLE) return ENXIO with a negative offset
lib/ubsan.c: don't mark __ubsan_handle_builtin_unreachable as noreturn
mm/vmstat.c: fix NUMA statistics updates
mm/gup.c: fix follow_page_mask() kerneldoc comment
ocfs2: free up write context when direct IO failed
scripts/faddr2line: fix location of start_kernel in comment
mm: don't reclaim inodes with many attached pages
mm, memory_hotplug: check zone_movable in has_unmovable_pages
mm/swapfile.c: use kvzalloc for swap_info_struct allocation
MAINTAINERS: update OMAP MMC entry
hugetlbfs: fix kernel BUG at fs/hugetlbfs/inode.c:444!
kernel/sched/psi.c: simplify cgroup_move_task()
z3fold: fix possible reclaim races

+172 -100
+4
CREDITS
··· 2138 2138 D: Soundblaster driver fixes, ISAPnP quirk 2139 2139 S: California, USA 2140 2140 2141 + N: Jarkko Lavinen 2142 + E: jarkko.lavinen@nokia.com 2143 + D: OMAP MMC support 2144 + 2141 2145 N: Jonathan Layes 2142 2146 D: ARPD support 2143 2147
+2 -2
MAINTAINERS
··· 10808 10808 F: drivers/staging/media/omap4iss/ 10809 10809 10810 10810 OMAP MMC SUPPORT 10811 - M: Jarkko Lavinen <jarkko.lavinen@nokia.com> 10811 + M: Aaro Koskinen <aaro.koskinen@iki.fi> 10812 10812 L: linux-omap@vger.kernel.org 10813 - S: Maintained 10813 + S: Odd Fixes 10814 10814 F: drivers/mmc/host/omap.c 10815 10815 10816 10816 OMAP POWER MANAGEMENT SUPPORT
+5 -2
fs/inode.c
··· 730 730 return LRU_REMOVED; 731 731 } 732 732 733 - /* recently referenced inodes get one more pass */ 734 - if (inode->i_state & I_REFERENCED) { 733 + /* 734 + * Recently referenced inodes and inodes with many attached pages 735 + * get one more pass. 736 + */ 737 + if (inode->i_state & I_REFERENCED || inode->i_data.nrpages > 1) { 735 738 inode->i_state &= ~I_REFERENCED; 736 739 spin_unlock(&inode->i_lock); 737 740 return LRU_ROTATE;
+10 -2
fs/ocfs2/aops.c
··· 2411 2411 /* this io's submitter should not have unlocked this before we could */ 2412 2412 BUG_ON(!ocfs2_iocb_is_rw_locked(iocb)); 2413 2413 2414 - if (bytes > 0 && private) 2415 - ret = ocfs2_dio_end_io_write(inode, private, offset, bytes); 2414 + if (bytes <= 0) 2415 + mlog_ratelimited(ML_ERROR, "Direct IO failed, bytes = %lld", 2416 + (long long)bytes); 2417 + if (private) { 2418 + if (bytes > 0) 2419 + ret = ocfs2_dio_end_io_write(inode, private, offset, 2420 + bytes); 2421 + else 2422 + ocfs2_dio_free_write_ctx(inode, private); 2423 + } 2416 2424 2417 2425 ocfs2_iocb_clear_rw_locked(iocb); 2418 2426
+9
fs/ocfs2/cluster/masklog.h
··· 178 178 ##__VA_ARGS__); \ 179 179 } while (0) 180 180 181 + #define mlog_ratelimited(mask, fmt, ...) \ 182 + do { \ 183 + static DEFINE_RATELIMIT_STATE(_rs, \ 184 + DEFAULT_RATELIMIT_INTERVAL, \ 185 + DEFAULT_RATELIMIT_BURST); \ 186 + if (__ratelimit(&_rs)) \ 187 + mlog(mask, fmt, ##__VA_ARGS__); \ 188 + } while (0) 189 + 181 190 #define mlog_errno(st) ({ \ 182 191 int _st = (st); \ 183 192 if (_st != -ERESTARTSYS && _st != -EINTR && \
+24 -23
kernel/sched/psi.c
··· 633 633 */ 634 634 void cgroup_move_task(struct task_struct *task, struct css_set *to) 635 635 { 636 - bool move_psi = !psi_disabled; 637 636 unsigned int task_flags = 0; 638 637 struct rq_flags rf; 639 638 struct rq *rq; 640 639 641 - if (move_psi) { 642 - rq = task_rq_lock(task, &rf); 643 - 644 - if (task_on_rq_queued(task)) 645 - task_flags = TSK_RUNNING; 646 - else if (task->in_iowait) 647 - task_flags = TSK_IOWAIT; 648 - 649 - if (task->flags & PF_MEMSTALL) 650 - task_flags |= TSK_MEMSTALL; 651 - 652 - if (task_flags) 653 - psi_task_change(task, task_flags, 0); 640 + if (psi_disabled) { 641 + /* 642 + * Lame to do this here, but the scheduler cannot be locked 643 + * from the outside, so we move cgroups from inside sched/. 644 + */ 645 + rcu_assign_pointer(task->cgroups, to); 646 + return; 654 647 } 655 648 656 - /* 657 - * Lame to do this here, but the scheduler cannot be locked 658 - * from the outside, so we move cgroups from inside sched/. 659 - */ 649 + rq = task_rq_lock(task, &rf); 650 + 651 + if (task_on_rq_queued(task)) 652 + task_flags = TSK_RUNNING; 653 + else if (task->in_iowait) 654 + task_flags = TSK_IOWAIT; 655 + 656 + if (task->flags & PF_MEMSTALL) 657 + task_flags |= TSK_MEMSTALL; 658 + 659 + if (task_flags) 660 + psi_task_change(task, task_flags, 0); 661 + 662 + /* See comment above */ 660 663 rcu_assign_pointer(task->cgroups, to); 661 664 662 - if (move_psi) { 663 - if (task_flags) 664 - psi_task_change(task, 0, task_flags); 665 + if (task_flags) 666 + psi_task_change(task, 0, task_flags); 665 667 666 - task_rq_unlock(rq, task, &rf); 667 - } 668 + task_rq_unlock(rq, task, &rf); 668 669 } 669 670 #endif /* CONFIG_CGROUPS */ 670 671
+1 -2
lib/ubsan.c
··· 427 427 EXPORT_SYMBOL(__ubsan_handle_shift_out_of_bounds); 428 428 429 429 430 - void __noreturn 431 - __ubsan_handle_builtin_unreachable(struct unreachable_data *data) 430 + void __ubsan_handle_builtin_unreachable(struct unreachable_data *data) 432 431 { 433 432 unsigned long flags; 434 433
+8 -2
mm/gup.c
··· 385 385 * @vma: vm_area_struct mapping @address 386 386 * @address: virtual address to look up 387 387 * @flags: flags modifying lookup behaviour 388 - * @page_mask: on output, *page_mask is set according to the size of the page 388 + * @ctx: contains dev_pagemap for %ZONE_DEVICE memory pinning and a 389 + * pointer to output page_mask 389 390 * 390 391 * @flags can have FOLL_ flags set, defined in <linux/mm.h> 391 392 * 392 - * Returns the mapped (struct page *), %NULL if no mapping exists, or 393 + * When getting pages from ZONE_DEVICE memory, the @ctx->pgmap caches 394 + * the device's dev_pagemap metadata to avoid repeating expensive lookups. 395 + * 396 + * On output, the @ctx->page_mask is set according to the size of the page. 397 + * 398 + * Return: the mapped (struct page *), %NULL if no mapping exists, or 393 399 * an error pointer if there is a mapping to something not represented 394 400 * by a page descriptor (see also vm_normal_page()). 395 401 */
+19 -4
mm/hugetlb.c
··· 3233 3233 int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src, 3234 3234 struct vm_area_struct *vma) 3235 3235 { 3236 - pte_t *src_pte, *dst_pte, entry; 3236 + pte_t *src_pte, *dst_pte, entry, dst_entry; 3237 3237 struct page *ptepage; 3238 3238 unsigned long addr; 3239 3239 int cow; ··· 3261 3261 break; 3262 3262 } 3263 3263 3264 - /* If the pagetables are shared don't copy or take references */ 3265 - if (dst_pte == src_pte) 3264 + /* 3265 + * If the pagetables are shared don't copy or take references. 3266 + * dst_pte == src_pte is the common case of src/dest sharing. 3267 + * 3268 + * However, src could have 'unshared' and dst shares with 3269 + * another vma. If dst_pte !none, this implies sharing. 3270 + * Check here before taking page table lock, and once again 3271 + * after taking the lock below. 3272 + */ 3273 + dst_entry = huge_ptep_get(dst_pte); 3274 + if ((dst_pte == src_pte) || !huge_pte_none(dst_entry)) 3266 3275 continue; 3267 3276 3268 3277 dst_ptl = huge_pte_lock(h, dst, dst_pte); 3269 3278 src_ptl = huge_pte_lockptr(h, src, src_pte); 3270 3279 spin_lock_nested(src_ptl, SINGLE_DEPTH_NESTING); 3271 3280 entry = huge_ptep_get(src_pte); 3272 - if (huge_pte_none(entry)) { /* skip none entry */ 3281 + dst_entry = huge_ptep_get(dst_pte); 3282 + if (huge_pte_none(entry) || !huge_pte_none(dst_entry)) { 3283 + /* 3284 + * Skip if src entry none. Also, skip in the 3285 + * unlikely case dst entry !none as this implies 3286 + * sharing with another vma. 3287 + */ 3273 3288 ; 3274 3289 } else if (unlikely(is_hugetlb_entry_migration(entry) || 3275 3290 is_hugetlb_entry_hwpoisoned(entry))) {
+1 -1
mm/memblock.c
··· 1179 1179 1180 1180 #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP 1181 1181 /* 1182 - * Common iterator interface used to define for_each_mem_range(). 1182 + * Common iterator interface used to define for_each_mem_pfn_range(). 1183 1183 */ 1184 1184 void __init_memblock __next_mem_pfn_range(int *idx, int nid, 1185 1185 unsigned long *out_start_pfn,
+17 -11
mm/page_alloc.c
··· 4061 4061 int reserve_flags; 4062 4062 4063 4063 /* 4064 - * In the slowpath, we sanity check order to avoid ever trying to 4065 - * reclaim >= MAX_ORDER areas which will never succeed. Callers may 4066 - * be using allocators in order of preference for an area that is 4067 - * too large. 4068 - */ 4069 - if (order >= MAX_ORDER) { 4070 - WARN_ON_ONCE(!(gfp_mask & __GFP_NOWARN)); 4071 - return NULL; 4072 - } 4073 - 4074 - /* 4075 4064 * We also sanity check to catch abuse of atomic reserves being used by 4076 4065 * callers that are not in atomic context. 4077 4066 */ ··· 4352 4363 unsigned int alloc_flags = ALLOC_WMARK_LOW; 4353 4364 gfp_t alloc_mask; /* The gfp_t that was actually used for allocation */ 4354 4365 struct alloc_context ac = { }; 4366 + 4367 + /* 4368 + * There are several places where we assume that the order value is sane 4369 + * so bail out early if the request is out of bound. 4370 + */ 4371 + if (unlikely(order >= MAX_ORDER)) { 4372 + WARN_ON_ONCE(!(gfp_mask & __GFP_NOWARN)); 4373 + return NULL; 4374 + } 4355 4375 4356 4376 gfp_mask &= gfp_allowed_mask; 4357 4377 alloc_mask = gfp_mask; ··· 7785 7787 7786 7788 if (PageReserved(page)) 7787 7789 goto unmovable; 7790 + 7791 + /* 7792 + * If the zone is movable and we have ruled out all reserved 7793 + * pages then it should be reasonably safe to assume the rest 7794 + * is movable. 7795 + */ 7796 + if (zone_idx(zone) == ZONE_MOVABLE) 7797 + continue; 7788 7798 7789 7799 /* 7790 7800 * Hugepages are not in LRU lists, but they're movable.
+1 -3
mm/shmem.c
··· 2563 2563 inode_lock(inode); 2564 2564 /* We're holding i_mutex so we can access i_size directly */ 2565 2565 2566 - if (offset < 0) 2567 - offset = -EINVAL; 2568 - else if (offset >= inode->i_size) 2566 + if (offset < 0 || offset >= inode->i_size) 2569 2567 offset = -ENXIO; 2570 2568 else { 2571 2569 start = offset >> PAGE_SHIFT;
+3 -3
mm/swapfile.c
··· 2813 2813 unsigned int type; 2814 2814 int i; 2815 2815 2816 - p = kzalloc(sizeof(*p), GFP_KERNEL); 2816 + p = kvzalloc(sizeof(*p), GFP_KERNEL); 2817 2817 if (!p) 2818 2818 return ERR_PTR(-ENOMEM); 2819 2819 ··· 2824 2824 } 2825 2825 if (type >= MAX_SWAPFILES) { 2826 2826 spin_unlock(&swap_lock); 2827 - kfree(p); 2827 + kvfree(p); 2828 2828 return ERR_PTR(-EPERM); 2829 2829 } 2830 2830 if (type >= nr_swapfiles) { ··· 2838 2838 smp_wmb(); 2839 2839 nr_swapfiles++; 2840 2840 } else { 2841 - kfree(p); 2841 + kvfree(p); 2842 2842 p = swap_info[type]; 2843 2843 /* 2844 2844 * Do not memset this entry: a racing procfs swap_next()
+4 -3
mm/vmstat.c
··· 1827 1827 1828 1828 /* 1829 1829 * The fast way of checking if there are any vmstat diffs. 1830 - * This works because the diffs are byte sized items. 1831 1830 */ 1832 - if (memchr_inv(p->vm_stat_diff, 0, NR_VM_ZONE_STAT_ITEMS)) 1831 + if (memchr_inv(p->vm_stat_diff, 0, NR_VM_ZONE_STAT_ITEMS * 1832 + sizeof(p->vm_stat_diff[0]))) 1833 1833 return true; 1834 1834 #ifdef CONFIG_NUMA 1835 - if (memchr_inv(p->vm_numa_stat_diff, 0, NR_VM_NUMA_STAT_ITEMS)) 1835 + if (memchr_inv(p->vm_numa_stat_diff, 0, NR_VM_NUMA_STAT_ITEMS * 1836 + sizeof(p->vm_numa_stat_diff[0]))) 1836 1837 return true; 1837 1838 #endif 1838 1839 }
+63 -40
mm/z3fold.c
··· 99 99 #define NCHUNKS ((PAGE_SIZE - ZHDR_SIZE_ALIGNED) >> CHUNK_SHIFT) 100 100 101 101 #define BUDDY_MASK (0x3) 102 + #define BUDDY_SHIFT 2 102 103 103 104 /** 104 105 * struct z3fold_pool - stores metadata for each z3fold pool ··· 146 145 MIDDLE_CHUNK_MAPPED, 147 146 NEEDS_COMPACTING, 148 147 PAGE_STALE, 149 - UNDER_RECLAIM 148 + PAGE_CLAIMED, /* by either reclaim or free */ 150 149 }; 151 150 152 151 /***************** ··· 175 174 clear_bit(MIDDLE_CHUNK_MAPPED, &page->private); 176 175 clear_bit(NEEDS_COMPACTING, &page->private); 177 176 clear_bit(PAGE_STALE, &page->private); 178 - clear_bit(UNDER_RECLAIM, &page->private); 177 + clear_bit(PAGE_CLAIMED, &page->private); 179 178 180 179 spin_lock_init(&zhdr->page_lock); 181 180 kref_init(&zhdr->refcount); ··· 224 223 unsigned long handle; 225 224 226 225 handle = (unsigned long)zhdr; 227 - if (bud != HEADLESS) 228 - handle += (bud + zhdr->first_num) & BUDDY_MASK; 226 + if (bud != HEADLESS) { 227 + handle |= (bud + zhdr->first_num) & BUDDY_MASK; 228 + if (bud == LAST) 229 + handle |= (zhdr->last_chunks << BUDDY_SHIFT); 230 + } 229 231 return handle; 230 232 } 231 233 ··· 236 232 static struct z3fold_header *handle_to_z3fold_header(unsigned long handle) 237 233 { 238 234 return (struct z3fold_header *)(handle & PAGE_MASK); 235 + } 236 + 237 + /* only for LAST bud, returns zero otherwise */ 238 + static unsigned short handle_to_chunks(unsigned long handle) 239 + { 240 + return (handle & ~PAGE_MASK) >> BUDDY_SHIFT; 239 241 } 240 242 241 243 /* ··· 730 720 page = virt_to_page(zhdr); 731 721 732 722 if (test_bit(PAGE_HEADLESS, &page->private)) { 733 - /* HEADLESS page stored */ 734 - bud = HEADLESS; 735 - } else { 736 - z3fold_page_lock(zhdr); 737 - bud = handle_to_buddy(handle); 738 - 739 - switch (bud) { 740 - case FIRST: 741 - zhdr->first_chunks = 0; 742 - break; 743 - case MIDDLE: 744 - zhdr->middle_chunks = 0; 745 - zhdr->start_middle = 0; 746 - break; 747 - case LAST: 748 - zhdr->last_chunks = 0; 749 - break; 750 - default: 751 - pr_err("%s: unknown bud %d\n", __func__, bud); 752 - WARN_ON(1); 753 - z3fold_page_unlock(zhdr); 754 - return; 723 + /* if a headless page is under reclaim, just leave. 724 + * NB: we use test_and_set_bit for a reason: if the bit 725 + * has not been set before, we release this page 726 + * immediately so we don't care about its value any more. 727 + */ 728 + if (!test_and_set_bit(PAGE_CLAIMED, &page->private)) { 729 + spin_lock(&pool->lock); 730 + list_del(&page->lru); 731 + spin_unlock(&pool->lock); 732 + free_z3fold_page(page); 733 + atomic64_dec(&pool->pages_nr); 755 734 } 735 + return; 756 736 } 757 737 758 - if (bud == HEADLESS) { 759 - spin_lock(&pool->lock); 760 - list_del(&page->lru); 761 - spin_unlock(&pool->lock); 762 - free_z3fold_page(page); 763 - atomic64_dec(&pool->pages_nr); 738 + /* Non-headless case */ 739 + z3fold_page_lock(zhdr); 740 + bud = handle_to_buddy(handle); 741 + 742 + switch (bud) { 743 + case FIRST: 744 + zhdr->first_chunks = 0; 745 + break; 746 + case MIDDLE: 747 + zhdr->middle_chunks = 0; 748 + break; 749 + case LAST: 750 + zhdr->last_chunks = 0; 751 + break; 752 + default: 753 + pr_err("%s: unknown bud %d\n", __func__, bud); 754 + WARN_ON(1); 755 + z3fold_page_unlock(zhdr); 764 756 return; 765 757 } 766 758 ··· 770 758 atomic64_dec(&pool->pages_nr); 771 759 return; 772 760 } 773 - if (test_bit(UNDER_RECLAIM, &page->private)) { 761 + if (test_bit(PAGE_CLAIMED, &page->private)) { 774 762 z3fold_page_unlock(zhdr); 775 763 return; 776 764 } ··· 848 836 } 849 837 list_for_each_prev(pos, &pool->lru) { 850 838 page = list_entry(pos, struct page, lru); 851 - if (test_bit(PAGE_HEADLESS, &page->private)) 852 - /* candidate found */ 853 - break; 839 + 840 + /* this bit could have been set by free, in which case 841 + * we pass over to the next page in the pool. 842 + */ 843 + if (test_and_set_bit(PAGE_CLAIMED, &page->private)) 844 + continue; 854 845 855 846 zhdr = page_address(page); 856 - if (!z3fold_page_trylock(zhdr)) 847 + if (test_bit(PAGE_HEADLESS, &page->private)) 848 + break; 849 + 850 + if (!z3fold_page_trylock(zhdr)) { 851 + zhdr = NULL; 857 852 continue; /* can't evict at this point */ 853 + } 858 854 kref_get(&zhdr->refcount); 859 855 list_del_init(&zhdr->buddy); 860 856 zhdr->cpu = -1; 861 - set_bit(UNDER_RECLAIM, &page->private); 862 857 break; 863 858 } 859 + 860 + if (!zhdr) 861 + break; 864 862 865 863 list_del_init(&page->lru); 866 864 spin_unlock(&pool->lock); ··· 920 898 if (test_bit(PAGE_HEADLESS, &page->private)) { 921 899 if (ret == 0) { 922 900 free_z3fold_page(page); 901 + atomic64_dec(&pool->pages_nr); 923 902 return 0; 924 903 } 925 904 spin_lock(&pool->lock); ··· 928 905 spin_unlock(&pool->lock); 929 906 } else { 930 907 z3fold_page_lock(zhdr); 931 - clear_bit(UNDER_RECLAIM, &page->private); 908 + clear_bit(PAGE_CLAIMED, &page->private); 932 909 if (kref_put(&zhdr->refcount, 933 910 release_z3fold_page_locked)) { 934 911 atomic64_dec(&pool->pages_nr); ··· 987 964 set_bit(MIDDLE_CHUNK_MAPPED, &page->private); 988 965 break; 989 966 case LAST: 990 - addr += PAGE_SIZE - (zhdr->last_chunks << CHUNK_SHIFT); 967 + addr += PAGE_SIZE - (handle_to_chunks(handle) << CHUNK_SHIFT); 991 968 break; 992 969 default: 993 970 pr_err("unknown buddy id %d\n", buddy);
+1 -1
scripts/faddr2line
··· 71 71 72 72 # Try to figure out the source directory prefix so we can remove it from the 73 73 # addr2line output. HACK ALERT: This assumes that start_kernel() is in 74 - # kernel/init.c! This only works for vmlinux. Otherwise it falls back to 74 + # init/main.c! This only works for vmlinux. Otherwise it falls back to 75 75 # printing the absolute path. 76 76 find_dir_prefix() { 77 77 local objfile=$1
-1
scripts/spdxcheck.py
··· 168 168 self.curline = 0 169 169 try: 170 170 for line in fd: 171 - line = line.decode(locale.getpreferredencoding(False), errors='ignore') 172 171 self.curline += 1 173 172 if self.curline > maxlines: 174 173 break