Skip to content

Commit c67a98c

Browse files
committed
Merge branch 'akpm' (patches from Andrew)
Merge misc fixes from Andrew Morton: "16 fixes" * emailed patches from Andrew Morton <[email protected]>: 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
2 parents 03582f3 + 45e7981 commit c67a98c

File tree

17 files changed

+169
-97
lines changed

17 files changed

+169
-97
lines changed

CREDITS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2138,6 +2138,10 @@ E: [email protected]
21382138
D: Soundblaster driver fixes, ISAPnP quirk
21392139
S: California, USA
21402140

2141+
N: Jarkko Lavinen
2142+
2143+
D: OMAP MMC support
2144+
21412145
N: Jonathan Layes
21422146
D: ARPD support
21432147

MAINTAINERS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10808,9 +10808,9 @@ F: drivers/media/platform/omap3isp/
1080810808
F: drivers/staging/media/omap4iss/
1080910809

1081010810
OMAP MMC SUPPORT
10811-
M: Jarkko Lavinen <[email protected]>
10811+
M: Aaro Koskinen <[email protected]>
1081210812
10813-
S: Maintained
10813+
S: Odd Fixes
1081410814
F: drivers/mmc/host/omap.c
1081510815

1081610816
OMAP POWER MANAGEMENT SUPPORT

fs/inode.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -730,8 +730,11 @@ static enum lru_status inode_lru_isolate(struct list_head *item,
730730
return LRU_REMOVED;
731731
}
732732

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) {
735738
inode->i_state &= ~I_REFERENCED;
736739
spin_unlock(&inode->i_lock);
737740
return LRU_ROTATE;

fs/ocfs2/aops.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2411,8 +2411,16 @@ static int ocfs2_dio_end_io(struct kiocb *iocb,
24112411
/* this io's submitter should not have unlocked this before we could */
24122412
BUG_ON(!ocfs2_iocb_is_rw_locked(iocb));
24132413

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+
}
24162424

24172425
ocfs2_iocb_clear_rw_locked(iocb);
24182426

fs/ocfs2/cluster/masklog.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,15 @@ do { \
178178
##__VA_ARGS__); \
179179
} while (0)
180180

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+
181190
#define mlog_errno(st) ({ \
182191
int _st = (st); \
183192
if (_st != -ERESTARTSYS && _st != -EINTR && \

kernel/sched/psi.c

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -633,38 +633,39 @@ void psi_cgroup_free(struct cgroup *cgroup)
633633
*/
634634
void cgroup_move_task(struct task_struct *task, struct css_set *to)
635635
{
636-
bool move_psi = !psi_disabled;
637636
unsigned int task_flags = 0;
638637
struct rq_flags rf;
639638
struct rq *rq;
640639

641-
if (move_psi) {
642-
rq = task_rq_lock(task, &rf);
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;
647+
}
643648

644-
if (task_on_rq_queued(task))
645-
task_flags = TSK_RUNNING;
646-
else if (task->in_iowait)
647-
task_flags = TSK_IOWAIT;
649+
rq = task_rq_lock(task, &rf);
648650

649-
if (task->flags & PF_MEMSTALL)
650-
task_flags |= TSK_MEMSTALL;
651+
if (task_on_rq_queued(task))
652+
task_flags = TSK_RUNNING;
653+
else if (task->in_iowait)
654+
task_flags = TSK_IOWAIT;
651655

652-
if (task_flags)
653-
psi_task_change(task, task_flags, 0);
654-
}
656+
if (task->flags & PF_MEMSTALL)
657+
task_flags |= TSK_MEMSTALL;
655658

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-
*/
659+
if (task_flags)
660+
psi_task_change(task, task_flags, 0);
661+
662+
/* See comment above */
660663
rcu_assign_pointer(task->cgroups, to);
661664

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);
665667

666-
task_rq_unlock(rq, task, &rf);
667-
}
668+
task_rq_unlock(rq, task, &rf);
668669
}
669670
#endif /* CONFIG_CGROUPS */
670671

lib/ubsan.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,8 +427,7 @@ void __ubsan_handle_shift_out_of_bounds(struct shift_out_of_bounds_data *data,
427427
EXPORT_SYMBOL(__ubsan_handle_shift_out_of_bounds);
428428

429429

430-
void __noreturn
431-
__ubsan_handle_builtin_unreachable(struct unreachable_data *data)
430+
void __ubsan_handle_builtin_unreachable(struct unreachable_data *data)
432431
{
433432
unsigned long flags;
434433

mm/gup.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,11 +385,17 @@ static struct page *follow_p4d_mask(struct vm_area_struct *vma,
385385
* @vma: vm_area_struct mapping @address
386386
* @address: virtual address to look up
387387
* @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
389390
*
390391
* @flags can have FOLL_ flags set, defined in <linux/mm.h>
391392
*
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
393399
* an error pointer if there is a mapping to something not represented
394400
* by a page descriptor (see also vm_normal_page()).
395401
*/

mm/hugetlb.c

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3233,7 +3233,7 @@ static int is_hugetlb_entry_hwpoisoned(pte_t pte)
32333233
int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src,
32343234
struct vm_area_struct *vma)
32353235
{
3236-
pte_t *src_pte, *dst_pte, entry;
3236+
pte_t *src_pte, *dst_pte, entry, dst_entry;
32373237
struct page *ptepage;
32383238
unsigned long addr;
32393239
int cow;
@@ -3261,15 +3261,30 @@ int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src,
32613261
break;
32623262
}
32633263

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))
32663275
continue;
32673276

32683277
dst_ptl = huge_pte_lock(h, dst, dst_pte);
32693278
src_ptl = huge_pte_lockptr(h, src, src_pte);
32703279
spin_lock_nested(src_ptl, SINGLE_DEPTH_NESTING);
32713280
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+
*/
32733288
;
32743289
} else if (unlikely(is_hugetlb_entry_migration(entry) ||
32753290
is_hugetlb_entry_hwpoisoned(entry))) {

mm/memblock.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1179,7 +1179,7 @@ void __init_memblock __next_mem_range_rev(u64 *idx, int nid,
11791179

11801180
#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
11811181
/*
1182-
* Common iterator interface used to define for_each_mem_range().
1182+
* Common iterator interface used to define for_each_mem_pfn_range().
11831183
*/
11841184
void __init_memblock __next_mem_pfn_range(int *idx, int nid,
11851185
unsigned long *out_start_pfn,

mm/page_alloc.c

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4060,17 +4060,6 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
40604060
unsigned int cpuset_mems_cookie;
40614061
int reserve_flags;
40624062

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-
40744063
/*
40754064
* We also sanity check to catch abuse of atomic reserves being used by
40764065
* callers that are not in atomic context.
@@ -4364,6 +4353,15 @@ __alloc_pages_nodemask(gfp_t gfp_mask, unsigned int order, int preferred_nid,
43644353
gfp_t alloc_mask; /* The gfp_t that was actually used for allocation */
43654354
struct alloc_context ac = { };
43664355

4356+
/*
4357+
* There are several places where we assume that the order value is sane
4358+
* so bail out early if the request is out of bound.
4359+
*/
4360+
if (unlikely(order >= MAX_ORDER)) {
4361+
WARN_ON_ONCE(!(gfp_mask & __GFP_NOWARN));
4362+
return NULL;
4363+
}
4364+
43674365
gfp_mask &= gfp_allowed_mask;
43684366
alloc_mask = gfp_mask;
43694367
if (!prepare_alloc_pages(gfp_mask, order, preferred_nid, nodemask, &ac, &alloc_mask, &alloc_flags))
@@ -7788,6 +7786,14 @@ bool has_unmovable_pages(struct zone *zone, struct page *page, int count,
77887786
if (PageReserved(page))
77897787
goto unmovable;
77907788

7789+
/*
7790+
* If the zone is movable and we have ruled out all reserved
7791+
* pages then it should be reasonably safe to assume the rest
7792+
* is movable.
7793+
*/
7794+
if (zone_idx(zone) == ZONE_MOVABLE)
7795+
continue;
7796+
77917797
/*
77927798
* Hugepages are not in LRU lists, but they're movable.
77937799
* We need not scan over tail pages bacause we don't

mm/shmem.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2563,9 +2563,7 @@ static loff_t shmem_file_llseek(struct file *file, loff_t offset, int whence)
25632563
inode_lock(inode);
25642564
/* We're holding i_mutex so we can access i_size directly */
25652565

2566-
if (offset < 0)
2567-
offset = -EINVAL;
2568-
else if (offset >= inode->i_size)
2566+
if (offset < 0 || offset >= inode->i_size)
25692567
offset = -ENXIO;
25702568
else {
25712569
start = offset >> PAGE_SHIFT;

mm/swapfile.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2813,7 +2813,7 @@ static struct swap_info_struct *alloc_swap_info(void)
28132813
unsigned int type;
28142814
int i;
28152815

2816-
p = kzalloc(sizeof(*p), GFP_KERNEL);
2816+
p = kvzalloc(sizeof(*p), GFP_KERNEL);
28172817
if (!p)
28182818
return ERR_PTR(-ENOMEM);
28192819

@@ -2824,7 +2824,7 @@ static struct swap_info_struct *alloc_swap_info(void)
28242824
}
28252825
if (type >= MAX_SWAPFILES) {
28262826
spin_unlock(&swap_lock);
2827-
kfree(p);
2827+
kvfree(p);
28282828
return ERR_PTR(-EPERM);
28292829
}
28302830
if (type >= nr_swapfiles) {
@@ -2838,7 +2838,7 @@ static struct swap_info_struct *alloc_swap_info(void)
28382838
smp_wmb();
28392839
nr_swapfiles++;
28402840
} else {
2841-
kfree(p);
2841+
kvfree(p);
28422842
p = swap_info[type];
28432843
/*
28442844
* Do not memset this entry: a racing procfs swap_next()

mm/vmstat.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1827,12 +1827,13 @@ static bool need_update(int cpu)
18271827

18281828
/*
18291829
* The fast way of checking if there are any vmstat diffs.
1830-
* This works because the diffs are byte sized items.
18311830
*/
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])))
18331833
return true;
18341834
#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])))
18361837
return true;
18371838
#endif
18381839
}

0 commit comments

Comments
 (0)