summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-01-05 12:16:18 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2019-01-05 12:16:18 -0500
commita65981109f294ba7e64b33ad3b4575a4636fce66 (patch)
tree1061a49f11544e18775630938a8bc53920fa0421
parent3fed6ae4b027f9c93be18520f87bd06bdffd196b (diff)
parentb685a7350ae76bc0f388e24b36d06a63776c68ee (diff)
Merge branch 'akpm' (patches from Andrew)
Merge more updates from Andrew Morton: - procfs updates - various misc bits - lib/ updates - epoll updates - autofs - fatfs - a few more MM bits * emailed patches from Andrew Morton <akpm@linux-foundation.org>: (58 commits) mm/page_io.c: fix polled swap page in checkpatch: add Co-developed-by to signature tags docs: fix Co-Developed-by docs drivers/base/platform.c: kmemleak ignore a known leak fs: don't open code lru_to_page() fs/: remove caller signal_pending branch predictions mm/: remove caller signal_pending branch predictions arch/arc/mm/fault.c: remove caller signal_pending_branch predictions kernel/sched/: remove caller signal_pending branch predictions kernel/locking/mutex.c: remove caller signal_pending branch predictions mm: select HAVE_MOVE_PMD on x86 for faster mremap mm: speed up mremap by 20x on large regions mm: treewide: remove unused address argument from pte_alloc functions initramfs: cleanup incomplete rootfs scripts/gdb: fix lx-version string output kernel/kcov.c: mark write_comp_data() as notrace kernel/sysctl: add panic_print into sysctl panic: add options to print system info when panic happens bfs: extra sanity checking and static inode bitmap exec: separate MM_ANONPAGES and RLIMIT_STACK accounting ...
-rw-r--r--Documentation/admin-guide/kernel-parameters.txt8
-rw-r--r--Documentation/process/coding-style.rst3
-rw-r--r--Documentation/process/submitting-patches.rst4
-rw-r--r--Documentation/sysctl/kernel.txt17
-rw-r--r--arch/Kconfig5
-rw-r--r--arch/alpha/include/asm/bitops.h4
-rw-r--r--arch/alpha/include/asm/pgalloc.h6
-rw-r--r--arch/arc/include/asm/bitops.h4
-rw-r--r--arch/arc/include/asm/pgalloc.h5
-rw-r--r--arch/arc/mm/fault.c2
-rw-r--r--arch/arm/include/asm/pgalloc.h4
-rw-r--r--arch/arm64/include/asm/pgalloc.h4
-rw-r--r--arch/c6x/include/asm/bitops.h2
-rw-r--r--arch/csky/include/asm/bitops.h2
-rw-r--r--arch/hexagon/include/asm/bitops.h2
-rw-r--r--arch/hexagon/include/asm/pgalloc.h6
-rw-r--r--arch/ia64/include/asm/bitops.h3
-rw-r--r--arch/ia64/include/asm/pgalloc.h5
-rw-r--r--arch/m68k/include/asm/bitops.h2
-rw-r--r--arch/m68k/include/asm/mcf_pgalloc.h8
-rw-r--r--arch/m68k/include/asm/motorola_pgalloc.h4
-rw-r--r--arch/m68k/include/asm/sun3_pgalloc.h6
-rw-r--r--arch/microblaze/include/asm/pgalloc.h19
-rw-r--r--arch/microblaze/mm/pgtable.c3
-rw-r--r--arch/mips/include/asm/bitops.h2
-rw-r--r--arch/mips/include/asm/pgalloc.h6
-rw-r--r--arch/nds32/include/asm/pgalloc.h5
-rw-r--r--arch/nios2/include/asm/pgalloc.h6
-rw-r--r--arch/openrisc/include/asm/bitops/fls.h2
-rw-r--r--arch/openrisc/include/asm/pgalloc.h5
-rw-r--r--arch/openrisc/mm/ioremap.c3
-rw-r--r--arch/parisc/include/asm/bitops.h2
-rw-r--r--arch/parisc/include/asm/pgalloc.h4
-rw-r--r--arch/powerpc/include/asm/book3s/32/pgalloc.h6
-rw-r--r--arch/powerpc/include/asm/book3s/64/pgalloc.h12
-rw-r--r--arch/powerpc/include/asm/nohash/32/pgalloc.h6
-rw-r--r--arch/powerpc/include/asm/nohash/64/pgalloc.h6
-rw-r--r--arch/powerpc/mm/pgtable-frag.c2
-rw-r--r--arch/powerpc/mm/pgtable_32.c8
-rw-r--r--arch/riscv/include/asm/pgalloc.h6
-rw-r--r--arch/s390/include/asm/bitops.h4
-rw-r--r--arch/s390/include/asm/pgalloc.h4
-rw-r--r--arch/sh/include/asm/pgalloc.h6
-rw-r--r--arch/sparc/include/asm/pgalloc_32.h5
-rw-r--r--arch/sparc/include/asm/pgalloc_64.h6
-rw-r--r--arch/sparc/mm/init_64.c6
-rw-r--r--arch/sparc/mm/srmmu.c4
-rw-r--r--arch/um/include/asm/pgalloc.h4
-rw-r--r--arch/um/kernel/mem.c4
-rw-r--r--arch/unicore32/include/asm/bitops.h2
-rw-r--r--arch/unicore32/include/asm/pgalloc.h4
-rw-r--r--arch/x86/Kconfig1
-rw-r--r--arch/x86/include/asm/bitops.h2
-rw-r--r--arch/x86/include/asm/pgalloc.h4
-rw-r--r--arch/x86/mm/pgtable.c4
-rw-r--r--arch/xtensa/include/asm/pgalloc.h8
-rw-r--r--drivers/base/platform.c3
-rw-r--r--drivers/dma-buf/udmabuf.c2
-rw-r--r--drivers/firmware/memmap.c2
-rw-r--r--fs/afs/file.c5
-rw-r--r--fs/afs/fs_probe.c2
-rw-r--r--fs/afs/vl_probe.c2
-rw-r--r--fs/autofs/autofs_i.h13
-rw-r--r--fs/autofs/dev-ioctl.c27
-rw-r--r--fs/autofs/init.c2
-rw-r--r--fs/autofs/inode.c67
-rw-r--r--fs/autofs/root.c16
-rw-r--r--fs/autofs/waitq.c10
-rw-r--r--fs/bfs/bfs.h11
-rw-r--r--fs/bfs/dir.c4
-rw-r--r--fs/bfs/file.c2
-rw-r--r--fs/bfs/inode.c65
-rw-r--r--fs/binfmt_script.c10
-rw-r--r--fs/btrfs/extent_io.c3
-rw-r--r--fs/buffer.c2
-rw-r--r--fs/ceph/addr.c5
-rw-r--r--fs/cifs/file.c3
-rw-r--r--fs/eventpoll.c218
-rw-r--r--fs/exec.c109
-rw-r--r--fs/ext4/readpage.c2
-rw-r--r--fs/fat/cache.c2
-rw-r--r--fs/fat/dir.c4
-rw-r--r--fs/fat/fat.h30
-rw-r--r--fs/fat/fatent.c16
-rw-r--r--fs/fat/inode.c26
-rw-r--r--fs/fat/misc.c2
-rw-r--r--fs/hfsplus/dir.c1
-rw-r--r--fs/hfsplus/hfsplus_fs.h2
-rw-r--r--fs/hfsplus/inode.c21
-rw-r--r--fs/ocfs2/aops.c3
-rw-r--r--fs/orangefs/inode.c2
-rw-r--r--fs/orangefs/orangefs-bufmap.c2
-rw-r--r--fs/proc/base.c18
-rw-r--r--fs/proc/inode.c4
-rw-r--r--fs/proc/util.c1
-rw-r--r--include/asm-generic/bitops/builtin-fls.h2
-rw-r--r--include/asm-generic/bitops/fls.h2
-rw-r--r--include/linux/binfmts.h1
-rw-r--r--include/linux/build_bug.h36
-rw-r--r--include/linux/genalloc.h13
-rw-r--r--include/linux/kernel.h1
-rw-r--r--include/linux/mm.h15
-rw-r--r--include/linux/mm_inline.h3
-rw-r--r--include/linux/printk.h2
-rw-r--r--include/linux/sched/task.h2
-rw-r--r--include/uapi/linux/auto_fs.h2
-rw-r--r--include/uapi/linux/bfs_fs.h2
-rw-r--r--include/uapi/linux/msdos_fs.h9
-rw-r--r--include/uapi/linux/sysctl.h1
-rw-r--r--init/initramfs.c6
-rw-r--r--init/main.c3
-rw-r--r--kernel/fork.c5
-rw-r--r--kernel/hung_task.c20
-rw-r--r--kernel/kcov.c2
-rw-r--r--kernel/locking/mutex.c2
-rw-r--r--kernel/panic.c28
-rw-r--r--kernel/sched/core.c2
-rw-r--r--kernel/sched/swait.c2
-rw-r--r--kernel/sched/wait.c2
-rw-r--r--kernel/sysctl.c9
-rw-r--r--kernel/sysctl_binary.c1
-rw-r--r--lib/find_bit_benchmark.c11
-rw-r--r--lib/genalloc.c24
-rw-r--r--mm/filemap.c2
-rw-r--r--mm/gup.c2
-rw-r--r--mm/huge_memory.c8
-rw-r--r--mm/hugetlb.c2
-rw-r--r--mm/kasan/init.c2
-rw-r--r--mm/memory.c17
-rw-r--r--mm/migrate.c2
-rw-r--r--mm/mremap.c66
-rw-r--r--mm/page_io.c4
-rw-r--r--mm/swap.c2
-rw-r--r--mm/userfaultfd.c2
-rwxr-xr-xscripts/checkpatch.pl14
-rw-r--r--scripts/gdb/linux/proc.py2
-rw-r--r--tools/include/asm-generic/bitops/fls.h2
-rw-r--r--virt/kvm/arm/mmu.c2
138 files changed, 746 insertions, 587 deletions
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 408781ee142c..e7b5c49702bb 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -3092,6 +3092,14 @@
3092 timeout < 0: reboot immediately 3092 timeout < 0: reboot immediately
3093 Format: <timeout> 3093 Format: <timeout>
3094 3094
3095 panic_print= Bitmask for printing system info when panic happens.
3096 User can chose combination of the following bits:
3097 bit 0: print all tasks info
3098 bit 1: print system memory info
3099 bit 2: print timer info
3100 bit 3: print locks info if CONFIG_LOCKDEP is on
3101 bit 4: print ftrace buffer
3102
3095 panic_on_warn panic() instead of WARN(). Useful to cause kdump 3103 panic_on_warn panic() instead of WARN(). Useful to cause kdump
3096 on a WARN(). 3104 on a WARN().
3097 3105
diff --git a/Documentation/process/coding-style.rst b/Documentation/process/coding-style.rst
index 277c113376a6..b78dd680c038 100644
--- a/Documentation/process/coding-style.rst
+++ b/Documentation/process/coding-style.rst
@@ -443,6 +443,9 @@ In function prototypes, include parameter names with their data types.
443Although this is not required by the C language, it is preferred in Linux 443Although this is not required by the C language, it is preferred in Linux
444because it is a simple way to add valuable information for the reader. 444because it is a simple way to add valuable information for the reader.
445 445
446Do not use the `extern' keyword with function prototypes as this makes
447lines longer and isn't strictly necessary.
448
446 449
4477) Centralized exiting of functions 4507) Centralized exiting of functions
448----------------------------------- 451-----------------------------------
diff --git a/Documentation/process/submitting-patches.rst b/Documentation/process/submitting-patches.rst
index c0917107b90a..30dc00a364e8 100644
--- a/Documentation/process/submitting-patches.rst
+++ b/Documentation/process/submitting-patches.rst
@@ -510,7 +510,7 @@ tracking your trees, and to people trying to troubleshoot bugs in your
510tree. 510tree.
511 511
512 512
51312) When to use Acked-by:, Cc:, and Co-Developed-by: 51312) When to use Acked-by:, Cc:, and Co-developed-by:
514------------------------------------------------------- 514-------------------------------------------------------
515 515
516The Signed-off-by: tag indicates that the signer was involved in the 516The Signed-off-by: tag indicates that the signer was involved in the
@@ -543,7 +543,7 @@ person it names - but it should indicate that this person was copied on the
543patch. This tag documents that potentially interested parties 543patch. This tag documents that potentially interested parties
544have been included in the discussion. 544have been included in the discussion.
545 545
546A Co-Developed-by: states that the patch was also created by another developer 546A Co-developed-by: states that the patch was also created by another developer
547along with the original author. This is useful at times when multiple people 547along with the original author. This is useful at times when multiple people
548work on a single patch. Note, this person also needs to have a Signed-off-by: 548work on a single patch. Note, this person also needs to have a Signed-off-by:
549line in the patch as well. 549line in the patch as well.
diff --git a/Documentation/sysctl/kernel.txt b/Documentation/sysctl/kernel.txt
index 1b8775298cf7..c0527d8a468a 100644
--- a/Documentation/sysctl/kernel.txt
+++ b/Documentation/sysctl/kernel.txt
@@ -60,6 +60,7 @@ show up in /proc/sys/kernel:
60- panic_on_stackoverflow 60- panic_on_stackoverflow
61- panic_on_unrecovered_nmi 61- panic_on_unrecovered_nmi
62- panic_on_warn 62- panic_on_warn
63- panic_print
63- panic_on_rcu_stall 64- panic_on_rcu_stall
64- perf_cpu_time_max_percent 65- perf_cpu_time_max_percent
65- perf_event_paranoid 66- perf_event_paranoid
@@ -654,6 +655,22 @@ a kernel rebuild when attempting to kdump at the location of a WARN().
654 655
655============================================================== 656==============================================================
656 657
658panic_print:
659
660Bitmask for printing system info when panic happens. User can chose
661combination of the following bits:
662
663bit 0: print all tasks info
664bit 1: print system memory info
665bit 2: print timer info
666bit 3: print locks info if CONFIG_LOCKDEP is on
667bit 4: print ftrace buffer
668
669So for example to print tasks and memory info on panic, user can:
670 echo 3 > /proc/sys/kernel/panic_print
671
672==============================================================
673
657panic_on_rcu_stall: 674panic_on_rcu_stall:
658 675
659When set to 1, calls panic() after RCU stall detection messages. This 676When set to 1, calls panic() after RCU stall detection messages. This
diff --git a/arch/Kconfig b/arch/Kconfig
index e1e540ffa979..b70c952ac838 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -535,6 +535,11 @@ config HAVE_IRQ_TIME_ACCOUNTING
535 Archs need to ensure they use a high enough resolution clock to 535 Archs need to ensure they use a high enough resolution clock to
536 support irq time accounting and then call enable_sched_clock_irqtime(). 536 support irq time accounting and then call enable_sched_clock_irqtime().
537 537
538config HAVE_MOVE_PMD
539 bool
540 help
541 Archs that select this are able to move page tables at the PMD level.
542
538config HAVE_ARCH_TRANSPARENT_HUGEPAGE 543config HAVE_ARCH_TRANSPARENT_HUGEPAGE
539 bool 544 bool
540 545
diff --git a/arch/alpha/include/asm/bitops.h b/arch/alpha/include/asm/bitops.h
index ca43f4d0b937..5adca78830b5 100644
--- a/arch/alpha/include/asm/bitops.h
+++ b/arch/alpha/include/asm/bitops.h
@@ -391,9 +391,9 @@ static inline unsigned long __fls(unsigned long x)
391 return fls64(x) - 1; 391 return fls64(x) - 1;
392} 392}
393 393
394static inline int fls(int x) 394static inline int fls(unsigned int x)
395{ 395{
396 return fls64((unsigned int) x); 396 return fls64(x);
397} 397}
398 398
399/* 399/*
diff --git a/arch/alpha/include/asm/pgalloc.h b/arch/alpha/include/asm/pgalloc.h
index ab3e3a8638fb..02f9f91bb4f0 100644
--- a/arch/alpha/include/asm/pgalloc.h
+++ b/arch/alpha/include/asm/pgalloc.h
@@ -52,7 +52,7 @@ pmd_free(struct mm_struct *mm, pmd_t *pmd)
52} 52}
53 53
54static inline pte_t * 54static inline pte_t *
55pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address) 55pte_alloc_one_kernel(struct mm_struct *mm)
56{ 56{
57 pte_t *pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_ZERO); 57 pte_t *pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_ZERO);
58 return pte; 58 return pte;
@@ -65,9 +65,9 @@ pte_free_kernel(struct mm_struct *mm, pte_t *pte)
65} 65}
66 66
67static inline pgtable_t 67static inline pgtable_t
68pte_alloc_one(struct mm_struct *mm, unsigned long address) 68pte_alloc_one(struct mm_struct *mm)
69{ 69{
70 pte_t *pte = pte_alloc_one_kernel(mm, address); 70 pte_t *pte = pte_alloc_one_kernel(mm);
71 struct page *page; 71 struct page *page;
72 72
73 if (!pte) 73 if (!pte)
diff --git a/arch/arc/include/asm/bitops.h b/arch/arc/include/asm/bitops.h
index 8da87feec59a..ee9246184033 100644
--- a/arch/arc/include/asm/bitops.h
+++ b/arch/arc/include/asm/bitops.h
@@ -278,7 +278,7 @@ static inline __attribute__ ((const)) int clz(unsigned int x)
278 return res; 278 return res;
279} 279}
280 280
281static inline int constant_fls(int x) 281static inline int constant_fls(unsigned int x)
282{ 282{
283 int r = 32; 283 int r = 32;
284 284
@@ -312,7 +312,7 @@ static inline int constant_fls(int x)
312 * @result: [1-32] 312 * @result: [1-32]
313 * fls(1) = 1, fls(0x80000000) = 32, fls(0) = 0 313 * fls(1) = 1, fls(0x80000000) = 32, fls(0) = 0
314 */ 314 */
315static inline __attribute__ ((const)) int fls(unsigned long x) 315static inline __attribute__ ((const)) int fls(unsigned int x)
316{ 316{
317 if (__builtin_constant_p(x)) 317 if (__builtin_constant_p(x))
318 return constant_fls(x); 318 return constant_fls(x);
diff --git a/arch/arc/include/asm/pgalloc.h b/arch/arc/include/asm/pgalloc.h
index 3749234b7419..9c9b5a5ebf2e 100644
--- a/arch/arc/include/asm/pgalloc.h
+++ b/arch/arc/include/asm/pgalloc.h
@@ -90,8 +90,7 @@ static inline int __get_order_pte(void)
90 return get_order(PTRS_PER_PTE * sizeof(pte_t)); 90 return get_order(PTRS_PER_PTE * sizeof(pte_t));
91} 91}
92 92
93static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, 93static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm)
94 unsigned long address)
95{ 94{
96 pte_t *pte; 95 pte_t *pte;
97 96
@@ -102,7 +101,7 @@ static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
102} 101}
103 102
104static inline pgtable_t 103static inline pgtable_t
105pte_alloc_one(struct mm_struct *mm, unsigned long address) 104pte_alloc_one(struct mm_struct *mm)
106{ 105{
107 pgtable_t pte_pg; 106 pgtable_t pte_pg;
108 struct page *page; 107 struct page *page;
diff --git a/arch/arc/mm/fault.c b/arch/arc/mm/fault.c
index e2d9fc3fea01..a1d723197084 100644
--- a/arch/arc/mm/fault.c
+++ b/arch/arc/mm/fault.c
@@ -142,7 +142,7 @@ good_area:
142 fault = handle_mm_fault(vma, address, flags); 142 fault = handle_mm_fault(vma, address, flags);
143 143
144 /* If Pagefault was interrupted by SIGKILL, exit page fault "early" */ 144 /* If Pagefault was interrupted by SIGKILL, exit page fault "early" */
145 if (unlikely(fatal_signal_pending(current))) { 145 if (fatal_signal_pending(current)) {
146 if ((fault & VM_FAULT_ERROR) && !(fault & VM_FAULT_RETRY)) 146 if ((fault & VM_FAULT_ERROR) && !(fault & VM_FAULT_RETRY))
147 up_read(&mm->mmap_sem); 147 up_read(&mm->mmap_sem);
148 if (user_mode(regs)) 148 if (user_mode(regs))
diff --git a/arch/arm/include/asm/pgalloc.h b/arch/arm/include/asm/pgalloc.h
index 2d7344f0e208..17ab72f0cc4e 100644
--- a/arch/arm/include/asm/pgalloc.h
+++ b/arch/arm/include/asm/pgalloc.h
@@ -81,7 +81,7 @@ static inline void clean_pte_table(pte_t *pte)
81 * +------------+ 81 * +------------+
82 */ 82 */
83static inline pte_t * 83static inline pte_t *
84pte_alloc_one_kernel(struct mm_struct *mm, unsigned long addr) 84pte_alloc_one_kernel(struct mm_struct *mm)
85{ 85{
86 pte_t *pte; 86 pte_t *pte;
87 87
@@ -93,7 +93,7 @@ pte_alloc_one_kernel(struct mm_struct *mm, unsigned long addr)
93} 93}
94 94
95static inline pgtable_t 95static inline pgtable_t
96pte_alloc_one(struct mm_struct *mm, unsigned long addr) 96pte_alloc_one(struct mm_struct *mm)
97{ 97{
98 struct page *pte; 98 struct page *pte;
99 99
diff --git a/arch/arm64/include/asm/pgalloc.h b/arch/arm64/include/asm/pgalloc.h
index 2e05bcd944c8..52fa47c73bf0 100644
--- a/arch/arm64/include/asm/pgalloc.h
+++ b/arch/arm64/include/asm/pgalloc.h
@@ -91,13 +91,13 @@ extern pgd_t *pgd_alloc(struct mm_struct *mm);
91extern void pgd_free(struct mm_struct *mm, pgd_t *pgdp); 91extern void pgd_free(struct mm_struct *mm, pgd_t *pgdp);
92 92
93static inline pte_t * 93static inline pte_t *
94pte_alloc_one_kernel(struct mm_struct *mm, unsigned long addr) 94pte_alloc_one_kernel(struct mm_struct *mm)
95{ 95{
96 return (pte_t *)__get_free_page(PGALLOC_GFP); 96 return (pte_t *)__get_free_page(PGALLOC_GFP);
97} 97}
98 98
99static inline pgtable_t 99static inline pgtable_t
100pte_alloc_one(struct mm_struct *mm, unsigned long addr) 100pte_alloc_one(struct mm_struct *mm)
101{ 101{
102 struct page *pte; 102 struct page *pte;
103 103
diff --git a/arch/c6x/include/asm/bitops.h b/arch/c6x/include/asm/bitops.h
index f0ab012401b6..8b68234ace18 100644
--- a/arch/c6x/include/asm/bitops.h
+++ b/arch/c6x/include/asm/bitops.h
@@ -54,7 +54,7 @@ static inline unsigned long __ffs(unsigned long x)
54 * This is defined the same way as ffs. 54 * This is defined the same way as ffs.
55 * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32. 55 * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32.
56 */ 56 */
57static inline int fls(int x) 57static inline int fls(unsigned int x)
58{ 58{
59 if (!x) 59 if (!x)
60 return 0; 60 return 0;
diff --git a/arch/csky/include/asm/bitops.h b/arch/csky/include/asm/bitops.h
index 335f2883fb1e..43b9838bff63 100644
--- a/arch/csky/include/asm/bitops.h
+++ b/arch/csky/include/asm/bitops.h
@@ -40,7 +40,7 @@ static __always_inline unsigned long __ffs(unsigned long x)
40/* 40/*
41 * asm-generic/bitops/fls.h 41 * asm-generic/bitops/fls.h
42 */ 42 */
43static __always_inline int fls(int x) 43static __always_inline int fls(unsigned int x)
44{ 44{
45 asm volatile( 45 asm volatile(
46 "ff1 %0\n" 46 "ff1 %0\n"
diff --git a/arch/hexagon/include/asm/bitops.h b/arch/hexagon/include/asm/bitops.h
index 2691a1857d20..bee974262387 100644
--- a/arch/hexagon/include/asm/bitops.h
+++ b/arch/hexagon/include/asm/bitops.h
@@ -211,7 +211,7 @@ static inline long ffz(int x)
211 * This is defined the same way as ffs. 211 * This is defined the same way as ffs.
212 * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32. 212 * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32.
213 */ 213 */
214static inline int fls(int x) 214static inline int fls(unsigned int x)
215{ 215{
216 int r; 216 int r;
217 217
diff --git a/arch/hexagon/include/asm/pgalloc.h b/arch/hexagon/include/asm/pgalloc.h
index eeebf862c46c..d36183887b60 100644
--- a/arch/hexagon/include/asm/pgalloc.h
+++ b/arch/hexagon/include/asm/pgalloc.h
@@ -59,8 +59,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
59 free_page((unsigned long) pgd); 59 free_page((unsigned long) pgd);
60} 60}
61 61
62static inline struct page *pte_alloc_one(struct mm_struct *mm, 62static inline struct page *pte_alloc_one(struct mm_struct *mm)
63 unsigned long address)
64{ 63{
65 struct page *pte; 64 struct page *pte;
66 65
@@ -75,8 +74,7 @@ static inline struct page *pte_alloc_one(struct mm_struct *mm,
75} 74}
76 75
77/* _kernel variant gets to use a different allocator */ 76/* _kernel variant gets to use a different allocator */
78static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, 77static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm)
79 unsigned long address)
80{ 78{
81 gfp_t flags = GFP_KERNEL | __GFP_ZERO; 79 gfp_t flags = GFP_KERNEL | __GFP_ZERO;
82 return (pte_t *) __get_free_page(flags); 80 return (pte_t *) __get_free_page(flags);
diff --git a/arch/ia64/include/asm/bitops.h b/arch/ia64/include/asm/bitops.h
index 56a774bf13fa..2f24ee6459d2 100644
--- a/arch/ia64/include/asm/bitops.h
+++ b/arch/ia64/include/asm/bitops.h
@@ -388,8 +388,7 @@ ia64_fls (unsigned long x)
388 * Find the last (most significant) bit set. Returns 0 for x==0 and 388 * Find the last (most significant) bit set. Returns 0 for x==0 and
389 * bits are numbered from 1..32 (e.g., fls(9) == 4). 389 * bits are numbered from 1..32 (e.g., fls(9) == 4).
390 */ 390 */
391static inline int 391static inline int fls(unsigned int t)
392fls (int t)
393{ 392{
394 unsigned long x = t & 0xffffffffu; 393 unsigned long x = t & 0xffffffffu;
395 394
diff --git a/arch/ia64/include/asm/pgalloc.h b/arch/ia64/include/asm/pgalloc.h
index 3ee5362f2661..c9e481023c25 100644
--- a/arch/ia64/include/asm/pgalloc.h
+++ b/arch/ia64/include/asm/pgalloc.h
@@ -83,7 +83,7 @@ pmd_populate_kernel(struct mm_struct *mm, pmd_t * pmd_entry, pte_t * pte)
83 pmd_val(*pmd_entry) = __pa(pte); 83 pmd_val(*pmd_entry) = __pa(pte);
84} 84}
85 85
86static inline pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long addr) 86static inline pgtable_t pte_alloc_one(struct mm_struct *mm)
87{ 87{
88 struct page *page; 88 struct page *page;
89 void *pg; 89 void *pg;
@@ -99,8 +99,7 @@ static inline pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long addr)
99 return page; 99 return page;
100} 100}
101 101
102static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, 102static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm)
103 unsigned long addr)
104{ 103{
105 return quicklist_alloc(0, GFP_KERNEL, NULL); 104 return quicklist_alloc(0, GFP_KERNEL, NULL);
106} 105}
diff --git a/arch/m68k/include/asm/bitops.h b/arch/m68k/include/asm/bitops.h
index d979f38af751..10133a968c8e 100644
--- a/arch/m68k/include/asm/bitops.h
+++ b/arch/m68k/include/asm/bitops.h
@@ -502,7 +502,7 @@ static inline unsigned long __ffs(unsigned long x)
502/* 502/*
503 * fls: find last bit set. 503 * fls: find last bit set.
504 */ 504 */
505static inline int fls(int x) 505static inline int fls(unsigned int x)
506{ 506{
507 int cnt; 507 int cnt;
508 508
diff --git a/arch/m68k/include/asm/mcf_pgalloc.h b/arch/m68k/include/asm/mcf_pgalloc.h
index 12fe700632f4..4399d712f6db 100644
--- a/arch/m68k/include/asm/mcf_pgalloc.h
+++ b/arch/m68k/include/asm/mcf_pgalloc.h
@@ -12,8 +12,7 @@ extern inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
12 12
13extern const char bad_pmd_string[]; 13extern const char bad_pmd_string[];
14 14
15extern inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, 15extern inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm)
16 unsigned long address)
17{ 16{
18 unsigned long page = __get_free_page(GFP_DMA); 17 unsigned long page = __get_free_page(GFP_DMA);
19 18
@@ -32,8 +31,6 @@ extern inline pmd_t *pmd_alloc_kernel(pgd_t *pgd, unsigned long address)
32#define pmd_alloc_one_fast(mm, address) ({ BUG(); ((pmd_t *)1); }) 31#define pmd_alloc_one_fast(mm, address) ({ BUG(); ((pmd_t *)1); })
33#define pmd_alloc_one(mm, address) ({ BUG(); ((pmd_t *)2); }) 32#define pmd_alloc_one(mm, address) ({ BUG(); ((pmd_t *)2); })
34 33
35#define pte_alloc_one_fast(mm, addr) pte_alloc_one(mm, addr)
36
37#define pmd_populate(mm, pmd, page) (pmd_val(*pmd) = \ 34#define pmd_populate(mm, pmd, page) (pmd_val(*pmd) = \
38 (unsigned long)(page_address(page))) 35 (unsigned long)(page_address(page)))
39 36
@@ -50,8 +47,7 @@ static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t page,
50 47
51#define __pmd_free_tlb(tlb, pmd, address) do { } while (0) 48#define __pmd_free_tlb(tlb, pmd, address) do { } while (0)
52 49
53static inline struct page *pte_alloc_one(struct mm_struct *mm, 50static inline struct page *pte_alloc_one(struct mm_struct *mm)
54 unsigned long address)
55{ 51{
56 struct page *page = alloc_pages(GFP_DMA, 0); 52 struct page *page = alloc_pages(GFP_DMA, 0);
57 pte_t *pte; 53 pte_t *pte;
diff --git a/arch/m68k/include/asm/motorola_pgalloc.h b/arch/m68k/include/asm/motorola_pgalloc.h
index 7859a86319cf..d04d9ba9b976 100644
--- a/arch/m68k/include/asm/motorola_pgalloc.h
+++ b/arch/m68k/include/asm/motorola_pgalloc.h
@@ -8,7 +8,7 @@
8extern pmd_t *get_pointer_table(void); 8extern pmd_t *get_pointer_table(void);
9extern int free_pointer_table(pmd_t *); 9extern int free_pointer_table(pmd_t *);
10 10
11static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address) 11static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm)
12{ 12{
13 pte_t *pte; 13 pte_t *pte;
14 14
@@ -28,7 +28,7 @@ static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
28 free_page((unsigned long) pte); 28 free_page((unsigned long) pte);
29} 29}
30 30
31static inline pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long address) 31static inline pgtable_t pte_alloc_one(struct mm_struct *mm)
32{ 32{
33 struct page *page; 33 struct page *page;
34 pte_t *pte; 34 pte_t *pte;
diff --git a/arch/m68k/include/asm/sun3_pgalloc.h b/arch/m68k/include/asm/sun3_pgalloc.h
index 11485d38de4e..1456c5eecbd9 100644
--- a/arch/m68k/include/asm/sun3_pgalloc.h
+++ b/arch/m68k/include/asm/sun3_pgalloc.h
@@ -35,8 +35,7 @@ do { \
35 tlb_remove_page((tlb), pte); \ 35 tlb_remove_page((tlb), pte); \
36} while (0) 36} while (0)
37 37
38static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, 38static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm)
39 unsigned long address)
40{ 39{
41 unsigned long page = __get_free_page(GFP_KERNEL); 40 unsigned long page = __get_free_page(GFP_KERNEL);
42 41
@@ -47,8 +46,7 @@ static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
47 return (pte_t *) (page); 46 return (pte_t *) (page);
48} 47}
49 48
50static inline pgtable_t pte_alloc_one(struct mm_struct *mm, 49static inline pgtable_t pte_alloc_one(struct mm_struct *mm)
51 unsigned long address)
52{ 50{
53 struct page *page = alloc_pages(GFP_KERNEL, 0); 51 struct page *page = alloc_pages(GFP_KERNEL, 0);
54 52
diff --git a/arch/microblaze/include/asm/pgalloc.h b/arch/microblaze/include/asm/pgalloc.h
index 7c89390c0c13..f4cc9ffc449e 100644
--- a/arch/microblaze/include/asm/pgalloc.h
+++ b/arch/microblaze/include/asm/pgalloc.h
@@ -108,10 +108,9 @@ static inline void free_pgd_slow(pgd_t *pgd)
108#define pmd_alloc_one_fast(mm, address) ({ BUG(); ((pmd_t *)1); }) 108#define pmd_alloc_one_fast(mm, address) ({ BUG(); ((pmd_t *)1); })
109#define pmd_alloc_one(mm, address) ({ BUG(); ((pmd_t *)2); }) 109#define pmd_alloc_one(mm, address) ({ BUG(); ((pmd_t *)2); })
110 110
111extern pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long addr); 111extern pte_t *pte_alloc_one_kernel(struct mm_struct *mm);
112 112
113static inline struct page *pte_alloc_one(struct mm_struct *mm, 113static inline struct page *pte_alloc_one(struct mm_struct *mm)
114 unsigned long address)
115{ 114{
116 struct page *ptepage; 115 struct page *ptepage;
117 116
@@ -132,20 +131,6 @@ static inline struct page *pte_alloc_one(struct mm_struct *mm,
132 return ptepage; 131 return ptepage;
133} 132}
134 133
135static inline pte_t *pte_alloc_one_fast(struct mm_struct *mm,
136 unsigned long address)
137{
138 unsigned long *ret;
139
140 ret = pte_quicklist;
141 if (ret != NULL) {
142 pte_quicklist = (unsigned long *)(*ret);
143 ret[0] = 0;
144 pgtable_cache_size--;
145 }
146 return (pte_t *)ret;
147}
148
149static inline void pte_free_fast(pte_t *pte) 134static inline void pte_free_fast(pte_t *pte)
150{ 135{
151 *(unsigned long **)pte = pte_quicklist; 136 *(unsigned long **)pte = pte_quicklist;
diff --git a/arch/microblaze/mm/pgtable.c b/arch/microblaze/mm/pgtable.c
index 7f525962cdfa..c2ce1e42b888 100644
--- a/arch/microblaze/mm/pgtable.c
+++ b/arch/microblaze/mm/pgtable.c
@@ -235,8 +235,7 @@ unsigned long iopa(unsigned long addr)
235 return pa; 235 return pa;
236} 236}
237 237
238__ref pte_t *pte_alloc_one_kernel(struct mm_struct *mm, 238__ref pte_t *pte_alloc_one_kernel(struct mm_struct *mm)
239 unsigned long address)
240{ 239{
241 pte_t *pte; 240 pte_t *pte;
242 if (mem_init_done) { 241 if (mem_init_done) {
diff --git a/arch/mips/include/asm/bitops.h b/arch/mips/include/asm/bitops.h
index f2a840fb6a9a..c4675957b21b 100644
--- a/arch/mips/include/asm/bitops.h
+++ b/arch/mips/include/asm/bitops.h
@@ -555,7 +555,7 @@ static inline unsigned long __ffs(unsigned long word)
555 * This is defined the same way as ffs. 555 * This is defined the same way as ffs.
556 * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32. 556 * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32.
557 */ 557 */
558static inline int fls(int x) 558static inline int fls(unsigned int x)
559{ 559{
560 int r; 560 int r;
561 561
diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
index 39b9f311c4ef..27808d9461f4 100644
--- a/arch/mips/include/asm/pgalloc.h
+++ b/arch/mips/include/asm/pgalloc.h
@@ -50,14 +50,12 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
50 free_pages((unsigned long)pgd, PGD_ORDER); 50 free_pages((unsigned long)pgd, PGD_ORDER);
51} 51}
52 52
53static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, 53static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm)
54 unsigned long address)
55{ 54{
56 return (pte_t *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, PTE_ORDER); 55 return (pte_t *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, PTE_ORDER);
57} 56}
58 57
59static inline struct page *pte_alloc_one(struct mm_struct *mm, 58static inline struct page *pte_alloc_one(struct mm_struct *mm)
60 unsigned long address)
61{ 59{
62 struct page *pte; 60 struct page *pte;
63 61
diff --git a/arch/nds32/include/asm/pgalloc.h b/arch/nds32/include/asm/pgalloc.h
index 27448869131a..3c5fee5b5759 100644
--- a/arch/nds32/include/asm/pgalloc.h
+++ b/arch/nds32/include/asm/pgalloc.h
@@ -22,8 +22,7 @@ extern void pgd_free(struct mm_struct *mm, pgd_t * pgd);
22 22
23#define check_pgt_cache() do { } while (0) 23#define check_pgt_cache() do { } while (0)
24 24
25static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, 25static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm)
26 unsigned long addr)
27{ 26{
28 pte_t *pte; 27 pte_t *pte;
29 28
@@ -34,7 +33,7 @@ static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
34 return pte; 33 return pte;
35} 34}
36 35
37static inline pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long addr) 36static inline pgtable_t pte_alloc_one(struct mm_struct *mm)
38{ 37{
39 pgtable_t pte; 38 pgtable_t pte;
40 39
diff --git a/arch/nios2/include/asm/pgalloc.h b/arch/nios2/include/asm/pgalloc.h
index bb47d08c8ef7..3a149ead1207 100644
--- a/arch/nios2/include/asm/pgalloc.h
+++ b/arch/nios2/include/asm/pgalloc.h
@@ -37,8 +37,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
37 free_pages((unsigned long)pgd, PGD_ORDER); 37 free_pages((unsigned long)pgd, PGD_ORDER);
38} 38}
39 39
40static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, 40static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm)
41 unsigned long address)
42{ 41{
43 pte_t *pte; 42 pte_t *pte;
44 43
@@ -47,8 +46,7 @@ static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
47 return pte; 46 return pte;
48} 47}
49 48
50static inline pgtable_t pte_alloc_one(struct mm_struct *mm, 49static inline pgtable_t pte_alloc_one(struct mm_struct *mm)
51 unsigned long address)
52{ 50{
53 struct page *pte; 51 struct page *pte;
54 52
diff --git a/arch/openrisc/include/asm/bitops/fls.h b/arch/openrisc/include/asm/bitops/fls.h
index 9efbf9ad86c4..57de5a1115bf 100644
--- a/arch/openrisc/include/asm/bitops/fls.h
+++ b/arch/openrisc/include/asm/bitops/fls.h
@@ -15,7 +15,7 @@
15 15
16#ifdef CONFIG_OPENRISC_HAVE_INST_FL1 16#ifdef CONFIG_OPENRISC_HAVE_INST_FL1
17 17
18static inline int fls(int x) 18static inline int fls(unsigned int x)
19{ 19{
20 int ret; 20 int ret;
21 21
diff --git a/arch/openrisc/include/asm/pgalloc.h b/arch/openrisc/include/asm/pgalloc.h
index 8999b9226512..149c82ee4b8b 100644
--- a/arch/openrisc/include/asm/pgalloc.h
+++ b/arch/openrisc/include/asm/pgalloc.h
@@ -70,10 +70,9 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
70 free_page((unsigned long)pgd); 70 free_page((unsigned long)pgd);
71} 71}
72 72
73extern pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address); 73extern pte_t *pte_alloc_one_kernel(struct mm_struct *mm);
74 74
75static inline struct page *pte_alloc_one(struct mm_struct *mm, 75static inline struct page *pte_alloc_one(struct mm_struct *mm)
76 unsigned long address)
77{ 76{
78 struct page *pte; 77 struct page *pte;
79 pte = alloc_pages(GFP_KERNEL, 0); 78 pte = alloc_pages(GFP_KERNEL, 0);
diff --git a/arch/openrisc/mm/ioremap.c b/arch/openrisc/mm/ioremap.c
index c9697529b3f0..270d1c9bc0d6 100644
--- a/arch/openrisc/mm/ioremap.c
+++ b/arch/openrisc/mm/ioremap.c
@@ -118,8 +118,7 @@ EXPORT_SYMBOL(iounmap);
118 * the memblock infrastructure. 118 * the memblock infrastructure.
119 */ 119 */
120 120
121pte_t __ref *pte_alloc_one_kernel(struct mm_struct *mm, 121pte_t __ref *pte_alloc_one_kernel(struct mm_struct *mm)
122 unsigned long address)
123{ 122{
124 pte_t *pte; 123 pte_t *pte;
125 124
diff --git a/arch/parisc/include/asm/bitops.h b/arch/parisc/include/asm/bitops.h
index 53252d4f9a57..a09eaebfdfd0 100644
--- a/arch/parisc/include/asm/bitops.h
+++ b/arch/parisc/include/asm/bitops.h
@@ -188,7 +188,7 @@ static __inline__ int ffs(int x)
188 * fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32. 188 * fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32.
189 */ 189 */
190 190
191static __inline__ int fls(int x) 191static __inline__ int fls(unsigned int x)
192{ 192{
193 int ret; 193 int ret;
194 if (!x) 194 if (!x)
diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h
index cf13275f7c6d..d05c678c77c4 100644
--- a/arch/parisc/include/asm/pgalloc.h
+++ b/arch/parisc/include/asm/pgalloc.h
@@ -122,7 +122,7 @@ pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, pte_t *pte)
122#define pmd_pgtable(pmd) pmd_page(pmd) 122#define pmd_pgtable(pmd) pmd_page(pmd)
123 123
124static inline pgtable_t 124static inline pgtable_t
125pte_alloc_one(struct mm_struct *mm, unsigned long address) 125pte_alloc_one(struct mm_struct *mm)
126{ 126{
127 struct page *page = alloc_page(GFP_KERNEL|__GFP_ZERO); 127 struct page *page = alloc_page(GFP_KERNEL|__GFP_ZERO);
128 if (!page) 128 if (!page)
@@ -135,7 +135,7 @@ pte_alloc_one(struct mm_struct *mm, unsigned long address)
135} 135}
136 136
137static inline pte_t * 137static inline pte_t *
138pte_alloc_one_kernel(struct mm_struct *mm, unsigned long addr) 138pte_alloc_one_kernel(struct mm_struct *mm)
139{ 139{
140 pte_t *pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_ZERO); 140 pte_t *pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_ZERO);
141 return pte; 141 return pte;
diff --git a/arch/powerpc/include/asm/book3s/32/pgalloc.h b/arch/powerpc/include/asm/book3s/32/pgalloc.h
index b5b955eb2fb7..3633502e102c 100644
--- a/arch/powerpc/include/asm/book3s/32/pgalloc.h
+++ b/arch/powerpc/include/asm/book3s/32/pgalloc.h
@@ -61,10 +61,10 @@ static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmdp,
61 61
62#define pmd_pgtable(pmd) ((pgtable_t)pmd_page_vaddr(pmd)) 62#define pmd_pgtable(pmd) ((pgtable_t)pmd_page_vaddr(pmd))
63 63
64extern pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long addr); 64extern pte_t *pte_alloc_one_kernel(struct mm_struct *mm);
65extern pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long addr); 65extern pgtable_t pte_alloc_one(struct mm_struct *mm);
66void pte_frag_destroy(void *pte_frag); 66void pte_frag_destroy(void *pte_frag);
67pte_t *pte_fragment_alloc(struct mm_struct *mm, unsigned long vmaddr, int kernel); 67pte_t *pte_fragment_alloc(struct mm_struct *mm, int kernel);
68void pte_fragment_free(unsigned long *table, int kernel); 68void pte_fragment_free(unsigned long *table, int kernel);
69 69
70static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte) 70static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
diff --git a/arch/powerpc/include/asm/book3s/64/pgalloc.h b/arch/powerpc/include/asm/book3s/64/pgalloc.h
index 4aba625389c4..9c1173283b96 100644
--- a/arch/powerpc/include/asm/book3s/64/pgalloc.h
+++ b/arch/powerpc/include/asm/book3s/64/pgalloc.h
@@ -39,7 +39,7 @@ extern struct vmemmap_backing *vmemmap_list;
39extern struct kmem_cache *pgtable_cache[]; 39extern struct kmem_cache *pgtable_cache[];
40#define PGT_CACHE(shift) pgtable_cache[shift] 40#define PGT_CACHE(shift) pgtable_cache[shift]
41 41
42extern pte_t *pte_fragment_alloc(struct mm_struct *, unsigned long, int); 42extern pte_t *pte_fragment_alloc(struct mm_struct *, int);
43extern pmd_t *pmd_fragment_alloc(struct mm_struct *, unsigned long); 43extern pmd_t *pmd_fragment_alloc(struct mm_struct *, unsigned long);
44extern void pte_fragment_free(unsigned long *, int); 44extern void pte_fragment_free(unsigned long *, int);
45extern void pmd_fragment_free(unsigned long *); 45extern void pmd_fragment_free(unsigned long *);
@@ -190,16 +190,14 @@ static inline pgtable_t pmd_pgtable(pmd_t pmd)
190 return (pgtable_t)pmd_page_vaddr(pmd); 190 return (pgtable_t)pmd_page_vaddr(pmd);
191} 191}
192 192
193static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, 193static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm)
194 unsigned long address)
195{ 194{
196 return (pte_t *)pte_fragment_alloc(mm, address, 1); 195 return (pte_t *)pte_fragment_alloc(mm, 1);
197} 196}
198 197
199static inline pgtable_t pte_alloc_one(struct mm_struct *mm, 198static inline pgtable_t pte_alloc_one(struct mm_struct *mm)
200 unsigned long address)
201{ 199{
202 return (pgtable_t)pte_fragment_alloc(mm, address, 0); 200 return (pgtable_t)pte_fragment_alloc(mm, 0);
203} 201}
204 202
205static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte) 203static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
diff --git a/arch/powerpc/include/asm/nohash/32/pgalloc.h b/arch/powerpc/include/asm/nohash/32/pgalloc.h
index 17963951bdb0..bd186e85b4f7 100644
--- a/arch/powerpc/include/asm/nohash/32/pgalloc.h
+++ b/arch/powerpc/include/asm/nohash/32/pgalloc.h
@@ -79,10 +79,10 @@ static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmdp,
79#define pmd_pgtable(pmd) ((pgtable_t)pmd_page_vaddr(pmd)) 79#define pmd_pgtable(pmd) ((pgtable_t)pmd_page_vaddr(pmd))
80#endif 80#endif
81 81
82extern pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long addr); 82extern pte_t *pte_alloc_one_kernel(struct mm_struct *mm);
83extern pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long addr); 83extern pgtable_t pte_alloc_one(struct mm_struct *mm);
84void pte_frag_destroy(void *pte_frag); 84void pte_frag_destroy(void *pte_frag);
85pte_t *pte_fragment_alloc(struct mm_struct *mm, unsigned long vmaddr, int kernel); 85pte_t *pte_fragment_alloc(struct mm_struct *mm, int kernel);
86void pte_fragment_free(unsigned long *table, int kernel); 86void pte_fragment_free(unsigned long *table, int kernel);
87 87
88static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte) 88static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
diff --git a/arch/powerpc/include/asm/nohash/64/pgalloc.h b/arch/powerpc/include/asm/nohash/64/pgalloc.h
index e95eb499a174..66d086f85bd5 100644
--- a/arch/powerpc/include/asm/nohash/64/pgalloc.h
+++ b/arch/powerpc/include/asm/nohash/64/pgalloc.h
@@ -93,14 +93,12 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
93} 93}
94 94
95 95
96static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, 96static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm)
97 unsigned long address)
98{ 97{
99 return (pte_t *)__get_free_page(GFP_KERNEL | __GFP_ZERO); 98 return (pte_t *)__get_free_page(GFP_KERNEL | __GFP_ZERO);
100} 99}
101 100
102static inline pgtable_t pte_alloc_one(struct mm_struct *mm, 101static inline pgtable_t pte_alloc_one(struct mm_struct *mm)
103 unsigned long address)
104{ 102{
105 struct page *page; 103 struct page *page;
106 pte_t *pte; 104 pte_t *pte;
diff --git a/arch/powerpc/mm/pgtable-frag.c b/arch/powerpc/mm/pgtable-frag.c
index af23a587f019..a7b05214760c 100644
--- a/arch/powerpc/mm/pgtable-frag.c
+++ b/arch/powerpc/mm/pgtable-frag.c
@@ -95,7 +95,7 @@ static pte_t *__alloc_for_ptecache(struct mm_struct *mm, int kernel)
95 return (pte_t *)ret; 95 return (pte_t *)ret;
96} 96}
97 97
98pte_t *pte_fragment_alloc(struct mm_struct *mm, unsigned long vmaddr, int kernel) 98pte_t *pte_fragment_alloc(struct mm_struct *mm, int kernel)
99{ 99{
100 pte_t *pte; 100 pte_t *pte;
101 101
diff --git a/arch/powerpc/mm/pgtable_32.c b/arch/powerpc/mm/pgtable_32.c
index d67215248d82..ded71126ce4c 100644
--- a/arch/powerpc/mm/pgtable_32.c
+++ b/arch/powerpc/mm/pgtable_32.c
@@ -43,17 +43,17 @@ EXPORT_SYMBOL(ioremap_bot); /* aka VMALLOC_END */
43 43
44extern char etext[], _stext[], _sinittext[], _einittext[]; 44extern char etext[], _stext[], _sinittext[], _einittext[];
45 45
46__ref pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address) 46__ref pte_t *pte_alloc_one_kernel(struct mm_struct *mm)
47{ 47{
48 if (!slab_is_available()) 48 if (!slab_is_available())
49 return memblock_alloc(PTE_FRAG_SIZE, PTE_FRAG_SIZE); 49 return memblock_alloc(PTE_FRAG_SIZE, PTE_FRAG_SIZE);
50 50
51 return (pte_t *)pte_fragment_alloc(mm, address, 1); 51 return (pte_t *)pte_fragment_alloc(mm, 1);
52} 52}
53 53
54pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long address) 54pgtable_t pte_alloc_one(struct mm_struct *mm)
55{ 55{
56 return (pgtable_t)pte_fragment_alloc(mm, address, 0); 56 return (pgtable_t)pte_fragment_alloc(mm, 0);
57} 57}
58 58
59void __iomem * 59void __iomem *
diff --git a/arch/riscv/include/asm/pgalloc.h b/arch/riscv/include/asm/pgalloc.h
index a79ed5faff3a..94043cf83c90 100644
--- a/arch/riscv/include/asm/pgalloc.h
+++ b/arch/riscv/include/asm/pgalloc.h
@@ -82,15 +82,13 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
82 82
83#endif /* __PAGETABLE_PMD_FOLDED */ 83#endif /* __PAGETABLE_PMD_FOLDED */
84 84
85static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, 85static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm)
86 unsigned long address)
87{ 86{
88 return (pte_t *)__get_free_page( 87 return (pte_t *)__get_free_page(
89 GFP_KERNEL | __GFP_RETRY_MAYFAIL | __GFP_ZERO); 88 GFP_KERNEL | __GFP_RETRY_MAYFAIL | __GFP_ZERO);
90} 89}
91 90
92static inline struct page *pte_alloc_one(struct mm_struct *mm, 91static inline struct page *pte_alloc_one(struct mm_struct *mm)
93 unsigned long address)
94{ 92{
95 struct page *pte; 93 struct page *pte;
96 94
diff --git a/arch/s390/include/asm/bitops.h b/arch/s390/include/asm/bitops.h
index 86e5b2fdee3c..d1f8a4d94cca 100644
--- a/arch/s390/include/asm/bitops.h
+++ b/arch/s390/include/asm/bitops.h
@@ -397,9 +397,9 @@ static inline int fls64(unsigned long word)
397 * This is defined the same way as ffs. 397 * This is defined the same way as ffs.
398 * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32. 398 * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32.
399 */ 399 */
400static inline int fls(int word) 400static inline int fls(unsigned int word)
401{ 401{
402 return fls64((unsigned int)word); 402 return fls64(word);
403} 403}
404 404
405#else /* CONFIG_HAVE_MARCH_Z9_109_FEATURES */ 405#else /* CONFIG_HAVE_MARCH_Z9_109_FEATURES */
diff --git a/arch/s390/include/asm/pgalloc.h b/arch/s390/include/asm/pgalloc.h
index 5ee733720a57..bccb8f4a63e2 100644
--- a/arch/s390/include/asm/pgalloc.h
+++ b/arch/s390/include/asm/pgalloc.h
@@ -139,8 +139,8 @@ static inline void pmd_populate(struct mm_struct *mm,
139/* 139/*
140 * page table entry allocation/free routines. 140 * page table entry allocation/free routines.
141 */ 141 */
142#define pte_alloc_one_kernel(mm, vmaddr) ((pte_t *) page_table_alloc(mm)) 142#define pte_alloc_one_kernel(mm) ((pte_t *)page_table_alloc(mm))
143#define pte_alloc_one(mm, vmaddr) ((pte_t *) page_table_alloc(mm)) 143#define pte_alloc_one(mm) ((pte_t *)page_table_alloc(mm))
144 144
145#define pte_free_kernel(mm, pte) page_table_free(mm, (unsigned long *) pte) 145#define pte_free_kernel(mm, pte) page_table_free(mm, (unsigned long *) pte)
146#define pte_free(mm, pte) page_table_free(mm, (unsigned long *) pte) 146#define pte_free(mm, pte) page_table_free(mm, (unsigned long *) pte)
diff --git a/arch/sh/include/asm/pgalloc.h b/arch/sh/include/asm/pgalloc.h
index ed053a359ab7..8ad73cb31121 100644
--- a/arch/sh/include/asm/pgalloc.h
+++ b/arch/sh/include/asm/pgalloc.h
@@ -32,14 +32,12 @@ static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
32/* 32/*
33 * Allocate and free page tables. 33 * Allocate and free page tables.
34 */ 34 */
35static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, 35static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm)
36 unsigned long address)
37{ 36{
38 return quicklist_alloc(QUICK_PT, GFP_KERNEL, NULL); 37 return quicklist_alloc(QUICK_PT, GFP_KERNEL, NULL);
39} 38}
40 39
41static inline pgtable_t pte_alloc_one(struct mm_struct *mm, 40static inline pgtable_t pte_alloc_one(struct mm_struct *mm)
42 unsigned long address)
43{ 41{
44 struct page *page; 42 struct page *page;
45 void *pg; 43 void *pg;
diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
index 90459481c6c7..282be50a4adf 100644
--- a/arch/sparc/include/asm/pgalloc_32.h
+++ b/arch/sparc/include/asm/pgalloc_32.h
@@ -58,10 +58,9 @@ void pmd_populate(struct mm_struct *mm, pmd_t *pmdp, struct page *ptep);
58void pmd_set(pmd_t *pmdp, pte_t *ptep); 58void pmd_set(pmd_t *pmdp, pte_t *ptep);
59#define pmd_populate_kernel(MM, PMD, PTE) pmd_set(PMD, PTE) 59#define pmd_populate_kernel(MM, PMD, PTE) pmd_set(PMD, PTE)
60 60
61pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long address); 61pgtable_t pte_alloc_one(struct mm_struct *mm);
62 62
63static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, 63static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm)
64 unsigned long address)
65{ 64{
66 return srmmu_get_nocache(PTE_SIZE, PTE_SIZE); 65 return srmmu_get_nocache(PTE_SIZE, PTE_SIZE);
67} 66}
diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
index 874632f34f62..48abccba4991 100644
--- a/arch/sparc/include/asm/pgalloc_64.h
+++ b/arch/sparc/include/asm/pgalloc_64.h
@@ -60,10 +60,8 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
60 kmem_cache_free(pgtable_cache, pmd); 60 kmem_cache_free(pgtable_cache, pmd);
61} 61}
62 62
63pte_t *pte_alloc_one_kernel(struct mm_struct *mm, 63pte_t *pte_alloc_one_kernel(struct mm_struct *mm);
64 unsigned long address); 64pgtable_t pte_alloc_one(struct mm_struct *mm);
65pgtable_t pte_alloc_one(struct mm_struct *mm,
66 unsigned long address);
67void pte_free_kernel(struct mm_struct *mm, pte_t *pte); 65void pte_free_kernel(struct mm_struct *mm, pte_t *pte);
68void pte_free(struct mm_struct *mm, pgtable_t ptepage); 66void pte_free(struct mm_struct *mm, pgtable_t ptepage);
69 67
diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
index 3c8aac21f426..b4221d3727d0 100644
--- a/arch/sparc/mm/init_64.c
+++ b/arch/sparc/mm/init_64.c
@@ -2925,8 +2925,7 @@ void __flush_tlb_all(void)
2925 : : "r" (pstate)); 2925 : : "r" (pstate));
2926} 2926}
2927 2927
2928pte_t *pte_alloc_one_kernel(struct mm_struct *mm, 2928pte_t *pte_alloc_one_kernel(struct mm_struct *mm)
2929 unsigned long address)
2930{ 2929{
2931 struct page *page = alloc_page(GFP_KERNEL | __GFP_ZERO); 2930 struct page *page = alloc_page(GFP_KERNEL | __GFP_ZERO);
2932 pte_t *pte = NULL; 2931 pte_t *pte = NULL;
@@ -2937,8 +2936,7 @@ pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
2937 return pte; 2936 return pte;
2938} 2937}
2939 2938
2940pgtable_t pte_alloc_one(struct mm_struct *mm, 2939pgtable_t pte_alloc_one(struct mm_struct *mm)
2941 unsigned long address)
2942{ 2940{
2943 struct page *page = alloc_page(GFP_KERNEL | __GFP_ZERO); 2941 struct page *page = alloc_page(GFP_KERNEL | __GFP_ZERO);
2944 if (!page) 2942 if (!page)
diff --git a/arch/sparc/mm/srmmu.c b/arch/sparc/mm/srmmu.c
index a6142c5abf61..b609362e846f 100644
--- a/arch/sparc/mm/srmmu.c
+++ b/arch/sparc/mm/srmmu.c
@@ -364,12 +364,12 @@ pgd_t *get_pgd_fast(void)
364 * Alignments up to the page size are the same for physical and virtual 364 * Alignments up to the page size are the same for physical and virtual
365 * addresses of the nocache area. 365 * addresses of the nocache area.
366 */ 366 */
367pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long address) 367pgtable_t pte_alloc_one(struct mm_struct *mm)
368{ 368{
369 unsigned long pte; 369 unsigned long pte;
370 struct page *page; 370 struct page *page;
371 371
372 if ((pte = (unsigned long)pte_alloc_one_kernel(mm, address)) == 0) 372 if ((pte = (unsigned long)pte_alloc_one_kernel(mm)) == 0)
373 return NULL; 373 return NULL;
374 page = pfn_to_page(__nocache_pa(pte) >> PAGE_SHIFT); 374 page = pfn_to_page(__nocache_pa(pte) >> PAGE_SHIFT);
375 if (!pgtable_page_ctor(page)) { 375 if (!pgtable_page_ctor(page)) {
diff --git a/arch/um/include/asm/pgalloc.h b/arch/um/include/asm/pgalloc.h
index bf90b2aa2002..99eb5682792a 100644
--- a/arch/um/include/asm/pgalloc.h
+++ b/arch/um/include/asm/pgalloc.h
@@ -25,8 +25,8 @@
25extern pgd_t *pgd_alloc(struct mm_struct *); 25extern pgd_t *pgd_alloc(struct mm_struct *);
26extern void pgd_free(struct mm_struct *mm, pgd_t *pgd); 26extern void pgd_free(struct mm_struct *mm, pgd_t *pgd);
27 27
28extern pte_t *pte_alloc_one_kernel(struct mm_struct *, unsigned long); 28extern pte_t *pte_alloc_one_kernel(struct mm_struct *);
29extern pgtable_t pte_alloc_one(struct mm_struct *, unsigned long); 29extern pgtable_t pte_alloc_one(struct mm_struct *);
30 30
31static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte) 31static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
32{ 32{
diff --git a/arch/um/kernel/mem.c b/arch/um/kernel/mem.c
index 8d21a83dd289..799b571a8f88 100644
--- a/arch/um/kernel/mem.c
+++ b/arch/um/kernel/mem.c
@@ -199,7 +199,7 @@ void pgd_free(struct mm_struct *mm, pgd_t *pgd)
199 free_page((unsigned long) pgd); 199 free_page((unsigned long) pgd);
200} 200}
201 201
202pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address) 202pte_t *pte_alloc_one_kernel(struct mm_struct *mm)
203{ 203{
204 pte_t *pte; 204 pte_t *pte;
205 205
@@ -207,7 +207,7 @@ pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
207 return pte; 207 return pte;
208} 208}
209 209
210pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long address) 210pgtable_t pte_alloc_one(struct mm_struct *mm)
211{ 211{
212 struct page *pte; 212 struct page *pte;
213 213
diff --git a/arch/unicore32/include/asm/bitops.h b/arch/unicore32/include/asm/bitops.h
index c0cbdbe17168..de5853761c22 100644
--- a/arch/unicore32/include/asm/bitops.h
+++ b/arch/unicore32/include/asm/bitops.h
@@ -22,7 +22,7 @@
22 * the cntlz instruction for much better code efficiency. 22 * the cntlz instruction for much better code efficiency.
23 */ 23 */
24 24
25static inline int fls(int x) 25static inline int fls(unsigned int x)
26{ 26{
27 int ret; 27 int ret;
28 28
diff --git a/arch/unicore32/include/asm/pgalloc.h b/arch/unicore32/include/asm/pgalloc.h
index f0fdb268f8f2..7cceabecf4e3 100644
--- a/arch/unicore32/include/asm/pgalloc.h
+++ b/arch/unicore32/include/asm/pgalloc.h
@@ -34,7 +34,7 @@ extern void free_pgd_slow(struct mm_struct *mm, pgd_t *pgd);
34 * Allocate one PTE table. 34 * Allocate one PTE table.
35 */ 35 */
36static inline pte_t * 36static inline pte_t *
37pte_alloc_one_kernel(struct mm_struct *mm, unsigned long addr) 37pte_alloc_one_kernel(struct mm_struct *mm)
38{ 38{
39 pte_t *pte; 39 pte_t *pte;
40 40
@@ -46,7 +46,7 @@ pte_alloc_one_kernel(struct mm_struct *mm, unsigned long addr)
46} 46}
47 47
48static inline pgtable_t 48static inline pgtable_t
49pte_alloc_one(struct mm_struct *mm, unsigned long addr) 49pte_alloc_one(struct mm_struct *mm)
50{ 50{
51 struct page *pte; 51 struct page *pte;
52 52
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index e260460210e1..6185d4f33296 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -172,6 +172,7 @@ config X86
172 select HAVE_MEMBLOCK_NODE_MAP 172 select HAVE_MEMBLOCK_NODE_MAP
173 select HAVE_MIXED_BREAKPOINTS_REGS 173 select HAVE_MIXED_BREAKPOINTS_REGS
174 select HAVE_MOD_ARCH_SPECIFIC 174 select HAVE_MOD_ARCH_SPECIFIC
175 select HAVE_MOVE_PMD
175 select HAVE_NMI 176 select HAVE_NMI
176 select HAVE_OPROFILE 177 select HAVE_OPROFILE
177 select HAVE_OPTPROBES 178 select HAVE_OPTPROBES
diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
index 124f9195eb3e..ad7b210aa3f6 100644
--- a/arch/x86/include/asm/bitops.h
+++ b/arch/x86/include/asm/bitops.h
@@ -448,7 +448,7 @@ static __always_inline int ffs(int x)
448 * set bit if value is nonzero. The last (most significant) bit is 448 * set bit if value is nonzero. The last (most significant) bit is
449 * at position 32. 449 * at position 32.
450 */ 450 */
451static __always_inline int fls(int x) 451static __always_inline int fls(unsigned int x)
452{ 452{
453 int r; 453 int r;
454 454
diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
index 1ea41aaef68b..a281e61ec60c 100644
--- a/arch/x86/include/asm/pgalloc.h
+++ b/arch/x86/include/asm/pgalloc.h
@@ -47,8 +47,8 @@ extern gfp_t __userpte_alloc_gfp;
47extern pgd_t *pgd_alloc(struct mm_struct *); 47extern pgd_t *pgd_alloc(struct mm_struct *);
48extern void pgd_free(struct mm_struct *mm, pgd_t *pgd); 48extern void pgd_free(struct mm_struct *mm, pgd_t *pgd);
49 49
50extern pte_t *pte_alloc_one_kernel(struct mm_struct *, unsigned long); 50extern pte_t *pte_alloc_one_kernel(struct mm_struct *);
51extern pgtable_t pte_alloc_one(struct mm_struct *, unsigned long); 51extern pgtable_t pte_alloc_one(struct mm_struct *);
52 52
53/* Should really implement gc for free page table pages. This could be 53/* Should really implement gc for free page table pages. This could be
54 done with a reference count in struct page. */ 54 done with a reference count in struct page. */
diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
index b0284eab14dc..7bd01709a091 100644
--- a/arch/x86/mm/pgtable.c
+++ b/arch/x86/mm/pgtable.c
@@ -23,12 +23,12 @@ EXPORT_SYMBOL(physical_mask);
23 23
24gfp_t __userpte_alloc_gfp = PGALLOC_GFP | PGALLOC_USER_GFP; 24gfp_t __userpte_alloc_gfp = PGALLOC_GFP | PGALLOC_USER_GFP;
25 25
26pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address) 26pte_t *pte_alloc_one_kernel(struct mm_struct *mm)
27{ 27{
28 return (pte_t *)__get_free_page(PGALLOC_GFP & ~__GFP_ACCOUNT); 28 return (pte_t *)__get_free_page(PGALLOC_GFP & ~__GFP_ACCOUNT);
29} 29}
30 30
31pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long address) 31pgtable_t pte_alloc_one(struct mm_struct *mm)
32{ 32{
33 struct page *pte; 33 struct page *pte;
34 34
diff --git a/arch/xtensa/include/asm/pgalloc.h b/arch/xtensa/include/asm/pgalloc.h
index 1065bc8bcae5..b3b388ff2f01 100644
--- a/arch/xtensa/include/asm/pgalloc.h
+++ b/arch/xtensa/include/asm/pgalloc.h
@@ -38,8 +38,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
38 free_page((unsigned long)pgd); 38 free_page((unsigned long)pgd);
39} 39}
40 40
41static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, 41static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm)
42 unsigned long address)
43{ 42{
44 pte_t *ptep; 43 pte_t *ptep;
45 int i; 44 int i;
@@ -52,13 +51,12 @@ static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
52 return ptep; 51 return ptep;
53} 52}
54 53
55static inline pgtable_t pte_alloc_one(struct mm_struct *mm, 54static inline pgtable_t pte_alloc_one(struct mm_struct *mm)
56 unsigned long addr)
57{ 55{
58 pte_t *pte; 56 pte_t *pte;
59 struct page *page; 57 struct page *page;
60 58
61 pte = pte_alloc_one_kernel(mm, addr); 59 pte = pte_alloc_one_kernel(mm);
62 if (!pte) 60 if (!pte)
63 return NULL; 61 return NULL;
64 page = virt_to_page(pte); 62 page = virt_to_page(pte);
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index be6c1eb3cbe2..1c958eb33ef4 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -26,6 +26,7 @@
26#include <linux/clk/clk-conf.h> 26#include <linux/clk/clk-conf.h>
27#include <linux/limits.h> 27#include <linux/limits.h>
28#include <linux/property.h> 28#include <linux/property.h>
29#include <linux/kmemleak.h>
29 30
30#include "base.h" 31#include "base.h"
31#include "power/power.h" 32#include "power/power.h"
@@ -524,6 +525,8 @@ struct platform_device *platform_device_register_full(
524 if (!pdev->dev.dma_mask) 525 if (!pdev->dev.dma_mask)
525 goto err; 526 goto err;
526 527
528 kmemleak_ignore(pdev->dev.dma_mask);
529
527 *pdev->dev.dma_mask = pdevinfo->dma_mask; 530 *pdev->dev.dma_mask = pdevinfo->dma_mask;
528 pdev->dev.coherent_dma_mask = pdevinfo->dma_mask; 531 pdev->dev.coherent_dma_mask = pdevinfo->dma_mask;
529 } 532 }
diff --git a/drivers/dma-buf/udmabuf.c b/drivers/dma-buf/udmabuf.c
index fc359ca4503d..cd57747286f2 100644
--- a/drivers/dma-buf/udmabuf.c
+++ b/drivers/dma-buf/udmabuf.c
@@ -20,7 +20,7 @@ struct udmabuf {
20 struct page **pages; 20 struct page **pages;
21}; 21};
22 22
23static int udmabuf_vm_fault(struct vm_fault *vmf) 23static vm_fault_t udmabuf_vm_fault(struct vm_fault *vmf)
24{ 24{
25 struct vm_area_struct *vma = vmf->vma; 25 struct vm_area_struct *vma = vmf->vma;
26 struct udmabuf *ubuf = vma->vm_private_data; 26 struct udmabuf *ubuf = vma->vm_private_data;
diff --git a/drivers/firmware/memmap.c b/drivers/firmware/memmap.c
index d168c87c7d30..ec4fd253a4e9 100644
--- a/drivers/firmware/memmap.c
+++ b/drivers/firmware/memmap.c
@@ -333,7 +333,7 @@ int __init firmware_map_add_early(u64 start, u64 end, const char *type)
333{ 333{
334 struct firmware_map_entry *entry; 334 struct firmware_map_entry *entry;
335 335
336 entry = memblock_alloc(sizeof(struct firmware_map_entry), 336 entry = memblock_alloc_nopanic(sizeof(struct firmware_map_entry),
337 SMP_CACHE_BYTES); 337 SMP_CACHE_BYTES);
338 if (WARN_ON(!entry)) 338 if (WARN_ON(!entry))
339 return -ENOMEM; 339 return -ENOMEM;
diff --git a/fs/afs/file.c b/fs/afs/file.c
index d6bc3f5d784b..323ae9912203 100644
--- a/fs/afs/file.c
+++ b/fs/afs/file.c
@@ -17,6 +17,7 @@
17#include <linux/writeback.h> 17#include <linux/writeback.h>
18#include <linux/gfp.h> 18#include <linux/gfp.h>
19#include <linux/task_io_accounting_ops.h> 19#include <linux/task_io_accounting_ops.h>
20#include <linux/mm.h>
20#include "internal.h" 21#include "internal.h"
21 22
22static int afs_file_mmap(struct file *file, struct vm_area_struct *vma); 23static int afs_file_mmap(struct file *file, struct vm_area_struct *vma);
@@ -441,7 +442,7 @@ static int afs_readpages_one(struct file *file, struct address_space *mapping,
441 /* Count the number of contiguous pages at the front of the list. Note 442 /* Count the number of contiguous pages at the front of the list. Note
442 * that the list goes prev-wards rather than next-wards. 443 * that the list goes prev-wards rather than next-wards.
443 */ 444 */
444 first = list_entry(pages->prev, struct page, lru); 445 first = lru_to_page(pages);
445 index = first->index + 1; 446 index = first->index + 1;
446 n = 1; 447 n = 1;
447 for (p = first->lru.prev; p != pages; p = p->prev) { 448 for (p = first->lru.prev; p != pages; p = p->prev) {
@@ -473,7 +474,7 @@ static int afs_readpages_one(struct file *file, struct address_space *mapping,
473 * page at the end of the file. 474 * page at the end of the file.
474 */ 475 */
475 do { 476 do {
476 page = list_entry(pages->prev, struct page, lru); 477 page = lru_to_page(pages);
477 list_del(&page->lru); 478 list_del(&page->lru);
478 index = page->index; 479 index = page->index;
479 if (add_to_page_cache_lru(page, mapping, index, 480 if (add_to_page_cache_lru(page, mapping, index,
diff --git a/fs/afs/fs_probe.c b/fs/afs/fs_probe.c
index fde6b4d4121e..3a9eaec06756 100644
--- a/fs/afs/fs_probe.c
+++ b/fs/afs/fs_probe.c
@@ -247,7 +247,7 @@ int afs_wait_for_fs_probes(struct afs_server_list *slist, unsigned long untried)
247 } 247 }
248 } 248 }
249 249
250 if (!still_probing || unlikely(signal_pending(current))) 250 if (!still_probing || signal_pending(current))
251 goto stop; 251 goto stop;
252 schedule(); 252 schedule();
253 } 253 }
diff --git a/fs/afs/vl_probe.c b/fs/afs/vl_probe.c
index f0b032976487..f402ee8171a1 100644
--- a/fs/afs/vl_probe.c
+++ b/fs/afs/vl_probe.c
@@ -248,7 +248,7 @@ int afs_wait_for_vl_probes(struct afs_vlserver_list *vllist,
248 } 248 }
249 } 249 }
250 250
251 if (!still_probing || unlikely(signal_pending(current))) 251 if (!still_probing || signal_pending(current))
252 goto stop; 252 goto stop;
253 schedule(); 253 schedule();
254 } 254 }
diff --git a/fs/autofs/autofs_i.h b/fs/autofs/autofs_i.h
index 9f9cadbfbd7a..3e59f0ed777b 100644
--- a/fs/autofs/autofs_i.h
+++ b/fs/autofs/autofs_i.h
@@ -42,6 +42,8 @@
42#endif 42#endif
43#define pr_fmt(fmt) KBUILD_MODNAME ":pid:%d:%s: " fmt, current->pid, __func__ 43#define pr_fmt(fmt) KBUILD_MODNAME ":pid:%d:%s: " fmt, current->pid, __func__
44 44
45extern struct file_system_type autofs_fs_type;
46
45/* 47/*
46 * Unified info structure. This is pointed to by both the dentry and 48 * Unified info structure. This is pointed to by both the dentry and
47 * inode structures. Each file in the filesystem has an instance of this 49 * inode structures. Each file in the filesystem has an instance of this
@@ -101,16 +103,19 @@ struct autofs_wait_queue {
101 103
102#define AUTOFS_SBI_MAGIC 0x6d4a556d 104#define AUTOFS_SBI_MAGIC 0x6d4a556d
103 105
106#define AUTOFS_SBI_CATATONIC 0x0001
107#define AUTOFS_SBI_STRICTEXPIRE 0x0002
108
104struct autofs_sb_info { 109struct autofs_sb_info {
105 u32 magic; 110 u32 magic;
106 int pipefd; 111 int pipefd;
107 struct file *pipe; 112 struct file *pipe;
108 struct pid *oz_pgrp; 113 struct pid *oz_pgrp;
109 int catatonic;
110 int version; 114 int version;
111 int sub_version; 115 int sub_version;
112 int min_proto; 116 int min_proto;
113 int max_proto; 117 int max_proto;
118 unsigned int flags;
114 unsigned long exp_timeout; 119 unsigned long exp_timeout;
115 unsigned int type; 120 unsigned int type;
116 struct super_block *sb; 121 struct super_block *sb;
@@ -126,8 +131,7 @@ struct autofs_sb_info {
126 131
127static inline struct autofs_sb_info *autofs_sbi(struct super_block *sb) 132static inline struct autofs_sb_info *autofs_sbi(struct super_block *sb)
128{ 133{
129 return sb->s_magic != AUTOFS_SUPER_MAGIC ? 134 return (struct autofs_sb_info *)(sb->s_fs_info);
130 NULL : (struct autofs_sb_info *)(sb->s_fs_info);
131} 135}
132 136
133static inline struct autofs_info *autofs_dentry_ino(struct dentry *dentry) 137static inline struct autofs_info *autofs_dentry_ino(struct dentry *dentry)
@@ -141,7 +145,8 @@ static inline struct autofs_info *autofs_dentry_ino(struct dentry *dentry)
141 */ 145 */
142static inline int autofs_oz_mode(struct autofs_sb_info *sbi) 146static inline int autofs_oz_mode(struct autofs_sb_info *sbi)
143{ 147{
144 return sbi->catatonic || task_pgrp(current) == sbi->oz_pgrp; 148 return ((sbi->flags & AUTOFS_SBI_CATATONIC) ||
149 task_pgrp(current) == sbi->oz_pgrp);
145} 150}
146 151
147struct inode *autofs_get_inode(struct super_block *, umode_t); 152struct inode *autofs_get_inode(struct super_block *, umode_t);
diff --git a/fs/autofs/dev-ioctl.c b/fs/autofs/dev-ioctl.c
index 86eafda4a652..e9fe74d1541b 100644
--- a/fs/autofs/dev-ioctl.c
+++ b/fs/autofs/dev-ioctl.c
@@ -151,22 +151,6 @@ out:
151 return err; 151 return err;
152} 152}
153 153
154/*
155 * Get the autofs super block info struct from the file opened on
156 * the autofs mount point.
157 */
158static struct autofs_sb_info *autofs_dev_ioctl_sbi(struct file *f)
159{
160 struct autofs_sb_info *sbi = NULL;
161 struct inode *inode;
162
163 if (f) {
164 inode = file_inode(f);
165 sbi = autofs_sbi(inode->i_sb);
166 }
167 return sbi;
168}
169
170/* Return autofs dev ioctl version */ 154/* Return autofs dev ioctl version */
171static int autofs_dev_ioctl_version(struct file *fp, 155static int autofs_dev_ioctl_version(struct file *fp,
172 struct autofs_sb_info *sbi, 156 struct autofs_sb_info *sbi,
@@ -366,7 +350,7 @@ static int autofs_dev_ioctl_setpipefd(struct file *fp,
366 pipefd = param->setpipefd.pipefd; 350 pipefd = param->setpipefd.pipefd;
367 351
368 mutex_lock(&sbi->wq_mutex); 352 mutex_lock(&sbi->wq_mutex);
369 if (!sbi->catatonic) { 353 if (!(sbi->flags & AUTOFS_SBI_CATATONIC)) {
370 mutex_unlock(&sbi->wq_mutex); 354 mutex_unlock(&sbi->wq_mutex);
371 return -EBUSY; 355 return -EBUSY;
372 } else { 356 } else {
@@ -393,7 +377,7 @@ static int autofs_dev_ioctl_setpipefd(struct file *fp,
393 swap(sbi->oz_pgrp, new_pid); 377 swap(sbi->oz_pgrp, new_pid);
394 sbi->pipefd = pipefd; 378 sbi->pipefd = pipefd;
395 sbi->pipe = pipe; 379 sbi->pipe = pipe;
396 sbi->catatonic = 0; 380 sbi->flags &= ~AUTOFS_SBI_CATATONIC;
397 } 381 }
398out: 382out:
399 put_pid(new_pid); 383 put_pid(new_pid);
@@ -658,6 +642,8 @@ static int _autofs_dev_ioctl(unsigned int command,
658 if (cmd != AUTOFS_DEV_IOCTL_VERSION_CMD && 642 if (cmd != AUTOFS_DEV_IOCTL_VERSION_CMD &&
659 cmd != AUTOFS_DEV_IOCTL_OPENMOUNT_CMD && 643 cmd != AUTOFS_DEV_IOCTL_OPENMOUNT_CMD &&
660 cmd != AUTOFS_DEV_IOCTL_CLOSEMOUNT_CMD) { 644 cmd != AUTOFS_DEV_IOCTL_CLOSEMOUNT_CMD) {
645 struct super_block *sb;
646
661 fp = fget(param->ioctlfd); 647 fp = fget(param->ioctlfd);
662 if (!fp) { 648 if (!fp) {
663 if (cmd == AUTOFS_DEV_IOCTL_ISMOUNTPOINT_CMD) 649 if (cmd == AUTOFS_DEV_IOCTL_ISMOUNTPOINT_CMD)
@@ -666,12 +652,13 @@ static int _autofs_dev_ioctl(unsigned int command,
666 goto out; 652 goto out;
667 } 653 }
668 654
669 sbi = autofs_dev_ioctl_sbi(fp); 655 sb = file_inode(fp)->i_sb;
670 if (!sbi || sbi->magic != AUTOFS_SBI_MAGIC) { 656 if (sb->s_type != &autofs_fs_type) {
671 err = -EINVAL; 657 err = -EINVAL;
672 fput(fp); 658 fput(fp);
673 goto out; 659 goto out;
674 } 660 }
661 sbi = autofs_sbi(sb);
675 662
676 /* 663 /*
677 * Admin needs to be able to set the mount catatonic in 664 * Admin needs to be able to set the mount catatonic in
diff --git a/fs/autofs/init.c b/fs/autofs/init.c
index 79ae07d9592f..c0c1db2cc6ea 100644
--- a/fs/autofs/init.c
+++ b/fs/autofs/init.c
@@ -16,7 +16,7 @@ static struct dentry *autofs_mount(struct file_system_type *fs_type,
16 return mount_nodev(fs_type, flags, data, autofs_fill_super); 16 return mount_nodev(fs_type, flags, data, autofs_fill_super);
17} 17}
18 18
19static struct file_system_type autofs_fs_type = { 19struct file_system_type autofs_fs_type = {
20 .owner = THIS_MODULE, 20 .owner = THIS_MODULE,
21 .name = "autofs", 21 .name = "autofs",
22 .mount = autofs_mount, 22 .mount = autofs_mount,
diff --git a/fs/autofs/inode.c b/fs/autofs/inode.c
index 846c052569dd..0e8ea2d9a2bb 100644
--- a/fs/autofs/inode.c
+++ b/fs/autofs/inode.c
@@ -87,6 +87,8 @@ static int autofs_show_options(struct seq_file *m, struct dentry *root)
87 seq_printf(m, ",direct"); 87 seq_printf(m, ",direct");
88 else 88 else
89 seq_printf(m, ",indirect"); 89 seq_printf(m, ",indirect");
90 if (sbi->flags & AUTOFS_SBI_STRICTEXPIRE)
91 seq_printf(m, ",strictexpire");
90#ifdef CONFIG_CHECKPOINT_RESTORE 92#ifdef CONFIG_CHECKPOINT_RESTORE
91 if (sbi->pipe) 93 if (sbi->pipe)
92 seq_printf(m, ",pipe_ino=%ld", file_inode(sbi->pipe)->i_ino); 94 seq_printf(m, ",pipe_ino=%ld", file_inode(sbi->pipe)->i_ino);
@@ -109,7 +111,7 @@ static const struct super_operations autofs_sops = {
109}; 111};
110 112
111enum {Opt_err, Opt_fd, Opt_uid, Opt_gid, Opt_pgrp, Opt_minproto, Opt_maxproto, 113enum {Opt_err, Opt_fd, Opt_uid, Opt_gid, Opt_pgrp, Opt_minproto, Opt_maxproto,
112 Opt_indirect, Opt_direct, Opt_offset}; 114 Opt_indirect, Opt_direct, Opt_offset, Opt_strictexpire};
113 115
114static const match_table_t tokens = { 116static const match_table_t tokens = {
115 {Opt_fd, "fd=%u"}, 117 {Opt_fd, "fd=%u"},
@@ -121,24 +123,28 @@ static const match_table_t tokens = {
121 {Opt_indirect, "indirect"}, 123 {Opt_indirect, "indirect"},
122 {Opt_direct, "direct"}, 124 {Opt_direct, "direct"},
123 {Opt_offset, "offset"}, 125 {Opt_offset, "offset"},
126 {Opt_strictexpire, "strictexpire"},
124 {Opt_err, NULL} 127 {Opt_err, NULL}
125}; 128};
126 129
127static int parse_options(char *options, int *pipefd, kuid_t *uid, kgid_t *gid, 130static int parse_options(char *options,
128 int *pgrp, bool *pgrp_set, unsigned int *type, 131 struct inode *root, int *pgrp, bool *pgrp_set,
129 int *minproto, int *maxproto) 132 struct autofs_sb_info *sbi)
130{ 133{
131 char *p; 134 char *p;
132 substring_t args[MAX_OPT_ARGS]; 135 substring_t args[MAX_OPT_ARGS];
133 int option; 136 int option;
137 int pipefd = -1;
138 kuid_t uid;
139 kgid_t gid;
134 140
135 *uid = current_uid(); 141 root->i_uid = current_uid();
136 *gid = current_gid(); 142 root->i_gid = current_gid();
137 143
138 *minproto = AUTOFS_MIN_PROTO_VERSION; 144 sbi->min_proto = AUTOFS_MIN_PROTO_VERSION;
139 *maxproto = AUTOFS_MAX_PROTO_VERSION; 145 sbi->max_proto = AUTOFS_MAX_PROTO_VERSION;
140 146
141 *pipefd = -1; 147 sbi->pipefd = -1;
142 148
143 if (!options) 149 if (!options)
144 return 1; 150 return 1;
@@ -152,22 +158,25 @@ static int parse_options(char *options, int *pipefd, kuid_t *uid, kgid_t *gid,
152 token = match_token(p, tokens, args); 158 token = match_token(p, tokens, args);
153 switch (token) { 159 switch (token) {
154 case Opt_fd: 160 case Opt_fd:
155 if (match_int(args, pipefd)) 161 if (match_int(args, &pipefd))
156 return 1; 162 return 1;
163 sbi->pipefd = pipefd;
157 break; 164 break;
158 case Opt_uid: 165 case Opt_uid:
159 if (match_int(args, &option)) 166 if (match_int(args, &option))
160 return 1; 167 return 1;
161 *uid = make_kuid(current_user_ns(), option); 168 uid = make_kuid(current_user_ns(), option);
162 if (!uid_valid(*uid)) 169 if (!uid_valid(uid))
163 return 1; 170 return 1;
171 root->i_uid = uid;
164 break; 172 break;
165 case Opt_gid: 173 case Opt_gid:
166 if (match_int(args, &option)) 174 if (match_int(args, &option))
167 return 1; 175 return 1;
168 *gid = make_kgid(current_user_ns(), option); 176 gid = make_kgid(current_user_ns(), option);
169 if (!gid_valid(*gid)) 177 if (!gid_valid(gid))
170 return 1; 178 return 1;
179 root->i_gid = gid;
171 break; 180 break;
172 case Opt_pgrp: 181 case Opt_pgrp:
173 if (match_int(args, &option)) 182 if (match_int(args, &option))
@@ -178,27 +187,30 @@ static int parse_options(char *options, int *pipefd, kuid_t *uid, kgid_t *gid,
178 case Opt_minproto: 187 case Opt_minproto:
179 if (match_int(args, &option)) 188 if (match_int(args, &option))
180 return 1; 189 return 1;
181 *minproto = option; 190 sbi->min_proto = option;
182 break; 191 break;
183 case Opt_maxproto: 192 case Opt_maxproto:
184 if (match_int(args, &option)) 193 if (match_int(args, &option))
185 return 1; 194 return 1;
186 *maxproto = option; 195 sbi->max_proto = option;
187 break; 196 break;
188 case Opt_indirect: 197 case Opt_indirect:
189 set_autofs_type_indirect(type); 198 set_autofs_type_indirect(&sbi->type);
190 break; 199 break;
191 case Opt_direct: 200 case Opt_direct:
192 set_autofs_type_direct(type); 201 set_autofs_type_direct(&sbi->type);
193 break; 202 break;
194 case Opt_offset: 203 case Opt_offset:
195 set_autofs_type_offset(type); 204 set_autofs_type_offset(&sbi->type);
205 break;
206 case Opt_strictexpire:
207 sbi->flags |= AUTOFS_SBI_STRICTEXPIRE;
196 break; 208 break;
197 default: 209 default:
198 return 1; 210 return 1;
199 } 211 }
200 } 212 }
201 return (*pipefd < 0); 213 return (sbi->pipefd < 0);
202} 214}
203 215
204int autofs_fill_super(struct super_block *s, void *data, int silent) 216int autofs_fill_super(struct super_block *s, void *data, int silent)
@@ -206,7 +218,6 @@ int autofs_fill_super(struct super_block *s, void *data, int silent)
206 struct inode *root_inode; 218 struct inode *root_inode;
207 struct dentry *root; 219 struct dentry *root;
208 struct file *pipe; 220 struct file *pipe;
209 int pipefd;
210 struct autofs_sb_info *sbi; 221 struct autofs_sb_info *sbi;
211 struct autofs_info *ino; 222 struct autofs_info *ino;
212 int pgrp = 0; 223 int pgrp = 0;
@@ -222,12 +233,12 @@ int autofs_fill_super(struct super_block *s, void *data, int silent)
222 sbi->magic = AUTOFS_SBI_MAGIC; 233 sbi->magic = AUTOFS_SBI_MAGIC;
223 sbi->pipefd = -1; 234 sbi->pipefd = -1;
224 sbi->pipe = NULL; 235 sbi->pipe = NULL;
225 sbi->catatonic = 1;
226 sbi->exp_timeout = 0; 236 sbi->exp_timeout = 0;
227 sbi->oz_pgrp = NULL; 237 sbi->oz_pgrp = NULL;
228 sbi->sb = s; 238 sbi->sb = s;
229 sbi->version = 0; 239 sbi->version = 0;
230 sbi->sub_version = 0; 240 sbi->sub_version = 0;
241 sbi->flags = AUTOFS_SBI_CATATONIC;
231 set_autofs_type_indirect(&sbi->type); 242 set_autofs_type_indirect(&sbi->type);
232 sbi->min_proto = 0; 243 sbi->min_proto = 0;
233 sbi->max_proto = 0; 244 sbi->max_proto = 0;
@@ -262,9 +273,7 @@ int autofs_fill_super(struct super_block *s, void *data, int silent)
262 root->d_fsdata = ino; 273 root->d_fsdata = ino;
263 274
264 /* Can this call block? */ 275 /* Can this call block? */
265 if (parse_options(data, &pipefd, &root_inode->i_uid, &root_inode->i_gid, 276 if (parse_options(data, root_inode, &pgrp, &pgrp_set, sbi)) {
266 &pgrp, &pgrp_set, &sbi->type, &sbi->min_proto,
267 &sbi->max_proto)) {
268 pr_err("called with bogus options\n"); 277 pr_err("called with bogus options\n");
269 goto fail_dput; 278 goto fail_dput;
270 } 279 }
@@ -303,8 +312,9 @@ int autofs_fill_super(struct super_block *s, void *data, int silent)
303 root_inode->i_fop = &autofs_root_operations; 312 root_inode->i_fop = &autofs_root_operations;
304 root_inode->i_op = &autofs_dir_inode_operations; 313 root_inode->i_op = &autofs_dir_inode_operations;
305 314
306 pr_debug("pipe fd = %d, pgrp = %u\n", pipefd, pid_nr(sbi->oz_pgrp)); 315 pr_debug("pipe fd = %d, pgrp = %u\n",
307 pipe = fget(pipefd); 316 sbi->pipefd, pid_nr(sbi->oz_pgrp));
317 pipe = fget(sbi->pipefd);
308 318
309 if (!pipe) { 319 if (!pipe) {
310 pr_err("could not open pipe file descriptor\n"); 320 pr_err("could not open pipe file descriptor\n");
@@ -314,8 +324,7 @@ int autofs_fill_super(struct super_block *s, void *data, int silent)
314 if (ret < 0) 324 if (ret < 0)
315 goto fail_fput; 325 goto fail_fput;
316 sbi->pipe = pipe; 326 sbi->pipe = pipe;
317 sbi->pipefd = pipefd; 327 sbi->flags &= ~AUTOFS_SBI_CATATONIC;
318 sbi->catatonic = 0;
319 328
320 /* 329 /*
321 * Success! Install the root dentry now to indicate completion. 330 * Success! Install the root dentry now to indicate completion.
diff --git a/fs/autofs/root.c b/fs/autofs/root.c
index 782e57b911ab..1246f396bf0e 100644
--- a/fs/autofs/root.c
+++ b/fs/autofs/root.c
@@ -275,8 +275,11 @@ static int autofs_mount_wait(const struct path *path, bool rcu_walk)
275 pr_debug("waiting for mount name=%pd\n", path->dentry); 275 pr_debug("waiting for mount name=%pd\n", path->dentry);
276 status = autofs_wait(sbi, path, NFY_MOUNT); 276 status = autofs_wait(sbi, path, NFY_MOUNT);
277 pr_debug("mount wait done status=%d\n", status); 277 pr_debug("mount wait done status=%d\n", status);
278 ino->last_used = jiffies;
279 return status;
278 } 280 }
279 ino->last_used = jiffies; 281 if (!(sbi->flags & AUTOFS_SBI_STRICTEXPIRE))
282 ino->last_used = jiffies;
280 return status; 283 return status;
281} 284}
282 285
@@ -510,7 +513,8 @@ static struct dentry *autofs_lookup(struct inode *dir,
510 sbi = autofs_sbi(dir->i_sb); 513 sbi = autofs_sbi(dir->i_sb);
511 514
512 pr_debug("pid = %u, pgrp = %u, catatonic = %d, oz_mode = %d\n", 515 pr_debug("pid = %u, pgrp = %u, catatonic = %d, oz_mode = %d\n",
513 current->pid, task_pgrp_nr(current), sbi->catatonic, 516 current->pid, task_pgrp_nr(current),
517 sbi->flags & AUTOFS_SBI_CATATONIC,
514 autofs_oz_mode(sbi)); 518 autofs_oz_mode(sbi));
515 519
516 active = autofs_lookup_active(dentry); 520 active = autofs_lookup_active(dentry);
@@ -563,7 +567,7 @@ static int autofs_dir_symlink(struct inode *dir,
563 * autofs mount is catatonic but the state of an autofs 567 * autofs mount is catatonic but the state of an autofs
564 * file system needs to be preserved over restarts. 568 * file system needs to be preserved over restarts.
565 */ 569 */
566 if (sbi->catatonic) 570 if (sbi->flags & AUTOFS_SBI_CATATONIC)
567 return -EACCES; 571 return -EACCES;
568 572
569 BUG_ON(!ino); 573 BUG_ON(!ino);
@@ -626,7 +630,7 @@ static int autofs_dir_unlink(struct inode *dir, struct dentry *dentry)
626 * autofs mount is catatonic but the state of an autofs 630 * autofs mount is catatonic but the state of an autofs
627 * file system needs to be preserved over restarts. 631 * file system needs to be preserved over restarts.
628 */ 632 */
629 if (sbi->catatonic) 633 if (sbi->flags & AUTOFS_SBI_CATATONIC)
630 return -EACCES; 634 return -EACCES;
631 635
632 if (atomic_dec_and_test(&ino->count)) { 636 if (atomic_dec_and_test(&ino->count)) {
@@ -714,7 +718,7 @@ static int autofs_dir_rmdir(struct inode *dir, struct dentry *dentry)
714 * autofs mount is catatonic but the state of an autofs 718 * autofs mount is catatonic but the state of an autofs
715 * file system needs to be preserved over restarts. 719 * file system needs to be preserved over restarts.
716 */ 720 */
717 if (sbi->catatonic) 721 if (sbi->flags & AUTOFS_SBI_CATATONIC)
718 return -EACCES; 722 return -EACCES;
719 723
720 spin_lock(&sbi->lookup_lock); 724 spin_lock(&sbi->lookup_lock);
@@ -759,7 +763,7 @@ static int autofs_dir_mkdir(struct inode *dir,
759 * autofs mount is catatonic but the state of an autofs 763 * autofs mount is catatonic but the state of an autofs
760 * file system needs to be preserved over restarts. 764 * file system needs to be preserved over restarts.
761 */ 765 */
762 if (sbi->catatonic) 766 if (sbi->flags & AUTOFS_SBI_CATATONIC)
763 return -EACCES; 767 return -EACCES;
764 768
765 pr_debug("dentry %p, creating %pd\n", dentry, dentry); 769 pr_debug("dentry %p, creating %pd\n", dentry, dentry);
diff --git a/fs/autofs/waitq.c b/fs/autofs/waitq.c
index f6385c6ef0a5..15a3e31d0904 100644
--- a/fs/autofs/waitq.c
+++ b/fs/autofs/waitq.c
@@ -20,14 +20,14 @@ void autofs_catatonic_mode(struct autofs_sb_info *sbi)
20 struct autofs_wait_queue *wq, *nwq; 20 struct autofs_wait_queue *wq, *nwq;
21 21
22 mutex_lock(&sbi->wq_mutex); 22 mutex_lock(&sbi->wq_mutex);
23 if (sbi->catatonic) { 23 if (sbi->flags & AUTOFS_SBI_CATATONIC) {
24 mutex_unlock(&sbi->wq_mutex); 24 mutex_unlock(&sbi->wq_mutex);
25 return; 25 return;
26 } 26 }
27 27
28 pr_debug("entering catatonic mode\n"); 28 pr_debug("entering catatonic mode\n");
29 29
30 sbi->catatonic = 1; 30 sbi->flags |= AUTOFS_SBI_CATATONIC;
31 wq = sbi->queues; 31 wq = sbi->queues;
32 sbi->queues = NULL; /* Erase all wait queues */ 32 sbi->queues = NULL; /* Erase all wait queues */
33 while (wq) { 33 while (wq) {
@@ -255,7 +255,7 @@ static int validate_request(struct autofs_wait_queue **wait,
255 struct autofs_wait_queue *wq; 255 struct autofs_wait_queue *wq;
256 struct autofs_info *ino; 256 struct autofs_info *ino;
257 257
258 if (sbi->catatonic) 258 if (sbi->flags & AUTOFS_SBI_CATATONIC)
259 return -ENOENT; 259 return -ENOENT;
260 260
261 /* Wait in progress, continue; */ 261 /* Wait in progress, continue; */
@@ -290,7 +290,7 @@ static int validate_request(struct autofs_wait_queue **wait,
290 if (mutex_lock_interruptible(&sbi->wq_mutex)) 290 if (mutex_lock_interruptible(&sbi->wq_mutex))
291 return -EINTR; 291 return -EINTR;
292 292
293 if (sbi->catatonic) 293 if (sbi->flags & AUTOFS_SBI_CATATONIC)
294 return -ENOENT; 294 return -ENOENT;
295 295
296 wq = autofs_find_wait(sbi, qstr); 296 wq = autofs_find_wait(sbi, qstr);
@@ -359,7 +359,7 @@ int autofs_wait(struct autofs_sb_info *sbi,
359 pid_t tgid; 359 pid_t tgid;
360 360
361 /* In catatonic mode, we don't wait for nobody */ 361 /* In catatonic mode, we don't wait for nobody */
362 if (sbi->catatonic) 362 if (sbi->flags & AUTOFS_SBI_CATATONIC)
363 return -ENOENT; 363 return -ENOENT;
364 364
365 /* 365 /*
diff --git a/fs/bfs/bfs.h b/fs/bfs/bfs.h
index 67aef3bb89e4..606f9378b2f0 100644
--- a/fs/bfs/bfs.h
+++ b/fs/bfs/bfs.h
@@ -1,13 +1,20 @@
1/* SPDX-License-Identifier: GPL-2.0 */ 1/* SPDX-License-Identifier: GPL-2.0 */
2/* 2/*
3 * fs/bfs/bfs.h 3 * fs/bfs/bfs.h
4 * Copyright (C) 1999 Tigran Aivazian <tigran@veritas.com> 4 * Copyright (C) 1999-2018 Tigran Aivazian <aivazian.tigran@gmail.com>
5 */ 5 */
6#ifndef _FS_BFS_BFS_H 6#ifndef _FS_BFS_BFS_H
7#define _FS_BFS_BFS_H 7#define _FS_BFS_BFS_H
8 8
9#include <linux/bfs_fs.h> 9#include <linux/bfs_fs.h>
10 10
11/* In theory BFS supports up to 512 inodes, numbered from 2 (for /) up to 513 inclusive.
12 In actual fact, attempting to create the 512th inode (i.e. inode No. 513 or file No. 511)
13 will fail with ENOSPC in bfs_add_entry(): the root directory cannot contain so many entries, counting '..'.
14 So, mkfs.bfs(8) should really limit its -N option to 511 and not 512. For now, we just print a warning
15 if a filesystem is mounted with such "impossible to fill up" number of inodes */
16#define BFS_MAX_LASTI 513
17
11/* 18/*
12 * BFS file system in-core superblock info 19 * BFS file system in-core superblock info
13 */ 20 */
@@ -17,7 +24,7 @@ struct bfs_sb_info {
17 unsigned long si_freei; 24 unsigned long si_freei;
18 unsigned long si_lf_eblk; 25 unsigned long si_lf_eblk;
19 unsigned long si_lasti; 26 unsigned long si_lasti;
20 unsigned long *si_imap; 27 DECLARE_BITMAP(si_imap, BFS_MAX_LASTI+1);
21 struct mutex bfs_lock; 28 struct mutex bfs_lock;
22}; 29};
23 30
diff --git a/fs/bfs/dir.c b/fs/bfs/dir.c
index f32f21c3bbc7..d8dfe3a0cb39 100644
--- a/fs/bfs/dir.c
+++ b/fs/bfs/dir.c
@@ -2,8 +2,8 @@
2/* 2/*
3 * fs/bfs/dir.c 3 * fs/bfs/dir.c
4 * BFS directory operations. 4 * BFS directory operations.
5 * Copyright (C) 1999,2000 Tigran Aivazian <tigran@veritas.com> 5 * Copyright (C) 1999-2018 Tigran Aivazian <aivazian.tigran@gmail.com>
6 * Made endianness-clean by Andrew Stribblehill <ads@wompom.org> 2005 6 * Made endianness-clean by Andrew Stribblehill <ads@wompom.org> 2005
7 */ 7 */
8 8
9#include <linux/time.h> 9#include <linux/time.h>
diff --git a/fs/bfs/file.c b/fs/bfs/file.c
index 1476cdd90cfb..0dceefc54b48 100644
--- a/fs/bfs/file.c
+++ b/fs/bfs/file.c
@@ -2,7 +2,7 @@
2/* 2/*
3 * fs/bfs/file.c 3 * fs/bfs/file.c
4 * BFS file operations. 4 * BFS file operations.
5 * Copyright (C) 1999,2000 Tigran Aivazian <tigran@veritas.com> 5 * Copyright (C) 1999-2018 Tigran Aivazian <aivazian.tigran@gmail.com>
6 * 6 *
7 * Make the file block allocation algorithm understand the size 7 * Make the file block allocation algorithm understand the size
8 * of the underlying block device. 8 * of the underlying block device.
diff --git a/fs/bfs/inode.c b/fs/bfs/inode.c
index d81c148682e7..d136b2aaafb3 100644
--- a/fs/bfs/inode.c
+++ b/fs/bfs/inode.c
@@ -1,10 +1,9 @@
1/* 1/*
2 * fs/bfs/inode.c 2 * fs/bfs/inode.c
3 * BFS superblock and inode operations. 3 * BFS superblock and inode operations.
4 * Copyright (C) 1999-2006 Tigran Aivazian <aivazian.tigran@gmail.com> 4 * Copyright (C) 1999-2018 Tigran Aivazian <aivazian.tigran@gmail.com>
5 * From fs/minix, Copyright (C) 1991, 1992 Linus Torvalds. 5 * From fs/minix, Copyright (C) 1991, 1992 Linus Torvalds.
6 * 6 * Made endianness-clean by Andrew Stribblehill <ads@wompom.org>, 2005.
7 * Made endianness-clean by Andrew Stribblehill <ads@wompom.org>, 2005.
8 */ 7 */
9 8
10#include <linux/module.h> 9#include <linux/module.h>
@@ -118,12 +117,12 @@ static int bfs_write_inode(struct inode *inode, struct writeback_control *wbc)
118{ 117{
119 struct bfs_sb_info *info = BFS_SB(inode->i_sb); 118 struct bfs_sb_info *info = BFS_SB(inode->i_sb);
120 unsigned int ino = (u16)inode->i_ino; 119 unsigned int ino = (u16)inode->i_ino;
121 unsigned long i_sblock; 120 unsigned long i_sblock;
122 struct bfs_inode *di; 121 struct bfs_inode *di;
123 struct buffer_head *bh; 122 struct buffer_head *bh;
124 int err = 0; 123 int err = 0;
125 124
126 dprintf("ino=%08x\n", ino); 125 dprintf("ino=%08x\n", ino);
127 126
128 di = find_inode(inode->i_sb, ino, &bh); 127 di = find_inode(inode->i_sb, ino, &bh);
129 if (IS_ERR(di)) 128 if (IS_ERR(di))
@@ -144,7 +143,7 @@ static int bfs_write_inode(struct inode *inode, struct writeback_control *wbc)
144 di->i_atime = cpu_to_le32(inode->i_atime.tv_sec); 143 di->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
145 di->i_mtime = cpu_to_le32(inode->i_mtime.tv_sec); 144 di->i_mtime = cpu_to_le32(inode->i_mtime.tv_sec);
146 di->i_ctime = cpu_to_le32(inode->i_ctime.tv_sec); 145 di->i_ctime = cpu_to_le32(inode->i_ctime.tv_sec);
147 i_sblock = BFS_I(inode)->i_sblock; 146 i_sblock = BFS_I(inode)->i_sblock;
148 di->i_sblock = cpu_to_le32(i_sblock); 147 di->i_sblock = cpu_to_le32(i_sblock);
149 di->i_eblock = cpu_to_le32(BFS_I(inode)->i_eblock); 148 di->i_eblock = cpu_to_le32(BFS_I(inode)->i_eblock);
150 di->i_eoffset = cpu_to_le32(i_sblock * BFS_BSIZE + inode->i_size - 1); 149 di->i_eoffset = cpu_to_le32(i_sblock * BFS_BSIZE + inode->i_size - 1);
@@ -188,13 +187,13 @@ static void bfs_evict_inode(struct inode *inode)
188 mark_buffer_dirty(bh); 187 mark_buffer_dirty(bh);
189 brelse(bh); 188 brelse(bh);
190 189
191 if (bi->i_dsk_ino) { 190 if (bi->i_dsk_ino) {
192 if (bi->i_sblock) 191 if (bi->i_sblock)
193 info->si_freeb += bi->i_eblock + 1 - bi->i_sblock; 192 info->si_freeb += bi->i_eblock + 1 - bi->i_sblock;
194 info->si_freei++; 193 info->si_freei++;
195 clear_bit(ino, info->si_imap); 194 clear_bit(ino, info->si_imap);
196 bfs_dump_imap("delete_inode", s); 195 bfs_dump_imap("evict_inode", s);
197 } 196 }
198 197
199 /* 198 /*
200 * If this was the last file, make the previous block 199 * If this was the last file, make the previous block
@@ -214,7 +213,6 @@ static void bfs_put_super(struct super_block *s)
214 return; 213 return;
215 214
216 mutex_destroy(&info->bfs_lock); 215 mutex_destroy(&info->bfs_lock);
217 kfree(info->si_imap);
218 kfree(info); 216 kfree(info);
219 s->s_fs_info = NULL; 217 s->s_fs_info = NULL;
220} 218}
@@ -311,8 +309,7 @@ void bfs_dump_imap(const char *prefix, struct super_block *s)
311 else 309 else
312 strcat(tmpbuf, "0"); 310 strcat(tmpbuf, "0");
313 } 311 }
314 printf("BFS-fs: %s: lasti=%08lx <%s>\n", 312 printf("%s: lasti=%08lx <%s>\n", prefix, BFS_SB(s)->si_lasti, tmpbuf);
315 prefix, BFS_SB(s)->si_lasti, tmpbuf);
316 free_page((unsigned long)tmpbuf); 313 free_page((unsigned long)tmpbuf);
317#endif 314#endif
318} 315}
@@ -322,7 +319,7 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent)
322 struct buffer_head *bh, *sbh; 319 struct buffer_head *bh, *sbh;
323 struct bfs_super_block *bfs_sb; 320 struct bfs_super_block *bfs_sb;
324 struct inode *inode; 321 struct inode *inode;
325 unsigned i, imap_len; 322 unsigned i;
326 struct bfs_sb_info *info; 323 struct bfs_sb_info *info;
327 int ret = -EINVAL; 324 int ret = -EINVAL;
328 unsigned long i_sblock, i_eblock, i_eoff, s_size; 325 unsigned long i_sblock, i_eblock, i_eoff, s_size;
@@ -341,8 +338,7 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent)
341 bfs_sb = (struct bfs_super_block *)sbh->b_data; 338 bfs_sb = (struct bfs_super_block *)sbh->b_data;
342 if (le32_to_cpu(bfs_sb->s_magic) != BFS_MAGIC) { 339 if (le32_to_cpu(bfs_sb->s_magic) != BFS_MAGIC) {
343 if (!silent) 340 if (!silent)
344 printf("No BFS filesystem on %s (magic=%08x)\n", 341 printf("No BFS filesystem on %s (magic=%08x)\n", s->s_id, le32_to_cpu(bfs_sb->s_magic));
345 s->s_id, le32_to_cpu(bfs_sb->s_magic));
346 goto out1; 342 goto out1;
347 } 343 }
348 if (BFS_UNCLEAN(bfs_sb, s) && !silent) 344 if (BFS_UNCLEAN(bfs_sb, s) && !silent)
@@ -351,18 +347,16 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent)
351 s->s_magic = BFS_MAGIC; 347 s->s_magic = BFS_MAGIC;
352 348
353 if (le32_to_cpu(bfs_sb->s_start) > le32_to_cpu(bfs_sb->s_end) || 349 if (le32_to_cpu(bfs_sb->s_start) > le32_to_cpu(bfs_sb->s_end) ||
354 le32_to_cpu(bfs_sb->s_start) < BFS_BSIZE) { 350 le32_to_cpu(bfs_sb->s_start) < sizeof(struct bfs_super_block) + sizeof(struct bfs_dirent)) {
355 printf("Superblock is corrupted\n"); 351 printf("Superblock is corrupted on %s\n", s->s_id);
356 goto out1; 352 goto out1;
357 } 353 }
358 354
359 info->si_lasti = (le32_to_cpu(bfs_sb->s_start) - BFS_BSIZE) / 355 info->si_lasti = (le32_to_cpu(bfs_sb->s_start) - BFS_BSIZE) / sizeof(struct bfs_inode) + BFS_ROOT_INO - 1;
360 sizeof(struct bfs_inode) 356 if (info->si_lasti == BFS_MAX_LASTI)
361 + BFS_ROOT_INO - 1; 357 printf("WARNING: filesystem %s was created with 512 inodes, the real maximum is 511, mounting anyway\n", s->s_id);
362 imap_len = (info->si_lasti / 8) + 1; 358 else if (info->si_lasti > BFS_MAX_LASTI) {
363 info->si_imap = kzalloc(imap_len, GFP_KERNEL | __GFP_NOWARN); 359 printf("Impossible last inode number %lu > %d on %s\n", info->si_lasti, BFS_MAX_LASTI, s->s_id);
364 if (!info->si_imap) {
365 printf("Cannot allocate %u bytes\n", imap_len);
366 goto out1; 360 goto out1;
367 } 361 }
368 for (i = 0; i < BFS_ROOT_INO; i++) 362 for (i = 0; i < BFS_ROOT_INO; i++)
@@ -372,26 +366,25 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent)
372 inode = bfs_iget(s, BFS_ROOT_INO); 366 inode = bfs_iget(s, BFS_ROOT_INO);
373 if (IS_ERR(inode)) { 367 if (IS_ERR(inode)) {
374 ret = PTR_ERR(inode); 368 ret = PTR_ERR(inode);
375 goto out2; 369 goto out1;
376 } 370 }
377 s->s_root = d_make_root(inode); 371 s->s_root = d_make_root(inode);
378 if (!s->s_root) { 372 if (!s->s_root) {
379 ret = -ENOMEM; 373 ret = -ENOMEM;
380 goto out2; 374 goto out1;
381 } 375 }
382 376
383 info->si_blocks = (le32_to_cpu(bfs_sb->s_end) + 1) >> BFS_BSIZE_BITS; 377 info->si_blocks = (le32_to_cpu(bfs_sb->s_end) + 1) >> BFS_BSIZE_BITS;
384 info->si_freeb = (le32_to_cpu(bfs_sb->s_end) + 1 378 info->si_freeb = (le32_to_cpu(bfs_sb->s_end) + 1 - le32_to_cpu(bfs_sb->s_start)) >> BFS_BSIZE_BITS;
385 - le32_to_cpu(bfs_sb->s_start)) >> BFS_BSIZE_BITS;
386 info->si_freei = 0; 379 info->si_freei = 0;
387 info->si_lf_eblk = 0; 380 info->si_lf_eblk = 0;
388 381
389 /* can we read the last block? */ 382 /* can we read the last block? */
390 bh = sb_bread(s, info->si_blocks - 1); 383 bh = sb_bread(s, info->si_blocks - 1);
391 if (!bh) { 384 if (!bh) {
392 printf("Last block not available: %lu\n", info->si_blocks - 1); 385 printf("Last block not available on %s: %lu\n", s->s_id, info->si_blocks - 1);
393 ret = -EIO; 386 ret = -EIO;
394 goto out3; 387 goto out2;
395 } 388 }
396 brelse(bh); 389 brelse(bh);
397 390
@@ -425,11 +418,11 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent)
425 (i_eoff != le32_to_cpu(-1) && i_eoff > s_size) || 418 (i_eoff != le32_to_cpu(-1) && i_eoff > s_size) ||
426 i_sblock * BFS_BSIZE > i_eoff) { 419 i_sblock * BFS_BSIZE > i_eoff) {
427 420
428 printf("Inode 0x%08x corrupted\n", i); 421 printf("Inode 0x%08x corrupted on %s\n", i, s->s_id);
429 422
430 brelse(bh); 423 brelse(bh);
431 ret = -EIO; 424 ret = -EIO;
432 goto out3; 425 goto out2;
433 } 426 }
434 427
435 if (!di->i_ino) { 428 if (!di->i_ino) {
@@ -445,14 +438,12 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent)
445 } 438 }
446 brelse(bh); 439 brelse(bh);
447 brelse(sbh); 440 brelse(sbh);
448 bfs_dump_imap("read_super", s); 441 bfs_dump_imap("fill_super", s);
449 return 0; 442 return 0;
450 443
451out3: 444out2:
452 dput(s->s_root); 445 dput(s->s_root);
453 s->s_root = NULL; 446 s->s_root = NULL;
454out2:
455 kfree(info->si_imap);
456out1: 447out1:
457 brelse(sbh); 448 brelse(sbh);
458out: 449out:
@@ -482,7 +473,7 @@ static int __init init_bfs_fs(void)
482 int err = init_inodecache(); 473 int err = init_inodecache();
483 if (err) 474 if (err)
484 goto out1; 475 goto out1;
485 err = register_filesystem(&bfs_fs_type); 476 err = register_filesystem(&bfs_fs_type);
486 if (err) 477 if (err)
487 goto out; 478 goto out;
488 return 0; 479 return 0;
diff --git a/fs/binfmt_script.c b/fs/binfmt_script.c
index 7cde3f46ad26..d0078cbb718b 100644
--- a/fs/binfmt_script.c
+++ b/fs/binfmt_script.c
@@ -42,10 +42,14 @@ static int load_script(struct linux_binprm *bprm)
42 fput(bprm->file); 42 fput(bprm->file);
43 bprm->file = NULL; 43 bprm->file = NULL;
44 44
45 bprm->buf[BINPRM_BUF_SIZE - 1] = '\0'; 45 for (cp = bprm->buf+2;; cp++) {
46 if ((cp = strchr(bprm->buf, '\n')) == NULL) 46 if (cp >= bprm->buf + BINPRM_BUF_SIZE)
47 cp = bprm->buf+BINPRM_BUF_SIZE-1; 47 return -ENOEXEC;
48 if (!*cp || (*cp == '\n'))
49 break;
50 }
48 *cp = '\0'; 51 *cp = '\0';
52
49 while (cp > bprm->buf) { 53 while (cp > bprm->buf) {
50 cp--; 54 cp--;
51 if ((*cp == ' ') || (*cp == '\t')) 55 if ((*cp == ' ') || (*cp == '\t'))
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index fc126b92ea59..52abe4082680 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -4103,8 +4103,7 @@ int extent_readpages(struct address_space *mapping, struct list_head *pages,
4103 4103
4104 while (!list_empty(pages)) { 4104 while (!list_empty(pages)) {
4105 for (nr = 0; nr < ARRAY_SIZE(pagepool) && !list_empty(pages);) { 4105 for (nr = 0; nr < ARRAY_SIZE(pagepool) && !list_empty(pages);) {
4106 struct page *page = list_entry(pages->prev, 4106 struct page *page = lru_to_page(pages);
4107 struct page, lru);
4108 4107
4109 prefetchw(&page->flags); 4108 prefetchw(&page->flags);
4110 list_del(&page->lru); 4109 list_del(&page->lru);
diff --git a/fs/buffer.c b/fs/buffer.c
index d60d61e8ed7d..52d024bfdbc1 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -2366,7 +2366,7 @@ static int cont_expand_zero(struct file *file, struct address_space *mapping,
2366 2366
2367 balance_dirty_pages_ratelimited(mapping); 2367 balance_dirty_pages_ratelimited(mapping);
2368 2368
2369 if (unlikely(fatal_signal_pending(current))) { 2369 if (fatal_signal_pending(current)) {
2370 err = -EINTR; 2370 err = -EINTR;
2371 goto out; 2371 goto out;
2372 } 2372 }
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index 8eade7a993c1..5d0c05e288cc 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -306,7 +306,7 @@ static int start_read(struct inode *inode, struct ceph_rw_context *rw_ctx,
306 struct ceph_osd_client *osdc = 306 struct ceph_osd_client *osdc =
307 &ceph_inode_to_client(inode)->client->osdc; 307 &ceph_inode_to_client(inode)->client->osdc;
308 struct ceph_inode_info *ci = ceph_inode(inode); 308 struct ceph_inode_info *ci = ceph_inode(inode);
309 struct page *page = list_entry(page_list->prev, struct page, lru); 309 struct page *page = lru_to_page(page_list);
310 struct ceph_vino vino; 310 struct ceph_vino vino;
311 struct ceph_osd_request *req; 311 struct ceph_osd_request *req;
312 u64 off; 312 u64 off;
@@ -333,8 +333,7 @@ static int start_read(struct inode *inode, struct ceph_rw_context *rw_ctx,
333 if (got) 333 if (got)
334 ceph_put_cap_refs(ci, got); 334 ceph_put_cap_refs(ci, got);
335 while (!list_empty(page_list)) { 335 while (!list_empty(page_list)) {
336 page = list_entry(page_list->prev, 336 page = lru_to_page(page_list);
337 struct page, lru);
338 list_del(&page->lru); 337 list_del(&page->lru);
339 put_page(page); 338 put_page(page);
340 } 339 }
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 5e405164394a..e3e3a7550205 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -33,6 +33,7 @@
33#include <linux/mount.h> 33#include <linux/mount.h>
34#include <linux/slab.h> 34#include <linux/slab.h>
35#include <linux/swap.h> 35#include <linux/swap.h>
36#include <linux/mm.h>
36#include <asm/div64.h> 37#include <asm/div64.h>
37#include "cifsfs.h" 38#include "cifsfs.h"
38#include "cifspdu.h" 39#include "cifspdu.h"
@@ -3964,7 +3965,7 @@ readpages_get_pages(struct address_space *mapping, struct list_head *page_list,
3964 3965
3965 INIT_LIST_HEAD(tmplist); 3966 INIT_LIST_HEAD(tmplist);
3966 3967
3967 page = list_entry(page_list->prev, struct page, lru); 3968 page = lru_to_page(page_list);
3968 3969
3969 /* 3970 /*
3970 * Lock the page and put it in the cache. Since no one else 3971 * Lock the page and put it in the cache. Since no one else
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index 7ebae39fbcb3..a5d219d920e7 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -381,7 +381,8 @@ static void ep_nested_calls_init(struct nested_calls *ncalls)
381 */ 381 */
382static inline int ep_events_available(struct eventpoll *ep) 382static inline int ep_events_available(struct eventpoll *ep)
383{ 383{
384 return !list_empty(&ep->rdllist) || ep->ovflist != EP_UNACTIVE_PTR; 384 return !list_empty_careful(&ep->rdllist) ||
385 READ_ONCE(ep->ovflist) != EP_UNACTIVE_PTR;
385} 386}
386 387
387#ifdef CONFIG_NET_RX_BUSY_POLL 388#ifdef CONFIG_NET_RX_BUSY_POLL
@@ -471,7 +472,6 @@ static inline void ep_set_busy_poll_napi_id(struct epitem *epi)
471 * no re-entered. 472 * no re-entered.
472 * 473 *
473 * @ncalls: Pointer to the nested_calls structure to be used for this call. 474 * @ncalls: Pointer to the nested_calls structure to be used for this call.
474 * @max_nests: Maximum number of allowed nesting calls.
475 * @nproc: Nested call core function pointer. 475 * @nproc: Nested call core function pointer.
476 * @priv: Opaque data to be passed to the @nproc callback. 476 * @priv: Opaque data to be passed to the @nproc callback.
477 * @cookie: Cookie to be used to identify this nested call. 477 * @cookie: Cookie to be used to identify this nested call.
@@ -480,7 +480,7 @@ static inline void ep_set_busy_poll_napi_id(struct epitem *epi)
480 * Returns: Returns the code returned by the @nproc callback, or -1 if 480 * Returns: Returns the code returned by the @nproc callback, or -1 if
481 * the maximum recursion limit has been exceeded. 481 * the maximum recursion limit has been exceeded.
482 */ 482 */
483static int ep_call_nested(struct nested_calls *ncalls, int max_nests, 483static int ep_call_nested(struct nested_calls *ncalls,
484 int (*nproc)(void *, void *, int), void *priv, 484 int (*nproc)(void *, void *, int), void *priv,
485 void *cookie, void *ctx) 485 void *cookie, void *ctx)
486{ 486{
@@ -499,7 +499,7 @@ static int ep_call_nested(struct nested_calls *ncalls, int max_nests,
499 */ 499 */
500 list_for_each_entry(tncur, lsthead, llink) { 500 list_for_each_entry(tncur, lsthead, llink) {
501 if (tncur->ctx == ctx && 501 if (tncur->ctx == ctx &&
502 (tncur->cookie == cookie || ++call_nests > max_nests)) { 502 (tncur->cookie == cookie || ++call_nests > EP_MAX_NESTS)) {
503 /* 503 /*
504 * Ops ... loop detected or maximum nest level reached. 504 * Ops ... loop detected or maximum nest level reached.
505 * We abort this wake by breaking the cycle itself. 505 * We abort this wake by breaking the cycle itself.
@@ -573,7 +573,7 @@ static void ep_poll_safewake(wait_queue_head_t *wq)
573{ 573{
574 int this_cpu = get_cpu(); 574 int this_cpu = get_cpu();
575 575
576 ep_call_nested(&poll_safewake_ncalls, EP_MAX_NESTS, 576 ep_call_nested(&poll_safewake_ncalls,
577 ep_poll_wakeup_proc, NULL, wq, (void *) (long) this_cpu); 577 ep_poll_wakeup_proc, NULL, wq, (void *) (long) this_cpu);
578 578
579 put_cpu(); 579 put_cpu();
@@ -699,7 +699,7 @@ static __poll_t ep_scan_ready_list(struct eventpoll *ep,
699 */ 699 */
700 spin_lock_irq(&ep->wq.lock); 700 spin_lock_irq(&ep->wq.lock);
701 list_splice_init(&ep->rdllist, &txlist); 701 list_splice_init(&ep->rdllist, &txlist);
702 ep->ovflist = NULL; 702 WRITE_ONCE(ep->ovflist, NULL);
703 spin_unlock_irq(&ep->wq.lock); 703 spin_unlock_irq(&ep->wq.lock);
704 704
705 /* 705 /*
@@ -713,7 +713,7 @@ static __poll_t ep_scan_ready_list(struct eventpoll *ep,
713 * other events might have been queued by the poll callback. 713 * other events might have been queued by the poll callback.
714 * We re-insert them inside the main ready-list here. 714 * We re-insert them inside the main ready-list here.
715 */ 715 */
716 for (nepi = ep->ovflist; (epi = nepi) != NULL; 716 for (nepi = READ_ONCE(ep->ovflist); (epi = nepi) != NULL;
717 nepi = epi->next, epi->next = EP_UNACTIVE_PTR) { 717 nepi = epi->next, epi->next = EP_UNACTIVE_PTR) {
718 /* 718 /*
719 * We need to check if the item is already in the list. 719 * We need to check if the item is already in the list.
@@ -731,7 +731,7 @@ static __poll_t ep_scan_ready_list(struct eventpoll *ep,
731 * releasing the lock, events will be queued in the normal way inside 731 * releasing the lock, events will be queued in the normal way inside
732 * ep->rdllist. 732 * ep->rdllist.
733 */ 733 */
734 ep->ovflist = EP_UNACTIVE_PTR; 734 WRITE_ONCE(ep->ovflist, EP_UNACTIVE_PTR);
735 735
736 /* 736 /*
737 * Quickly re-inject items left on "txlist". 737 * Quickly re-inject items left on "txlist".
@@ -1154,10 +1154,10 @@ static int ep_poll_callback(wait_queue_entry_t *wait, unsigned mode, int sync, v
1154 * semantics). All the events that happen during that period of time are 1154 * semantics). All the events that happen during that period of time are
1155 * chained in ep->ovflist and requeued later on. 1155 * chained in ep->ovflist and requeued later on.
1156 */ 1156 */
1157 if (unlikely(ep->ovflist != EP_UNACTIVE_PTR)) { 1157 if (READ_ONCE(ep->ovflist) != EP_UNACTIVE_PTR) {
1158 if (epi->next == EP_UNACTIVE_PTR) { 1158 if (epi->next == EP_UNACTIVE_PTR) {
1159 epi->next = ep->ovflist; 1159 epi->next = READ_ONCE(ep->ovflist);
1160 ep->ovflist = epi; 1160 WRITE_ONCE(ep->ovflist, epi);
1161 if (epi->ws) { 1161 if (epi->ws) {
1162 /* 1162 /*
1163 * Activate ep->ws since epi->ws may get 1163 * Activate ep->ws since epi->ws may get
@@ -1333,7 +1333,6 @@ static int reverse_path_check_proc(void *priv, void *cookie, int call_nests)
1333 } 1333 }
1334 } else { 1334 } else {
1335 error = ep_call_nested(&poll_loop_ncalls, 1335 error = ep_call_nested(&poll_loop_ncalls,
1336 EP_MAX_NESTS,
1337 reverse_path_check_proc, 1336 reverse_path_check_proc,
1338 child_file, child_file, 1337 child_file, child_file,
1339 current); 1338 current);
@@ -1367,7 +1366,7 @@ static int reverse_path_check(void)
1367 /* let's call this for all tfiles */ 1366 /* let's call this for all tfiles */
1368 list_for_each_entry(current_file, &tfile_check_list, f_tfile_llink) { 1367 list_for_each_entry(current_file, &tfile_check_list, f_tfile_llink) {
1369 path_count_init(); 1368 path_count_init();
1370 error = ep_call_nested(&poll_loop_ncalls, EP_MAX_NESTS, 1369 error = ep_call_nested(&poll_loop_ncalls,
1371 reverse_path_check_proc, current_file, 1370 reverse_path_check_proc, current_file,
1372 current_file, current); 1371 current_file, current);
1373 if (error) 1372 if (error)
@@ -1626,21 +1625,24 @@ static __poll_t ep_send_events_proc(struct eventpoll *ep, struct list_head *head
1626{ 1625{
1627 struct ep_send_events_data *esed = priv; 1626 struct ep_send_events_data *esed = priv;
1628 __poll_t revents; 1627 __poll_t revents;
1629 struct epitem *epi; 1628 struct epitem *epi, *tmp;
1630 struct epoll_event __user *uevent; 1629 struct epoll_event __user *uevent = esed->events;
1631 struct wakeup_source *ws; 1630 struct wakeup_source *ws;
1632 poll_table pt; 1631 poll_table pt;
1633 1632
1634 init_poll_funcptr(&pt, NULL); 1633 init_poll_funcptr(&pt, NULL);
1634 esed->res = 0;
1635 1635
1636 /* 1636 /*
1637 * We can loop without lock because we are passed a task private list. 1637 * We can loop without lock because we are passed a task private list.
1638 * Items cannot vanish during the loop because ep_scan_ready_list() is 1638 * Items cannot vanish during the loop because ep_scan_ready_list() is
1639 * holding "mtx" during this call. 1639 * holding "mtx" during this call.
1640 */ 1640 */
1641 for (esed->res = 0, uevent = esed->events; 1641 lockdep_assert_held(&ep->mtx);
1642 !list_empty(head) && esed->res < esed->maxevents;) { 1642
1643 epi = list_first_entry(head, struct epitem, rdllink); 1643 list_for_each_entry_safe(epi, tmp, head, rdllink) {
1644 if (esed->res >= esed->maxevents)
1645 break;
1644 1646
1645 /* 1647 /*
1646 * Activate ep->ws before deactivating epi->ws to prevent 1648 * Activate ep->ws before deactivating epi->ws to prevent
@@ -1660,42 +1662,42 @@ static __poll_t ep_send_events_proc(struct eventpoll *ep, struct list_head *head
1660 1662
1661 list_del_init(&epi->rdllink); 1663 list_del_init(&epi->rdllink);
1662 1664
1663 revents = ep_item_poll(epi, &pt, 1);
1664
1665 /* 1665 /*
1666 * If the event mask intersect the caller-requested one, 1666 * If the event mask intersect the caller-requested one,
1667 * deliver the event to userspace. Again, ep_scan_ready_list() 1667 * deliver the event to userspace. Again, ep_scan_ready_list()
1668 * is holding "mtx", so no operations coming from userspace 1668 * is holding ep->mtx, so no operations coming from userspace
1669 * can change the item. 1669 * can change the item.
1670 */ 1670 */
1671 if (revents) { 1671 revents = ep_item_poll(epi, &pt, 1);
1672 if (__put_user(revents, &uevent->events) || 1672 if (!revents)
1673 __put_user(epi->event.data, &uevent->data)) { 1673 continue;
1674 list_add(&epi->rdllink, head); 1674
1675 ep_pm_stay_awake(epi); 1675 if (__put_user(revents, &uevent->events) ||
1676 if (!esed->res) 1676 __put_user(epi->event.data, &uevent->data)) {
1677 esed->res = -EFAULT; 1677 list_add(&epi->rdllink, head);
1678 return 0; 1678 ep_pm_stay_awake(epi);
1679 } 1679 if (!esed->res)
1680 esed->res++; 1680 esed->res = -EFAULT;
1681 uevent++; 1681 return 0;
1682 if (epi->event.events & EPOLLONESHOT) 1682 }
1683 epi->event.events &= EP_PRIVATE_BITS; 1683 esed->res++;
1684 else if (!(epi->event.events & EPOLLET)) { 1684 uevent++;
1685 /* 1685 if (epi->event.events & EPOLLONESHOT)
1686 * If this file has been added with Level 1686 epi->event.events &= EP_PRIVATE_BITS;
1687 * Trigger mode, we need to insert back inside 1687 else if (!(epi->event.events & EPOLLET)) {
1688 * the ready list, so that the next call to 1688 /*
1689 * epoll_wait() will check again the events 1689 * If this file has been added with Level
1690 * availability. At this point, no one can insert 1690 * Trigger mode, we need to insert back inside
1691 * into ep->rdllist besides us. The epoll_ctl() 1691 * the ready list, so that the next call to
1692 * callers are locked out by 1692 * epoll_wait() will check again the events
1693 * ep_scan_ready_list() holding "mtx" and the 1693 * availability. At this point, no one can insert
1694 * poll callback will queue them in ep->ovflist. 1694 * into ep->rdllist besides us. The epoll_ctl()
1695 */ 1695 * callers are locked out by
1696 list_add_tail(&epi->rdllink, &ep->rdllist); 1696 * ep_scan_ready_list() holding "mtx" and the
1697 ep_pm_stay_awake(epi); 1697 * poll callback will queue them in ep->ovflist.
1698 } 1698 */
1699 list_add_tail(&epi->rdllink, &ep->rdllist);
1700 ep_pm_stay_awake(epi);
1699 } 1701 }
1700 } 1702 }
1701 1703
@@ -1747,6 +1749,7 @@ static int ep_poll(struct eventpoll *ep, struct epoll_event __user *events,
1747{ 1749{
1748 int res = 0, eavail, timed_out = 0; 1750 int res = 0, eavail, timed_out = 0;
1749 u64 slack = 0; 1751 u64 slack = 0;
1752 bool waiter = false;
1750 wait_queue_entry_t wait; 1753 wait_queue_entry_t wait;
1751 ktime_t expires, *to = NULL; 1754 ktime_t expires, *to = NULL;
1752 1755
@@ -1761,11 +1764,18 @@ static int ep_poll(struct eventpoll *ep, struct epoll_event __user *events,
1761 } else if (timeout == 0) { 1764 } else if (timeout == 0) {
1762 /* 1765 /*
1763 * Avoid the unnecessary trip to the wait queue loop, if the 1766 * Avoid the unnecessary trip to the wait queue loop, if the
1764 * caller specified a non blocking operation. 1767 * caller specified a non blocking operation. We still need
1768 * lock because we could race and not see an epi being added
1769 * to the ready list while in irq callback. Thus incorrectly
1770 * returning 0 back to userspace.
1765 */ 1771 */
1766 timed_out = 1; 1772 timed_out = 1;
1773
1767 spin_lock_irq(&ep->wq.lock); 1774 spin_lock_irq(&ep->wq.lock);
1768 goto check_events; 1775 eavail = ep_events_available(ep);
1776 spin_unlock_irq(&ep->wq.lock);
1777
1778 goto send_events;
1769 } 1779 }
1770 1780
1771fetch_events: 1781fetch_events:
@@ -1773,64 +1783,66 @@ fetch_events:
1773 if (!ep_events_available(ep)) 1783 if (!ep_events_available(ep))
1774 ep_busy_loop(ep, timed_out); 1784 ep_busy_loop(ep, timed_out);
1775 1785
1776 spin_lock_irq(&ep->wq.lock); 1786 eavail = ep_events_available(ep);
1787 if (eavail)
1788 goto send_events;
1777 1789
1778 if (!ep_events_available(ep)) { 1790 /*
1779 /* 1791 * Busy poll timed out. Drop NAPI ID for now, we can add
1780 * Busy poll timed out. Drop NAPI ID for now, we can add 1792 * it back in when we have moved a socket with a valid NAPI
1781 * it back in when we have moved a socket with a valid NAPI 1793 * ID onto the ready list.
1782 * ID onto the ready list. 1794 */
1783 */ 1795 ep_reset_busy_poll_napi_id(ep);
1784 ep_reset_busy_poll_napi_id(ep);
1785 1796
1786 /* 1797 /*
1787 * We don't have any available event to return to the caller. 1798 * We don't have any available event to return to the caller. We need
1788 * We need to sleep here, and we will be wake up by 1799 * to sleep here, and we will be woken by ep_poll_callback() when events
1789 * ep_poll_callback() when events will become available. 1800 * become available.
1790 */ 1801 */
1802 if (!waiter) {
1803 waiter = true;
1791 init_waitqueue_entry(&wait, current); 1804 init_waitqueue_entry(&wait, current);
1792 __add_wait_queue_exclusive(&ep->wq, &wait);
1793 1805
1794 for (;;) { 1806 spin_lock_irq(&ep->wq.lock);
1795 /* 1807 __add_wait_queue_exclusive(&ep->wq, &wait);
1796 * We don't want to sleep if the ep_poll_callback() sends us 1808 spin_unlock_irq(&ep->wq.lock);
1797 * a wakeup in between. That's why we set the task state 1809 }
1798 * to TASK_INTERRUPTIBLE before doing the checks.
1799 */
1800 set_current_state(TASK_INTERRUPTIBLE);
1801 /*
1802 * Always short-circuit for fatal signals to allow
1803 * threads to make a timely exit without the chance of
1804 * finding more events available and fetching
1805 * repeatedly.
1806 */
1807 if (fatal_signal_pending(current)) {
1808 res = -EINTR;
1809 break;
1810 }
1811 if (ep_events_available(ep) || timed_out)
1812 break;
1813 if (signal_pending(current)) {
1814 res = -EINTR;
1815 break;
1816 }
1817 1810
1818 spin_unlock_irq(&ep->wq.lock); 1811 for (;;) {
1819 if (!schedule_hrtimeout_range(to, slack, HRTIMER_MODE_ABS)) 1812 /*
1820 timed_out = 1; 1813 * We don't want to sleep if the ep_poll_callback() sends us
1814 * a wakeup in between. That's why we set the task state
1815 * to TASK_INTERRUPTIBLE before doing the checks.
1816 */
1817 set_current_state(TASK_INTERRUPTIBLE);
1818 /*
1819 * Always short-circuit for fatal signals to allow
1820 * threads to make a timely exit without the chance of
1821 * finding more events available and fetching
1822 * repeatedly.
1823 */
1824 if (fatal_signal_pending(current)) {
1825 res = -EINTR;
1826 break;
1827 }
1821 1828
1822 spin_lock_irq(&ep->wq.lock); 1829 eavail = ep_events_available(ep);
1830 if (eavail)
1831 break;
1832 if (signal_pending(current)) {
1833 res = -EINTR;
1834 break;
1823 } 1835 }
1824 1836
1825 __remove_wait_queue(&ep->wq, &wait); 1837 if (!schedule_hrtimeout_range(to, slack, HRTIMER_MODE_ABS)) {
1826 __set_current_state(TASK_RUNNING); 1838 timed_out = 1;
1839 break;
1840 }
1827 } 1841 }
1828check_events:
1829 /* Is it worth to try to dig for events ? */
1830 eavail = ep_events_available(ep);
1831 1842
1832 spin_unlock_irq(&ep->wq.lock); 1843 __set_current_state(TASK_RUNNING);
1833 1844
1845send_events:
1834 /* 1846 /*
1835 * Try to transfer events to user space. In case we get 0 events and 1847 * Try to transfer events to user space. In case we get 0 events and
1836 * there's still timeout left over, we go trying again in search of 1848 * there's still timeout left over, we go trying again in search of
@@ -1840,6 +1852,12 @@ check_events:
1840 !(res = ep_send_events(ep, events, maxevents)) && !timed_out) 1852 !(res = ep_send_events(ep, events, maxevents)) && !timed_out)
1841 goto fetch_events; 1853 goto fetch_events;
1842 1854
1855 if (waiter) {
1856 spin_lock_irq(&ep->wq.lock);
1857 __remove_wait_queue(&ep->wq, &wait);
1858 spin_unlock_irq(&ep->wq.lock);
1859 }
1860
1843 return res; 1861 return res;
1844} 1862}
1845 1863
@@ -1876,7 +1894,7 @@ static int ep_loop_check_proc(void *priv, void *cookie, int call_nests)
1876 ep_tovisit = epi->ffd.file->private_data; 1894 ep_tovisit = epi->ffd.file->private_data;
1877 if (ep_tovisit->visited) 1895 if (ep_tovisit->visited)
1878 continue; 1896 continue;
1879 error = ep_call_nested(&poll_loop_ncalls, EP_MAX_NESTS, 1897 error = ep_call_nested(&poll_loop_ncalls,
1880 ep_loop_check_proc, epi->ffd.file, 1898 ep_loop_check_proc, epi->ffd.file,
1881 ep_tovisit, current); 1899 ep_tovisit, current);
1882 if (error != 0) 1900 if (error != 0)
@@ -1916,7 +1934,7 @@ static int ep_loop_check(struct eventpoll *ep, struct file *file)
1916 int ret; 1934 int ret;
1917 struct eventpoll *ep_cur, *ep_next; 1935 struct eventpoll *ep_cur, *ep_next;
1918 1936
1919 ret = ep_call_nested(&poll_loop_ncalls, EP_MAX_NESTS, 1937 ret = ep_call_nested(&poll_loop_ncalls,
1920 ep_loop_check_proc, file, ep, current); 1938 ep_loop_check_proc, file, ep, current);
1921 /* clear visited list */ 1939 /* clear visited list */
1922 list_for_each_entry_safe(ep_cur, ep_next, &visited_list, 1940 list_for_each_entry_safe(ep_cur, ep_next, &visited_list,
diff --git a/fs/exec.c b/fs/exec.c
index fc281b738a98..44320d893f1a 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -218,55 +218,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
218 if (ret <= 0) 218 if (ret <= 0)
219 return NULL; 219 return NULL;
220 220
221 if (write) { 221 if (write)
222 unsigned long size = bprm->vma->vm_end - bprm->vma->vm_start; 222 acct_arg_size(bprm, vma_pages(bprm->vma));
223 unsigned long ptr_size, limit;
224
225 /*
226 * Since the stack will hold pointers to the strings, we
227 * must account for them as well.
228 *
229 * The size calculation is the entire vma while each arg page is
230 * built, so each time we get here it's calculating how far it
231 * is currently (rather than each call being just the newly
232 * added size from the arg page). As a result, we need to
233 * always add the entire size of the pointers, so that on the
234 * last call to get_arg_page() we'll actually have the entire
235 * correct size.
236 */
237 ptr_size = (bprm->argc + bprm->envc) * sizeof(void *);
238 if (ptr_size > ULONG_MAX - size)
239 goto fail;
240 size += ptr_size;
241
242 acct_arg_size(bprm, size / PAGE_SIZE);
243
244 /*
245 * We've historically supported up to 32 pages (ARG_MAX)
246 * of argument strings even with small stacks
247 */
248 if (size <= ARG_MAX)
249 return page;
250
251 /*
252 * Limit to 1/4 of the max stack size or 3/4 of _STK_LIM
253 * (whichever is smaller) for the argv+env strings.
254 * This ensures that:
255 * - the remaining binfmt code will not run out of stack space,
256 * - the program will have a reasonable amount of stack left
257 * to work from.
258 */
259 limit = _STK_LIM / 4 * 3;
260 limit = min(limit, bprm->rlim_stack.rlim_cur / 4);
261 if (size > limit)
262 goto fail;
263 }
264 223
265 return page; 224 return page;
266
267fail:
268 put_page(page);
269 return NULL;
270} 225}
271 226
272static void put_arg_page(struct page *page) 227static void put_arg_page(struct page *page)
@@ -492,6 +447,50 @@ static int count(struct user_arg_ptr argv, int max)
492 return i; 447 return i;
493} 448}
494 449
450static int prepare_arg_pages(struct linux_binprm *bprm,
451 struct user_arg_ptr argv, struct user_arg_ptr envp)
452{
453 unsigned long limit, ptr_size;
454
455 bprm->argc = count(argv, MAX_ARG_STRINGS);
456 if (bprm->argc < 0)
457 return bprm->argc;
458
459 bprm->envc = count(envp, MAX_ARG_STRINGS);
460 if (bprm->envc < 0)
461 return bprm->envc;
462
463 /*
464 * Limit to 1/4 of the max stack size or 3/4 of _STK_LIM
465 * (whichever is smaller) for the argv+env strings.
466 * This ensures that:
467 * - the remaining binfmt code will not run out of stack space,
468 * - the program will have a reasonable amount of stack left
469 * to work from.
470 */
471 limit = _STK_LIM / 4 * 3;
472 limit = min(limit, bprm->rlim_stack.rlim_cur / 4);
473 /*
474 * We've historically supported up to 32 pages (ARG_MAX)
475 * of argument strings even with small stacks
476 */
477 limit = max_t(unsigned long, limit, ARG_MAX);
478 /*
479 * We must account for the size of all the argv and envp pointers to
480 * the argv and envp strings, since they will also take up space in
481 * the stack. They aren't stored until much later when we can't
482 * signal to the parent that the child has run out of stack space.
483 * Instead, calculate it here so it's possible to fail gracefully.
484 */
485 ptr_size = (bprm->argc + bprm->envc) * sizeof(void *);
486 if (limit <= ptr_size)
487 return -E2BIG;
488 limit -= ptr_size;
489
490 bprm->argmin = bprm->p - limit;
491 return 0;
492}
493
495/* 494/*
496 * 'copy_strings()' copies argument/environment strings from the old 495 * 'copy_strings()' copies argument/environment strings from the old
497 * processes's memory to the new process's stack. The call to get_user_pages() 496 * processes's memory to the new process's stack. The call to get_user_pages()
@@ -527,6 +526,10 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
527 pos = bprm->p; 526 pos = bprm->p;
528 str += len; 527 str += len;
529 bprm->p -= len; 528 bprm->p -= len;
529#ifdef CONFIG_MMU
530 if (bprm->p < bprm->argmin)
531 goto out;
532#endif
530 533
531 while (len > 0) { 534 while (len > 0) {
532 int offset, bytes_to_copy; 535 int offset, bytes_to_copy;
@@ -1084,7 +1087,7 @@ static int de_thread(struct task_struct *tsk)
1084 __set_current_state(TASK_KILLABLE); 1087 __set_current_state(TASK_KILLABLE);
1085 spin_unlock_irq(lock); 1088 spin_unlock_irq(lock);
1086 schedule(); 1089 schedule();
1087 if (unlikely(__fatal_signal_pending(tsk))) 1090 if (__fatal_signal_pending(tsk))
1088 goto killed; 1091 goto killed;
1089 spin_lock_irq(lock); 1092 spin_lock_irq(lock);
1090 } 1093 }
@@ -1112,7 +1115,7 @@ static int de_thread(struct task_struct *tsk)
1112 write_unlock_irq(&tasklist_lock); 1115 write_unlock_irq(&tasklist_lock);
1113 cgroup_threadgroup_change_end(tsk); 1116 cgroup_threadgroup_change_end(tsk);
1114 schedule(); 1117 schedule();
1115 if (unlikely(__fatal_signal_pending(tsk))) 1118 if (__fatal_signal_pending(tsk))
1116 goto killed; 1119 goto killed;
1117 } 1120 }
1118 1121
@@ -1789,12 +1792,8 @@ static int __do_execve_file(int fd, struct filename *filename,
1789 if (retval) 1792 if (retval)
1790 goto out_unmark; 1793 goto out_unmark;
1791 1794
1792 bprm->argc = count(argv, MAX_ARG_STRINGS); 1795 retval = prepare_arg_pages(bprm, argv, envp);
1793 if ((retval = bprm->argc) < 0) 1796 if (retval < 0)
1794 goto out;
1795
1796 bprm->envc = count(envp, MAX_ARG_STRINGS);
1797 if ((retval = bprm->envc) < 0)
1798 goto out; 1797 goto out;
1799 1798
1800 retval = prepare_binprm(bprm); 1799 retval = prepare_binprm(bprm);
diff --git a/fs/ext4/readpage.c b/fs/ext4/readpage.c
index f461d75ac049..6aa282ee455a 100644
--- a/fs/ext4/readpage.c
+++ b/fs/ext4/readpage.c
@@ -128,7 +128,7 @@ int ext4_mpage_readpages(struct address_space *mapping,
128 128
129 prefetchw(&page->flags); 129 prefetchw(&page->flags);
130 if (pages) { 130 if (pages) {
131 page = list_entry(pages->prev, struct page, lru); 131 page = lru_to_page(pages);
132 list_del(&page->lru); 132 list_del(&page->lru);
133 if (add_to_page_cache_lru(page, mapping, page->index, 133 if (add_to_page_cache_lru(page, mapping, page->index,
134 readahead_gfp_mask(mapping))) 134 readahead_gfp_mask(mapping)))
diff --git a/fs/fat/cache.c b/fs/fat/cache.c
index 78d501c1fb65..738e427e2d21 100644
--- a/fs/fat/cache.c
+++ b/fs/fat/cache.c
@@ -363,7 +363,7 @@ int fat_bmap(struct inode *inode, sector_t sector, sector_t *phys,
363 363
364 *phys = 0; 364 *phys = 0;
365 *mapped_blocks = 0; 365 *mapped_blocks = 0;
366 if ((sbi->fat_bits != 32) && (inode->i_ino == MSDOS_ROOT_INO)) { 366 if (!is_fat32(sbi) && (inode->i_ino == MSDOS_ROOT_INO)) {
367 if (sector < (sbi->dir_entries >> sbi->dir_per_block_bits)) { 367 if (sector < (sbi->dir_entries >> sbi->dir_per_block_bits)) {
368 *phys = sector + sbi->dir_start; 368 *phys = sector + sbi->dir_start;
369 *mapped_blocks = 1; 369 *mapped_blocks = 1;
diff --git a/fs/fat/dir.c b/fs/fat/dir.c
index 0295a095b920..9d01db37183f 100644
--- a/fs/fat/dir.c
+++ b/fs/fat/dir.c
@@ -57,7 +57,7 @@ static inline void fat_dir_readahead(struct inode *dir, sector_t iblock,
57 if ((iblock & (sbi->sec_per_clus - 1)) || sbi->sec_per_clus == 1) 57 if ((iblock & (sbi->sec_per_clus - 1)) || sbi->sec_per_clus == 1)
58 return; 58 return;
59 /* root dir of FAT12/FAT16 */ 59 /* root dir of FAT12/FAT16 */
60 if ((sbi->fat_bits != 32) && (dir->i_ino == MSDOS_ROOT_INO)) 60 if (!is_fat32(sbi) && (dir->i_ino == MSDOS_ROOT_INO))
61 return; 61 return;
62 62
63 bh = sb_find_get_block(sb, phys); 63 bh = sb_find_get_block(sb, phys);
@@ -1313,7 +1313,7 @@ int fat_add_entries(struct inode *dir, void *slots, int nr_slots,
1313 } 1313 }
1314 } 1314 }
1315 if (dir->i_ino == MSDOS_ROOT_INO) { 1315 if (dir->i_ino == MSDOS_ROOT_INO) {
1316 if (sbi->fat_bits != 32) 1316 if (!is_fat32(sbi))
1317 goto error; 1317 goto error;
1318 } else if (MSDOS_I(dir)->i_start == 0) { 1318 } else if (MSDOS_I(dir)->i_start == 0) {
1319 fat_msg(sb, KERN_ERR, "Corrupted directory (i_pos %lld)", 1319 fat_msg(sb, KERN_ERR, "Corrupted directory (i_pos %lld)",
diff --git a/fs/fat/fat.h b/fs/fat/fat.h
index 4e1b2f6df5e6..922a0c6ba46c 100644
--- a/fs/fat/fat.h
+++ b/fs/fat/fat.h
@@ -142,6 +142,34 @@ static inline struct msdos_sb_info *MSDOS_SB(struct super_block *sb)
142 return sb->s_fs_info; 142 return sb->s_fs_info;
143} 143}
144 144
145/*
146 * Functions that determine the variant of the FAT file system (i.e.,
147 * whether this is FAT12, FAT16 or FAT32.
148 */
149static inline bool is_fat12(const struct msdos_sb_info *sbi)
150{
151 return sbi->fat_bits == 12;
152}
153
154static inline bool is_fat16(const struct msdos_sb_info *sbi)
155{
156 return sbi->fat_bits == 16;
157}
158
159static inline bool is_fat32(const struct msdos_sb_info *sbi)
160{
161 return sbi->fat_bits == 32;
162}
163
164/* Maximum number of clusters */
165static inline u32 max_fat(struct super_block *sb)
166{
167 struct msdos_sb_info *sbi = MSDOS_SB(sb);
168
169 return is_fat32(sbi) ? MAX_FAT32 :
170 is_fat16(sbi) ? MAX_FAT16 : MAX_FAT12;
171}
172
145static inline struct msdos_inode_info *MSDOS_I(struct inode *inode) 173static inline struct msdos_inode_info *MSDOS_I(struct inode *inode)
146{ 174{
147 return container_of(inode, struct msdos_inode_info, vfs_inode); 175 return container_of(inode, struct msdos_inode_info, vfs_inode);
@@ -257,7 +285,7 @@ static inline int fat_get_start(const struct msdos_sb_info *sbi,
257 const struct msdos_dir_entry *de) 285 const struct msdos_dir_entry *de)
258{ 286{
259 int cluster = le16_to_cpu(de->start); 287 int cluster = le16_to_cpu(de->start);
260 if (sbi->fat_bits == 32) 288 if (is_fat32(sbi))
261 cluster |= (le16_to_cpu(de->starthi) << 16); 289 cluster |= (le16_to_cpu(de->starthi) << 16);
262 return cluster; 290 return cluster;
263} 291}
diff --git a/fs/fat/fatent.c b/fs/fat/fatent.c
index f58c0cacc531..495edeafd60a 100644
--- a/fs/fat/fatent.c
+++ b/fs/fat/fatent.c
@@ -290,19 +290,17 @@ void fat_ent_access_init(struct super_block *sb)
290 290
291 mutex_init(&sbi->fat_lock); 291 mutex_init(&sbi->fat_lock);
292 292
293 switch (sbi->fat_bits) { 293 if (is_fat32(sbi)) {
294 case 32:
295 sbi->fatent_shift = 2; 294 sbi->fatent_shift = 2;
296 sbi->fatent_ops = &fat32_ops; 295 sbi->fatent_ops = &fat32_ops;
297 break; 296 } else if (is_fat16(sbi)) {
298 case 16:
299 sbi->fatent_shift = 1; 297 sbi->fatent_shift = 1;
300 sbi->fatent_ops = &fat16_ops; 298 sbi->fatent_ops = &fat16_ops;
301 break; 299 } else if (is_fat12(sbi)) {
302 case 12:
303 sbi->fatent_shift = -1; 300 sbi->fatent_shift = -1;
304 sbi->fatent_ops = &fat12_ops; 301 sbi->fatent_ops = &fat12_ops;
305 break; 302 } else {
303 fat_fs_error(sb, "invalid FAT variant, %u bits", sbi->fat_bits);
306 } 304 }
307} 305}
308 306
@@ -310,7 +308,7 @@ static void mark_fsinfo_dirty(struct super_block *sb)
310{ 308{
311 struct msdos_sb_info *sbi = MSDOS_SB(sb); 309 struct msdos_sb_info *sbi = MSDOS_SB(sb);
312 310
313 if (sb_rdonly(sb) || sbi->fat_bits != 32) 311 if (sb_rdonly(sb) || !is_fat32(sbi))
314 return; 312 return;
315 313
316 __mark_inode_dirty(sbi->fsinfo_inode, I_DIRTY_SYNC); 314 __mark_inode_dirty(sbi->fsinfo_inode, I_DIRTY_SYNC);
@@ -327,7 +325,7 @@ static inline int fat_ent_update_ptr(struct super_block *sb,
327 /* Is this fatent's blocks including this entry? */ 325 /* Is this fatent's blocks including this entry? */
328 if (!fatent->nr_bhs || bhs[0]->b_blocknr != blocknr) 326 if (!fatent->nr_bhs || bhs[0]->b_blocknr != blocknr)
329 return 0; 327 return 0;
330 if (sbi->fat_bits == 12) { 328 if (is_fat12(sbi)) {
331 if ((offset + 1) < sb->s_blocksize) { 329 if ((offset + 1) < sb->s_blocksize) {
332 /* This entry is on bhs[0]. */ 330 /* This entry is on bhs[0]. */
333 if (fatent->nr_bhs == 2) { 331 if (fatent->nr_bhs == 2) {
diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index c0b5b5c3373b..79bb0e73a65f 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -686,7 +686,7 @@ static void fat_set_state(struct super_block *sb,
686 686
687 b = (struct fat_boot_sector *) bh->b_data; 687 b = (struct fat_boot_sector *) bh->b_data;
688 688
689 if (sbi->fat_bits == 32) { 689 if (is_fat32(sbi)) {
690 if (set) 690 if (set)
691 b->fat32.state |= FAT_STATE_DIRTY; 691 b->fat32.state |= FAT_STATE_DIRTY;
692 else 692 else
@@ -1396,7 +1396,7 @@ static int fat_read_root(struct inode *inode)
1396 inode->i_mode = fat_make_mode(sbi, ATTR_DIR, S_IRWXUGO); 1396 inode->i_mode = fat_make_mode(sbi, ATTR_DIR, S_IRWXUGO);
1397 inode->i_op = sbi->dir_ops; 1397 inode->i_op = sbi->dir_ops;
1398 inode->i_fop = &fat_dir_operations; 1398 inode->i_fop = &fat_dir_operations;
1399 if (sbi->fat_bits == 32) { 1399 if (is_fat32(sbi)) {
1400 MSDOS_I(inode)->i_start = sbi->root_cluster; 1400 MSDOS_I(inode)->i_start = sbi->root_cluster;
1401 error = fat_calc_dir_size(inode); 1401 error = fat_calc_dir_size(inode);
1402 if (error < 0) 1402 if (error < 0)
@@ -1423,7 +1423,7 @@ static unsigned long calc_fat_clusters(struct super_block *sb)
1423 struct msdos_sb_info *sbi = MSDOS_SB(sb); 1423 struct msdos_sb_info *sbi = MSDOS_SB(sb);
1424 1424
1425 /* Divide first to avoid overflow */ 1425 /* Divide first to avoid overflow */
1426 if (sbi->fat_bits != 12) { 1426 if (!is_fat12(sbi)) {
1427 unsigned long ent_per_sec = sb->s_blocksize * 8 / sbi->fat_bits; 1427 unsigned long ent_per_sec = sb->s_blocksize * 8 / sbi->fat_bits;
1428 return ent_per_sec * sbi->fat_length; 1428 return ent_per_sec * sbi->fat_length;
1429 } 1429 }
@@ -1743,7 +1743,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat,
1743 } 1743 }
1744 1744
1745 /* interpret volume ID as a little endian 32 bit integer */ 1745 /* interpret volume ID as a little endian 32 bit integer */
1746 if (sbi->fat_bits == 32) 1746 if (is_fat32(sbi))
1747 sbi->vol_id = bpb.fat32_vol_id; 1747 sbi->vol_id = bpb.fat32_vol_id;
1748 else /* fat 16 or 12 */ 1748 else /* fat 16 or 12 */
1749 sbi->vol_id = bpb.fat16_vol_id; 1749 sbi->vol_id = bpb.fat16_vol_id;
@@ -1769,11 +1769,11 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat,
1769 1769
1770 total_clusters = (total_sectors - sbi->data_start) / sbi->sec_per_clus; 1770 total_clusters = (total_sectors - sbi->data_start) / sbi->sec_per_clus;
1771 1771
1772 if (sbi->fat_bits != 32) 1772 if (!is_fat32(sbi))
1773 sbi->fat_bits = (total_clusters > MAX_FAT12) ? 16 : 12; 1773 sbi->fat_bits = (total_clusters > MAX_FAT12) ? 16 : 12;
1774 1774
1775 /* some OSes set FAT_STATE_DIRTY and clean it on unmount. */ 1775 /* some OSes set FAT_STATE_DIRTY and clean it on unmount. */
1776 if (sbi->fat_bits == 32) 1776 if (is_fat32(sbi))
1777 sbi->dirty = bpb.fat32_state & FAT_STATE_DIRTY; 1777 sbi->dirty = bpb.fat32_state & FAT_STATE_DIRTY;
1778 else /* fat 16 or 12 */ 1778 else /* fat 16 or 12 */
1779 sbi->dirty = bpb.fat16_state & FAT_STATE_DIRTY; 1779 sbi->dirty = bpb.fat16_state & FAT_STATE_DIRTY;
@@ -1781,7 +1781,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat,
1781 /* check that FAT table does not overflow */ 1781 /* check that FAT table does not overflow */
1782 fat_clusters = calc_fat_clusters(sb); 1782 fat_clusters = calc_fat_clusters(sb);
1783 total_clusters = min(total_clusters, fat_clusters - FAT_START_ENT); 1783 total_clusters = min(total_clusters, fat_clusters - FAT_START_ENT);
1784 if (total_clusters > MAX_FAT(sb)) { 1784 if (total_clusters > max_fat(sb)) {
1785 if (!silent) 1785 if (!silent)
1786 fat_msg(sb, KERN_ERR, "count of clusters too big (%u)", 1786 fat_msg(sb, KERN_ERR, "count of clusters too big (%u)",
1787 total_clusters); 1787 total_clusters);
@@ -1803,11 +1803,15 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat,
1803 fat_ent_access_init(sb); 1803 fat_ent_access_init(sb);
1804 1804
1805 /* 1805 /*
1806 * The low byte of FAT's first entry must have same value with 1806 * The low byte of the first FAT entry must have the same value as
1807 * media-field. But in real world, too many devices is 1807 * the media field of the boot sector. But in real world, too many
1808 * writing wrong value. So, removed that validity check. 1808 * devices are writing wrong values. So, removed that validity check.
1809 * 1809 *
1810 * if (FAT_FIRST_ENT(sb, media) != first) 1810 * The removed check compared the first FAT entry to a value dependent
1811 * on the media field like this:
1812 * == (0x0F00 | media), for FAT12
1813 * == (0XFF00 | media), for FAT16
1814 * == (0x0FFFFF | media), for FAT32
1811 */ 1815 */
1812 1816
1813 error = -EINVAL; 1817 error = -EINVAL;
diff --git a/fs/fat/misc.c b/fs/fat/misc.c
index fce0a76f3f1e..4fc950bb6433 100644
--- a/fs/fat/misc.c
+++ b/fs/fat/misc.c
@@ -64,7 +64,7 @@ int fat_clusters_flush(struct super_block *sb)
64 struct buffer_head *bh; 64 struct buffer_head *bh;
65 struct fat_boot_fsinfo *fsinfo; 65 struct fat_boot_fsinfo *fsinfo;
66 66
67 if (sbi->fat_bits != 32) 67 if (!is_fat32(sbi))
68 return 0; 68 return 0;
69 69
70 bh = sb_bread(sb, sbi->fsinfo_sector); 70 bh = sb_bread(sb, sbi->fsinfo_sector);
diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
index f37662675c3a..29a9dcfbe81f 100644
--- a/fs/hfsplus/dir.c
+++ b/fs/hfsplus/dir.c
@@ -565,6 +565,7 @@ const struct inode_operations hfsplus_dir_inode_operations = {
565 .symlink = hfsplus_symlink, 565 .symlink = hfsplus_symlink,
566 .mknod = hfsplus_mknod, 566 .mknod = hfsplus_mknod,
567 .rename = hfsplus_rename, 567 .rename = hfsplus_rename,
568 .getattr = hfsplus_getattr,
568 .listxattr = hfsplus_listxattr, 569 .listxattr = hfsplus_listxattr,
569}; 570};
570 571
diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h
index dd7ad9f13e3a..b8471bf05def 100644
--- a/fs/hfsplus/hfsplus_fs.h
+++ b/fs/hfsplus/hfsplus_fs.h
@@ -488,6 +488,8 @@ void hfsplus_inode_write_fork(struct inode *inode,
488 struct hfsplus_fork_raw *fork); 488 struct hfsplus_fork_raw *fork);
489int hfsplus_cat_read_inode(struct inode *inode, struct hfs_find_data *fd); 489int hfsplus_cat_read_inode(struct inode *inode, struct hfs_find_data *fd);
490int hfsplus_cat_write_inode(struct inode *inode); 490int hfsplus_cat_write_inode(struct inode *inode);
491int hfsplus_getattr(const struct path *path, struct kstat *stat,
492 u32 request_mask, unsigned int query_flags);
491int hfsplus_file_fsync(struct file *file, loff_t start, loff_t end, 493int hfsplus_file_fsync(struct file *file, loff_t start, loff_t end,
492 int datasync); 494 int datasync);
493 495
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
index d7ab9d8c4b67..d131c8ea7eb6 100644
--- a/fs/hfsplus/inode.c
+++ b/fs/hfsplus/inode.c
@@ -270,6 +270,26 @@ static int hfsplus_setattr(struct dentry *dentry, struct iattr *attr)
270 return 0; 270 return 0;
271} 271}
272 272
273int hfsplus_getattr(const struct path *path, struct kstat *stat,
274 u32 request_mask, unsigned int query_flags)
275{
276 struct inode *inode = d_inode(path->dentry);
277 struct hfsplus_inode_info *hip = HFSPLUS_I(inode);
278
279 if (inode->i_flags & S_APPEND)
280 stat->attributes |= STATX_ATTR_APPEND;
281 if (inode->i_flags & S_IMMUTABLE)
282 stat->attributes |= STATX_ATTR_IMMUTABLE;
283 if (hip->userflags & HFSPLUS_FLG_NODUMP)
284 stat->attributes |= STATX_ATTR_NODUMP;
285
286 stat->attributes_mask |= STATX_ATTR_APPEND | STATX_ATTR_IMMUTABLE |
287 STATX_ATTR_NODUMP;
288
289 generic_fillattr(inode, stat);
290 return 0;
291}
292
273int hfsplus_file_fsync(struct file *file, loff_t start, loff_t end, 293int hfsplus_file_fsync(struct file *file, loff_t start, loff_t end,
274 int datasync) 294 int datasync)
275{ 295{
@@ -329,6 +349,7 @@ int hfsplus_file_fsync(struct file *file, loff_t start, loff_t end,
329 349
330static const struct inode_operations hfsplus_file_inode_operations = { 350static const struct inode_operations hfsplus_file_inode_operations = {
331 .setattr = hfsplus_setattr, 351 .setattr = hfsplus_setattr,
352 .getattr = hfsplus_getattr,
332 .listxattr = hfsplus_listxattr, 353 .listxattr = hfsplus_listxattr,
333}; 354};
334 355
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
index eb1ce30412dc..832c1759a09a 100644
--- a/fs/ocfs2/aops.c
+++ b/fs/ocfs2/aops.c
@@ -30,6 +30,7 @@
30#include <linux/quotaops.h> 30#include <linux/quotaops.h>
31#include <linux/blkdev.h> 31#include <linux/blkdev.h>
32#include <linux/uio.h> 32#include <linux/uio.h>
33#include <linux/mm.h>
33 34
34#include <cluster/masklog.h> 35#include <cluster/masklog.h>
35 36
@@ -397,7 +398,7 @@ static int ocfs2_readpages(struct file *filp, struct address_space *mapping,
397 * Check whether a remote node truncated this file - we just 398 * Check whether a remote node truncated this file - we just
398 * drop out in that case as it's not worth handling here. 399 * drop out in that case as it's not worth handling here.
399 */ 400 */
400 last = list_entry(pages->prev, struct page, lru); 401 last = lru_to_page(pages);
401 start = (loff_t)last->index << PAGE_SHIFT; 402 start = (loff_t)last->index << PAGE_SHIFT;
402 if (start >= i_size_read(inode)) 403 if (start >= i_size_read(inode))
403 goto out_unlock; 404 goto out_unlock;
diff --git a/fs/orangefs/inode.c b/fs/orangefs/inode.c
index fe53381b26b1..f038235c64bd 100644
--- a/fs/orangefs/inode.c
+++ b/fs/orangefs/inode.c
@@ -77,7 +77,7 @@ static int orangefs_readpages(struct file *file,
77 for (page_idx = 0; page_idx < nr_pages; page_idx++) { 77 for (page_idx = 0; page_idx < nr_pages; page_idx++) {
78 struct page *page; 78 struct page *page;
79 79
80 page = list_entry(pages->prev, struct page, lru); 80 page = lru_to_page(pages);
81 list_del(&page->lru); 81 list_del(&page->lru);
82 if (!add_to_page_cache(page, 82 if (!add_to_page_cache(page,
83 mapping, 83 mapping,
diff --git a/fs/orangefs/orangefs-bufmap.c b/fs/orangefs/orangefs-bufmap.c
index c4e98c9c1621..443bcd8c3c19 100644
--- a/fs/orangefs/orangefs-bufmap.c
+++ b/fs/orangefs/orangefs-bufmap.c
@@ -105,7 +105,7 @@ static int wait_for_free(struct slot_map *m)
105 left = t; 105 left = t;
106 else 106 else
107 left = t + (left - n); 107 left = t + (left - n);
108 if (unlikely(signal_pending(current))) 108 if (signal_pending(current))
109 left = -EINTR; 109 left = -EINTR;
110 } while (left > 0); 110 } while (left > 0);
111 111
diff --git a/fs/proc/base.c b/fs/proc/base.c
index d7fd1ca807d2..633a63462573 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -581,8 +581,10 @@ static int proc_pid_limits(struct seq_file *m, struct pid_namespace *ns,
581 /* 581 /*
582 * print the file header 582 * print the file header
583 */ 583 */
584 seq_printf(m, "%-25s %-20s %-20s %-10s\n", 584 seq_puts(m, "Limit "
585 "Limit", "Soft Limit", "Hard Limit", "Units"); 585 "Soft Limit "
586 "Hard Limit "
587 "Units \n");
586 588
587 for (i = 0; i < RLIM_NLIMITS; i++) { 589 for (i = 0; i < RLIM_NLIMITS; i++) {
588 if (rlim[i].rlim_cur == RLIM_INFINITY) 590 if (rlim[i].rlim_cur == RLIM_INFINITY)
@@ -2356,10 +2358,13 @@ static ssize_t timerslack_ns_write(struct file *file, const char __user *buf,
2356 return -ESRCH; 2358 return -ESRCH;
2357 2359
2358 if (p != current) { 2360 if (p != current) {
2359 if (!capable(CAP_SYS_NICE)) { 2361 rcu_read_lock();
2362 if (!ns_capable(__task_cred(p)->user_ns, CAP_SYS_NICE)) {
2363 rcu_read_unlock();
2360 count = -EPERM; 2364 count = -EPERM;
2361 goto out; 2365 goto out;
2362 } 2366 }
2367 rcu_read_unlock();
2363 2368
2364 err = security_task_setscheduler(p); 2369 err = security_task_setscheduler(p);
2365 if (err) { 2370 if (err) {
@@ -2392,11 +2397,14 @@ static int timerslack_ns_show(struct seq_file *m, void *v)
2392 return -ESRCH; 2397 return -ESRCH;
2393 2398
2394 if (p != current) { 2399 if (p != current) {
2395 2400 rcu_read_lock();
2396 if (!capable(CAP_SYS_NICE)) { 2401 if (!ns_capable(__task_cred(p)->user_ns, CAP_SYS_NICE)) {
2402 rcu_read_unlock();
2397 err = -EPERM; 2403 err = -EPERM;
2398 goto out; 2404 goto out;
2399 } 2405 }
2406 rcu_read_unlock();
2407
2400 err = security_task_getscheduler(p); 2408 err = security_task_getscheduler(p);
2401 if (err) 2409 if (err)
2402 goto out; 2410 goto out;
diff --git a/fs/proc/inode.c b/fs/proc/inode.c
index 5792f9e39466..da649ccd6804 100644
--- a/fs/proc/inode.c
+++ b/fs/proc/inode.c
@@ -59,7 +59,6 @@ static struct kmem_cache *pde_opener_cache __ro_after_init;
59static struct inode *proc_alloc_inode(struct super_block *sb) 59static struct inode *proc_alloc_inode(struct super_block *sb)
60{ 60{
61 struct proc_inode *ei; 61 struct proc_inode *ei;
62 struct inode *inode;
63 62
64 ei = kmem_cache_alloc(proc_inode_cachep, GFP_KERNEL); 63 ei = kmem_cache_alloc(proc_inode_cachep, GFP_KERNEL);
65 if (!ei) 64 if (!ei)
@@ -71,8 +70,7 @@ static struct inode *proc_alloc_inode(struct super_block *sb)
71 ei->sysctl = NULL; 70 ei->sysctl = NULL;
72 ei->sysctl_entry = NULL; 71 ei->sysctl_entry = NULL;
73 ei->ns_ops = NULL; 72 ei->ns_ops = NULL;
74 inode = &ei->vfs_inode; 73 return &ei->vfs_inode;
75 return inode;
76} 74}
77 75
78static void proc_i_callback(struct rcu_head *head) 76static void proc_i_callback(struct rcu_head *head)
diff --git a/fs/proc/util.c b/fs/proc/util.c
index b161cfa0f9fa..98f8adc17345 100644
--- a/fs/proc/util.c
+++ b/fs/proc/util.c
@@ -1,4 +1,5 @@
1#include <linux/dcache.h> 1#include <linux/dcache.h>
2#include "internal.h"
2 3
3unsigned name_to_int(const struct qstr *qstr) 4unsigned name_to_int(const struct qstr *qstr)
4{ 5{
diff --git a/include/asm-generic/bitops/builtin-fls.h b/include/asm-generic/bitops/builtin-fls.h
index 62daf940989d..c8455cc28841 100644
--- a/include/asm-generic/bitops/builtin-fls.h
+++ b/include/asm-generic/bitops/builtin-fls.h
@@ -9,7 +9,7 @@
9 * This is defined the same way as ffs. 9 * This is defined the same way as ffs.
10 * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32. 10 * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32.
11 */ 11 */
12static __always_inline int fls(int x) 12static __always_inline int fls(unsigned int x)
13{ 13{
14 return x ? sizeof(x) * 8 - __builtin_clz(x) : 0; 14 return x ? sizeof(x) * 8 - __builtin_clz(x) : 0;
15} 15}
diff --git a/include/asm-generic/bitops/fls.h b/include/asm-generic/bitops/fls.h
index 753aecaab641..b168bb10e1be 100644
--- a/include/asm-generic/bitops/fls.h
+++ b/include/asm-generic/bitops/fls.h
@@ -10,7 +10,7 @@
10 * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32. 10 * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32.
11 */ 11 */
12 12
13static __always_inline int fls(int x) 13static __always_inline int fls(unsigned int x)
14{ 14{
15 int r = 32; 15 int r = 32;
16 16
diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
index e9f5fe69df31..03200a8c0178 100644
--- a/include/linux/binfmts.h
+++ b/include/linux/binfmts.h
@@ -25,6 +25,7 @@ struct linux_binprm {
25#endif 25#endif
26 struct mm_struct *mm; 26 struct mm_struct *mm;
27 unsigned long p; /* current top of mem */ 27 unsigned long p; /* current top of mem */
28 unsigned long argmin; /* rlimit marker for copy_strings() */
28 unsigned int 29 unsigned int
29 /* 30 /*
30 * True after the bprm_set_creds hook has been called once 31 * True after the bprm_set_creds hook has been called once
diff --git a/include/linux/build_bug.h b/include/linux/build_bug.h
index 43d1fd50d433..faeec7433aab 100644
--- a/include/linux/build_bug.h
+++ b/include/linux/build_bug.h
@@ -5,21 +5,8 @@
5#include <linux/compiler.h> 5#include <linux/compiler.h>
6 6
7#ifdef __CHECKER__ 7#ifdef __CHECKER__
8#define __BUILD_BUG_ON_NOT_POWER_OF_2(n) (0)
9#define BUILD_BUG_ON_NOT_POWER_OF_2(n) (0)
10#define BUILD_BUG_ON_ZERO(e) (0) 8#define BUILD_BUG_ON_ZERO(e) (0)
11#define BUILD_BUG_ON_INVALID(e) (0)
12#define BUILD_BUG_ON_MSG(cond, msg) (0)
13#define BUILD_BUG_ON(condition) (0)
14#define BUILD_BUG() (0)
15#else /* __CHECKER__ */ 9#else /* __CHECKER__ */
16
17/* Force a compilation error if a constant expression is not a power of 2 */
18#define __BUILD_BUG_ON_NOT_POWER_OF_2(n) \
19 BUILD_BUG_ON(((n) & ((n) - 1)) != 0)
20#define BUILD_BUG_ON_NOT_POWER_OF_2(n) \
21 BUILD_BUG_ON((n) == 0 || (((n) & ((n) - 1)) != 0))
22
23/* 10/*
24 * Force a compilation error if condition is true, but also produce a 11 * Force a compilation error if condition is true, but also produce a
25 * result (of value 0 and type size_t), so the expression can be used 12 * result (of value 0 and type size_t), so the expression can be used
@@ -27,6 +14,13 @@
27 * aren't permitted). 14 * aren't permitted).
28 */ 15 */
29#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:(-!!(e)); })) 16#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:(-!!(e)); }))
17#endif /* __CHECKER__ */
18
19/* Force a compilation error if a constant expression is not a power of 2 */
20#define __BUILD_BUG_ON_NOT_POWER_OF_2(n) \
21 BUILD_BUG_ON(((n) & ((n) - 1)) != 0)
22#define BUILD_BUG_ON_NOT_POWER_OF_2(n) \
23 BUILD_BUG_ON((n) == 0 || (((n) & ((n) - 1)) != 0))
30 24
31/* 25/*
32 * BUILD_BUG_ON_INVALID() permits the compiler to check the validity of the 26 * BUILD_BUG_ON_INVALID() permits the compiler to check the validity of the
@@ -51,23 +45,9 @@
51 * If you have some code which relies on certain constants being equal, or 45 * If you have some code which relies on certain constants being equal, or
52 * some other compile-time-evaluated condition, you should use BUILD_BUG_ON to 46 * some other compile-time-evaluated condition, you should use BUILD_BUG_ON to
53 * detect if someone changes it. 47 * detect if someone changes it.
54 *
55 * The implementation uses gcc's reluctance to create a negative array, but gcc
56 * (as of 4.4) only emits that error for obvious cases (e.g. not arguments to
57 * inline functions). Luckily, in 4.3 they added the "error" function
58 * attribute just for this type of case. Thus, we use a negative sized array
59 * (should always create an error on gcc versions older than 4.4) and then call
60 * an undefined function with the error attribute (should always create an
61 * error on gcc 4.3 and later). If for some reason, neither creates a
62 * compile-time error, we'll still have a link-time error, which is harder to
63 * track down.
64 */ 48 */
65#ifndef __OPTIMIZE__
66#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
67#else
68#define BUILD_BUG_ON(condition) \ 49#define BUILD_BUG_ON(condition) \
69 BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition) 50 BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
70#endif
71 51
72/** 52/**
73 * BUILD_BUG - break compile if used. 53 * BUILD_BUG - break compile if used.
@@ -78,6 +58,4 @@
78 */ 58 */
79#define BUILD_BUG() BUILD_BUG_ON_MSG(1, "BUILD_BUG failed") 59#define BUILD_BUG() BUILD_BUG_ON_MSG(1, "BUILD_BUG failed")
80 60
81#endif /* __CHECKER__ */
82
83#endif /* _LINUX_BUILD_BUG_H */ 61#endif /* _LINUX_BUILD_BUG_H */
diff --git a/include/linux/genalloc.h b/include/linux/genalloc.h
index 872f930f1b06..dd0a452373e7 100644
--- a/include/linux/genalloc.h
+++ b/include/linux/genalloc.h
@@ -51,7 +51,8 @@ typedef unsigned long (*genpool_algo_t)(unsigned long *map,
51 unsigned long size, 51 unsigned long size,
52 unsigned long start, 52 unsigned long start,
53 unsigned int nr, 53 unsigned int nr,
54 void *data, struct gen_pool *pool); 54 void *data, struct gen_pool *pool,
55 unsigned long start_addr);
55 56
56/* 57/*
57 * General purpose special memory pool descriptor. 58 * General purpose special memory pool descriptor.
@@ -131,24 +132,24 @@ extern void gen_pool_set_algo(struct gen_pool *pool, genpool_algo_t algo,
131 132
132extern unsigned long gen_pool_first_fit(unsigned long *map, unsigned long size, 133extern unsigned long gen_pool_first_fit(unsigned long *map, unsigned long size,
133 unsigned long start, unsigned int nr, void *data, 134 unsigned long start, unsigned int nr, void *data,
134 struct gen_pool *pool); 135 struct gen_pool *pool, unsigned long start_addr);
135 136
136extern unsigned long gen_pool_fixed_alloc(unsigned long *map, 137extern unsigned long gen_pool_fixed_alloc(unsigned long *map,
137 unsigned long size, unsigned long start, unsigned int nr, 138 unsigned long size, unsigned long start, unsigned int nr,
138 void *data, struct gen_pool *pool); 139 void *data, struct gen_pool *pool, unsigned long start_addr);
139 140
140extern unsigned long gen_pool_first_fit_align(unsigned long *map, 141extern unsigned long gen_pool_first_fit_align(unsigned long *map,
141 unsigned long size, unsigned long start, unsigned int nr, 142 unsigned long size, unsigned long start, unsigned int nr,
142 void *data, struct gen_pool *pool); 143 void *data, struct gen_pool *pool, unsigned long start_addr);
143 144
144 145
145extern unsigned long gen_pool_first_fit_order_align(unsigned long *map, 146extern unsigned long gen_pool_first_fit_order_align(unsigned long *map,
146 unsigned long size, unsigned long start, unsigned int nr, 147 unsigned long size, unsigned long start, unsigned int nr,
147 void *data, struct gen_pool *pool); 148 void *data, struct gen_pool *pool, unsigned long start_addr);
148 149
149extern unsigned long gen_pool_best_fit(unsigned long *map, unsigned long size, 150extern unsigned long gen_pool_best_fit(unsigned long *map, unsigned long size,
150 unsigned long start, unsigned int nr, void *data, 151 unsigned long start, unsigned int nr, void *data,
151 struct gen_pool *pool); 152 struct gen_pool *pool, unsigned long start_addr);
152 153
153 154
154extern struct gen_pool *devm_gen_pool_create(struct device *dev, 155extern struct gen_pool *devm_gen_pool_create(struct device *dev,
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index d6aac75b51ba..8f0e68e250a7 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -527,6 +527,7 @@ static inline u32 int_sqrt64(u64 x)
527extern void bust_spinlocks(int yes); 527extern void bust_spinlocks(int yes);
528extern int oops_in_progress; /* If set, an oops, panic(), BUG() or die() is in progress */ 528extern int oops_in_progress; /* If set, an oops, panic(), BUG() or die() is in progress */
529extern int panic_timeout; 529extern int panic_timeout;
530extern unsigned long panic_print;
530extern int panic_on_oops; 531extern int panic_on_oops;
531extern int panic_on_unrecovered_nmi; 532extern int panic_on_unrecovered_nmi;
532extern int panic_on_io_nmi; 533extern int panic_on_io_nmi;
diff --git a/include/linux/mm.h b/include/linux/mm.h
index ea1f12d15365..80bb6408fe73 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -171,6 +171,8 @@ extern int overcommit_kbytes_handler(struct ctl_table *, int, void __user *,
171/* test whether an address (unsigned long or pointer) is aligned to PAGE_SIZE */ 171/* test whether an address (unsigned long or pointer) is aligned to PAGE_SIZE */
172#define PAGE_ALIGNED(addr) IS_ALIGNED((unsigned long)(addr), PAGE_SIZE) 172#define PAGE_ALIGNED(addr) IS_ALIGNED((unsigned long)(addr), PAGE_SIZE)
173 173
174#define lru_to_page(head) (list_entry((head)->prev, struct page, lru))
175
174/* 176/*
175 * Linux kernel virtual memory manager primitives. 177 * Linux kernel virtual memory manager primitives.
176 * The idea being to have a "virtual" mm in the same way 178 * The idea being to have a "virtual" mm in the same way
@@ -1873,8 +1875,8 @@ static inline void mm_inc_nr_ptes(struct mm_struct *mm) {}
1873static inline void mm_dec_nr_ptes(struct mm_struct *mm) {} 1875static inline void mm_dec_nr_ptes(struct mm_struct *mm) {}
1874#endif 1876#endif
1875 1877
1876int __pte_alloc(struct mm_struct *mm, pmd_t *pmd, unsigned long address); 1878int __pte_alloc(struct mm_struct *mm, pmd_t *pmd);
1877int __pte_alloc_kernel(pmd_t *pmd, unsigned long address); 1879int __pte_alloc_kernel(pmd_t *pmd);
1878 1880
1879/* 1881/*
1880 * The following ifdef needed to get the 4level-fixup.h header to work. 1882 * The following ifdef needed to get the 4level-fixup.h header to work.
@@ -2005,18 +2007,17 @@ static inline void pgtable_page_dtor(struct page *page)
2005 pte_unmap(pte); \ 2007 pte_unmap(pte); \
2006} while (0) 2008} while (0)
2007 2009
2008#define pte_alloc(mm, pmd, address) \ 2010#define pte_alloc(mm, pmd) (unlikely(pmd_none(*(pmd))) && __pte_alloc(mm, pmd))
2009 (unlikely(pmd_none(*(pmd))) && __pte_alloc(mm, pmd, address))
2010 2011
2011#define pte_alloc_map(mm, pmd, address) \ 2012#define pte_alloc_map(mm, pmd, address) \
2012 (pte_alloc(mm, pmd, address) ? NULL : pte_offset_map(pmd, address)) 2013 (pte_alloc(mm, pmd) ? NULL : pte_offset_map(pmd, address))
2013 2014
2014#define pte_alloc_map_lock(mm, pmd, address, ptlp) \ 2015#define pte_alloc_map_lock(mm, pmd, address, ptlp) \
2015 (pte_alloc(mm, pmd, address) ? \ 2016 (pte_alloc(mm, pmd) ? \
2016 NULL : pte_offset_map_lock(mm, pmd, address, ptlp)) 2017 NULL : pte_offset_map_lock(mm, pmd, address, ptlp))
2017 2018
2018#define pte_alloc_kernel(pmd, address) \ 2019#define pte_alloc_kernel(pmd, address) \
2019 ((unlikely(pmd_none(*(pmd))) && __pte_alloc_kernel(pmd, address))? \ 2020 ((unlikely(pmd_none(*(pmd))) && __pte_alloc_kernel(pmd))? \
2020 NULL: pte_offset_kernel(pmd, address)) 2021 NULL: pte_offset_kernel(pmd, address))
2021 2022
2022#if USE_SPLIT_PMD_PTLOCKS 2023#if USE_SPLIT_PMD_PTLOCKS
diff --git a/include/linux/mm_inline.h b/include/linux/mm_inline.h
index 10191c28fc04..04ec454d44ce 100644
--- a/include/linux/mm_inline.h
+++ b/include/linux/mm_inline.h
@@ -124,7 +124,4 @@ static __always_inline enum lru_list page_lru(struct page *page)
124 } 124 }
125 return lru; 125 return lru;
126} 126}
127
128#define lru_to_page(head) (list_entry((head)->prev, struct page, lru))
129
130#endif 127#endif
diff --git a/include/linux/printk.h b/include/linux/printk.h
index 55aa96975fa2..77740a506ebb 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -264,7 +264,7 @@ static inline void show_regs_print_info(const char *log_lvl)
264{ 264{
265} 265}
266 266
267static inline asmlinkage void dump_stack(void) 267static inline void dump_stack(void)
268{ 268{
269} 269}
270 270
diff --git a/include/linux/sched/task.h b/include/linux/sched/task.h
index 108ede99e533..44c6f15800ff 100644
--- a/include/linux/sched/task.h
+++ b/include/linux/sched/task.h
@@ -39,6 +39,8 @@ void __noreturn do_task_dead(void);
39 39
40extern void proc_caches_init(void); 40extern void proc_caches_init(void);
41 41
42extern void fork_init(void);
43
42extern void release_task(struct task_struct * p); 44extern void release_task(struct task_struct * p);
43 45
44#ifdef CONFIG_HAVE_COPY_THREAD_TLS 46#ifdef CONFIG_HAVE_COPY_THREAD_TLS
diff --git a/include/uapi/linux/auto_fs.h b/include/uapi/linux/auto_fs.h
index df31aa9c9a8c..082119630b49 100644
--- a/include/uapi/linux/auto_fs.h
+++ b/include/uapi/linux/auto_fs.h
@@ -23,7 +23,7 @@
23#define AUTOFS_MIN_PROTO_VERSION 3 23#define AUTOFS_MIN_PROTO_VERSION 3
24#define AUTOFS_MAX_PROTO_VERSION 5 24#define AUTOFS_MAX_PROTO_VERSION 5
25 25
26#define AUTOFS_PROTO_SUBVERSION 3 26#define AUTOFS_PROTO_SUBVERSION 4
27 27
28/* 28/*
29 * The wait_queue_token (autofs_wqt_t) is part of a structure which is passed 29 * The wait_queue_token (autofs_wqt_t) is part of a structure which is passed
diff --git a/include/uapi/linux/bfs_fs.h b/include/uapi/linux/bfs_fs.h
index 940b04772af8..08f6b4956359 100644
--- a/include/uapi/linux/bfs_fs.h
+++ b/include/uapi/linux/bfs_fs.h
@@ -1,7 +1,7 @@
1/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 1/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2/* 2/*
3 * include/linux/bfs_fs.h - BFS data structures on disk. 3 * include/linux/bfs_fs.h - BFS data structures on disk.
4 * Copyright (C) 1999 Tigran Aivazian <tigran@veritas.com> 4 * Copyright (C) 1999-2018 Tigran Aivazian <aivazian.tigran@gmail.com>
5 */ 5 */
6 6
7#ifndef _LINUX_BFS_FS_H 7#ifndef _LINUX_BFS_FS_H
diff --git a/include/uapi/linux/msdos_fs.h b/include/uapi/linux/msdos_fs.h
index fde753735aba..a5773899f4d9 100644
--- a/include/uapi/linux/msdos_fs.h
+++ b/include/uapi/linux/msdos_fs.h
@@ -58,9 +58,6 @@
58#define MSDOS_DOT ". " /* ".", padded to MSDOS_NAME chars */ 58#define MSDOS_DOT ". " /* ".", padded to MSDOS_NAME chars */
59#define MSDOS_DOTDOT ".. " /* "..", padded to MSDOS_NAME chars */ 59#define MSDOS_DOTDOT ".. " /* "..", padded to MSDOS_NAME chars */
60 60
61#define FAT_FIRST_ENT(s, x) ((MSDOS_SB(s)->fat_bits == 32 ? 0x0FFFFF00 : \
62 MSDOS_SB(s)->fat_bits == 16 ? 0xFF00 : 0xF00) | (x))
63
64/* start of data cluster's entry (number of reserved clusters) */ 61/* start of data cluster's entry (number of reserved clusters) */
65#define FAT_START_ENT 2 62#define FAT_START_ENT 2
66 63
@@ -68,8 +65,6 @@
68#define MAX_FAT12 0xFF4 65#define MAX_FAT12 0xFF4
69#define MAX_FAT16 0xFFF4 66#define MAX_FAT16 0xFFF4
70#define MAX_FAT32 0x0FFFFFF6 67#define MAX_FAT32 0x0FFFFFF6
71#define MAX_FAT(s) (MSDOS_SB(s)->fat_bits == 32 ? MAX_FAT32 : \
72 MSDOS_SB(s)->fat_bits == 16 ? MAX_FAT16 : MAX_FAT12)
73 68
74/* bad cluster mark */ 69/* bad cluster mark */
75#define BAD_FAT12 0xFF7 70#define BAD_FAT12 0xFF7
@@ -135,7 +130,7 @@ struct fat_boot_sector {
135 for mount state. */ 130 for mount state. */
136 __u8 signature; /* extended boot signature */ 131 __u8 signature; /* extended boot signature */
137 __u8 vol_id[4]; /* volume ID */ 132 __u8 vol_id[4]; /* volume ID */
138 __u8 vol_label[11]; /* volume label */ 133 __u8 vol_label[MSDOS_NAME]; /* volume label */
139 __u8 fs_type[8]; /* file system type */ 134 __u8 fs_type[8]; /* file system type */
140 /* other fields are not added here */ 135 /* other fields are not added here */
141 } fat16; 136 } fat16;
@@ -158,7 +153,7 @@ struct fat_boot_sector {
158 for mount state. */ 153 for mount state. */
159 __u8 signature; /* extended boot signature */ 154 __u8 signature; /* extended boot signature */
160 __u8 vol_id[4]; /* volume ID */ 155 __u8 vol_id[4]; /* volume ID */
161 __u8 vol_label[11]; /* volume label */ 156 __u8 vol_label[MSDOS_NAME]; /* volume label */
162 __u8 fs_type[8]; /* file system type */ 157 __u8 fs_type[8]; /* file system type */
163 /* other fields are not added here */ 158 /* other fields are not added here */
164 } fat32; 159 } fat32;
diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
index d71013fffaf6..87aa2a6d9125 100644
--- a/include/uapi/linux/sysctl.h
+++ b/include/uapi/linux/sysctl.h
@@ -153,6 +153,7 @@ enum
153 KERN_NMI_WATCHDOG=75, /* int: enable/disable nmi watchdog */ 153 KERN_NMI_WATCHDOG=75, /* int: enable/disable nmi watchdog */
154 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */ 154 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
155 KERN_PANIC_ON_WARN=77, /* int: call panic() in WARN() functions */ 155 KERN_PANIC_ON_WARN=77, /* int: call panic() in WARN() functions */
156 KERN_PANIC_PRINT=78, /* ulong: bitmask to print system info on panic */
156}; 157};
157 158
158 159
diff --git a/init/initramfs.c b/init/initramfs.c
index fca899622937..7cea802d00ef 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -550,7 +550,6 @@ skip:
550 initrd_end = 0; 550 initrd_end = 0;
551} 551}
552 552
553#ifdef CONFIG_BLK_DEV_RAM
554#define BUF_SIZE 1024 553#define BUF_SIZE 1024
555static void __init clean_rootfs(void) 554static void __init clean_rootfs(void)
556{ 555{
@@ -597,7 +596,6 @@ static void __init clean_rootfs(void)
597 ksys_close(fd); 596 ksys_close(fd);
598 kfree(buf); 597 kfree(buf);
599} 598}
600#endif
601 599
602static int __init populate_rootfs(void) 600static int __init populate_rootfs(void)
603{ 601{
@@ -640,8 +638,10 @@ static int __init populate_rootfs(void)
640 printk(KERN_INFO "Unpacking initramfs...\n"); 638 printk(KERN_INFO "Unpacking initramfs...\n");
641 err = unpack_to_rootfs((char *)initrd_start, 639 err = unpack_to_rootfs((char *)initrd_start,
642 initrd_end - initrd_start); 640 initrd_end - initrd_start);
643 if (err) 641 if (err) {
644 printk(KERN_EMERG "Initramfs unpacking failed: %s\n", err); 642 printk(KERN_EMERG "Initramfs unpacking failed: %s\n", err);
643 clean_rootfs();
644 }
645 free_initrd(); 645 free_initrd();
646#endif 646#endif
647 } 647 }
diff --git a/init/main.c b/init/main.c
index 86d894852bef..e2e80ca3165a 100644
--- a/init/main.c
+++ b/init/main.c
@@ -105,7 +105,6 @@
105static int kernel_init(void *); 105static int kernel_init(void *);
106 106
107extern void init_IRQ(void); 107extern void init_IRQ(void);
108extern void fork_init(void);
109extern void radix_tree_init(void); 108extern void radix_tree_init(void);
110 109
111/* 110/*
@@ -930,7 +929,7 @@ static initcall_entry_t *initcall_levels[] __initdata = {
930}; 929};
931 930
932/* Keep these in sync with initcalls in include/linux/init.h */ 931/* Keep these in sync with initcalls in include/linux/init.h */
933static char *initcall_level_names[] __initdata = { 932static const char *initcall_level_names[] __initdata = {
934 "pure", 933 "pure",
935 "core", 934 "core",
936 "postcore", 935 "postcore",
diff --git a/kernel/fork.c b/kernel/fork.c
index d439c48ecf18..a60459947f18 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -164,10 +164,6 @@ static inline void free_task_struct(struct task_struct *tsk)
164} 164}
165#endif 165#endif
166 166
167void __weak arch_release_thread_stack(unsigned long *stack)
168{
169}
170
171#ifndef CONFIG_ARCH_THREAD_STACK_ALLOCATOR 167#ifndef CONFIG_ARCH_THREAD_STACK_ALLOCATOR
172 168
173/* 169/*
@@ -422,7 +418,6 @@ static void release_task_stack(struct task_struct *tsk)
422 return; /* Better to leak the stack than to free prematurely */ 418 return; /* Better to leak the stack than to free prematurely */
423 419
424 account_kernel_stack(tsk, -1); 420 account_kernel_stack(tsk, -1);
425 arch_release_thread_stack(tsk->stack);
426 free_thread_stack(tsk); 421 free_thread_stack(tsk);
427 tsk->stack = NULL; 422 tsk->stack = NULL;
428#ifdef CONFIG_VMAP_STACK 423#ifdef CONFIG_VMAP_STACK
diff --git a/kernel/hung_task.c b/kernel/hung_task.c
index cb8e3e8ac7b9..4a9191617076 100644
--- a/kernel/hung_task.c
+++ b/kernel/hung_task.c
@@ -34,7 +34,7 @@ int __read_mostly sysctl_hung_task_check_count = PID_MAX_LIMIT;
34 * is disabled during the critical section. It also controls the size of 34 * is disabled during the critical section. It also controls the size of
35 * the RCU grace period. So it needs to be upper-bound. 35 * the RCU grace period. So it needs to be upper-bound.
36 */ 36 */
37#define HUNG_TASK_BATCHING 1024 37#define HUNG_TASK_LOCK_BREAK (HZ / 10)
38 38
39/* 39/*
40 * Zero means infinite timeout - no checking done: 40 * Zero means infinite timeout - no checking done:
@@ -112,8 +112,11 @@ static void check_hung_task(struct task_struct *t, unsigned long timeout)
112 112
113 trace_sched_process_hang(t); 113 trace_sched_process_hang(t);
114 114
115 if (!sysctl_hung_task_warnings && !sysctl_hung_task_panic) 115 if (sysctl_hung_task_panic) {
116 return; 116 console_verbose();
117 hung_task_show_lock = true;
118 hung_task_call_panic = true;
119 }
117 120
118 /* 121 /*
119 * Ok, the task did not get scheduled for more than 2 minutes, 122 * Ok, the task did not get scheduled for more than 2 minutes,
@@ -135,11 +138,6 @@ static void check_hung_task(struct task_struct *t, unsigned long timeout)
135 } 138 }
136 139
137 touch_nmi_watchdog(); 140 touch_nmi_watchdog();
138
139 if (sysctl_hung_task_panic) {
140 hung_task_show_lock = true;
141 hung_task_call_panic = true;
142 }
143} 141}
144 142
145/* 143/*
@@ -173,7 +171,7 @@ static bool rcu_lock_break(struct task_struct *g, struct task_struct *t)
173static void check_hung_uninterruptible_tasks(unsigned long timeout) 171static void check_hung_uninterruptible_tasks(unsigned long timeout)
174{ 172{
175 int max_count = sysctl_hung_task_check_count; 173 int max_count = sysctl_hung_task_check_count;
176 int batch_count = HUNG_TASK_BATCHING; 174 unsigned long last_break = jiffies;
177 struct task_struct *g, *t; 175 struct task_struct *g, *t;
178 176
179 /* 177 /*
@@ -188,10 +186,10 @@ static void check_hung_uninterruptible_tasks(unsigned long timeout)
188 for_each_process_thread(g, t) { 186 for_each_process_thread(g, t) {
189 if (!max_count--) 187 if (!max_count--)
190 goto unlock; 188 goto unlock;
191 if (!--batch_count) { 189 if (time_after(jiffies, last_break + HUNG_TASK_LOCK_BREAK)) {
192 batch_count = HUNG_TASK_BATCHING;
193 if (!rcu_lock_break(g, t)) 190 if (!rcu_lock_break(g, t))
194 goto unlock; 191 goto unlock;
192 last_break = jiffies;
195 } 193 }
196 /* use "==" to skip the TASK_KILLABLE tasks waiting on NFS */ 194 /* use "==" to skip the TASK_KILLABLE tasks waiting on NFS */
197 if (t->state == TASK_UNINTERRUPTIBLE) 195 if (t->state == TASK_UNINTERRUPTIBLE)
diff --git a/kernel/kcov.c b/kernel/kcov.c
index 97959d7b77e2..c2277dbdbfb1 100644
--- a/kernel/kcov.c
+++ b/kernel/kcov.c
@@ -112,7 +112,7 @@ void notrace __sanitizer_cov_trace_pc(void)
112EXPORT_SYMBOL(__sanitizer_cov_trace_pc); 112EXPORT_SYMBOL(__sanitizer_cov_trace_pc);
113 113
114#ifdef CONFIG_KCOV_ENABLE_COMPARISONS 114#ifdef CONFIG_KCOV_ENABLE_COMPARISONS
115static void write_comp_data(u64 type, u64 arg1, u64 arg2, u64 ip) 115static void notrace write_comp_data(u64 type, u64 arg1, u64 arg2, u64 ip)
116{ 116{
117 struct task_struct *t; 117 struct task_struct *t;
118 u64 *area; 118 u64 *area;
diff --git a/kernel/locking/mutex.c b/kernel/locking/mutex.c
index 3f8a35104285..db578783dd36 100644
--- a/kernel/locking/mutex.c
+++ b/kernel/locking/mutex.c
@@ -987,7 +987,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
987 * wait_lock. This ensures the lock cancellation is ordered 987 * wait_lock. This ensures the lock cancellation is ordered
988 * against mutex_unlock() and wake-ups do not go missing. 988 * against mutex_unlock() and wake-ups do not go missing.
989 */ 989 */
990 if (unlikely(signal_pending_state(state, current))) { 990 if (signal_pending_state(state, current)) {
991 ret = -EINTR; 991 ret = -EINTR;
992 goto err; 992 goto err;
993 } 993 }
diff --git a/kernel/panic.c b/kernel/panic.c
index d10c340c43b0..f121e6ba7e11 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -46,6 +46,13 @@ int panic_on_warn __read_mostly;
46int panic_timeout = CONFIG_PANIC_TIMEOUT; 46int panic_timeout = CONFIG_PANIC_TIMEOUT;
47EXPORT_SYMBOL_GPL(panic_timeout); 47EXPORT_SYMBOL_GPL(panic_timeout);
48 48
49#define PANIC_PRINT_TASK_INFO 0x00000001
50#define PANIC_PRINT_MEM_INFO 0x00000002
51#define PANIC_PRINT_TIMER_INFO 0x00000004
52#define PANIC_PRINT_LOCK_INFO 0x00000008
53#define PANIC_PRINT_FTRACE_INFO 0x00000010
54unsigned long panic_print;
55
49ATOMIC_NOTIFIER_HEAD(panic_notifier_list); 56ATOMIC_NOTIFIER_HEAD(panic_notifier_list);
50 57
51EXPORT_SYMBOL(panic_notifier_list); 58EXPORT_SYMBOL(panic_notifier_list);
@@ -125,6 +132,24 @@ void nmi_panic(struct pt_regs *regs, const char *msg)
125} 132}
126EXPORT_SYMBOL(nmi_panic); 133EXPORT_SYMBOL(nmi_panic);
127 134
135static void panic_print_sys_info(void)
136{
137 if (panic_print & PANIC_PRINT_TASK_INFO)
138 show_state();
139
140 if (panic_print & PANIC_PRINT_MEM_INFO)
141 show_mem(0, NULL);
142
143 if (panic_print & PANIC_PRINT_TIMER_INFO)
144 sysrq_timer_list_show();
145
146 if (panic_print & PANIC_PRINT_LOCK_INFO)
147 debug_show_all_locks();
148
149 if (panic_print & PANIC_PRINT_FTRACE_INFO)
150 ftrace_dump(DUMP_ALL);
151}
152
128/** 153/**
129 * panic - halt the system 154 * panic - halt the system
130 * @fmt: The text string to print 155 * @fmt: The text string to print
@@ -254,6 +279,8 @@ void panic(const char *fmt, ...)
254 debug_locks_off(); 279 debug_locks_off();
255 console_flush_on_panic(); 280 console_flush_on_panic();
256 281
282 panic_print_sys_info();
283
257 if (!panic_blink) 284 if (!panic_blink)
258 panic_blink = no_blink; 285 panic_blink = no_blink;
259 286
@@ -658,6 +685,7 @@ void refcount_error_report(struct pt_regs *regs, const char *err)
658#endif 685#endif
659 686
660core_param(panic, panic_timeout, int, 0644); 687core_param(panic, panic_timeout, int, 0644);
688core_param(panic_print, panic_print, ulong, 0644);
661core_param(pause_on_oops, pause_on_oops, int, 0644); 689core_param(pause_on_oops, pause_on_oops, int, 0644);
662core_param(panic_on_warn, panic_on_warn, int, 0644); 690core_param(panic_on_warn, panic_on_warn, int, 0644);
663core_param(crash_kexec_post_notifiers, crash_kexec_post_notifiers, bool, 0644); 691core_param(crash_kexec_post_notifiers, crash_kexec_post_notifiers, bool, 0644);
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 1f3e19fd6dc6..223f78d5c111 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3416,7 +3416,7 @@ static void __sched notrace __schedule(bool preempt)
3416 3416
3417 switch_count = &prev->nivcsw; 3417 switch_count = &prev->nivcsw;
3418 if (!preempt && prev->state) { 3418 if (!preempt && prev->state) {
3419 if (unlikely(signal_pending_state(prev->state, prev))) { 3419 if (signal_pending_state(prev->state, prev)) {
3420 prev->state = TASK_RUNNING; 3420 prev->state = TASK_RUNNING;
3421 } else { 3421 } else {
3422 deactivate_task(rq, prev, DEQUEUE_SLEEP | DEQUEUE_NOCLOCK); 3422 deactivate_task(rq, prev, DEQUEUE_SLEEP | DEQUEUE_NOCLOCK);
diff --git a/kernel/sched/swait.c b/kernel/sched/swait.c
index 66b59ac77c22..e83a3f8449f6 100644
--- a/kernel/sched/swait.c
+++ b/kernel/sched/swait.c
@@ -93,7 +93,7 @@ long prepare_to_swait_event(struct swait_queue_head *q, struct swait_queue *wait
93 long ret = 0; 93 long ret = 0;
94 94
95 raw_spin_lock_irqsave(&q->lock, flags); 95 raw_spin_lock_irqsave(&q->lock, flags);
96 if (unlikely(signal_pending_state(state, current))) { 96 if (signal_pending_state(state, current)) {
97 /* 97 /*
98 * See prepare_to_wait_event(). TL;DR, subsequent swake_up_one() 98 * See prepare_to_wait_event(). TL;DR, subsequent swake_up_one()
99 * must not see us. 99 * must not see us.
diff --git a/kernel/sched/wait.c b/kernel/sched/wait.c
index 5dd47f1103d1..6eb1f8efd221 100644
--- a/kernel/sched/wait.c
+++ b/kernel/sched/wait.c
@@ -264,7 +264,7 @@ long prepare_to_wait_event(struct wait_queue_head *wq_head, struct wait_queue_en
264 long ret = 0; 264 long ret = 0;
265 265
266 spin_lock_irqsave(&wq_head->lock, flags); 266 spin_lock_irqsave(&wq_head->lock, flags);
267 if (unlikely(signal_pending_state(state, current))) { 267 if (signal_pending_state(state, current)) {
268 /* 268 /*
269 * Exclusive waiter must not fail if it was selected by wakeup, 269 * Exclusive waiter must not fail if it was selected by wakeup,
270 * it should "consume" the condition we were waiting for. 270 * it should "consume" the condition we were waiting for.
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 1825f712e73b..ba4d9e85feb8 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -807,6 +807,13 @@ static struct ctl_table kern_table[] = {
807 .mode = 0644, 807 .mode = 0644,
808 .proc_handler = proc_dointvec, 808 .proc_handler = proc_dointvec,
809 }, 809 },
810 {
811 .procname = "panic_print",
812 .data = &panic_print,
813 .maxlen = sizeof(unsigned long),
814 .mode = 0644,
815 .proc_handler = proc_doulongvec_minmax,
816 },
810#if defined CONFIG_PRINTK 817#if defined CONFIG_PRINTK
811 { 818 {
812 .procname = "printk", 819 .procname = "printk",
@@ -2787,6 +2794,8 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
2787 bool neg; 2794 bool neg;
2788 2795
2789 left -= proc_skip_spaces(&p); 2796 left -= proc_skip_spaces(&p);
2797 if (!left)
2798 break;
2790 2799
2791 err = proc_get_long(&p, &left, &val, &neg, 2800 err = proc_get_long(&p, &left, &val, &neg,
2792 proc_wspace_sep, 2801 proc_wspace_sep,
diff --git a/kernel/sysctl_binary.c b/kernel/sysctl_binary.c
index 07148b497451..73c132095a7b 100644
--- a/kernel/sysctl_binary.c
+++ b/kernel/sysctl_binary.c
@@ -140,6 +140,7 @@ static const struct bin_table bin_kern_table[] = {
140 { CTL_INT, KERN_MAX_LOCK_DEPTH, "max_lock_depth" }, 140 { CTL_INT, KERN_MAX_LOCK_DEPTH, "max_lock_depth" },
141 { CTL_INT, KERN_PANIC_ON_NMI, "panic_on_unrecovered_nmi" }, 141 { CTL_INT, KERN_PANIC_ON_NMI, "panic_on_unrecovered_nmi" },
142 { CTL_INT, KERN_PANIC_ON_WARN, "panic_on_warn" }, 142 { CTL_INT, KERN_PANIC_ON_WARN, "panic_on_warn" },
143 { CTL_ULONG, KERN_PANIC_PRINT, "panic_print" },
143 {} 144 {}
144}; 145};
145 146
diff --git a/lib/find_bit_benchmark.c b/lib/find_bit_benchmark.c
index 5367ffa5c18f..f0e394dd2beb 100644
--- a/lib/find_bit_benchmark.c
+++ b/lib/find_bit_benchmark.c
@@ -108,14 +108,13 @@ static int __init test_find_next_and_bit(const void *bitmap,
108 const void *bitmap2, unsigned long len) 108 const void *bitmap2, unsigned long len)
109{ 109{
110 unsigned long i, cnt; 110 unsigned long i, cnt;
111 cycles_t cycles; 111 ktime_t time;
112 112
113 cycles = get_cycles(); 113 time = ktime_get();
114 for (cnt = i = 0; i < BITMAP_LEN; cnt++) 114 for (cnt = i = 0; i < BITMAP_LEN; cnt++)
115 i = find_next_and_bit(bitmap, bitmap2, BITMAP_LEN, i+1); 115 i = find_next_and_bit(bitmap, bitmap2, BITMAP_LEN, i + 1);
116 cycles = get_cycles() - cycles; 116 time = ktime_get() - time;
117 pr_err("find_next_and_bit:\t\t%llu cycles, %ld iterations\n", 117 pr_err("find_next_and_bit: %18llu ns, %6ld iterations\n", time, cnt);
118 (u64)cycles, cnt);
119 118
120 return 0; 119 return 0;
121} 120}
diff --git a/lib/genalloc.c b/lib/genalloc.c
index ca06adc4f445..f365d71cdc77 100644
--- a/lib/genalloc.c
+++ b/lib/genalloc.c
@@ -187,7 +187,7 @@ int gen_pool_add_virt(struct gen_pool *pool, unsigned long virt, phys_addr_t phy
187 int nbytes = sizeof(struct gen_pool_chunk) + 187 int nbytes = sizeof(struct gen_pool_chunk) +
188 BITS_TO_LONGS(nbits) * sizeof(long); 188 BITS_TO_LONGS(nbits) * sizeof(long);
189 189
190 chunk = kzalloc_node(nbytes, GFP_KERNEL, nid); 190 chunk = vzalloc_node(nbytes, nid);
191 if (unlikely(chunk == NULL)) 191 if (unlikely(chunk == NULL))
192 return -ENOMEM; 192 return -ENOMEM;
193 193
@@ -251,7 +251,7 @@ void gen_pool_destroy(struct gen_pool *pool)
251 bit = find_next_bit(chunk->bits, end_bit, 0); 251 bit = find_next_bit(chunk->bits, end_bit, 0);
252 BUG_ON(bit < end_bit); 252 BUG_ON(bit < end_bit);
253 253
254 kfree(chunk); 254 vfree(chunk);
255 } 255 }
256 kfree_const(pool->name); 256 kfree_const(pool->name);
257 kfree(pool); 257 kfree(pool);
@@ -311,7 +311,7 @@ unsigned long gen_pool_alloc_algo(struct gen_pool *pool, size_t size,
311 end_bit = chunk_size(chunk) >> order; 311 end_bit = chunk_size(chunk) >> order;
312retry: 312retry:
313 start_bit = algo(chunk->bits, end_bit, start_bit, 313 start_bit = algo(chunk->bits, end_bit, start_bit,
314 nbits, data, pool); 314 nbits, data, pool, chunk->start_addr);
315 if (start_bit >= end_bit) 315 if (start_bit >= end_bit)
316 continue; 316 continue;
317 remain = bitmap_set_ll(chunk->bits, start_bit, nbits); 317 remain = bitmap_set_ll(chunk->bits, start_bit, nbits);
@@ -525,7 +525,7 @@ EXPORT_SYMBOL(gen_pool_set_algo);
525 */ 525 */
526unsigned long gen_pool_first_fit(unsigned long *map, unsigned long size, 526unsigned long gen_pool_first_fit(unsigned long *map, unsigned long size,
527 unsigned long start, unsigned int nr, void *data, 527 unsigned long start, unsigned int nr, void *data,
528 struct gen_pool *pool) 528 struct gen_pool *pool, unsigned long start_addr)
529{ 529{
530 return bitmap_find_next_zero_area(map, size, start, nr, 0); 530 return bitmap_find_next_zero_area(map, size, start, nr, 0);
531} 531}
@@ -543,16 +543,19 @@ EXPORT_SYMBOL(gen_pool_first_fit);
543 */ 543 */
544unsigned long gen_pool_first_fit_align(unsigned long *map, unsigned long size, 544unsigned long gen_pool_first_fit_align(unsigned long *map, unsigned long size,
545 unsigned long start, unsigned int nr, void *data, 545 unsigned long start, unsigned int nr, void *data,
546 struct gen_pool *pool) 546 struct gen_pool *pool, unsigned long start_addr)
547{ 547{
548 struct genpool_data_align *alignment; 548 struct genpool_data_align *alignment;
549 unsigned long align_mask; 549 unsigned long align_mask, align_off;
550 int order; 550 int order;
551 551
552 alignment = data; 552 alignment = data;
553 order = pool->min_alloc_order; 553 order = pool->min_alloc_order;
554 align_mask = ((alignment->align + (1UL << order) - 1) >> order) - 1; 554 align_mask = ((alignment->align + (1UL << order) - 1) >> order) - 1;
555 return bitmap_find_next_zero_area(map, size, start, nr, align_mask); 555 align_off = (start_addr & (alignment->align - 1)) >> order;
556
557 return bitmap_find_next_zero_area_off(map, size, start, nr,
558 align_mask, align_off);
556} 559}
557EXPORT_SYMBOL(gen_pool_first_fit_align); 560EXPORT_SYMBOL(gen_pool_first_fit_align);
558 561
@@ -567,7 +570,7 @@ EXPORT_SYMBOL(gen_pool_first_fit_align);
567 */ 570 */
568unsigned long gen_pool_fixed_alloc(unsigned long *map, unsigned long size, 571unsigned long gen_pool_fixed_alloc(unsigned long *map, unsigned long size,
569 unsigned long start, unsigned int nr, void *data, 572 unsigned long start, unsigned int nr, void *data,
570 struct gen_pool *pool) 573 struct gen_pool *pool, unsigned long start_addr)
571{ 574{
572 struct genpool_data_fixed *fixed_data; 575 struct genpool_data_fixed *fixed_data;
573 int order; 576 int order;
@@ -601,7 +604,8 @@ EXPORT_SYMBOL(gen_pool_fixed_alloc);
601 */ 604 */
602unsigned long gen_pool_first_fit_order_align(unsigned long *map, 605unsigned long gen_pool_first_fit_order_align(unsigned long *map,
603 unsigned long size, unsigned long start, 606 unsigned long size, unsigned long start,
604 unsigned int nr, void *data, struct gen_pool *pool) 607 unsigned int nr, void *data, struct gen_pool *pool,
608 unsigned long start_addr)
605{ 609{
606 unsigned long align_mask = roundup_pow_of_two(nr) - 1; 610 unsigned long align_mask = roundup_pow_of_two(nr) - 1;
607 611
@@ -624,7 +628,7 @@ EXPORT_SYMBOL(gen_pool_first_fit_order_align);
624 */ 628 */
625unsigned long gen_pool_best_fit(unsigned long *map, unsigned long size, 629unsigned long gen_pool_best_fit(unsigned long *map, unsigned long size,
626 unsigned long start, unsigned int nr, void *data, 630 unsigned long start, unsigned int nr, void *data,
627 struct gen_pool *pool) 631 struct gen_pool *pool, unsigned long start_addr)
628{ 632{
629 unsigned long start_bit = size; 633 unsigned long start_bit = size;
630 unsigned long len = size + 1; 634 unsigned long len = size + 1;
diff --git a/mm/filemap.c b/mm/filemap.c
index 29655fb47a2c..9f5e323e883e 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -1125,7 +1125,7 @@ static inline int wait_on_page_bit_common(wait_queue_head_t *q,
1125 break; 1125 break;
1126 } 1126 }
1127 1127
1128 if (unlikely(signal_pending_state(state, current))) { 1128 if (signal_pending_state(state, current)) {
1129 ret = -EINTR; 1129 ret = -EINTR;
1130 break; 1130 break;
1131 } 1131 }
diff --git a/mm/gup.c b/mm/gup.c
index 6f591ccb8eca..05acd7e2eb22 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -727,7 +727,7 @@ retry:
727 * If we have a pending SIGKILL, don't keep faulting pages and 727 * If we have a pending SIGKILL, don't keep faulting pages and
728 * potentially allocating memory. 728 * potentially allocating memory.
729 */ 729 */
730 if (unlikely(fatal_signal_pending(current))) { 730 if (fatal_signal_pending(current)) {
731 ret = -ERESTARTSYS; 731 ret = -ERESTARTSYS;
732 goto out; 732 goto out;
733 } 733 }
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index cbd977b1d60d..faf357eaf0ce 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -568,7 +568,7 @@ static vm_fault_t __do_huge_pmd_anonymous_page(struct vm_fault *vmf,
568 return VM_FAULT_FALLBACK; 568 return VM_FAULT_FALLBACK;
569 } 569 }
570 570
571 pgtable = pte_alloc_one(vma->vm_mm, haddr); 571 pgtable = pte_alloc_one(vma->vm_mm);
572 if (unlikely(!pgtable)) { 572 if (unlikely(!pgtable)) {
573 ret = VM_FAULT_OOM; 573 ret = VM_FAULT_OOM;
574 goto release; 574 goto release;
@@ -702,7 +702,7 @@ vm_fault_t do_huge_pmd_anonymous_page(struct vm_fault *vmf)
702 struct page *zero_page; 702 struct page *zero_page;
703 bool set; 703 bool set;
704 vm_fault_t ret; 704 vm_fault_t ret;
705 pgtable = pte_alloc_one(vma->vm_mm, haddr); 705 pgtable = pte_alloc_one(vma->vm_mm);
706 if (unlikely(!pgtable)) 706 if (unlikely(!pgtable))
707 return VM_FAULT_OOM; 707 return VM_FAULT_OOM;
708 zero_page = mm_get_huge_zero_page(vma->vm_mm); 708 zero_page = mm_get_huge_zero_page(vma->vm_mm);
@@ -791,7 +791,7 @@ vm_fault_t vmf_insert_pfn_pmd(struct vm_area_struct *vma, unsigned long addr,
791 return VM_FAULT_SIGBUS; 791 return VM_FAULT_SIGBUS;
792 792
793 if (arch_needs_pgtable_deposit()) { 793 if (arch_needs_pgtable_deposit()) {
794 pgtable = pte_alloc_one(vma->vm_mm, addr); 794 pgtable = pte_alloc_one(vma->vm_mm);
795 if (!pgtable) 795 if (!pgtable)
796 return VM_FAULT_OOM; 796 return VM_FAULT_OOM;
797 } 797 }
@@ -927,7 +927,7 @@ int copy_huge_pmd(struct mm_struct *dst_mm, struct mm_struct *src_mm,
927 if (!vma_is_anonymous(vma)) 927 if (!vma_is_anonymous(vma))
928 return 0; 928 return 0;
929 929
930 pgtable = pte_alloc_one(dst_mm, addr); 930 pgtable = pte_alloc_one(dst_mm);
931 if (unlikely(!pgtable)) 931 if (unlikely(!pgtable))
932 goto out; 932 goto out;
933 933
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index e37efd5d8318..745088810965 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -4231,7 +4231,7 @@ long follow_hugetlb_page(struct mm_struct *mm, struct vm_area_struct *vma,
4231 * If we have a pending SIGKILL, don't keep faulting pages and 4231 * If we have a pending SIGKILL, don't keep faulting pages and
4232 * potentially allocating memory. 4232 * potentially allocating memory.
4233 */ 4233 */
4234 if (unlikely(fatal_signal_pending(current))) { 4234 if (fatal_signal_pending(current)) {
4235 remainder = 0; 4235 remainder = 0;
4236 break; 4236 break;
4237 } 4237 }
diff --git a/mm/kasan/init.c b/mm/kasan/init.c
index 34afad56497b..45a1b5e38e1e 100644
--- a/mm/kasan/init.c
+++ b/mm/kasan/init.c
@@ -123,7 +123,7 @@ static int __ref zero_pmd_populate(pud_t *pud, unsigned long addr,
123 pte_t *p; 123 pte_t *p;
124 124
125 if (slab_is_available()) 125 if (slab_is_available())
126 p = pte_alloc_one_kernel(&init_mm, addr); 126 p = pte_alloc_one_kernel(&init_mm);
127 else 127 else
128 p = early_alloc(PAGE_SIZE, NUMA_NO_NODE); 128 p = early_alloc(PAGE_SIZE, NUMA_NO_NODE);
129 if (!p) 129 if (!p)
diff --git a/mm/memory.c b/mm/memory.c
index 2dd2f9ab57f4..a52663c0612d 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -400,10 +400,10 @@ void free_pgtables(struct mmu_gather *tlb, struct vm_area_struct *vma,
400 } 400 }
401} 401}
402 402
403int __pte_alloc(struct mm_struct *mm, pmd_t *pmd, unsigned long address) 403int __pte_alloc(struct mm_struct *mm, pmd_t *pmd)
404{ 404{
405 spinlock_t *ptl; 405 spinlock_t *ptl;
406 pgtable_t new = pte_alloc_one(mm, address); 406 pgtable_t new = pte_alloc_one(mm);
407 if (!new) 407 if (!new)
408 return -ENOMEM; 408 return -ENOMEM;
409 409
@@ -434,9 +434,9 @@ int __pte_alloc(struct mm_struct *mm, pmd_t *pmd, unsigned long address)
434 return 0; 434 return 0;
435} 435}
436 436
437int __pte_alloc_kernel(pmd_t *pmd, unsigned long address) 437int __pte_alloc_kernel(pmd_t *pmd)
438{ 438{
439 pte_t *new = pte_alloc_one_kernel(&init_mm, address); 439 pte_t *new = pte_alloc_one_kernel(&init_mm);
440 if (!new) 440 if (!new)
441 return -ENOMEM; 441 return -ENOMEM;
442 442
@@ -2896,7 +2896,7 @@ static vm_fault_t do_anonymous_page(struct vm_fault *vmf)
2896 * 2896 *
2897 * Here we only have down_read(mmap_sem). 2897 * Here we only have down_read(mmap_sem).
2898 */ 2898 */
2899 if (pte_alloc(vma->vm_mm, vmf->pmd, vmf->address)) 2899 if (pte_alloc(vma->vm_mm, vmf->pmd))
2900 return VM_FAULT_OOM; 2900 return VM_FAULT_OOM;
2901 2901
2902 /* See the comment in pte_alloc_one_map() */ 2902 /* See the comment in pte_alloc_one_map() */
@@ -3043,7 +3043,7 @@ static vm_fault_t pte_alloc_one_map(struct vm_fault *vmf)
3043 pmd_populate(vma->vm_mm, vmf->pmd, vmf->prealloc_pte); 3043 pmd_populate(vma->vm_mm, vmf->pmd, vmf->prealloc_pte);
3044 spin_unlock(vmf->ptl); 3044 spin_unlock(vmf->ptl);
3045 vmf->prealloc_pte = NULL; 3045 vmf->prealloc_pte = NULL;
3046 } else if (unlikely(pte_alloc(vma->vm_mm, vmf->pmd, vmf->address))) { 3046 } else if (unlikely(pte_alloc(vma->vm_mm, vmf->pmd))) {
3047 return VM_FAULT_OOM; 3047 return VM_FAULT_OOM;
3048 } 3048 }
3049map_pte: 3049map_pte:
@@ -3122,7 +3122,7 @@ static vm_fault_t do_set_pmd(struct vm_fault *vmf, struct page *page)
3122 * related to pte entry. Use the preallocated table for that. 3122 * related to pte entry. Use the preallocated table for that.
3123 */ 3123 */
3124 if (arch_needs_pgtable_deposit() && !vmf->prealloc_pte) { 3124 if (arch_needs_pgtable_deposit() && !vmf->prealloc_pte) {
3125 vmf->prealloc_pte = pte_alloc_one(vma->vm_mm, vmf->address); 3125 vmf->prealloc_pte = pte_alloc_one(vma->vm_mm);
3126 if (!vmf->prealloc_pte) 3126 if (!vmf->prealloc_pte)
3127 return VM_FAULT_OOM; 3127 return VM_FAULT_OOM;
3128 smp_wmb(); /* See comment in __pte_alloc() */ 3128 smp_wmb(); /* See comment in __pte_alloc() */
@@ -3360,8 +3360,7 @@ static vm_fault_t do_fault_around(struct vm_fault *vmf)
3360 start_pgoff + nr_pages - 1); 3360 start_pgoff + nr_pages - 1);
3361 3361
3362 if (pmd_none(*vmf->pmd)) { 3362 if (pmd_none(*vmf->pmd)) {
3363 vmf->prealloc_pte = pte_alloc_one(vmf->vma->vm_mm, 3363 vmf->prealloc_pte = pte_alloc_one(vmf->vma->vm_mm);
3364 vmf->address);
3365 if (!vmf->prealloc_pte) 3364 if (!vmf->prealloc_pte)
3366 goto out; 3365 goto out;
3367 smp_wmb(); /* See comment in __pte_alloc() */ 3366 smp_wmb(); /* See comment in __pte_alloc() */
diff --git a/mm/migrate.c b/mm/migrate.c
index 5d1839a9148d..ccf8966caf6f 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -2636,7 +2636,7 @@ static void migrate_vma_insert_page(struct migrate_vma *migrate,
2636 * 2636 *
2637 * Here we only have down_read(mmap_sem). 2637 * Here we only have down_read(mmap_sem).
2638 */ 2638 */
2639 if (pte_alloc(mm, pmdp, addr)) 2639 if (pte_alloc(mm, pmdp))
2640 goto abort; 2640 goto abort;
2641 2641
2642 /* See the comment in pte_alloc_one_map() */ 2642 /* See the comment in pte_alloc_one_map() */
diff --git a/mm/mremap.c b/mm/mremap.c
index def01d86e36f..3320616ed93f 100644
--- a/mm/mremap.c
+++ b/mm/mremap.c
@@ -191,6 +191,52 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
191 drop_rmap_locks(vma); 191 drop_rmap_locks(vma);
192} 192}
193 193
194#ifdef CONFIG_HAVE_MOVE_PMD
195static bool move_normal_pmd(struct vm_area_struct *vma, unsigned long old_addr,
196 unsigned long new_addr, unsigned long old_end,
197 pmd_t *old_pmd, pmd_t *new_pmd)
198{
199 spinlock_t *old_ptl, *new_ptl;
200 struct mm_struct *mm = vma->vm_mm;
201 pmd_t pmd;
202
203 if ((old_addr & ~PMD_MASK) || (new_addr & ~PMD_MASK)
204 || old_end - old_addr < PMD_SIZE)
205 return false;
206
207 /*
208 * The destination pmd shouldn't be established, free_pgtables()
209 * should have release it.
210 */
211 if (WARN_ON(!pmd_none(*new_pmd)))
212 return false;
213
214 /*
215 * We don't have to worry about the ordering of src and dst
216 * ptlocks because exclusive mmap_sem prevents deadlock.
217 */
218 old_ptl = pmd_lock(vma->vm_mm, old_pmd);
219 new_ptl = pmd_lockptr(mm, new_pmd);
220 if (new_ptl != old_ptl)
221 spin_lock_nested(new_ptl, SINGLE_DEPTH_NESTING);
222
223 /* Clear the pmd */
224 pmd = *old_pmd;
225 pmd_clear(old_pmd);
226
227 VM_BUG_ON(!pmd_none(*new_pmd));
228
229 /* Set the new pmd */
230 set_pmd_at(mm, new_addr, new_pmd, pmd);
231 flush_tlb_range(vma, old_addr, old_addr + PMD_SIZE);
232 if (new_ptl != old_ptl)
233 spin_unlock(new_ptl);
234 spin_unlock(old_ptl);
235
236 return true;
237}
238#endif
239
194unsigned long move_page_tables(struct vm_area_struct *vma, 240unsigned long move_page_tables(struct vm_area_struct *vma,
195 unsigned long old_addr, struct vm_area_struct *new_vma, 241 unsigned long old_addr, struct vm_area_struct *new_vma,
196 unsigned long new_addr, unsigned long len, 242 unsigned long new_addr, unsigned long len,
@@ -235,8 +281,26 @@ unsigned long move_page_tables(struct vm_area_struct *vma,
235 split_huge_pmd(vma, old_pmd, old_addr); 281 split_huge_pmd(vma, old_pmd, old_addr);
236 if (pmd_trans_unstable(old_pmd)) 282 if (pmd_trans_unstable(old_pmd))
237 continue; 283 continue;
284 } else if (extent == PMD_SIZE) {
285#ifdef CONFIG_HAVE_MOVE_PMD
286 /*
287 * If the extent is PMD-sized, try to speed the move by
288 * moving at the PMD level if possible.
289 */
290 bool moved;
291
292 if (need_rmap_locks)
293 take_rmap_locks(vma);
294 moved = move_normal_pmd(vma, old_addr, new_addr,
295 old_end, old_pmd, new_pmd);
296 if (need_rmap_locks)
297 drop_rmap_locks(vma);
298 if (moved)
299 continue;
300#endif
238 } 301 }
239 if (pte_alloc(new_vma->vm_mm, new_pmd, new_addr)) 302
303 if (pte_alloc(new_vma->vm_mm, new_pmd))
240 break; 304 break;
241 next = (new_addr + PMD_SIZE) & PMD_MASK; 305 next = (new_addr + PMD_SIZE) & PMD_MASK;
242 if (extent > next - new_addr) 306 if (extent > next - new_addr)
diff --git a/mm/page_io.c b/mm/page_io.c
index d975fa3f02aa..2e8019d0e048 100644
--- a/mm/page_io.c
+++ b/mm/page_io.c
@@ -401,6 +401,8 @@ int swap_readpage(struct page *page, bool synchronous)
401 get_task_struct(current); 401 get_task_struct(current);
402 bio->bi_private = current; 402 bio->bi_private = current;
403 bio_set_op_attrs(bio, REQ_OP_READ, 0); 403 bio_set_op_attrs(bio, REQ_OP_READ, 0);
404 if (synchronous)
405 bio->bi_opf |= REQ_HIPRI;
404 count_vm_event(PSWPIN); 406 count_vm_event(PSWPIN);
405 bio_get(bio); 407 bio_get(bio);
406 qc = submit_bio(bio); 408 qc = submit_bio(bio);
@@ -410,7 +412,7 @@ int swap_readpage(struct page *page, bool synchronous)
410 break; 412 break;
411 413
412 if (!blk_poll(disk->queue, qc, true)) 414 if (!blk_poll(disk->queue, qc, true))
413 break; 415 io_schedule();
414 } 416 }
415 __set_current_state(TASK_RUNNING); 417 __set_current_state(TASK_RUNNING);
416 bio_put(bio); 418 bio_put(bio);
diff --git a/mm/swap.c b/mm/swap.c
index 4d8a1f1afaab..4929bc1be60e 100644
--- a/mm/swap.c
+++ b/mm/swap.c
@@ -126,7 +126,7 @@ void put_pages_list(struct list_head *pages)
126 while (!list_empty(pages)) { 126 while (!list_empty(pages)) {
127 struct page *victim; 127 struct page *victim;
128 128
129 victim = list_entry(pages->prev, struct page, lru); 129 victim = lru_to_page(pages);
130 list_del(&victim->lru); 130 list_del(&victim->lru);
131 put_page(victim); 131 put_page(victim);
132 } 132 }
diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c
index 48368589f519..065c1ce191c4 100644
--- a/mm/userfaultfd.c
+++ b/mm/userfaultfd.c
@@ -550,7 +550,7 @@ retry:
550 break; 550 break;
551 } 551 }
552 if (unlikely(pmd_none(dst_pmdval)) && 552 if (unlikely(pmd_none(dst_pmdval)) &&
553 unlikely(__pte_alloc(dst_mm, dst_pmd, dst_addr))) { 553 unlikely(__pte_alloc(dst_mm, dst_pmd))) {
554 err = -ENOMEM; 554 err = -ENOMEM;
555 break; 555 break;
556 } 556 }
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 377f373db6c0..b737ca9d7204 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -468,6 +468,7 @@ our $logFunctions = qr{(?x:
468 468
469our $signature_tags = qr{(?xi: 469our $signature_tags = qr{(?xi:
470 Signed-off-by:| 470 Signed-off-by:|
471 Co-developed-by:|
471 Acked-by:| 472 Acked-by:|
472 Tested-by:| 473 Tested-by:|
473 Reviewed-by:| 474 Reviewed-by:|
@@ -3890,14 +3891,23 @@ sub process {
3890 WARN("STATIC_CONST_CHAR_ARRAY", 3891 WARN("STATIC_CONST_CHAR_ARRAY",
3891 "static const char * array should probably be static const char * const\n" . 3892 "static const char * array should probably be static const char * const\n" .
3892 $herecurr); 3893 $herecurr);
3893 } 3894 }
3895
3896# check for initialized const char arrays that should be static const
3897 if ($line =~ /^\+\s*const\s+(char|unsigned\s+char|_*u8|(?:[us]_)?int8_t)\s+\w+\s*\[\s*(?:\w+\s*)?\]\s*=\s*"/) {
3898 if (WARN("STATIC_CONST_CHAR_ARRAY",
3899 "const array should probably be static const\n" . $herecurr) &&
3900 $fix) {
3901 $fixed[$fixlinenr] =~ s/(^.\s*)const\b/${1}static const/;
3902 }
3903 }
3894 3904
3895# check for static char foo[] = "bar" declarations. 3905# check for static char foo[] = "bar" declarations.
3896 if ($line =~ /\bstatic\s+char\s+(\w+)\s*\[\s*\]\s*=\s*"/) { 3906 if ($line =~ /\bstatic\s+char\s+(\w+)\s*\[\s*\]\s*=\s*"/) {
3897 WARN("STATIC_CONST_CHAR_ARRAY", 3907 WARN("STATIC_CONST_CHAR_ARRAY",
3898 "static char array declaration should probably be static const char\n" . 3908 "static char array declaration should probably be static const char\n" .
3899 $herecurr); 3909 $herecurr);
3900 } 3910 }
3901 3911
3902# check for const <foo> const where <foo> is not a pointer or array type 3912# check for const <foo> const where <foo> is not a pointer or array type
3903 if ($sline =~ /\bconst\s+($BasicType)\s+const\b/) { 3913 if ($sline =~ /\bconst\s+($BasicType)\s+const\b/) {
diff --git a/scripts/gdb/linux/proc.py b/scripts/gdb/linux/proc.py
index 086d27223c0c..0aebd7565b03 100644
--- a/scripts/gdb/linux/proc.py
+++ b/scripts/gdb/linux/proc.py
@@ -41,7 +41,7 @@ class LxVersion(gdb.Command):
41 41
42 def invoke(self, arg, from_tty): 42 def invoke(self, arg, from_tty):
43 # linux_banner should contain a newline 43 # linux_banner should contain a newline
44 gdb.write(gdb.parse_and_eval("linux_banner").string()) 44 gdb.write(gdb.parse_and_eval("(char *)linux_banner").string())
45 45
46LxVersion() 46LxVersion()
47 47
diff --git a/tools/include/asm-generic/bitops/fls.h b/tools/include/asm-generic/bitops/fls.h
index 753aecaab641..b168bb10e1be 100644
--- a/tools/include/asm-generic/bitops/fls.h
+++ b/tools/include/asm-generic/bitops/fls.h
@@ -10,7 +10,7 @@
10 * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32. 10 * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32.
11 */ 11 */
12 12
13static __always_inline int fls(int x) 13static __always_inline int fls(unsigned int x)
14{ 14{
15 int r = 32; 15 int r = 32;
16 16
diff --git a/virt/kvm/arm/mmu.c b/virt/kvm/arm/mmu.c
index 3053bf2584f8..fbdf3ac2f001 100644
--- a/virt/kvm/arm/mmu.c
+++ b/virt/kvm/arm/mmu.c
@@ -647,7 +647,7 @@ static int create_hyp_pmd_mappings(pud_t *pud, unsigned long start,
647 BUG_ON(pmd_sect(*pmd)); 647 BUG_ON(pmd_sect(*pmd));
648 648
649 if (pmd_none(*pmd)) { 649 if (pmd_none(*pmd)) {
650 pte = pte_alloc_one_kernel(NULL, addr); 650 pte = pte_alloc_one_kernel(NULL);
651 if (!pte) { 651 if (!pte) {
652 kvm_err("Cannot allocate Hyp pte\n"); 652 kvm_err("Cannot allocate Hyp pte\n");
653 return -ENOMEM; 653 return -ENOMEM;