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

0 commit comments

Comments
 (0)