aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-10-13 19:29:08 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-10-13 19:29:08 -0400
commit06d97c58f65cc747573a3fa8569cca0169e5096e (patch)
treef8379d122eb8e49cface843dc594baef3ceae48e
parente837d9134be8018d15421546c1defd35a1bb3d06 (diff)
parent61b639723be5a9fc4812d5d85cb769589afa5a38 (diff)
Merge branch 'akpm' (patches from Andrew)
Merge misc fixes from Andrew Morton: "18 fixes" * emailed patches from Andrew Morton <akpm@linux-foundation.org>: mm, swap: use page-cluster as max window of VMA based swap readahead mm: page_vma_mapped: ensure pmd is loaded with READ_ONCE outside of lock kmemleak: clear stale pointers from task stacks fs/binfmt_misc.c: node could be NULL when evicting inode fs/mpage.c: fix mpage_writepage() for pages with buffers linux/kernel.h: add/correct kernel-doc notation tty: fall back to N_NULL if switching to N_TTY fails during hangup Revert "vmalloc: back off when the current task is killed" mm/cma.c: take __GFP_NOWARN into account in cma_alloc() scripts/kallsyms.c: ignore symbol type 'n' userfaultfd: selftest: exercise -EEXIST only in background transfer mm: only display online cpus of the numa node mm: remove unnecessary WARN_ONCE in page_vma_mapped_walk(). mm/mempolicy: fix NUMA_INTERLEAVE_HIT counter include/linux/of.h: provide of_n_{addr,size}_cells wrappers for !CONFIG_OF mm/madvise.c: add description for MADV_WIPEONFORK and MADV_KEEPONFORK lib/Kconfig.debug: kernel hacking menu: runtime testing: keep tests together mm/migrate: fix indexing bug (off by one) and avoid out of bound access
-rw-r--r--Documentation/ABI/testing/sysfs-kernel-mm-swap10
-rw-r--r--drivers/base/node.c12
-rw-r--r--drivers/tty/tty_ldisc.c11
-rw-r--r--fs/binfmt_misc.c2
-rw-r--r--fs/block_dev.c6
-rw-r--r--fs/mpage.c14
-rw-r--r--include/linux/buffer_head.h1
-rw-r--r--include/linux/kernel.h90
-rw-r--r--include/linux/of.h10
-rw-r--r--include/linux/thread_info.h2
-rw-r--r--kernel/fork.c4
-rw-r--r--lib/Kconfig.debug143
-rw-r--r--mm/cma.c2
-rw-r--r--mm/madvise.c7
-rw-r--r--mm/mempolicy.c7
-rw-r--r--mm/migrate.c3
-rw-r--r--mm/page_vma_mapped.c28
-rw-r--r--mm/swap_state.c41
-rw-r--r--mm/vmalloc.c6
-rw-r--r--scripts/kallsyms.c2
-rw-r--r--tools/testing/selftests/vm/userfaultfd.c25
21 files changed, 245 insertions, 181 deletions
diff --git a/Documentation/ABI/testing/sysfs-kernel-mm-swap b/Documentation/ABI/testing/sysfs-kernel-mm-swap
index 587db52084c7..94672016c268 100644
--- a/Documentation/ABI/testing/sysfs-kernel-mm-swap
+++ b/Documentation/ABI/testing/sysfs-kernel-mm-swap
@@ -14,13 +14,3 @@ Description: Enable/disable VMA based swap readahead.
14 still used for tmpfs etc. other users. If set to 14 still used for tmpfs etc. other users. If set to
15 false, the global swap readahead algorithm will be 15 false, the global swap readahead algorithm will be
16 used for all swappable pages. 16 used for all swappable pages.
17
18What: /sys/kernel/mm/swap/vma_ra_max_order
19Date: August 2017
20Contact: Linux memory management mailing list <linux-mm@kvack.org>
21Description: The max readahead size in order for VMA based swap readahead
22
23 VMA based swap readahead algorithm will readahead at
24 most 1 << max_order pages for each readahead. The
25 real readahead size for each readahead will be scaled
26 according to the estimation algorithm.
diff --git a/drivers/base/node.c b/drivers/base/node.c
index 3855902f2c5b..aae2402f3791 100644
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -27,13 +27,21 @@ static struct bus_type node_subsys = {
27 27
28static ssize_t node_read_cpumap(struct device *dev, bool list, char *buf) 28static ssize_t node_read_cpumap(struct device *dev, bool list, char *buf)
29{ 29{
30 ssize_t n;
31 cpumask_var_t mask;
30 struct node *node_dev = to_node(dev); 32 struct node *node_dev = to_node(dev);
31 const struct cpumask *mask = cpumask_of_node(node_dev->dev.id);
32 33
33 /* 2008/04/07: buf currently PAGE_SIZE, need 9 chars per 32 bits. */ 34 /* 2008/04/07: buf currently PAGE_SIZE, need 9 chars per 32 bits. */
34 BUILD_BUG_ON((NR_CPUS/32 * 9) > (PAGE_SIZE-1)); 35 BUILD_BUG_ON((NR_CPUS/32 * 9) > (PAGE_SIZE-1));
35 36
36 return cpumap_print_to_pagebuf(list, buf, mask); 37 if (!alloc_cpumask_var(&mask, GFP_KERNEL))
38 return 0;
39
40 cpumask_and(mask, cpumask_of_node(node_dev->dev.id), cpu_online_mask);
41 n = cpumap_print_to_pagebuf(list, buf, mask);
42 free_cpumask_var(mask);
43
44 return n;
37} 45}
38 46
39static inline ssize_t node_read_cpumask(struct device *dev, 47static inline ssize_t node_read_cpumask(struct device *dev,
diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
index 2fe216b276e2..84a8ac2a779f 100644
--- a/drivers/tty/tty_ldisc.c
+++ b/drivers/tty/tty_ldisc.c
@@ -694,10 +694,8 @@ int tty_ldisc_reinit(struct tty_struct *tty, int disc)
694 tty_set_termios_ldisc(tty, disc); 694 tty_set_termios_ldisc(tty, disc);
695 retval = tty_ldisc_open(tty, tty->ldisc); 695 retval = tty_ldisc_open(tty, tty->ldisc);
696 if (retval) { 696 if (retval) {
697 if (!WARN_ON(disc == N_TTY)) { 697 tty_ldisc_put(tty->ldisc);
698 tty_ldisc_put(tty->ldisc); 698 tty->ldisc = NULL;
699 tty->ldisc = NULL;
700 }
701 } 699 }
702 return retval; 700 return retval;
703} 701}
@@ -752,8 +750,9 @@ void tty_ldisc_hangup(struct tty_struct *tty, bool reinit)
752 750
753 if (tty->ldisc) { 751 if (tty->ldisc) {
754 if (reinit) { 752 if (reinit) {
755 if (tty_ldisc_reinit(tty, tty->termios.c_line) < 0) 753 if (tty_ldisc_reinit(tty, tty->termios.c_line) < 0 &&
756 tty_ldisc_reinit(tty, N_TTY); 754 tty_ldisc_reinit(tty, N_TTY) < 0)
755 WARN_ON(tty_ldisc_reinit(tty, N_NULL) < 0);
757 } else 756 } else
758 tty_ldisc_kill(tty); 757 tty_ldisc_kill(tty);
759 } 758 }
diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c
index 2a46762def31..a7c5a9861bef 100644
--- a/fs/binfmt_misc.c
+++ b/fs/binfmt_misc.c
@@ -596,7 +596,7 @@ static void bm_evict_inode(struct inode *inode)
596{ 596{
597 Node *e = inode->i_private; 597 Node *e = inode->i_private;
598 598
599 if (e->flags & MISC_FMT_OPEN_FILE) 599 if (e && e->flags & MISC_FMT_OPEN_FILE)
600 filp_close(e->interp_file, NULL); 600 filp_close(e->interp_file, NULL);
601 601
602 clear_inode(inode); 602 clear_inode(inode);
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 93d088ffc05c..789f55e851ae 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -716,10 +716,12 @@ int bdev_write_page(struct block_device *bdev, sector_t sector,
716 716
717 set_page_writeback(page); 717 set_page_writeback(page);
718 result = ops->rw_page(bdev, sector + get_start_sect(bdev), page, true); 718 result = ops->rw_page(bdev, sector + get_start_sect(bdev), page, true);
719 if (result) 719 if (result) {
720 end_page_writeback(page); 720 end_page_writeback(page);
721 else 721 } else {
722 clean_page_buffers(page);
722 unlock_page(page); 723 unlock_page(page);
724 }
723 blk_queue_exit(bdev->bd_queue); 725 blk_queue_exit(bdev->bd_queue);
724 return result; 726 return result;
725} 727}
diff --git a/fs/mpage.c b/fs/mpage.c
index 37bb77c1302c..c991faec70b9 100644
--- a/fs/mpage.c
+++ b/fs/mpage.c
@@ -468,6 +468,16 @@ static void clean_buffers(struct page *page, unsigned first_unmapped)
468 try_to_free_buffers(page); 468 try_to_free_buffers(page);
469} 469}
470 470
471/*
472 * For situations where we want to clean all buffers attached to a page.
473 * We don't need to calculate how many buffers are attached to the page,
474 * we just need to specify a number larger than the maximum number of buffers.
475 */
476void clean_page_buffers(struct page *page)
477{
478 clean_buffers(page, ~0U);
479}
480
471static int __mpage_writepage(struct page *page, struct writeback_control *wbc, 481static int __mpage_writepage(struct page *page, struct writeback_control *wbc,
472 void *data) 482 void *data)
473{ 483{
@@ -605,10 +615,8 @@ alloc_new:
605 if (bio == NULL) { 615 if (bio == NULL) {
606 if (first_unmapped == blocks_per_page) { 616 if (first_unmapped == blocks_per_page) {
607 if (!bdev_write_page(bdev, blocks[0] << (blkbits - 9), 617 if (!bdev_write_page(bdev, blocks[0] << (blkbits - 9),
608 page, wbc)) { 618 page, wbc))
609 clean_buffers(page, first_unmapped);
610 goto out; 619 goto out;
611 }
612 } 620 }
613 bio = mpage_alloc(bdev, blocks[0] << (blkbits - 9), 621 bio = mpage_alloc(bdev, blocks[0] << (blkbits - 9),
614 BIO_MAX_PAGES, GFP_NOFS|__GFP_HIGH); 622 BIO_MAX_PAGES, GFP_NOFS|__GFP_HIGH);
diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h
index c8dae555eccf..446b24cac67d 100644
--- a/include/linux/buffer_head.h
+++ b/include/linux/buffer_head.h
@@ -232,6 +232,7 @@ int generic_write_end(struct file *, struct address_space *,
232 loff_t, unsigned, unsigned, 232 loff_t, unsigned, unsigned,
233 struct page *, void *); 233 struct page *, void *);
234void page_zero_new_buffers(struct page *page, unsigned from, unsigned to); 234void page_zero_new_buffers(struct page *page, unsigned from, unsigned to);
235void clean_page_buffers(struct page *page);
235int cont_write_begin(struct file *, struct address_space *, loff_t, 236int cont_write_begin(struct file *, struct address_space *, loff_t,
236 unsigned, unsigned, struct page **, void **, 237 unsigned, unsigned, struct page **, void **,
237 get_block_t *, loff_t *); 238 get_block_t *, loff_t *);
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 0ad4c3044cf9..91189bb0c818 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -44,6 +44,12 @@
44 44
45#define STACK_MAGIC 0xdeadbeef 45#define STACK_MAGIC 0xdeadbeef
46 46
47/**
48 * REPEAT_BYTE - repeat the value @x multiple times as an unsigned long value
49 * @x: value to repeat
50 *
51 * NOTE: @x is not checked for > 0xff; larger values produce odd results.
52 */
47#define REPEAT_BYTE(x) ((~0ul / 0xff) * (x)) 53#define REPEAT_BYTE(x) ((~0ul / 0xff) * (x))
48 54
49/* @a is a power of 2 value */ 55/* @a is a power of 2 value */
@@ -57,6 +63,10 @@
57#define READ 0 63#define READ 0
58#define WRITE 1 64#define WRITE 1
59 65
66/**
67 * ARRAY_SIZE - get the number of elements in array @arr
68 * @arr: array to be sized
69 */
60#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr)) 70#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
61 71
62#define u64_to_user_ptr(x) ( \ 72#define u64_to_user_ptr(x) ( \
@@ -76,7 +86,15 @@
76#define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1) 86#define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1)
77#define round_down(x, y) ((x) & ~__round_mask(x, y)) 87#define round_down(x, y) ((x) & ~__round_mask(x, y))
78 88
89/**
90 * FIELD_SIZEOF - get the size of a struct's field
91 * @t: the target struct
92 * @f: the target struct's field
93 * Return: the size of @f in the struct definition without having a
94 * declared instance of @t.
95 */
79#define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f)) 96#define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f))
97
80#define DIV_ROUND_UP __KERNEL_DIV_ROUND_UP 98#define DIV_ROUND_UP __KERNEL_DIV_ROUND_UP
81 99
82#define DIV_ROUND_DOWN_ULL(ll, d) \ 100#define DIV_ROUND_DOWN_ULL(ll, d) \
@@ -107,7 +125,7 @@
107/* 125/*
108 * Divide positive or negative dividend by positive or negative divisor 126 * Divide positive or negative dividend by positive or negative divisor
109 * and round to closest integer. Result is undefined for negative 127 * and round to closest integer. Result is undefined for negative
110 * divisors if he dividend variable type is unsigned and for negative 128 * divisors if the dividend variable type is unsigned and for negative
111 * dividends if the divisor variable type is unsigned. 129 * dividends if the divisor variable type is unsigned.
112 */ 130 */
113#define DIV_ROUND_CLOSEST(x, divisor)( \ 131#define DIV_ROUND_CLOSEST(x, divisor)( \
@@ -247,13 +265,13 @@ extern int _cond_resched(void);
247 * @ep_ro: right open interval endpoint 265 * @ep_ro: right open interval endpoint
248 * 266 *
249 * Perform a "reciprocal multiplication" in order to "scale" a value into 267 * Perform a "reciprocal multiplication" in order to "scale" a value into
250 * range [0, ep_ro), where the upper interval endpoint is right-open. 268 * range [0, @ep_ro), where the upper interval endpoint is right-open.
251 * This is useful, e.g. for accessing a index of an array containing 269 * This is useful, e.g. for accessing a index of an array containing
252 * ep_ro elements, for example. Think of it as sort of modulus, only that 270 * @ep_ro elements, for example. Think of it as sort of modulus, only that
253 * the result isn't that of modulo. ;) Note that if initial input is a 271 * the result isn't that of modulo. ;) Note that if initial input is a
254 * small value, then result will return 0. 272 * small value, then result will return 0.
255 * 273 *
256 * Return: a result based on val in interval [0, ep_ro). 274 * Return: a result based on @val in interval [0, @ep_ro).
257 */ 275 */
258static inline u32 reciprocal_scale(u32 val, u32 ep_ro) 276static inline u32 reciprocal_scale(u32 val, u32 ep_ro)
259{ 277{
@@ -618,8 +636,8 @@ do { \
618 * trace_printk - printf formatting in the ftrace buffer 636 * trace_printk - printf formatting in the ftrace buffer
619 * @fmt: the printf format for printing 637 * @fmt: the printf format for printing
620 * 638 *
621 * Note: __trace_printk is an internal function for trace_printk and 639 * Note: __trace_printk is an internal function for trace_printk() and
622 * the @ip is passed in via the trace_printk macro. 640 * the @ip is passed in via the trace_printk() macro.
623 * 641 *
624 * This function allows a kernel developer to debug fast path sections 642 * This function allows a kernel developer to debug fast path sections
625 * that printk is not appropriate for. By scattering in various 643 * that printk is not appropriate for. By scattering in various
@@ -629,7 +647,7 @@ do { \
629 * This is intended as a debugging tool for the developer only. 647 * This is intended as a debugging tool for the developer only.
630 * Please refrain from leaving trace_printks scattered around in 648 * Please refrain from leaving trace_printks scattered around in
631 * your code. (Extra memory is used for special buffers that are 649 * your code. (Extra memory is used for special buffers that are
632 * allocated when trace_printk() is used) 650 * allocated when trace_printk() is used.)
633 * 651 *
634 * A little optization trick is done here. If there's only one 652 * A little optization trick is done here. If there's only one
635 * argument, there's no need to scan the string for printf formats. 653 * argument, there's no need to scan the string for printf formats.
@@ -681,7 +699,7 @@ int __trace_printk(unsigned long ip, const char *fmt, ...);
681 * the @ip is passed in via the trace_puts macro. 699 * the @ip is passed in via the trace_puts macro.
682 * 700 *
683 * This is similar to trace_printk() but is made for those really fast 701 * This is similar to trace_printk() but is made for those really fast
684 * paths that a developer wants the least amount of "Heisenbug" affects, 702 * paths that a developer wants the least amount of "Heisenbug" effects,
685 * where the processing of the print format is still too much. 703 * where the processing of the print format is still too much.
686 * 704 *
687 * This function allows a kernel developer to debug fast path sections 705 * This function allows a kernel developer to debug fast path sections
@@ -692,7 +710,7 @@ int __trace_printk(unsigned long ip, const char *fmt, ...);
692 * This is intended as a debugging tool for the developer only. 710 * This is intended as a debugging tool for the developer only.
693 * Please refrain from leaving trace_puts scattered around in 711 * Please refrain from leaving trace_puts scattered around in
694 * your code. (Extra memory is used for special buffers that are 712 * your code. (Extra memory is used for special buffers that are
695 * allocated when trace_puts() is used) 713 * allocated when trace_puts() is used.)
696 * 714 *
697 * Returns: 0 if nothing was written, positive # if string was. 715 * Returns: 0 if nothing was written, positive # if string was.
698 * (1 when __trace_bputs is used, strlen(str) when __trace_puts is used) 716 * (1 when __trace_bputs is used, strlen(str) when __trace_puts is used)
@@ -771,6 +789,12 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
771 t2 min2 = (y); \ 789 t2 min2 = (y); \
772 (void) (&min1 == &min2); \ 790 (void) (&min1 == &min2); \
773 min1 < min2 ? min1 : min2; }) 791 min1 < min2 ? min1 : min2; })
792
793/**
794 * min - return minimum of two values of the same or compatible types
795 * @x: first value
796 * @y: second value
797 */
774#define min(x, y) \ 798#define min(x, y) \
775 __min(typeof(x), typeof(y), \ 799 __min(typeof(x), typeof(y), \
776 __UNIQUE_ID(min1_), __UNIQUE_ID(min2_), \ 800 __UNIQUE_ID(min1_), __UNIQUE_ID(min2_), \
@@ -781,12 +805,31 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
781 t2 max2 = (y); \ 805 t2 max2 = (y); \
782 (void) (&max1 == &max2); \ 806 (void) (&max1 == &max2); \
783 max1 > max2 ? max1 : max2; }) 807 max1 > max2 ? max1 : max2; })
808
809/**
810 * max - return maximum of two values of the same or compatible types
811 * @x: first value
812 * @y: second value
813 */
784#define max(x, y) \ 814#define max(x, y) \
785 __max(typeof(x), typeof(y), \ 815 __max(typeof(x), typeof(y), \
786 __UNIQUE_ID(max1_), __UNIQUE_ID(max2_), \ 816 __UNIQUE_ID(max1_), __UNIQUE_ID(max2_), \
787 x, y) 817 x, y)
788 818
819/**
820 * min3 - return minimum of three values
821 * @x: first value
822 * @y: second value
823 * @z: third value
824 */
789#define min3(x, y, z) min((typeof(x))min(x, y), z) 825#define min3(x, y, z) min((typeof(x))min(x, y), z)
826
827/**
828 * max3 - return maximum of three values
829 * @x: first value
830 * @y: second value
831 * @z: third value
832 */
790#define max3(x, y, z) max((typeof(x))max(x, y), z) 833#define max3(x, y, z) max((typeof(x))max(x, y), z)
791 834
792/** 835/**
@@ -805,8 +848,8 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
805 * @lo: lowest allowable value 848 * @lo: lowest allowable value
806 * @hi: highest allowable value 849 * @hi: highest allowable value
807 * 850 *
808 * This macro does strict typechecking of lo/hi to make sure they are of the 851 * This macro does strict typechecking of @lo/@hi to make sure they are of the
809 * same type as val. See the unnecessary pointer comparisons. 852 * same type as @val. See the unnecessary pointer comparisons.
810 */ 853 */
811#define clamp(val, lo, hi) min((typeof(val))max(val, lo), hi) 854#define clamp(val, lo, hi) min((typeof(val))max(val, lo), hi)
812 855
@@ -816,11 +859,24 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
816 * 859 *
817 * Or not use min/max/clamp at all, of course. 860 * Or not use min/max/clamp at all, of course.
818 */ 861 */
862
863/**
864 * min_t - return minimum of two values, using the specified type
865 * @type: data type to use
866 * @x: first value
867 * @y: second value
868 */
819#define min_t(type, x, y) \ 869#define min_t(type, x, y) \
820 __min(type, type, \ 870 __min(type, type, \
821 __UNIQUE_ID(min1_), __UNIQUE_ID(min2_), \ 871 __UNIQUE_ID(min1_), __UNIQUE_ID(min2_), \
822 x, y) 872 x, y)
823 873
874/**
875 * max_t - return maximum of two values, using the specified type
876 * @type: data type to use
877 * @x: first value
878 * @y: second value
879 */
824#define max_t(type, x, y) \ 880#define max_t(type, x, y) \
825 __max(type, type, \ 881 __max(type, type, \
826 __UNIQUE_ID(min1_), __UNIQUE_ID(min2_), \ 882 __UNIQUE_ID(min1_), __UNIQUE_ID(min2_), \
@@ -834,7 +890,7 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
834 * @hi: maximum allowable value 890 * @hi: maximum allowable value
835 * 891 *
836 * This macro does no typechecking and uses temporary variables of type 892 * This macro does no typechecking and uses temporary variables of type
837 * 'type' to make all the comparisons. 893 * @type to make all the comparisons.
838 */ 894 */
839#define clamp_t(type, val, lo, hi) min_t(type, max_t(type, val, lo), hi) 895#define clamp_t(type, val, lo, hi) min_t(type, max_t(type, val, lo), hi)
840 896
@@ -845,15 +901,17 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
845 * @hi: maximum allowable value 901 * @hi: maximum allowable value
846 * 902 *
847 * This macro does no typechecking and uses temporary variables of whatever 903 * This macro does no typechecking and uses temporary variables of whatever
848 * type the input argument 'val' is. This is useful when val is an unsigned 904 * type the input argument @val is. This is useful when @val is an unsigned
849 * type and min and max are literals that will otherwise be assigned a signed 905 * type and @lo and @hi are literals that will otherwise be assigned a signed
850 * integer type. 906 * integer type.
851 */ 907 */
852#define clamp_val(val, lo, hi) clamp_t(typeof(val), val, lo, hi) 908#define clamp_val(val, lo, hi) clamp_t(typeof(val), val, lo, hi)
853 909
854 910
855/* 911/**
856 * swap - swap value of @a and @b 912 * swap - swap values of @a and @b
913 * @a: first value
914 * @b: second value
857 */ 915 */
858#define swap(a, b) \ 916#define swap(a, b) \
859 do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0) 917 do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0)
diff --git a/include/linux/of.h b/include/linux/of.h
index cfc34117fc92..b240ed69dc96 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -734,6 +734,16 @@ static inline struct device_node *of_get_cpu_node(int cpu,
734 return NULL; 734 return NULL;
735} 735}
736 736
737static inline int of_n_addr_cells(struct device_node *np)
738{
739 return 0;
740
741}
742static inline int of_n_size_cells(struct device_node *np)
743{
744 return 0;
745}
746
737static inline int of_property_read_u64(const struct device_node *np, 747static inline int of_property_read_u64(const struct device_node *np,
738 const char *propname, u64 *out_value) 748 const char *propname, u64 *out_value)
739{ 749{
diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
index 905d769d8ddc..5f7eeab990fe 100644
--- a/include/linux/thread_info.h
+++ b/include/linux/thread_info.h
@@ -42,7 +42,7 @@ enum {
42#define THREAD_ALIGN THREAD_SIZE 42#define THREAD_ALIGN THREAD_SIZE
43#endif 43#endif
44 44
45#ifdef CONFIG_DEBUG_STACK_USAGE 45#if IS_ENABLED(CONFIG_DEBUG_STACK_USAGE) || IS_ENABLED(CONFIG_DEBUG_KMEMLEAK)
46# define THREADINFO_GFP (GFP_KERNEL_ACCOUNT | __GFP_NOTRACK | \ 46# define THREADINFO_GFP (GFP_KERNEL_ACCOUNT | __GFP_NOTRACK | \
47 __GFP_ZERO) 47 __GFP_ZERO)
48#else 48#else
diff --git a/kernel/fork.c b/kernel/fork.c
index e702cb9ffbd8..07cc743698d3 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -215,6 +215,10 @@ static unsigned long *alloc_thread_stack_node(struct task_struct *tsk, int node)
215 if (!s) 215 if (!s)
216 continue; 216 continue;
217 217
218#ifdef CONFIG_DEBUG_KMEMLEAK
219 /* Clear stale pointers from reused stack. */
220 memset(s->addr, 0, THREAD_SIZE);
221#endif
218 tsk->stack_vm_area = s; 222 tsk->stack_vm_area = s;
219 return s->addr; 223 return s->addr;
220 } 224 }
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 2689b7c50c52..c1e720a22c71 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -1590,6 +1590,54 @@ config LATENCYTOP
1590 1590
1591source kernel/trace/Kconfig 1591source kernel/trace/Kconfig
1592 1592
1593config PROVIDE_OHCI1394_DMA_INIT
1594 bool "Remote debugging over FireWire early on boot"
1595 depends on PCI && X86
1596 help
1597 If you want to debug problems which hang or crash the kernel early
1598 on boot and the crashing machine has a FireWire port, you can use
1599 this feature to remotely access the memory of the crashed machine
1600 over FireWire. This employs remote DMA as part of the OHCI1394
1601 specification which is now the standard for FireWire controllers.
1602
1603 With remote DMA, you can monitor the printk buffer remotely using
1604 firescope and access all memory below 4GB using fireproxy from gdb.
1605 Even controlling a kernel debugger is possible using remote DMA.
1606
1607 Usage:
1608
1609 If ohci1394_dma=early is used as boot parameter, it will initialize
1610 all OHCI1394 controllers which are found in the PCI config space.
1611
1612 As all changes to the FireWire bus such as enabling and disabling
1613 devices cause a bus reset and thereby disable remote DMA for all
1614 devices, be sure to have the cable plugged and FireWire enabled on
1615 the debugging host before booting the debug target for debugging.
1616
1617 This code (~1k) is freed after boot. By then, the firewire stack
1618 in charge of the OHCI-1394 controllers should be used instead.
1619
1620 See Documentation/debugging-via-ohci1394.txt for more information.
1621
1622config DMA_API_DEBUG
1623 bool "Enable debugging of DMA-API usage"
1624 depends on HAVE_DMA_API_DEBUG
1625 help
1626 Enable this option to debug the use of the DMA API by device drivers.
1627 With this option you will be able to detect common bugs in device
1628 drivers like double-freeing of DMA mappings or freeing mappings that
1629 were never allocated.
1630
1631 This also attempts to catch cases where a page owned by DMA is
1632 accessed by the cpu in a way that could cause data corruption. For
1633 example, this enables cow_user_page() to check that the source page is
1634 not undergoing DMA.
1635
1636 This option causes a performance degradation. Use only if you want to
1637 debug device drivers and dma interactions.
1638
1639 If unsure, say N.
1640
1593menu "Runtime Testing" 1641menu "Runtime Testing"
1594 1642
1595config LKDTM 1643config LKDTM
@@ -1749,56 +1797,6 @@ config TEST_PARMAN
1749 1797
1750 If unsure, say N. 1798 If unsure, say N.
1751 1799
1752endmenu # runtime tests
1753
1754config PROVIDE_OHCI1394_DMA_INIT
1755 bool "Remote debugging over FireWire early on boot"
1756 depends on PCI && X86
1757 help
1758 If you want to debug problems which hang or crash the kernel early
1759 on boot and the crashing machine has a FireWire port, you can use
1760 this feature to remotely access the memory of the crashed machine
1761 over FireWire. This employs remote DMA as part of the OHCI1394
1762 specification which is now the standard for FireWire controllers.
1763
1764 With remote DMA, you can monitor the printk buffer remotely using
1765 firescope and access all memory below 4GB using fireproxy from gdb.
1766 Even controlling a kernel debugger is possible using remote DMA.
1767
1768 Usage:
1769
1770 If ohci1394_dma=early is used as boot parameter, it will initialize
1771 all OHCI1394 controllers which are found in the PCI config space.
1772
1773 As all changes to the FireWire bus such as enabling and disabling
1774 devices cause a bus reset and thereby disable remote DMA for all
1775 devices, be sure to have the cable plugged and FireWire enabled on
1776 the debugging host before booting the debug target for debugging.
1777
1778 This code (~1k) is freed after boot. By then, the firewire stack
1779 in charge of the OHCI-1394 controllers should be used instead.
1780
1781 See Documentation/debugging-via-ohci1394.txt for more information.
1782
1783config DMA_API_DEBUG
1784 bool "Enable debugging of DMA-API usage"
1785 depends on HAVE_DMA_API_DEBUG
1786 help
1787 Enable this option to debug the use of the DMA API by device drivers.
1788 With this option you will be able to detect common bugs in device
1789 drivers like double-freeing of DMA mappings or freeing mappings that
1790 were never allocated.
1791
1792 This also attempts to catch cases where a page owned by DMA is
1793 accessed by the cpu in a way that could cause data corruption. For
1794 example, this enables cow_user_page() to check that the source page is
1795 not undergoing DMA.
1796
1797 This option causes a performance degradation. Use only if you want to
1798 debug device drivers and dma interactions.
1799
1800 If unsure, say N.
1801
1802config TEST_LKM 1800config TEST_LKM
1803 tristate "Test module loading with 'hello world' module" 1801 tristate "Test module loading with 'hello world' module"
1804 default n 1802 default n
@@ -1873,18 +1871,6 @@ config TEST_UDELAY
1873 1871
1874 If unsure, say N. 1872 If unsure, say N.
1875 1873
1876config MEMTEST
1877 bool "Memtest"
1878 depends on HAVE_MEMBLOCK
1879 ---help---
1880 This option adds a kernel parameter 'memtest', which allows memtest
1881 to be set.
1882 memtest=0, mean disabled; -- default
1883 memtest=1, mean do 1 test pattern;
1884 ...
1885 memtest=17, mean do 17 test patterns.
1886 If you are unsure how to answer this question, answer N.
1887
1888config TEST_STATIC_KEYS 1874config TEST_STATIC_KEYS
1889 tristate "Test static keys" 1875 tristate "Test static keys"
1890 default n 1876 default n
@@ -1894,16 +1880,6 @@ config TEST_STATIC_KEYS
1894 1880
1895 If unsure, say N. 1881 If unsure, say N.
1896 1882
1897config BUG_ON_DATA_CORRUPTION
1898 bool "Trigger a BUG when data corruption is detected"
1899 select DEBUG_LIST
1900 help
1901 Select this option if the kernel should BUG when it encounters
1902 data corruption in kernel memory structures when they get checked
1903 for validity.
1904
1905 If unsure, say N.
1906
1907config TEST_KMOD 1883config TEST_KMOD
1908 tristate "kmod stress tester" 1884 tristate "kmod stress tester"
1909 default n 1885 default n
@@ -1941,6 +1917,29 @@ config TEST_DEBUG_VIRTUAL
1941 1917
1942 If unsure, say N. 1918 If unsure, say N.
1943 1919
1920endmenu # runtime tests
1921
1922config MEMTEST
1923 bool "Memtest"
1924 depends on HAVE_MEMBLOCK
1925 ---help---
1926 This option adds a kernel parameter 'memtest', which allows memtest
1927 to be set.
1928 memtest=0, mean disabled; -- default
1929 memtest=1, mean do 1 test pattern;
1930 ...
1931 memtest=17, mean do 17 test patterns.
1932 If you are unsure how to answer this question, answer N.
1933
1934config BUG_ON_DATA_CORRUPTION
1935 bool "Trigger a BUG when data corruption is detected"
1936 select DEBUG_LIST
1937 help
1938 Select this option if the kernel should BUG when it encounters
1939 data corruption in kernel memory structures when they get checked
1940 for validity.
1941
1942 If unsure, say N.
1944 1943
1945source "samples/Kconfig" 1944source "samples/Kconfig"
1946 1945
diff --git a/mm/cma.c b/mm/cma.c
index c0da318c020e..022e52bd8370 100644
--- a/mm/cma.c
+++ b/mm/cma.c
@@ -460,7 +460,7 @@ struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align,
460 460
461 trace_cma_alloc(pfn, page, count, align); 461 trace_cma_alloc(pfn, page, count, align);
462 462
463 if (ret) { 463 if (ret && !(gfp_mask & __GFP_NOWARN)) {
464 pr_info("%s: alloc failed, req-size: %zu pages, ret: %d\n", 464 pr_info("%s: alloc failed, req-size: %zu pages, ret: %d\n",
465 __func__, count, ret); 465 __func__, count, ret);
466 cma_debug_show_areas(cma); 466 cma_debug_show_areas(cma);
diff --git a/mm/madvise.c b/mm/madvise.c
index 25bade36e9ca..fd70d6aabc3e 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -757,6 +757,9 @@ madvise_behavior_valid(int behavior)
757 * MADV_DONTFORK - omit this area from child's address space when forking: 757 * MADV_DONTFORK - omit this area from child's address space when forking:
758 * typically, to avoid COWing pages pinned by get_user_pages(). 758 * typically, to avoid COWing pages pinned by get_user_pages().
759 * MADV_DOFORK - cancel MADV_DONTFORK: no longer omit this area when forking. 759 * MADV_DOFORK - cancel MADV_DONTFORK: no longer omit this area when forking.
760 * MADV_WIPEONFORK - present the child process with zero-filled memory in this
761 * range after a fork.
762 * MADV_KEEPONFORK - undo the effect of MADV_WIPEONFORK
760 * MADV_HWPOISON - trigger memory error handler as if the given memory range 763 * MADV_HWPOISON - trigger memory error handler as if the given memory range
761 * were corrupted by unrecoverable hardware memory failure. 764 * were corrupted by unrecoverable hardware memory failure.
762 * MADV_SOFT_OFFLINE - try to soft-offline the given range of memory. 765 * MADV_SOFT_OFFLINE - try to soft-offline the given range of memory.
@@ -777,7 +780,9 @@ madvise_behavior_valid(int behavior)
777 * zero - success 780 * zero - success
778 * -EINVAL - start + len < 0, start is not page-aligned, 781 * -EINVAL - start + len < 0, start is not page-aligned,
779 * "behavior" is not a valid value, or application 782 * "behavior" is not a valid value, or application
780 * is attempting to release locked or shared pages. 783 * is attempting to release locked or shared pages,
784 * or the specified address range includes file, Huge TLB,
785 * MAP_SHARED or VMPFNMAP range.
781 * -ENOMEM - addresses in the specified range are not currently 786 * -ENOMEM - addresses in the specified range are not currently
782 * mapped, or are outside the AS of the process. 787 * mapped, or are outside the AS of the process.
783 * -EIO - an I/O error occurred while paging in data. 788 * -EIO - an I/O error occurred while paging in data.
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index 006ba625c0b8..a2af6d58a68f 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -1920,8 +1920,11 @@ static struct page *alloc_page_interleave(gfp_t gfp, unsigned order,
1920 struct page *page; 1920 struct page *page;
1921 1921
1922 page = __alloc_pages(gfp, order, nid); 1922 page = __alloc_pages(gfp, order, nid);
1923 if (page && page_to_nid(page) == nid) 1923 if (page && page_to_nid(page) == nid) {
1924 inc_zone_page_state(page, NUMA_INTERLEAVE_HIT); 1924 preempt_disable();
1925 __inc_numa_state(page_zone(page), NUMA_INTERLEAVE_HIT);
1926 preempt_enable();
1927 }
1925 return page; 1928 return page;
1926} 1929}
1927 1930
diff --git a/mm/migrate.c b/mm/migrate.c
index 6954c1435833..e00814ca390e 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -2146,8 +2146,9 @@ static int migrate_vma_collect_hole(unsigned long start,
2146 unsigned long addr; 2146 unsigned long addr;
2147 2147
2148 for (addr = start & PAGE_MASK; addr < end; addr += PAGE_SIZE) { 2148 for (addr = start & PAGE_MASK; addr < end; addr += PAGE_SIZE) {
2149 migrate->src[migrate->npages++] = MIGRATE_PFN_MIGRATE; 2149 migrate->src[migrate->npages] = MIGRATE_PFN_MIGRATE;
2150 migrate->dst[migrate->npages] = 0; 2150 migrate->dst[migrate->npages] = 0;
2151 migrate->npages++;
2151 migrate->cpages++; 2152 migrate->cpages++;
2152 } 2153 }
2153 2154
diff --git a/mm/page_vma_mapped.c b/mm/page_vma_mapped.c
index 6a03946469a9..53afbb919a1c 100644
--- a/mm/page_vma_mapped.c
+++ b/mm/page_vma_mapped.c
@@ -6,17 +6,6 @@
6 6
7#include "internal.h" 7#include "internal.h"
8 8
9static inline bool check_pmd(struct page_vma_mapped_walk *pvmw)
10{
11 pmd_t pmde;
12 /*
13 * Make sure we don't re-load pmd between present and !trans_huge check.
14 * We need a consistent view.
15 */
16 pmde = READ_ONCE(*pvmw->pmd);
17 return pmd_present(pmde) && !pmd_trans_huge(pmde);
18}
19
20static inline bool not_found(struct page_vma_mapped_walk *pvmw) 9static inline bool not_found(struct page_vma_mapped_walk *pvmw)
21{ 10{
22 page_vma_mapped_walk_done(pvmw); 11 page_vma_mapped_walk_done(pvmw);
@@ -116,6 +105,7 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw)
116 pgd_t *pgd; 105 pgd_t *pgd;
117 p4d_t *p4d; 106 p4d_t *p4d;
118 pud_t *pud; 107 pud_t *pud;
108 pmd_t pmde;
119 109
120 /* The only possible pmd mapping has been handled on last iteration */ 110 /* The only possible pmd mapping has been handled on last iteration */
121 if (pvmw->pmd && !pvmw->pte) 111 if (pvmw->pmd && !pvmw->pte)
@@ -148,7 +138,13 @@ restart:
148 if (!pud_present(*pud)) 138 if (!pud_present(*pud))
149 return false; 139 return false;
150 pvmw->pmd = pmd_offset(pud, pvmw->address); 140 pvmw->pmd = pmd_offset(pud, pvmw->address);
151 if (pmd_trans_huge(*pvmw->pmd) || is_pmd_migration_entry(*pvmw->pmd)) { 141 /*
142 * Make sure the pmd value isn't cached in a register by the
143 * compiler and used as a stale value after we've observed a
144 * subsequent update.
145 */
146 pmde = READ_ONCE(*pvmw->pmd);
147 if (pmd_trans_huge(pmde) || is_pmd_migration_entry(pmde)) {
152 pvmw->ptl = pmd_lock(mm, pvmw->pmd); 148 pvmw->ptl = pmd_lock(mm, pvmw->pmd);
153 if (likely(pmd_trans_huge(*pvmw->pmd))) { 149 if (likely(pmd_trans_huge(*pvmw->pmd))) {
154 if (pvmw->flags & PVMW_MIGRATION) 150 if (pvmw->flags & PVMW_MIGRATION)
@@ -167,17 +163,15 @@ restart:
167 return not_found(pvmw); 163 return not_found(pvmw);
168 return true; 164 return true;
169 } 165 }
170 } else 166 }
171 WARN_ONCE(1, "Non present huge pmd without pmd migration enabled!");
172 return not_found(pvmw); 167 return not_found(pvmw);
173 } else { 168 } else {
174 /* THP pmd was split under us: handle on pte level */ 169 /* THP pmd was split under us: handle on pte level */
175 spin_unlock(pvmw->ptl); 170 spin_unlock(pvmw->ptl);
176 pvmw->ptl = NULL; 171 pvmw->ptl = NULL;
177 } 172 }
178 } else { 173 } else if (!pmd_present(pmde)) {
179 if (!check_pmd(pvmw)) 174 return false;
180 return false;
181 } 175 }
182 if (!map_pte(pvmw)) 176 if (!map_pte(pvmw))
183 goto next_pte; 177 goto next_pte;
diff --git a/mm/swap_state.c b/mm/swap_state.c
index ed91091d1e68..05b6803f0cce 100644
--- a/mm/swap_state.c
+++ b/mm/swap_state.c
@@ -39,10 +39,6 @@ struct address_space *swapper_spaces[MAX_SWAPFILES];
39static unsigned int nr_swapper_spaces[MAX_SWAPFILES]; 39static unsigned int nr_swapper_spaces[MAX_SWAPFILES];
40bool swap_vma_readahead = true; 40bool swap_vma_readahead = true;
41 41
42#define SWAP_RA_MAX_ORDER_DEFAULT 3
43
44static int swap_ra_max_order = SWAP_RA_MAX_ORDER_DEFAULT;
45
46#define SWAP_RA_WIN_SHIFT (PAGE_SHIFT / 2) 42#define SWAP_RA_WIN_SHIFT (PAGE_SHIFT / 2)
47#define SWAP_RA_HITS_MASK ((1UL << SWAP_RA_WIN_SHIFT) - 1) 43#define SWAP_RA_HITS_MASK ((1UL << SWAP_RA_WIN_SHIFT) - 1)
48#define SWAP_RA_HITS_MAX SWAP_RA_HITS_MASK 44#define SWAP_RA_HITS_MAX SWAP_RA_HITS_MASK
@@ -664,6 +660,13 @@ struct page *swap_readahead_detect(struct vm_fault *vmf,
664 pte_t *tpte; 660 pte_t *tpte;
665#endif 661#endif
666 662
663 max_win = 1 << min_t(unsigned int, READ_ONCE(page_cluster),
664 SWAP_RA_ORDER_CEILING);
665 if (max_win == 1) {
666 swap_ra->win = 1;
667 return NULL;
668 }
669
667 faddr = vmf->address; 670 faddr = vmf->address;
668 entry = pte_to_swp_entry(vmf->orig_pte); 671 entry = pte_to_swp_entry(vmf->orig_pte);
669 if ((unlikely(non_swap_entry(entry)))) 672 if ((unlikely(non_swap_entry(entry))))
@@ -672,12 +675,6 @@ struct page *swap_readahead_detect(struct vm_fault *vmf,
672 if (page) 675 if (page)
673 return page; 676 return page;
674 677
675 max_win = 1 << READ_ONCE(swap_ra_max_order);
676 if (max_win == 1) {
677 swap_ra->win = 1;
678 return NULL;
679 }
680
681 fpfn = PFN_DOWN(faddr); 678 fpfn = PFN_DOWN(faddr);
682 swap_ra_info = GET_SWAP_RA_VAL(vma); 679 swap_ra_info = GET_SWAP_RA_VAL(vma);
683 pfn = PFN_DOWN(SWAP_RA_ADDR(swap_ra_info)); 680 pfn = PFN_DOWN(SWAP_RA_ADDR(swap_ra_info));
@@ -786,32 +783,8 @@ static struct kobj_attribute vma_ra_enabled_attr =
786 __ATTR(vma_ra_enabled, 0644, vma_ra_enabled_show, 783 __ATTR(vma_ra_enabled, 0644, vma_ra_enabled_show,
787 vma_ra_enabled_store); 784 vma_ra_enabled_store);
788 785
789static ssize_t vma_ra_max_order_show(struct kobject *kobj,
790 struct kobj_attribute *attr, char *buf)
791{
792 return sprintf(buf, "%d\n", swap_ra_max_order);
793}
794static ssize_t vma_ra_max_order_store(struct kobject *kobj,
795 struct kobj_attribute *attr,
796 const char *buf, size_t count)
797{
798 int err, v;
799
800 err = kstrtoint(buf, 10, &v);
801 if (err || v > SWAP_RA_ORDER_CEILING || v <= 0)
802 return -EINVAL;
803
804 swap_ra_max_order = v;
805
806 return count;
807}
808static struct kobj_attribute vma_ra_max_order_attr =
809 __ATTR(vma_ra_max_order, 0644, vma_ra_max_order_show,
810 vma_ra_max_order_store);
811
812static struct attribute *swap_attrs[] = { 786static struct attribute *swap_attrs[] = {
813 &vma_ra_enabled_attr.attr, 787 &vma_ra_enabled_attr.attr,
814 &vma_ra_max_order_attr.attr,
815 NULL, 788 NULL,
816}; 789};
817 790
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 8a43db6284eb..673942094328 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -1695,11 +1695,6 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
1695 for (i = 0; i < area->nr_pages; i++) { 1695 for (i = 0; i < area->nr_pages; i++) {
1696 struct page *page; 1696 struct page *page;
1697 1697
1698 if (fatal_signal_pending(current)) {
1699 area->nr_pages = i;
1700 goto fail_no_warn;
1701 }
1702
1703 if (node == NUMA_NO_NODE) 1698 if (node == NUMA_NO_NODE)
1704 page = alloc_page(alloc_mask|highmem_mask); 1699 page = alloc_page(alloc_mask|highmem_mask);
1705 else 1700 else
@@ -1723,7 +1718,6 @@ fail:
1723 warn_alloc(gfp_mask, NULL, 1718 warn_alloc(gfp_mask, NULL,
1724 "vmalloc: allocation failure, allocated %ld of %ld bytes", 1719 "vmalloc: allocation failure, allocated %ld of %ld bytes",
1725 (area->nr_pages*PAGE_SIZE), area->size); 1720 (area->nr_pages*PAGE_SIZE), area->size);
1726fail_no_warn:
1727 vfree(area->addr); 1721 vfree(area->addr);
1728 return NULL; 1722 return NULL;
1729} 1723}
diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c
index 5d554419170b..9ee9bf7fd1a2 100644
--- a/scripts/kallsyms.c
+++ b/scripts/kallsyms.c
@@ -158,7 +158,7 @@ static int read_symbol(FILE *in, struct sym_entry *s)
158 else if (str[0] == '$') 158 else if (str[0] == '$')
159 return -1; 159 return -1;
160 /* exclude debugging symbols */ 160 /* exclude debugging symbols */
161 else if (stype == 'N') 161 else if (stype == 'N' || stype == 'n')
162 return -1; 162 return -1;
163 163
164 /* include the type field in the symbol name, so that it gets 164 /* include the type field in the symbol name, so that it gets
diff --git a/tools/testing/selftests/vm/userfaultfd.c b/tools/testing/selftests/vm/userfaultfd.c
index a2c53a3d223d..de2f9ec8a87f 100644
--- a/tools/testing/selftests/vm/userfaultfd.c
+++ b/tools/testing/selftests/vm/userfaultfd.c
@@ -397,7 +397,7 @@ static void retry_copy_page(int ufd, struct uffdio_copy *uffdio_copy,
397 } 397 }
398} 398}
399 399
400static int copy_page(int ufd, unsigned long offset) 400static int __copy_page(int ufd, unsigned long offset, bool retry)
401{ 401{
402 struct uffdio_copy uffdio_copy; 402 struct uffdio_copy uffdio_copy;
403 403
@@ -418,7 +418,7 @@ static int copy_page(int ufd, unsigned long offset)
418 fprintf(stderr, "UFFDIO_COPY unexpected copy %Ld\n", 418 fprintf(stderr, "UFFDIO_COPY unexpected copy %Ld\n",
419 uffdio_copy.copy), exit(1); 419 uffdio_copy.copy), exit(1);
420 } else { 420 } else {
421 if (test_uffdio_copy_eexist) { 421 if (test_uffdio_copy_eexist && retry) {
422 test_uffdio_copy_eexist = false; 422 test_uffdio_copy_eexist = false;
423 retry_copy_page(ufd, &uffdio_copy, offset); 423 retry_copy_page(ufd, &uffdio_copy, offset);
424 } 424 }
@@ -427,6 +427,16 @@ static int copy_page(int ufd, unsigned long offset)
427 return 0; 427 return 0;
428} 428}
429 429
430static int copy_page_retry(int ufd, unsigned long offset)
431{
432 return __copy_page(ufd, offset, true);
433}
434
435static int copy_page(int ufd, unsigned long offset)
436{
437 return __copy_page(ufd, offset, false);
438}
439
430static void *uffd_poll_thread(void *arg) 440static void *uffd_poll_thread(void *arg)
431{ 441{
432 unsigned long cpu = (unsigned long) arg; 442 unsigned long cpu = (unsigned long) arg;
@@ -544,7 +554,7 @@ static void *background_thread(void *arg)
544 for (page_nr = cpu * nr_pages_per_cpu; 554 for (page_nr = cpu * nr_pages_per_cpu;
545 page_nr < (cpu+1) * nr_pages_per_cpu; 555 page_nr < (cpu+1) * nr_pages_per_cpu;
546 page_nr++) 556 page_nr++)
547 copy_page(uffd, page_nr * page_size); 557 copy_page_retry(uffd, page_nr * page_size);
548 558
549 return NULL; 559 return NULL;
550} 560}
@@ -779,7 +789,7 @@ static void retry_uffdio_zeropage(int ufd,
779 } 789 }
780} 790}
781 791
782static int uffdio_zeropage(int ufd, unsigned long offset) 792static int __uffdio_zeropage(int ufd, unsigned long offset, bool retry)
783{ 793{
784 struct uffdio_zeropage uffdio_zeropage; 794 struct uffdio_zeropage uffdio_zeropage;
785 int ret; 795 int ret;
@@ -814,7 +824,7 @@ static int uffdio_zeropage(int ufd, unsigned long offset)
814 fprintf(stderr, "UFFDIO_ZEROPAGE unexpected %Ld\n", 824 fprintf(stderr, "UFFDIO_ZEROPAGE unexpected %Ld\n",
815 uffdio_zeropage.zeropage), exit(1); 825 uffdio_zeropage.zeropage), exit(1);
816 } else { 826 } else {
817 if (test_uffdio_zeropage_eexist) { 827 if (test_uffdio_zeropage_eexist && retry) {
818 test_uffdio_zeropage_eexist = false; 828 test_uffdio_zeropage_eexist = false;
819 retry_uffdio_zeropage(ufd, &uffdio_zeropage, 829 retry_uffdio_zeropage(ufd, &uffdio_zeropage,
820 offset); 830 offset);
@@ -830,6 +840,11 @@ static int uffdio_zeropage(int ufd, unsigned long offset)
830 return 0; 840 return 0;
831} 841}
832 842
843static int uffdio_zeropage(int ufd, unsigned long offset)
844{
845 return __uffdio_zeropage(ufd, offset, false);
846}
847
833/* exercise UFFDIO_ZEROPAGE */ 848/* exercise UFFDIO_ZEROPAGE */
834static int userfaultfd_zeropage_test(void) 849static int userfaultfd_zeropage_test(void)
835{ 850{