Skip to content

Commit 6531e11

Browse files
committed
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
2 parents 380ef2c + 3a6ab5c commit 6531e11

File tree

16 files changed

+54
-30
lines changed

16 files changed

+54
-30
lines changed

arch/alpha/kernel/setup.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,7 @@ setup_arch(char **cmdline_p)
634634

635635
/* Find our memory. */
636636
setup_memory(kernel_end);
637+
memblock_set_bottom_up(true);
637638

638639
/* First guess at cpu cache sizes. Do this before init_arch. */
639640
determine_cpu_caches(cpu->type);

arch/alpha/mm/numa.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,14 @@ setup_memory_node(int nid, void *kernel_end)
144144
if (!nid && (node_max_pfn < end_kernel_pfn || node_min_pfn > start_kernel_pfn))
145145
panic("kernel loaded out of ram");
146146

147+
memblock_add(PFN_PHYS(node_min_pfn),
148+
(node_max_pfn - node_min_pfn) << PAGE_SHIFT);
149+
147150
/* Zone start phys-addr must be 2^(MAX_ORDER-1) aligned.
148151
Note that we round this down, not up - node memory
149152
has much larger alignment than 8Mb, so it's safe. */
150153
node_min_pfn &= ~((1UL << (MAX_ORDER-1))-1);
151154

152-
memblock_add(PFN_PHYS(node_min_pfn),
153-
(node_max_pfn - node_min_pfn) << PAGE_SHIFT);
154-
155155
NODE_DATA(nid)->node_start_pfn = node_min_pfn;
156156
NODE_DATA(nid)->node_present_pages = node_max_pfn - node_min_pfn;
157157

arch/arm64/include/asm/memory.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,6 @@
3434
*/
3535
#define PCI_IO_SIZE SZ_16M
3636

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-
4637
/*
4738
* VMEMMAP_SIZE - allows the whole linear region to be covered by
4839
* a struct page array

arch/arm64/mm/init.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -610,14 +610,6 @@ void __init mem_init(void)
610610
BUILD_BUG_ON(TASK_SIZE_32 > TASK_SIZE_64);
611611
#endif
612612

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-
621613
if (PAGE_SIZE >= 16384 && get_num_physpages() <= 128) {
622614
extern int sysctl_overcommit_memory;
623615
/*

arch/sh/include/asm/io.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#define __IO_PREFIX generic
2525
#include <asm/io_generic.h>
2626
#include <asm/io_trapped.h>
27+
#include <asm-generic/pci_iomap.h>
2728
#include <mach/mangle-port.h>
2829

2930
#define __raw_writeb(v,a) (__chk_io_ptr(a), *(volatile u8 __force *)(a) = (v))

fs/iomap.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@ iomap_page_create(struct inode *inode, struct page *page)
116116
atomic_set(&iop->read_count, 0);
117117
atomic_set(&iop->write_count, 0);
118118
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);
119125
set_page_private(page, (unsigned long)iop);
120126
SetPagePrivate(page);
121127
return iop;
@@ -132,6 +138,7 @@ iomap_page_release(struct page *page)
132138
WARN_ON_ONCE(atomic_read(&iop->write_count));
133139
ClearPagePrivate(page);
134140
set_page_private(page, 0);
141+
put_page(page);
135142
kfree(iop);
136143
}
137144

fs/userfaultfd.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1566,7 +1566,6 @@ static int userfaultfd_unregister(struct userfaultfd_ctx *ctx,
15661566
cond_resched();
15671567

15681568
BUG_ON(!vma_can_userfault(vma));
1569-
WARN_ON(!(vma->vm_flags & VM_MAYWRITE));
15701569

15711570
/*
15721571
* Nothing to do: this vma is already registered into this
@@ -1575,6 +1574,8 @@ static int userfaultfd_unregister(struct userfaultfd_ctx *ctx,
15751574
if (!vma->vm_userfaultfd_ctx.ctx)
15761575
goto skip;
15771576

1577+
WARN_ON(!(vma->vm_flags & VM_MAYWRITE));
1578+
15781579
if (vma->vm_start > start)
15791580
start = vma->vm_start;
15801581
vma_end = min(end, vma->vm_end);

include/asm-generic/fixmap.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#define __ASM_GENERIC_FIXMAP_H
1717

1818
#include <linux/bug.h>
19+
#include <linux/mm_types.h>
1920

2021
#define __fix_to_virt(x) (FIXADDR_TOP - ((x) << PAGE_SHIFT))
2122
#define __virt_to_fix(x) ((FIXADDR_TOP - ((x)&PAGE_MASK)) >> PAGE_SHIFT)

include/linux/mm_types.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,11 @@ struct page {
206206
#endif
207207
} _struct_page_alignment;
208208

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+
209214
#define PAGE_FRAG_CACHE_MAX_SIZE __ALIGN_MASK(32768, ~PAGE_MASK)
210215
#define PAGE_FRAG_CACHE_MAX_ORDER get_order(PAGE_FRAG_CACHE_MAX_SIZE)
211216

include/linux/mmzone.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,12 @@ void memory_present(int nid, unsigned long start, unsigned long end);
783783
static inline void memory_present(int nid, unsigned long start, unsigned long end) {}
784784
#endif
785785

786+
#if defined(CONFIG_SPARSEMEM)
787+
void memblocks_present(void);
788+
#else
789+
static inline void memblocks_present(void) {}
790+
#endif
791+
786792
#ifdef CONFIG_HAVE_MEMORYLESS_NODES
787793
int local_memory_node(int node_id);
788794
#else

init/Kconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,8 +515,8 @@ config PSI_DEFAULT_DISABLED
515515
depends on PSI
516516
help
517517
If set, pressure stall information tracking will be disabled
518-
per default but can be enabled through passing psi_enable=1
519-
on the kernel commandline during boot.
518+
per default but can be enabled through passing psi=1 on the
519+
kernel commandline during boot.
520520

521521
endmenu # "CPU/Task time and stats accounting"
522522

mm/hugetlb.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,10 +1248,11 @@ void free_huge_page(struct page *page)
12481248
(struct hugepage_subpool *)page_private(page);
12491249
bool restore_reserve;
12501250

1251-
set_page_private(page, 0);
1252-
page->mapping = NULL;
12531251
VM_BUG_ON_PAGE(page_count(page), page);
12541252
VM_BUG_ON_PAGE(page_mapcount(page), page);
1253+
1254+
set_page_private(page, 0);
1255+
page->mapping = NULL;
12551256
restore_reserve = PagePrivate(page);
12561257
ClearPagePrivate(page);
12571258

mm/memblock.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1727,7 +1727,7 @@ static int __init_memblock memblock_search(struct memblock_type *type, phys_addr
17271727
return -1;
17281728
}
17291729

1730-
bool __init memblock_is_reserved(phys_addr_t addr)
1730+
bool __init_memblock memblock_is_reserved(phys_addr_t addr)
17311731
{
17321732
return memblock_search(&memblock.reserved, addr) != -1;
17331733
}

mm/sparse.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,22 @@ void __init memory_present(int nid, unsigned long start, unsigned long end)
239239
}
240240
}
241241

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+
*/
247+
void __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+
242258
/*
243259
* Subtle, we encode the real pfn into the mem_map such that
244260
* the identity pfn - section_mem_map will return the actual

scripts/checkstack.pl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
$xs = "[0-9a-f ]"; # hex character or space
4848
$funcre = qr/^$x* <(.*)>:$/;
4949
if ($arch eq 'aarch64') {
50-
#ffffffc0006325cc: a9bb7bfd stp x29, x30, [sp,#-80]!
51-
$re = qr/^.*stp.*sp,\#-([0-9]{1,8})\]\!/o;
50+
#ffffffc0006325cc: a9bb7bfd stp x29, x30, [sp, #-80]!
51+
$re = qr/^.*stp.*sp, \#-([0-9]{1,8})\]\!/o;
5252
} elsif ($arch eq 'arm') {
5353
#c0008ffc: e24dd064 sub sp, sp, #100 ; 0x64
5454
$re = qr/.*sub.*sp, sp, #(([0-9]{2}|[3-9])[0-9]{2})/o;

scripts/spdxcheck.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ def parse_lines(self, fd, maxlines, fname):
168168
self.curline = 0
169169
try:
170170
for line in fd:
171+
line = line.decode(locale.getpreferredencoding(False), errors='ignore')
171172
self.curline += 1
172173
if self.curline > maxlines:
173174
break
@@ -249,12 +250,13 @@ def scan_git_subtree(tree, path):
249250

250251
try:
251252
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, '-')
253255
else:
254256
if args.path:
255257
for p in args.path:
256258
if os.path.isfile(p):
257-
parser.parse_lines(open(p), args.maxlines, p)
259+
parser.parse_lines(open(p, 'rb'), args.maxlines, p)
258260
elif os.path.isdir(p):
259261
scan_git_subtree(repo.head.reference.commit.tree, p)
260262
else:

0 commit comments

Comments
 (0)