aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-12-14 18:35:30 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2018-12-14 18:35:30 -0500
commit6531e115b7ab84f563fcd7f0d2d05ccf971aaaf9 (patch)
tree04aa4f87b471e870a44ef94ee935d3a87bb12c4e
parent380ef2c9ad4fdd5fdd81055857be21ae5f581877 (diff)
parent3a6ab5c7dc114057fd67750e308e1745dafc0e6a (diff)
Merge branch 'akpm' (patches from Andrew)
Merge misc fixes from Andrew Morton: "11 fixes" * emailed patches from Andrew Morton <akpm@linux-foundation.org>: scripts/spdxcheck.py: always open files in binary mode checkstack.pl: fix for aarch64 userfaultfd: check VM_MAYWRITE was set after verifying the uffd is registered fs/iomap.c: get/put the page in iomap_page_create/release() hugetlbfs: call VM_BUG_ON_PAGE earlier in free_huge_page() memblock: annotate memblock_is_reserved() with __init_memblock psi: fix reference to kernel commandline enable arch/sh/include/asm/io.h: provide prototypes for PCI I/O mapping in asm/io.h mm/sparse: add common helper to mark all memblocks present mm: introduce common STRUCT_PAGE_MAX_SHIFT define alpha: fix hang caused by the bootmem removal
-rw-r--r--arch/alpha/kernel/setup.c1
-rw-r--r--arch/alpha/mm/numa.c6
-rw-r--r--arch/arm64/include/asm/memory.h9
-rw-r--r--arch/arm64/mm/init.c8
-rw-r--r--arch/sh/include/asm/io.h1
-rw-r--r--fs/iomap.c7
-rw-r--r--fs/userfaultfd.c3
-rw-r--r--include/asm-generic/fixmap.h1
-rw-r--r--include/linux/mm_types.h5
-rw-r--r--include/linux/mmzone.h6
-rw-r--r--init/Kconfig4
-rw-r--r--mm/hugetlb.c5
-rw-r--r--mm/memblock.c2
-rw-r--r--mm/sparse.c16
-rwxr-xr-xscripts/checkstack.pl4
-rwxr-xr-xscripts/spdxcheck.py6
16 files changed, 54 insertions, 30 deletions
diff --git a/arch/alpha/kernel/setup.c b/arch/alpha/kernel/setup.c
index a37fd990bd55..4b5b1b244f86 100644
--- a/arch/alpha/kernel/setup.c
+++ b/arch/alpha/kernel/setup.c
@@ -634,6 +634,7 @@ setup_arch(char **cmdline_p)
634 634
635 /* Find our memory. */ 635 /* Find our memory. */
636 setup_memory(kernel_end); 636 setup_memory(kernel_end);
637 memblock_set_bottom_up(true);
637 638
638 /* First guess at cpu cache sizes. Do this before init_arch. */ 639 /* First guess at cpu cache sizes. Do this before init_arch. */
639 determine_cpu_caches(cpu->type); 640 determine_cpu_caches(cpu->type);
diff --git a/arch/alpha/mm/numa.c b/arch/alpha/mm/numa.c
index 74846553e3f1..d0b73371e985 100644
--- a/arch/alpha/mm/numa.c
+++ b/arch/alpha/mm/numa.c
@@ -144,14 +144,14 @@ setup_memory_node(int nid, void *kernel_end)
144 if (!nid && (node_max_pfn < end_kernel_pfn || node_min_pfn > start_kernel_pfn)) 144 if (!nid && (node_max_pfn < end_kernel_pfn || node_min_pfn > start_kernel_pfn))
145 panic("kernel loaded out of ram"); 145 panic("kernel loaded out of ram");
146 146
147 memblock_add(PFN_PHYS(node_min_pfn),
148 (node_max_pfn - node_min_pfn) << PAGE_SHIFT);
149
147 /* Zone start phys-addr must be 2^(MAX_ORDER-1) aligned. 150 /* Zone start phys-addr must be 2^(MAX_ORDER-1) aligned.
148 Note that we round this down, not up - node memory 151 Note that we round this down, not up - node memory
149 has much larger alignment than 8Mb, so it's safe. */ 152 has much larger alignment than 8Mb, so it's safe. */
150 node_min_pfn &= ~((1UL << (MAX_ORDER-1))-1); 153 node_min_pfn &= ~((1UL << (MAX_ORDER-1))-1);
151 154
152 memblock_add(PFN_PHYS(node_min_pfn),
153 (node_max_pfn - node_min_pfn) << PAGE_SHIFT);
154
155 NODE_DATA(nid)->node_start_pfn = node_min_pfn; 155 NODE_DATA(nid)->node_start_pfn = node_min_pfn;
156 NODE_DATA(nid)->node_present_pages = node_max_pfn - node_min_pfn; 156 NODE_DATA(nid)->node_present_pages = node_max_pfn - node_min_pfn;
157 157
diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
index b96442960aea..f0a5c9531e8b 100644
--- a/arch/arm64/include/asm/memory.h
+++ b/arch/arm64/include/asm/memory.h
@@ -35,15 +35,6 @@
35#define PCI_IO_SIZE SZ_16M 35#define PCI_IO_SIZE SZ_16M
36 36
37/* 37/*
38 * Log2 of the upper bound of the size of a struct page. Used for sizing
39 * the vmemmap region only, does not affect actual memory footprint.
40 * We don't use sizeof(struct page) directly since taking its size here
41 * requires its definition to be available at this point in the inclusion
42 * chain, and it may not be a power of 2 in the first place.
43 */
44#define STRUCT_PAGE_MAX_SHIFT 6
45
46/*
47 * VMEMMAP_SIZE - allows the whole linear region to be covered by 38 * VMEMMAP_SIZE - allows the whole linear region to be covered by
48 * a struct page array 39 * a struct page array
49 */ 40 */
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index 9b432d9fcada..0340e45655c6 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -610,14 +610,6 @@ void __init mem_init(void)
610 BUILD_BUG_ON(TASK_SIZE_32 > TASK_SIZE_64); 610 BUILD_BUG_ON(TASK_SIZE_32 > TASK_SIZE_64);
611#endif 611#endif
612 612
613#ifdef CONFIG_SPARSEMEM_VMEMMAP
614 /*
615 * Make sure we chose the upper bound of sizeof(struct page)
616 * correctly when sizing the VMEMMAP array.
617 */
618 BUILD_BUG_ON(sizeof(struct page) > (1 << STRUCT_PAGE_MAX_SHIFT));
619#endif
620
621 if (PAGE_SIZE >= 16384 && get_num_physpages() <= 128) { 613 if (PAGE_SIZE >= 16384 && get_num_physpages() <= 128) {
622 extern int sysctl_overcommit_memory; 614 extern int sysctl_overcommit_memory;
623 /* 615 /*
diff --git a/arch/sh/include/asm/io.h b/arch/sh/include/asm/io.h
index 98cb8c802b1a..4f7f235f15f8 100644
--- a/arch/sh/include/asm/io.h
+++ b/arch/sh/include/asm/io.h
@@ -24,6 +24,7 @@
24#define __IO_PREFIX generic 24#define __IO_PREFIX generic
25#include <asm/io_generic.h> 25#include <asm/io_generic.h>
26#include <asm/io_trapped.h> 26#include <asm/io_trapped.h>
27#include <asm-generic/pci_iomap.h>
27#include <mach/mangle-port.h> 28#include <mach/mangle-port.h>
28 29
29#define __raw_writeb(v,a) (__chk_io_ptr(a), *(volatile u8 __force *)(a) = (v)) 30#define __raw_writeb(v,a) (__chk_io_ptr(a), *(volatile u8 __force *)(a) = (v))
diff --git a/fs/iomap.c b/fs/iomap.c
index d6bc98ae8d35..5bc172f3dfe8 100644
--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -116,6 +116,12 @@ iomap_page_create(struct inode *inode, struct page *page)
116 atomic_set(&iop->read_count, 0); 116 atomic_set(&iop->read_count, 0);
117 atomic_set(&iop->write_count, 0); 117 atomic_set(&iop->write_count, 0);
118 bitmap_zero(iop->uptodate, PAGE_SIZE / SECTOR_SIZE); 118 bitmap_zero(iop->uptodate, PAGE_SIZE / SECTOR_SIZE);
119
120 /*
121 * migrate_page_move_mapping() assumes that pages with private data have
122 * their count elevated by 1.
123 */
124 get_page(page);
119 set_page_private(page, (unsigned long)iop); 125 set_page_private(page, (unsigned long)iop);
120 SetPagePrivate(page); 126 SetPagePrivate(page);
121 return iop; 127 return iop;
@@ -132,6 +138,7 @@ iomap_page_release(struct page *page)
132 WARN_ON_ONCE(atomic_read(&iop->write_count)); 138 WARN_ON_ONCE(atomic_read(&iop->write_count));
133 ClearPagePrivate(page); 139 ClearPagePrivate(page);
134 set_page_private(page, 0); 140 set_page_private(page, 0);
141 put_page(page);
135 kfree(iop); 142 kfree(iop);
136} 143}
137 144
diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c
index cd58939dc977..7a85e609fc27 100644
--- a/fs/userfaultfd.c
+++ b/fs/userfaultfd.c
@@ -1566,7 +1566,6 @@ static int userfaultfd_unregister(struct userfaultfd_ctx *ctx,
1566 cond_resched(); 1566 cond_resched();
1567 1567
1568 BUG_ON(!vma_can_userfault(vma)); 1568 BUG_ON(!vma_can_userfault(vma));
1569 WARN_ON(!(vma->vm_flags & VM_MAYWRITE));
1570 1569
1571 /* 1570 /*
1572 * Nothing to do: this vma is already registered into this 1571 * Nothing to do: this vma is already registered into this
@@ -1575,6 +1574,8 @@ static int userfaultfd_unregister(struct userfaultfd_ctx *ctx,
1575 if (!vma->vm_userfaultfd_ctx.ctx) 1574 if (!vma->vm_userfaultfd_ctx.ctx)
1576 goto skip; 1575 goto skip;
1577 1576
1577 WARN_ON(!(vma->vm_flags & VM_MAYWRITE));
1578
1578 if (vma->vm_start > start) 1579 if (vma->vm_start > start)
1579 start = vma->vm_start; 1580 start = vma->vm_start;
1580 vma_end = min(end, vma->vm_end); 1581 vma_end = min(end, vma->vm_end);
diff --git a/include/asm-generic/fixmap.h b/include/asm-generic/fixmap.h
index 827e4d3bbc7a..8cc7b09c1bc7 100644
--- a/include/asm-generic/fixmap.h
+++ b/include/asm-generic/fixmap.h
@@ -16,6 +16,7 @@
16#define __ASM_GENERIC_FIXMAP_H 16#define __ASM_GENERIC_FIXMAP_H
17 17
18#include <linux/bug.h> 18#include <linux/bug.h>
19#include <linux/mm_types.h>
19 20
20#define __fix_to_virt(x) (FIXADDR_TOP - ((x) << PAGE_SHIFT)) 21#define __fix_to_virt(x) (FIXADDR_TOP - ((x) << PAGE_SHIFT))
21#define __virt_to_fix(x) ((FIXADDR_TOP - ((x)&PAGE_MASK)) >> PAGE_SHIFT) 22#define __virt_to_fix(x) ((FIXADDR_TOP - ((x)&PAGE_MASK)) >> PAGE_SHIFT)
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index 5ed8f6292a53..2c471a2c43fa 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -206,6 +206,11 @@ struct page {
206#endif 206#endif
207} _struct_page_alignment; 207} _struct_page_alignment;
208 208
209/*
210 * Used for sizing the vmemmap region on some architectures
211 */
212#define STRUCT_PAGE_MAX_SHIFT (order_base_2(sizeof(struct page)))
213
209#define PAGE_FRAG_CACHE_MAX_SIZE __ALIGN_MASK(32768, ~PAGE_MASK) 214#define PAGE_FRAG_CACHE_MAX_SIZE __ALIGN_MASK(32768, ~PAGE_MASK)
210#define PAGE_FRAG_CACHE_MAX_ORDER get_order(PAGE_FRAG_CACHE_MAX_SIZE) 215#define PAGE_FRAG_CACHE_MAX_ORDER get_order(PAGE_FRAG_CACHE_MAX_SIZE)
211 216
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 847705a6d0ec..db023a92f3a4 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -783,6 +783,12 @@ void memory_present(int nid, unsigned long start, unsigned long end);
783static inline void memory_present(int nid, unsigned long start, unsigned long end) {} 783static inline void memory_present(int nid, unsigned long start, unsigned long end) {}
784#endif 784#endif
785 785
786#if defined(CONFIG_SPARSEMEM)
787void memblocks_present(void);
788#else
789static inline void memblocks_present(void) {}
790#endif
791
786#ifdef CONFIG_HAVE_MEMORYLESS_NODES 792#ifdef CONFIG_HAVE_MEMORYLESS_NODES
787int local_memory_node(int node_id); 793int local_memory_node(int node_id);
788#else 794#else
diff --git a/init/Kconfig b/init/Kconfig
index cf5b5a0dcbc2..ed9352513c32 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -515,8 +515,8 @@ config PSI_DEFAULT_DISABLED
515 depends on PSI 515 depends on PSI
516 help 516 help
517 If set, pressure stall information tracking will be disabled 517 If set, pressure stall information tracking will be disabled
518 per default but can be enabled through passing psi_enable=1 518 per default but can be enabled through passing psi=1 on the
519 on the kernel commandline during boot. 519 kernel commandline during boot.
520 520
521endmenu # "CPU/Task time and stats accounting" 521endmenu # "CPU/Task time and stats accounting"
522 522
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 705a3e9cc910..a80832487981 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1248,10 +1248,11 @@ void free_huge_page(struct page *page)
1248 (struct hugepage_subpool *)page_private(page); 1248 (struct hugepage_subpool *)page_private(page);
1249 bool restore_reserve; 1249 bool restore_reserve;
1250 1250
1251 set_page_private(page, 0);
1252 page->mapping = NULL;
1253 VM_BUG_ON_PAGE(page_count(page), page); 1251 VM_BUG_ON_PAGE(page_count(page), page);
1254 VM_BUG_ON_PAGE(page_mapcount(page), page); 1252 VM_BUG_ON_PAGE(page_mapcount(page), page);
1253
1254 set_page_private(page, 0);
1255 page->mapping = NULL;
1255 restore_reserve = PagePrivate(page); 1256 restore_reserve = PagePrivate(page);
1256 ClearPagePrivate(page); 1257 ClearPagePrivate(page);
1257 1258
diff --git a/mm/memblock.c b/mm/memblock.c
index 9a2d5ae81ae1..81ae63ca78d0 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -1727,7 +1727,7 @@ static int __init_memblock memblock_search(struct memblock_type *type, phys_addr
1727 return -1; 1727 return -1;
1728} 1728}
1729 1729
1730bool __init memblock_is_reserved(phys_addr_t addr) 1730bool __init_memblock memblock_is_reserved(phys_addr_t addr)
1731{ 1731{
1732 return memblock_search(&memblock.reserved, addr) != -1; 1732 return memblock_search(&memblock.reserved, addr) != -1;
1733} 1733}
diff --git a/mm/sparse.c b/mm/sparse.c
index 33307fc05c4d..3abc8cc50201 100644
--- a/mm/sparse.c
+++ b/mm/sparse.c
@@ -240,6 +240,22 @@ void __init memory_present(int nid, unsigned long start, unsigned long end)
240} 240}
241 241
242/* 242/*
243 * Mark all memblocks as present using memory_present(). This is a
244 * convienence function that is useful for a number of arches
245 * to mark all of the systems memory as present during initialization.
246 */
247void __init memblocks_present(void)
248{
249 struct memblock_region *reg;
250
251 for_each_memblock(memory, reg) {
252 memory_present(memblock_get_region_node(reg),
253 memblock_region_memory_base_pfn(reg),
254 memblock_region_memory_end_pfn(reg));
255 }
256}
257
258/*
243 * Subtle, we encode the real pfn into the mem_map such that 259 * Subtle, we encode the real pfn into the mem_map such that
244 * the identity pfn - section_mem_map will return the actual 260 * the identity pfn - section_mem_map will return the actual
245 * physical page frame number. 261 * physical page frame number.
diff --git a/scripts/checkstack.pl b/scripts/checkstack.pl
index 8081b6cf67d2..34414c6efad6 100755
--- a/scripts/checkstack.pl
+++ b/scripts/checkstack.pl
@@ -47,8 +47,8 @@ my (@stack, $re, $dre, $x, $xs, $funcre);
47 $xs = "[0-9a-f ]"; # hex character or space 47 $xs = "[0-9a-f ]"; # hex character or space
48 $funcre = qr/^$x* <(.*)>:$/; 48 $funcre = qr/^$x* <(.*)>:$/;
49 if ($arch eq 'aarch64') { 49 if ($arch eq 'aarch64') {
50 #ffffffc0006325cc: a9bb7bfd stp x29, x30, [sp,#-80]! 50 #ffffffc0006325cc: a9bb7bfd stp x29, x30, [sp, #-80]!
51 $re = qr/^.*stp.*sp,\#-([0-9]{1,8})\]\!/o; 51 $re = qr/^.*stp.*sp, \#-([0-9]{1,8})\]\!/o;
52 } elsif ($arch eq 'arm') { 52 } elsif ($arch eq 'arm') {
53 #c0008ffc: e24dd064 sub sp, sp, #100 ; 0x64 53 #c0008ffc: e24dd064 sub sp, sp, #100 ; 0x64
54 $re = qr/.*sub.*sp, sp, #(([0-9]{2}|[3-9])[0-9]{2})/o; 54 $re = qr/.*sub.*sp, sp, #(([0-9]{2}|[3-9])[0-9]{2})/o;
diff --git a/scripts/spdxcheck.py b/scripts/spdxcheck.py
index 5056fb3b897d..e559c6294c39 100755
--- a/scripts/spdxcheck.py
+++ b/scripts/spdxcheck.py
@@ -168,6 +168,7 @@ class id_parser(object):
168 self.curline = 0 168 self.curline = 0
169 try: 169 try:
170 for line in fd: 170 for line in fd:
171 line = line.decode(locale.getpreferredencoding(False), errors='ignore')
171 self.curline += 1 172 self.curline += 1
172 if self.curline > maxlines: 173 if self.curline > maxlines:
173 break 174 break
@@ -249,12 +250,13 @@ if __name__ == '__main__':
249 250
250 try: 251 try:
251 if len(args.path) and args.path[0] == '-': 252 if len(args.path) and args.path[0] == '-':
252 parser.parse_lines(sys.stdin, args.maxlines, '-') 253 stdin = os.fdopen(sys.stdin.fileno(), 'rb')
254 parser.parse_lines(stdin, args.maxlines, '-')
253 else: 255 else:
254 if args.path: 256 if args.path:
255 for p in args.path: 257 for p in args.path:
256 if os.path.isfile(p): 258 if os.path.isfile(p):
257 parser.parse_lines(open(p), args.maxlines, p) 259 parser.parse_lines(open(p, 'rb'), args.maxlines, p)
258 elif os.path.isdir(p): 260 elif os.path.isdir(p):
259 scan_git_subtree(repo.head.reference.commit.tree, p) 261 scan_git_subtree(repo.head.reference.commit.tree, p)
260 else: 262 else: