Skip to contentSkip to conversation

incoming

PATCH In review Andrew Morton 3 participants 167 messages Jun 2, 2020 – Jun 15, 2020 Page 2 of 2

Subsystems (97)
lore
Share & tools
lore
author maintainer
#107 lore raw

PATCH 105/128 mm: remove unmap_vmap_area

In reply to Andrew Morton

From: Christoph Hellwig <[email protected]>
Subject: mm: remove unmap_vmap_area

This function just has a single caller, open code it there.

Cc Christian Borntraeger <[email protected]>
Cc Christophe Leroy <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc David Airlie <[email protected]>
Cc Gao Xiang <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Haiyang Zhang <[email protected]>
Cc Johannes Weiner <[email protected]>
Cc "K. Y. Srinivasan" <[email protected]>
Cc Laura Abbott <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Michael Kelley <[email protected]>
Cc Minchan Kim <[email protected]>
Cc Nitin Gupta <[email protected]>
Cc Robin Murphy <[email protected]>
Cc Sakari Ailus <[email protected]>
Cc Stephen Hemminger <[email protected]>
Cc Sumit Semwal <[email protected]>
Cc Wei Liu <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Heiko Carstens <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Vasily Gorbik <[email protected]>
Cc Will Deacon <[email protected]>

---

 mm/vmalloc.c |   10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)
mm/vmalloc.c renamed from mm/vmalloc.c~mm-remove-unmap_vmap_area +0 -6
@@ -1249,14 +1249,6 @@ int unregister_vmap_purge_notifier(struc
 EXPORT_SYMBOL_GPL(unregister_vmap_purge_notifier);
 
 /*
- * Clear the pagetable entries of a given vmap_area
- */
-static void unmap_vmap_area(struct vmap_area *va)
-{
-	unmap_kernel_range_noflush(va->va_start, va->va_end - va->va_start);
-}
author maintainer
#108 lore raw

PATCH 106/128 mm: remove the prot argument from vm_map_ram

In reply to Andrew Morton

From: Christoph Hellwig <[email protected]>
Subject: mm: remove the prot argument from vm_map_ram

This is always PAGE_KERNEL - for long term mappings with other properties vmap should be used.

Cc Christian Borntraeger <[email protected]>
Cc Christophe Leroy <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc David Airlie <[email protected]>
Cc Gao Xiang <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Haiyang Zhang <[email protected]>
Cc Johannes Weiner <[email protected]>
Cc "K. Y. Srinivasan" <[email protected]>
Cc Laura Abbott <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Michael Kelley <[email protected]>
Cc Minchan Kim <[email protected]>
Cc Nitin Gupta <[email protected]>
Cc Robin Murphy <[email protected]>
Cc Sakari Ailus <[email protected]>
Cc Stephen Hemminger <[email protected]>
Cc Sumit Semwal <[email protected]>
Cc Wei Liu <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Heiko Carstens <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Vasily Gorbik <[email protected]>
Cc Will Deacon <[email protected]>

---

 drivers/gpu/drm/i915/gem/selftests/mock_dmabuf.c   |    2 +-
 drivers/media/common/videobuf2/videobuf2-dma-sg.c  |    3 +--
 drivers/media/common/videobuf2/videobuf2-vmalloc.c |    3 +--
 fs/erofs/decompressor.c                            |    2 +-
 fs/xfs/xfs_buf.c                                   |    2 +-
 include/linux/vmalloc.h                            |    3 +--
 mm/nommu.c                                         |    2 +-
 mm/vmalloc.c                                       |    4 ++--
 8 files changed, 9 insertions(+), 12 deletions(-)
drivers/gpu/drm/i915/gem/selftests/mock_dmabuf.c renamed from drivers/gpu/drm/i915/gem/selftests/mock_dmabuf.c~mm-remove-the-prot-argument-from-vm_map_ram +1 -1
@@ -66,7 +66,7 @@ static void *mock_dmabuf_vmap(struct dma
 {
 	struct mock_dmabuf *mock = to_mock(dma_buf);
 
-	return vm_map_ram(mock->pages, mock->npages, 0, PAGE_KERNEL);
+	return vm_map_ram(mock->pages, mock->npages, 0);
 }
 
 static void mock_dmabuf_vunmap(struct dma_buf *dma_buf, void *vaddr)
drivers/media/common/videobuf2/videobuf2-dma-sg.c renamed from drivers/media/common/videobuf2/videobuf2-dma-sg.c~mm-remove-the-prot-argument-from-vm_map_ram +1 -2
@@ -309,8 +309,7 @@ static void *vb2_dma_sg_vaddr(void *buf_
 		if (buf->db_attach)
 			buf->vaddr = dma_buf_vmap(buf->db_attach->dmabuf);
 		else
-			buf->vaddr = vm_map_ram(buf->pages,
-					buf->num_pages, -1, PAGE_KERNEL);
+			buf->vaddr = vm_map_ram(buf->pages, buf->num_pages, -1);
 	}
 
 	/* add offset in case userptr is not page-aligned */
drivers/media/common/videobuf2/videobuf2-vmalloc.c renamed from drivers/media/common/videobuf2/videobuf2-vmalloc.c~mm-remove-the-prot-argument-from-vm_map_ram +1 -2
@@ -107,8 +107,7 @@ static void *vb2_vmalloc_get_userptr(str
 		buf->vaddr = (__force void *)
 			ioremap(__pfn_to_phys(nums[0]), size + offset);
 	} else {
-		buf->vaddr = vm_map_ram(frame_vector_pages(vec), n_pages, -1,
-					PAGE_KERNEL);
+		buf->vaddr = vm_map_ram(frame_vector_pages(vec), n_pages, -1);
 	}
 
 	if (!buf->vaddr)
fs/erofs/decompressor.c renamed from fs/erofs/decompressor.c~mm-remove-the-prot-argument-from-vm_map_ram +1 -1
@@ -274,7 +274,7 @@ static int z_erofs_decompress_generic(st
 
 	i = 0;
 	while (1) {
-		dst = vm_map_ram(rq->out, nrpages_out, -1, PAGE_KERNEL);
+		dst = vm_map_ram(rq->out, nrpages_out, -1);
 
 		/* retry two more times (totally 3 times) */
 		if (dst || ++i >= 3)
fs/xfs/xfs_buf.c renamed from fs/xfs/xfs_buf.c~mm-remove-the-prot-argument-from-vm_map_ram +1 -1
@@ -477,7 +477,7 @@ _xfs_buf_map_pages(
 		nofs_flag = memalloc_nofs_save();
 		do {
 			bp->b_addr = vm_map_ram(bp->b_pages, bp->b_page_count,
-						-1, PAGE_KERNEL);
+						-1);
 			if (bp->b_addr)
 				break;
 			vm_unmap_aliases();
include/linux/vmalloc.h renamed from include/linux/vmalloc.h~mm-remove-the-prot-argument-from-vm_map_ram +1 -2
@@ -88,8 +88,7 @@ struct vmap_area {
  *	Highlevel APIs for driver use
  */
 extern void vm_unmap_ram(const void *mem, unsigned int count);
-extern void *vm_map_ram(struct page **pages, unsigned int count,
-				int node, pgprot_t prot);
+extern void *vm_map_ram(struct page **pages, unsigned int count, int node);
 extern void vm_unmap_aliases(void);
 
 #ifdef CONFIG_MMU
mm/nommu.c renamed from mm/nommu.c~mm-remove-the-prot-argument-from-vm_map_ram +1 -1
@@ -351,7 +351,7 @@ void vunmap(const void *addr)
 }
 EXPORT_SYMBOL(vunmap);
 
-void *vm_map_ram(struct page **pages, unsigned int count, int node, pgprot_t prot)
+void *vm_map_ram(struct page **pages, unsigned int count, int node)
 {
 	BUG();
 	return NULL;
mm/vmalloc.c renamed from mm/vmalloc.c~mm-remove-the-prot-argument-from-vm_map_ram +2 -2
@@ -1835,7 +1835,7 @@ EXPORT_SYMBOL(vm_unmap_ram);
  *
  * Returns: a pointer to the address that has been mapped, or %NULL on failure
  */
-void *vm_map_ram(struct page **pages, unsigned int count, int node, pgprot_t prot)
+void *vm_map_ram(struct page **pages, unsigned int count, int node)
 {
 	unsigned long size = (unsigned long)count << PAGE_SHIFT;
 	unsigned long addr;
@@ -1859,7 +1859,7 @@ void *vm_map_ram(struct page **pages, un
 
 	kasan_unpoison_vmalloc(mem, size);
 
-	if (map_kernel_range(addr, size, prot, pages) < 0) {
+	if (map_kernel_range(addr, size, PAGE_KERNEL, pages) < 0) {
 		vm_unmap_ram(mem, count);
 		return NULL;
 	}

_

author maintainer
#109 lore raw

PATCH 107/128 mm: enforce that vmap can't map pages executable

In reply to Andrew Morton

From: Christoph Hellwig <[email protected]>
Subject: mm: enforce that vmap can't map pages executable

To help enforcing the W^X protection don't allow remapping existing pages as executable.

x86 bits from Peter Zijlstra, arm64 bits from Mark Rutland.

Cc Mark Rutland <[email protected]>.
Cc Christian Borntraeger <[email protected]>
Cc Christophe Leroy <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc David Airlie <[email protected]>
Cc Gao Xiang <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Haiyang Zhang <[email protected]>
Cc Johannes Weiner <[email protected]>
Cc "K. Y. Srinivasan" <[email protected]>
Cc Laura Abbott <[email protected]>
Cc Michael Kelley <[email protected]>
Cc Minchan Kim <[email protected]>
Cc Nitin Gupta <[email protected]>
Cc Robin Murphy <[email protected]>
Cc Sakari Ailus <[email protected]>
Cc Stephen Hemminger <[email protected]>
Cc Sumit Semwal <[email protected]>
Cc Wei Liu <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Heiko Carstens <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Vasily Gorbik <[email protected]>
Cc Will Deacon <[email protected]>

---

 arch/arm64/include/asm/pgtable.h     |    3 +++
 arch/x86/include/asm/pgtable_types.h |    6 ++++++
 include/asm-generic/pgtable.h        |    4 ++++
 mm/vmalloc.c                         |    2 +-
 4 files changed, 14 insertions(+), 1 deletion(-)
arch/arm64/include/asm/pgtable.h renamed from arch/arm64/include/asm/pgtable.h~mm-enforce-that-vmap-cant-map-pages-executable +3 -0
@@ -407,6 +407,9 @@ static inline pmd_t pmd_mkdevmap(pmd_t p
 #define __pgprot_modify(prot,mask,bits) \
 	__pgprot((pgprot_val(prot) & ~(mask)) | (bits))
 
+#define pgprot_nx(prot) \
+	__pgprot_modify(prot, 0, PTE_PXN)
+
 /*
  * Mark the prot value as uncacheable and unbufferable.
  */
arch/x86/include/asm/pgtable_types.h renamed from arch/x86/include/asm/pgtable_types.h~mm-enforce-that-vmap-cant-map-pages-executable +6 -0
@@ -282,6 +282,12 @@ typedef struct pgprot { pgprotval_t pgpr
 
 typedef struct { pgdval_t pgd; } pgd_t;
 
+static inline pgprot_t pgprot_nx(pgprot_t prot)
+{
+	return __pgprot(pgprot_val(prot) | _PAGE_NX);
+}
+#define pgprot_nx pgprot_nx
+
 #ifdef CONFIG_X86_PAE
 
 /*
include/asm-generic/pgtable.h renamed from include/asm-generic/pgtable.h~mm-enforce-that-vmap-cant-map-pages-executable +4 -0
@@ -491,6 +491,10 @@ static inline int arch_unmap_one(struct
 #define flush_tlb_fix_spurious_fault(vma, address) flush_tlb_page(vma, address)
 #endif
 
+#ifndef pgprot_nx
+#define pgprot_nx(prot)	(prot)
+#endif
+
 #ifndef pgprot_noncached
 #define pgprot_noncached(prot)	(prot)
 #endif
mm/vmalloc.c renamed from mm/vmalloc.c~mm-enforce-that-vmap-cant-map-pages-executable +1 -1
@@ -2391,7 +2391,7 @@ void *vmap(struct page **pages, unsigned
 	if (!area)
 		return NULL;
 
-	if (map_kernel_range((unsigned long)area->addr, size, prot,
+	if (map_kernel_range((unsigned long)area->addr, size, pgprot_nx(prot),
 			pages) < 0) {
 		vunmap(area->addr);
 		return NULL;

_

author maintainer
#110 lore raw

PATCH 108/128 gpu/drm: remove the powerpc hack in drm_legacy_sg_alloc

In reply to Andrew Morton

From: Christoph Hellwig <[email protected]>
Subject: gpu/drm: remove the powerpc hack in drm_legacy_sg_alloc

The non-cached vmalloc mapping was initially added as a hack for the first-gen amigaone platform (6xx/book32s), isn't fully supported upstream, and which used the legacy radeon driver together with non-coherent DMA. However this only ever worked reliably for DRI .

Remove the hack as it is the last user of __vmalloc passing a page protection flag other than PAGE_KERNEL and didn't do anything for other platforms with non-coherent DMA.

Cc Christian Borntraeger <[email protected]>
Cc Christophe Leroy <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc David Airlie <[email protected]>
Cc Gao Xiang <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Haiyang Zhang <[email protected]>
Cc Johannes Weiner <[email protected]>
Cc "K. Y. Srinivasan" <[email protected]>
Cc Laura Abbott <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Michael Kelley <[email protected]>
Cc Minchan Kim <[email protected]>
Cc Nitin Gupta <[email protected]>
Cc Robin Murphy <[email protected]>
Cc Sakari Ailus <[email protected]>
Cc Stephen Hemminger <[email protected]>
Cc Sumit Semwal <[email protected]>
Cc Wei Liu <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Heiko Carstens <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Vasily Gorbik <[email protected]>
Cc Will Deacon <[email protected]>

---

 drivers/gpu/drm/drm_scatter.c |   11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)
drivers/gpu/drm/drm_scatter.c renamed from drivers/gpu/drm/drm_scatter.c~gpu-drm-remove-the-powerpc-hack-in-drm_legacy_sg_alloc +0 -8
@@ -43,15 +43,6 @@
 
 #define DEBUG_SCATTER 0
 
-static inline void *drm_vmalloc_dma(unsigned long size)
-{
-#if defined(__powerpc__) && defined(CONFIG_NOT_COHERENT_CACHE)
-	return __vmalloc(size, GFP_KERNEL, pgprot_noncached_wc(PAGE_KERNEL));
-#else
-	return vmalloc_32(size);
-#endif
-}
author maintainer
#111 lore raw

PATCH 109/128 mm: remove the pgprot argument to __vmalloc

In reply to Andrew Morton

From: Christoph Hellwig <[email protected]>
Subject: mm: remove the pgprot argument to __vmalloc

The pgprot argument to __vmalloc is always PAGE_KERNEL now, so remove it.

Cc Christian Borntraeger <[email protected]>
Cc Christophe Leroy <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc David Airlie <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Haiyang Zhang <[email protected]>
Cc Johannes Weiner <[email protected]>
Cc "K. Y. Srinivasan" <[email protected]>
Cc Laura Abbott <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Minchan Kim <[email protected]>
Cc Nitin Gupta <[email protected]>
Cc Robin Murphy <[email protected]>
Cc Sakari Ailus <[email protected]>
Cc Stephen Hemminger <[email protected]>
Cc Sumit Semwal <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Heiko Carstens <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Vasily Gorbik <[email protected]>
Cc Will Deacon <[email protected]>

---

 arch/x86/hyperv/hv_init.c              |    3 +--
 arch/x86/include/asm/kvm_host.h        |    3 +--
 arch/x86/kvm/svm/sev.c                 |    3 +--
 drivers/block/drbd/drbd_bitmap.c       |    4 +---
 drivers/gpu/drm/etnaviv/etnaviv_dump.c |    4 ++--
 drivers/lightnvm/pblk-init.c           |    5 ++---
 drivers/md/dm-bufio.c                  |    4 ++--
 drivers/mtd/ubi/io.c                   |    4 ++--
 drivers/scsi/sd_zbc.c                  |    3 +--
 fs/gfs2/dir.c                          |    9 ++++-----
 fs/gfs2/quota.c                        |    2 +-
 fs/nfs/blocklayout/extent_tree.c       |    2 +-
 fs/ntfs/malloc.h                       |    2 +-
 fs/ubifs/debug.c                       |    2 +-
 fs/ubifs/lprops.c                      |    2 +-
 fs/ubifs/lpt_commit.c                  |    4 ++--
 fs/ubifs/orphan.c                      |    2 +-
 fs/xfs/kmem.c                          |    2 +-
 include/linux/vmalloc.h                |    2 +-
 kernel/bpf/core.c                      |    6 +++---
 kernel/groups.c                        |    2 +-
 kernel/module.c                        |    3 +--
 mm/nommu.c                             |   15 +++++++--------
 mm/page_alloc.c                        |    2 +-
 mm/percpu.c                            |    2 +-
 mm/vmalloc.c                           |    4 ++--
 net/bridge/netfilter/ebtables.c        |    6 ++----
 sound/core/memalloc.c                  |    2 +-
 sound/core/pcm_memory.c                |    2 +-
 29 files changed, 47 insertions(+), 59 deletions(-)
arch/x86/hyperv/hv_init.c renamed from arch/x86/hyperv/hv_init.c~mm-remove-the-pgprot-argument-to-__vmalloc +1 -2
@@ -97,8 +97,7 @@ static int hv_cpu_init(unsigned int cpu)
 	 * not be stopped in the case of CPU offlining and the VM will hang.
 	 */
 	if (!*hvp) {
-		*hvp = __vmalloc(PAGE_SIZE, GFP_KERNEL | __GFP_ZERO,
-				 PAGE_KERNEL);
+		*hvp = __vmalloc(PAGE_SIZE, GFP_KERNEL | __GFP_ZERO);
 	}
 
 	if (*hvp) {
arch/x86/include/asm/kvm_host.h renamed from arch/x86/include/asm/kvm_host.h~mm-remove-the-pgprot-argument-to-__vmalloc +1 -2
@@ -1279,8 +1279,7 @@ extern struct kmem_cache *x86_fpu_cache;
 #define __KVM_HAVE_ARCH_VM_ALLOC
 static inline struct kvm *kvm_arch_alloc_vm(void)
 {
-	return __vmalloc(kvm_x86_ops.vm_size,
-			 GFP_KERNEL_ACCOUNT | __GFP_ZERO, PAGE_KERNEL);
+	return __vmalloc(kvm_x86_ops.vm_size, GFP_KERNEL_ACCOUNT | __GFP_ZERO);
 }
 void kvm_arch_free_vm(struct kvm *kvm);
 
arch/x86/kvm/svm/sev.c renamed from arch/x86/kvm/svm/sev.c~mm-remove-the-pgprot-argument-to-__vmalloc +1 -2
@@ -336,8 +336,7 @@ static struct page **sev_pin_memory(stru
 	/* Avoid using vmalloc for smaller buffers. */
 	size = npages * sizeof(struct page *);
 	if (size > PAGE_SIZE)
-		pages = __vmalloc(size, GFP_KERNEL_ACCOUNT | __GFP_ZERO,
-				  PAGE_KERNEL);
+		pages = __vmalloc(size, GFP_KERNEL_ACCOUNT | __GFP_ZERO);
 	else
 		pages = kmalloc(size, GFP_KERNEL_ACCOUNT);
 
drivers/block/drbd/drbd_bitmap.c renamed from drivers/block/drbd/drbd_bitmap.c~mm-remove-the-pgprot-argument-to-__vmalloc +1 -3
@@ -396,9 +396,7 @@ static struct page **bm_realloc_pages(st
 	bytes = sizeof(struct page *)*want;
 	new_pages = kzalloc(bytes, GFP_NOIO | __GFP_NOWARN);
 	if (!new_pages) {
-		new_pages = __vmalloc(bytes,
-				GFP_NOIO | __GFP_ZERO,
-				PAGE_KERNEL);
+		new_pages = __vmalloc(bytes, GFP_NOIO | __GFP_ZERO);
 		if (!new_pages)
 			return NULL;
 	}
drivers/gpu/drm/etnaviv/etnaviv_dump.c renamed from drivers/gpu/drm/etnaviv/etnaviv_dump.c~mm-remove-the-pgprot-argument-to-__vmalloc +2 -2
@@ -154,8 +154,8 @@ void etnaviv_core_dump(struct etnaviv_ge
 	file_size += sizeof(*iter.hdr) * n_obj;
 
 	/* Allocate the file in vmalloc memory, it's likely to be big */
-	iter.start = __vmalloc(file_size, GFP_KERNEL | __GFP_NOWARN | __GFP_NORETRY,
-			       PAGE_KERNEL);
+	iter.start = __vmalloc(file_size, GFP_KERNEL | __GFP_NOWARN |
+			__GFP_NORETRY);
 	if (!iter.start) {
 		mutex_unlock(&gpu->mmu_context->lock);
 		dev_warn(gpu->dev, "failed to allocate devcoredump file\n");
drivers/lightnvm/pblk-init.c renamed from drivers/lightnvm/pblk-init.c~mm-remove-the-pgprot-argument-to-__vmalloc +2 -3
@@ -145,9 +145,8 @@ static int pblk_l2p_init(struct pblk *pb
 	int ret = 0;
 
 	map_size = pblk_trans_map_size(pblk);
-	pblk->trans_map = __vmalloc(map_size, GFP_KERNEL | __GFP_NOWARN
-					| __GFP_RETRY_MAYFAIL | __GFP_HIGHMEM,
-					PAGE_KERNEL);
+	pblk->trans_map = __vmalloc(map_size, GFP_KERNEL | __GFP_NOWARN |
+				    __GFP_RETRY_MAYFAIL | __GFP_HIGHMEM);
 	if (!pblk->trans_map) {
 		pblk_err(pblk, "failed to allocate L2P (need %zu of memory)\n",
 				map_size);
drivers/md/dm-bufio.c renamed from drivers/md/dm-bufio.c~mm-remove-the-pgprot-argument-to-__vmalloc +2 -2
@@ -400,13 +400,13 @@ static void *alloc_buffer_data(struct dm
 	 */
 	if (gfp_mask & __GFP_NORETRY) {
 		unsigned noio_flag = memalloc_noio_save();
-		void *ptr = __vmalloc(c->block_size, gfp_mask, PAGE_KERNEL);
+		void *ptr = __vmalloc(c->block_size, gfp_mask);
 
 		memalloc_noio_restore(noio_flag);
 		return ptr;
 	}
 
-	return __vmalloc(c->block_size, gfp_mask, PAGE_KERNEL);
+	return __vmalloc(c->block_size, gfp_mask);
 }
 
 /*
drivers/mtd/ubi/io.c renamed from drivers/mtd/ubi/io.c~mm-remove-the-pgprot-argument-to-__vmalloc +2 -2
@@ -1297,7 +1297,7 @@ static int self_check_write(struct ubi_d
 	if (!ubi_dbg_chk_io(ubi))
 		return 0;
 
-	buf1 = __vmalloc(len, GFP_NOFS, PAGE_KERNEL);
+	buf1 = __vmalloc(len, GFP_NOFS);
 	if (!buf1) {
 		ubi_err(ubi, "cannot allocate memory to check writes");
 		return 0;
@@ -1361,7 +1361,7 @@ int ubi_self_check_all_ff(struct ubi_dev
 	if (!ubi_dbg_chk_io(ubi))
 		return 0;
 
-	buf = __vmalloc(len, GFP_NOFS, PAGE_KERNEL);
+	buf = __vmalloc(len, GFP_NOFS);
 	if (!buf) {
 		ubi_err(ubi, "cannot allocate memory to check for 0xFFs");
 		return 0;
drivers/scsi/sd_zbc.c renamed from drivers/scsi/sd_zbc.c~mm-remove-the-pgprot-argument-to-__vmalloc +1 -2
@@ -136,8 +136,7 @@ static void *sd_zbc_alloc_report_buffer(
 
 	while (bufsize >= SECTOR_SIZE) {
 		buf = __vmalloc(bufsize,
-				GFP_KERNEL | __GFP_ZERO | __GFP_NORETRY,
-				PAGE_KERNEL);
+				GFP_KERNEL | __GFP_ZERO | __GFP_NORETRY);
 		if (buf) {
 			*buflen = bufsize;
 			return buf;
fs/gfs2/dir.c renamed from fs/gfs2/dir.c~mm-remove-the-pgprot-argument-to-__vmalloc +4 -5
@@ -354,7 +354,7 @@ static __be64 *gfs2_dir_get_hash_table(s
 
 	hc = kmalloc(hsize, GFP_NOFS | __GFP_NOWARN);
 	if (hc == NULL)
-		hc = __vmalloc(hsize, GFP_NOFS, PAGE_KERNEL);
+		hc = __vmalloc(hsize, GFP_NOFS);
 
 	if (hc == NULL)
 		return ERR_PTR(-ENOMEM);
@@ -1166,7 +1166,7 @@ static int dir_double_exhash(struct gfs2
 
 	hc2 = kmalloc_array(hsize_bytes, 2, GFP_NOFS | __GFP_NOWARN);
 	if (hc2 == NULL)
-		hc2 = __vmalloc(hsize_bytes * 2, GFP_NOFS, PAGE_KERNEL);
+		hc2 = __vmalloc(hsize_bytes * 2, GFP_NOFS);
 
 	if (!hc2)
 		return -ENOMEM;
@@ -1327,7 +1327,7 @@ static void *gfs2_alloc_sort_buffer(unsi
 	if (size < KMALLOC_MAX_SIZE)
 		ptr = kmalloc(size, GFP_NOFS | __GFP_NOWARN);
 	if (!ptr)
-		ptr = __vmalloc(size, GFP_NOFS, PAGE_KERNEL);
+		ptr = __vmalloc(size, GFP_NOFS);
 	return ptr;
 }
 
@@ -1987,8 +1987,7 @@ static int leaf_dealloc(struct gfs2_inod
 
 	ht = kzalloc(size, GFP_NOFS | __GFP_NOWARN);
 	if (ht == NULL)
-		ht = __vmalloc(size, GFP_NOFS | __GFP_NOWARN | __GFP_ZERO,
-			       PAGE_KERNEL);
+		ht = __vmalloc(size, GFP_NOFS | __GFP_NOWARN | __GFP_ZERO);
 	if (!ht)
 		return -ENOMEM;
 
fs/gfs2/quota.c renamed from fs/gfs2/quota.c~mm-remove-the-pgprot-argument-to-__vmalloc +1 -1
@@ -1365,7 +1365,7 @@ int gfs2_quota_init(struct gfs2_sbd *sdp
 	sdp->sd_quota_bitmap = kzalloc(bm_size, GFP_NOFS | __GFP_NOWARN);
 	if (sdp->sd_quota_bitmap == NULL)
 		sdp->sd_quota_bitmap = __vmalloc(bm_size, GFP_NOFS |
-						 __GFP_ZERO, PAGE_KERNEL);
+						 __GFP_ZERO);
 	if (!sdp->sd_quota_bitmap)
 		return error;
 
fs/nfs/blocklayout/extent_tree.c renamed from fs/nfs/blocklayout/extent_tree.c~mm-remove-the-pgprot-argument-to-__vmalloc +1 -1
@@ -582,7 +582,7 @@ retry:
 		if (!arg->layoutupdate_pages)
 			return -ENOMEM;
 
-		start_p = __vmalloc(buffer_size, GFP_NOFS, PAGE_KERNEL);
+		start_p = __vmalloc(buffer_size, GFP_NOFS);
 		if (!start_p) {
 			kfree(arg->layoutupdate_pages);
 			return -ENOMEM;
fs/ntfs/malloc.h renamed from fs/ntfs/malloc.h~mm-remove-the-pgprot-argument-to-__vmalloc +1 -1
@@ -34,7 +34,7 @@ static inline void *__ntfs_malloc(unsign
 		/* return (void *)__get_free_page(gfp_mask); */
 	}
 	if (likely((size >> PAGE_SHIFT) < totalram_pages()))
-		return __vmalloc(size, gfp_mask, PAGE_KERNEL);
+		return __vmalloc(size, gfp_mask);
 	return NULL;
 }
 
fs/ubifs/debug.c renamed from fs/ubifs/debug.c~mm-remove-the-pgprot-argument-to-__vmalloc +1 -1
@@ -815,7 +815,7 @@ void ubifs_dump_leb(const struct ubifs_i
 
 	pr_err("(pid %d) start dumping LEB %d\n", current->pid, lnum);
 
-	buf = __vmalloc(c->leb_size, GFP_NOFS, PAGE_KERNEL);
+	buf = __vmalloc(c->leb_size, GFP_NOFS);
 	if (!buf) {
 		ubifs_err(c, "cannot allocate memory for dumping LEB %d", lnum);
 		return;
fs/ubifs/lprops.c renamed from fs/ubifs/lprops.c~mm-remove-the-pgprot-argument-to-__vmalloc +1 -1
@@ -1095,7 +1095,7 @@ static int scan_check_cb(struct ubifs_in
 		return LPT_SCAN_CONTINUE;
 	}
 
-	buf = __vmalloc(c->leb_size, GFP_NOFS, PAGE_KERNEL);
+	buf = __vmalloc(c->leb_size, GFP_NOFS);
 	if (!buf)
 		return -ENOMEM;
 
fs/ubifs/lpt_commit.c renamed from fs/ubifs/lpt_commit.c~mm-remove-the-pgprot-argument-to-__vmalloc +2 -2
@@ -1596,7 +1596,7 @@ static int dbg_check_ltab_lnum(struct ub
 	if (!dbg_is_chk_lprops(c))
 		return 0;
 
-	buf = p = __vmalloc(c->leb_size, GFP_NOFS, PAGE_KERNEL);
+	buf = p = __vmalloc(c->leb_size, GFP_NOFS);
 	if (!buf) {
 		ubifs_err(c, "cannot allocate memory for ltab checking");
 		return 0;
@@ -1845,7 +1845,7 @@ static void dump_lpt_leb(const struct ub
 	void *buf, *p;
 
 	pr_err("(pid %d) start dumping LEB %d\n", current->pid, lnum);
-	buf = p = __vmalloc(c->leb_size, GFP_NOFS, PAGE_KERNEL);
+	buf = p = __vmalloc(c->leb_size, GFP_NOFS);
 	if (!buf) {
 		ubifs_err(c, "cannot allocate memory to dump LPT");
 		return;
fs/ubifs/orphan.c renamed from fs/ubifs/orphan.c~mm-remove-the-pgprot-argument-to-__vmalloc +1 -1
@@ -977,7 +977,7 @@ static int dbg_scan_orphans(struct ubifs
 	if (c->no_orphs)
 		return 0;
 
-	buf = __vmalloc(c->leb_size, GFP_NOFS, PAGE_KERNEL);
+	buf = __vmalloc(c->leb_size, GFP_NOFS);
 	if (!buf) {
 		ubifs_err(c, "cannot allocate memory to check orphans");
 		return 0;
fs/xfs/kmem.c renamed from fs/xfs/kmem.c~mm-remove-the-pgprot-argument-to-__vmalloc +1 -1
@@ -48,7 +48,7 @@ __kmem_vmalloc(size_t size, xfs_km_flags
 	if (flags & KM_NOFS)
 		nofs_flag = memalloc_nofs_save();
 
-	ptr = __vmalloc(size, lflags, PAGE_KERNEL);
+	ptr = __vmalloc(size, lflags);
 
 	if (flags & KM_NOFS)
 		memalloc_nofs_restore(nofs_flag);
include/linux/vmalloc.h renamed from include/linux/vmalloc.h~mm-remove-the-pgprot-argument-to-__vmalloc +1 -1
@@ -110,7 +110,7 @@ extern void *vmalloc_user_node_flags(uns
 extern void *vmalloc_exec(unsigned long size);
 extern void *vmalloc_32(unsigned long size);
 extern void *vmalloc_32_user(unsigned long size);
-extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
+extern void *__vmalloc(unsigned long size, gfp_t gfp_mask);
 extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
 			unsigned long start, unsigned long end, gfp_t gfp_mask,
 			pgprot_t prot, unsigned long vm_flags, int node,
kernel/bpf/core.c renamed from kernel/bpf/core.c~mm-remove-the-pgprot-argument-to-__vmalloc +3 -3
@@ -82,7 +82,7 @@ struct bpf_prog *bpf_prog_alloc_no_stats
 	struct bpf_prog *fp;
 
 	size = round_up(size, PAGE_SIZE);
-	fp = __vmalloc(size, gfp_flags, PAGE_KERNEL);
+	fp = __vmalloc(size, gfp_flags);
 	if (fp == NULL)
 		return NULL;
 
@@ -232,7 +232,7 @@ struct bpf_prog *bpf_prog_realloc(struct
 	if (ret)
 		return NULL;
 
-	fp = __vmalloc(size, gfp_flags, PAGE_KERNEL);
+	fp = __vmalloc(size, gfp_flags);
 	if (fp == NULL) {
 		__bpf_prog_uncharge(fp_old->aux->user, delta);
 	} else {
@@ -1089,7 +1089,7 @@ static struct bpf_prog *bpf_prog_clone_c
 	gfp_t gfp_flags = GFP_KERNEL | __GFP_ZERO | gfp_extra_flags;
 	struct bpf_prog *fp;
 
-	fp = __vmalloc(fp_other->pages * PAGE_SIZE, gfp_flags, PAGE_KERNEL);
+	fp = __vmalloc(fp_other->pages * PAGE_SIZE, gfp_flags);
 	if (fp != NULL) {
 		/* aux->prog still points to the fp_other one, so
 		 * when promoting the clone to the real program,
kernel/groups.c renamed from kernel/groups.c~mm-remove-the-pgprot-argument-to-__vmalloc +1 -1
@@ -20,7 +20,7 @@ struct group_info *groups_alloc(int gids
 	len = sizeof(struct group_info) + sizeof(kgid_t) * gidsetsize;
 	gi = kmalloc(len, GFP_KERNEL_ACCOUNT|__GFP_NOWARN|__GFP_NORETRY);
 	if (!gi)
-		gi = __vmalloc(len, GFP_KERNEL_ACCOUNT, PAGE_KERNEL);
+		gi = __vmalloc(len, GFP_KERNEL_ACCOUNT);
 	if (!gi)
 		return NULL;
 
kernel/module.c renamed from kernel/module.c~mm-remove-the-pgprot-argument-to-__vmalloc +1 -2
@@ -2951,8 +2951,7 @@ static int copy_module_from_user(const v
 		return err;
 
 	/* Suck in entire file: we'll want most of it. */
-	info->hdr = __vmalloc(info->len,
-			GFP_KERNEL | __GFP_NOWARN, PAGE_KERNEL);
+	info->hdr = __vmalloc(info->len, GFP_KERNEL | __GFP_NOWARN);
 	if (!info->hdr)
 		return -ENOMEM;
 
mm/nommu.c renamed from mm/nommu.c~mm-remove-the-pgprot-argument-to-__vmalloc +7 -8
@@ -140,7 +140,7 @@ void vfree(const void *addr)
 }
 EXPORT_SYMBOL(vfree);
 
-void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot)
+void *__vmalloc(unsigned long size, gfp_t gfp_mask)
 {
 	/*
 	 *  You can't specify __GFP_HIGHMEM with kmalloc() since kmalloc()
@@ -152,14 +152,14 @@ EXPORT_SYMBOL(__vmalloc);
 
 void *__vmalloc_node_flags(unsigned long size, int node, gfp_t flags)
 {
-	return __vmalloc(size, flags, PAGE_KERNEL);
+	return __vmalloc(size, flags);
 }
 
 static void *__vmalloc_user_flags(unsigned long size, gfp_t flags)
 {
 	void *ret;
 
-	ret = __vmalloc(size, flags, PAGE_KERNEL);
+	ret = __vmalloc(size, flags);
 	if (ret) {
 		struct vm_area_struct *vma;
 
@@ -230,7 +230,7 @@ long vwrite(char *buf, char *addr, unsig
  */
 void *vmalloc(unsigned long size)
 {
-       return __vmalloc(size, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL);
+       return __vmalloc(size, GFP_KERNEL | __GFP_HIGHMEM);
 }
 EXPORT_SYMBOL(vmalloc);
 
@@ -248,8 +248,7 @@ EXPORT_SYMBOL(vmalloc);
  */
 void *vzalloc(unsigned long size)
 {
-	return __vmalloc(size, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO,
-			PAGE_KERNEL);
+	return __vmalloc(size, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO);
 }
 EXPORT_SYMBOL(vzalloc);
 
@@ -302,7 +301,7 @@ EXPORT_SYMBOL(vzalloc_node);
 
 void *vmalloc_exec(unsigned long size)
 {
-	return __vmalloc(size, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC);
+	return __vmalloc(size, GFP_KERNEL | __GFP_HIGHMEM);
 }
 
 /**
@@ -314,7 +313,7 @@ void *vmalloc_exec(unsigned long size)
  */
 void *vmalloc_32(unsigned long size)
 {
-	return __vmalloc(size, GFP_KERNEL, PAGE_KERNEL);
+	return __vmalloc(size, GFP_KERNEL);
 }
 EXPORT_SYMBOL(vmalloc_32);
 
mm/page_alloc.c renamed from mm/page_alloc.c~mm-remove-the-pgprot-argument-to-__vmalloc +1 -1
@@ -8250,7 +8250,7 @@ void *__init alloc_large_system_hash(con
 				table = memblock_alloc_raw(size,
 							   SMP_CACHE_BYTES);
 		} else if (get_order(size) >= MAX_ORDER || hashdist) {
-			table = __vmalloc(size, gfp_flags, PAGE_KERNEL);
+			table = __vmalloc(size, gfp_flags);
 			virt = true;
 		} else {
 			/*
mm/percpu.c renamed from mm/percpu.c~mm-remove-the-pgprot-argument-to-__vmalloc +1 -1
@@ -482,7 +482,7 @@ static void *pcpu_mem_zalloc(size_t size
 	if (size <= PAGE_SIZE)
 		return kzalloc(size, gfp);
 	else
-		return __vmalloc(size, gfp | __GFP_ZERO, PAGE_KERNEL);
+		return __vmalloc(size, gfp | __GFP_ZERO);
 }
 
 /**
mm/vmalloc.c renamed from mm/vmalloc.c~mm-remove-the-pgprot-argument-to-__vmalloc +2 -2
@@ -2564,9 +2564,9 @@ static void *__vmalloc_node(unsigned lon
 				gfp_mask, prot, 0, node, caller);
 }
 
-void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot)
+void *__vmalloc(unsigned long size, gfp_t gfp_mask)
 {
-	return __vmalloc_node(size, 1, gfp_mask, prot, NUMA_NO_NODE,
+	return __vmalloc_node(size, 1, gfp_mask, PAGE_KERNEL, NUMA_NO_NODE,
 				__builtin_return_address(0));
 }
 EXPORT_SYMBOL(__vmalloc);
net/bridge/netfilter/ebtables.c renamed from net/bridge/netfilter/ebtables.c~mm-remove-the-pgprot-argument-to-__vmalloc +2 -4
@@ -1095,16 +1095,14 @@ static int do_replace(struct net *net, c
 	tmp.name[sizeof(tmp.name) - 1] = 0;
 
 	countersize = COUNTER_OFFSET(tmp.nentries) * nr_cpu_ids;
-	newinfo = __vmalloc(sizeof(*newinfo) + countersize, GFP_KERNEL_ACCOUNT,
-			    PAGE_KERNEL);
+	newinfo = __vmalloc(sizeof(*newinfo) + countersize, GFP_KERNEL_ACCOUNT);
 	if (!newinfo)
 		return -ENOMEM;
 
 	if (countersize)
 		memset(newinfo->counters, 0, countersize);
 
-	newinfo->entries = __vmalloc(tmp.entries_size, GFP_KERNEL_ACCOUNT,
-				     PAGE_KERNEL);
+	newinfo->entries = __vmalloc(tmp.entries_size, GFP_KERNEL_ACCOUNT);
 	if (!newinfo->entries) {
 		ret = -ENOMEM;
 		goto free_newinfo;
sound/core/memalloc.c renamed from sound/core/memalloc.c~mm-remove-the-pgprot-argument-to-__vmalloc +1 -1
@@ -143,7 +143,7 @@ int snd_dma_alloc_pages(int type, struct
 		break;
 	case SNDRV_DMA_TYPE_VMALLOC:
 		gfp = snd_mem_get_gfp_flags(device, GFP_KERNEL | __GFP_HIGHMEM);
-		dmab->area = __vmalloc(size, gfp, PAGE_KERNEL);
+		dmab->area = __vmalloc(size, gfp);
 		dmab->addr = 0;
 		break;
 #ifdef CONFIG_HAS_DMA
sound/core/pcm_memory.c renamed from sound/core/pcm_memory.c~mm-remove-the-pgprot-argument-to-__vmalloc +1 -1
@@ -460,7 +460,7 @@ int _snd_pcm_lib_alloc_vmalloc_buffer(st
 			return 0; /* already large enough */
 		vfree(runtime->dma_area);
 	}
-	runtime->dma_area = __vmalloc(size, gfp_flags, PAGE_KERNEL);
+	runtime->dma_area = __vmalloc(size, gfp_flags);
 	if (!runtime->dma_area)
 		return -ENOMEM;
 	runtime->dma_bytes = size;

_

author maintainer
#112 lore raw

PATCH 110/128 mm: remove the prot argument to __vmalloc_node

In reply to Andrew Morton

From: Christoph Hellwig <[email protected]>
Subject: mm: remove the prot argument to __vmalloc_node

This is always PAGE_KERNEL now.

Cc Christian Borntraeger <[email protected]>
Cc Christophe Leroy <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc David Airlie <[email protected]>
Cc Gao Xiang <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Haiyang Zhang <[email protected]>
Cc Johannes Weiner <[email protected]>
Cc "K. Y. Srinivasan" <[email protected]>
Cc Laura Abbott <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Michael Kelley <[email protected]>
Cc Minchan Kim <[email protected]>
Cc Nitin Gupta <[email protected]>
Cc Robin Murphy <[email protected]>
Cc Sakari Ailus <[email protected]>
Cc Stephen Hemminger <[email protected]>
Cc Sumit Semwal <[email protected]>
Cc Wei Liu <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Heiko Carstens <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Vasily Gorbik <[email protected]>
Cc Will Deacon <[email protected]>

---

 mm/vmalloc.c |   35 ++++++++++++++---------------------
 1 file changed, 14 insertions(+), 21 deletions(-)
mm/vmalloc.c renamed from mm/vmalloc.c~mm-remove-the-prot-argument-to-__vmalloc_node +14 -21
@@ -2402,8 +2402,7 @@ void *vmap(struct page **pages, unsigned
 EXPORT_SYMBOL(vmap);
 
 static void *__vmalloc_node(unsigned long size, unsigned long align,
-			    gfp_t gfp_mask, pgprot_t prot,
-			    int node, const void *caller);
+			    gfp_t gfp_mask, int node, const void *caller);
 static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
 				 pgprot_t prot, int node)
 {
@@ -2421,7 +2420,7 @@ static void *__vmalloc_area_node(struct
 	/* Please note that the recursion is strictly bounded. */
 	if (array_size > PAGE_SIZE) {
 		pages = __vmalloc_node(array_size, 1, nested_gfp|highmem_mask,
-				PAGE_KERNEL, node, area->caller);
+				node, area->caller);
 	} else {
 		pages = kmalloc_node(array_size, nested_gfp, node);
 	}
@@ -2540,13 +2539,11 @@ EXPORT_SYMBOL_GPL(__vmalloc_node_range);
  * @size:	    allocation size
  * @align:	    desired alignment
  * @gfp_mask:	    flags for the page level allocator
- * @prot:	    protection mask for the allocated pages
  * @node:	    node to use for allocation or NUMA_NO_NODE
  * @caller:	    caller's return address
  *
- * Allocate enough pages to cover @size from the page level
- * allocator with @gfp_mask flags.  Map them into contiguous
- * kernel virtual space, using a pagetable protection of @prot.
+ * Allocate enough pages to cover @size from the page level allocator with
+ * @gfp_mask flags.  Map them into contiguous kernel virtual space.
  *
  * Reclaim modifiers in @gfp_mask - __GFP_NORETRY, __GFP_RETRY_MAYFAIL
  * and __GFP_NOFAIL are not supported
@@ -2557,16 +2554,15 @@ EXPORT_SYMBOL_GPL(__vmalloc_node_range);
  * Return: pointer to the allocated memory or %NULL on error
  */
 static void *__vmalloc_node(unsigned long size, unsigned long align,
-			    gfp_t gfp_mask, pgprot_t prot,
-			    int node, const void *caller)
+			    gfp_t gfp_mask, int node, const void *caller)
 {
 	return __vmalloc_node_range(size, align, VMALLOC_START, VMALLOC_END,
-				gfp_mask, prot, 0, node, caller);
+				gfp_mask, PAGE_KERNEL, 0, node, caller);
 }
 
 void *__vmalloc(unsigned long size, gfp_t gfp_mask)
 {
-	return __vmalloc_node(size, 1, gfp_mask, PAGE_KERNEL, NUMA_NO_NODE,
+	return __vmalloc_node(size, 1, gfp_mask, NUMA_NO_NODE,
 				__builtin_return_address(0));
 }
 EXPORT_SYMBOL(__vmalloc);
@@ -2574,15 +2570,15 @@ EXPORT_SYMBOL(__vmalloc);
 static inline void *__vmalloc_node_flags(unsigned long size,
 					int node, gfp_t flags)
 {
-	return __vmalloc_node(size, 1, flags, PAGE_KERNEL,
-					node, __builtin_return_address(0));
+	return __vmalloc_node(size, 1, flags, node,
+				__builtin_return_address(0));
 }
 
 
 void *__vmalloc_node_flags_caller(unsigned long size, int node, gfp_t flags,
 				  void *caller)
 {
-	return __vmalloc_node(size, 1, flags, PAGE_KERNEL, node, caller);
+	return __vmalloc_node(size, 1, flags, node, caller);
 }
 
 /**
@@ -2657,8 +2653,8 @@ EXPORT_SYMBOL(vmalloc_user);
  */
 void *vmalloc_node(unsigned long size, int node)
 {
-	return __vmalloc_node(size, 1, GFP_KERNEL, PAGE_KERNEL,
-					node, __builtin_return_address(0));
+	return __vmalloc_node(size, 1, GFP_KERNEL, node,
+			__builtin_return_address(0));
 }
 EXPORT_SYMBOL(vmalloc_node);
 
@@ -2671,9 +2667,6 @@ EXPORT_SYMBOL(vmalloc_node);
  * allocator and map them into contiguous kernel virtual space.
  * The memory allocated is set to zero.
  *
- * For tight control over page level allocator and protection flags
- * use __vmalloc_node() instead.
- *
  * Return: pointer to the allocated memory or %NULL on error
  */
 void *vzalloc_node(unsigned long size, int node)
@@ -2746,8 +2739,8 @@ void *vmalloc_exec(unsigned long size)
  */
 void *vmalloc_32(unsigned long size)
 {
-	return __vmalloc_node(size, 1, GFP_VMALLOC32, PAGE_KERNEL,
-			      NUMA_NO_NODE, __builtin_return_address(0));
+	return __vmalloc_node(size, 1, GFP_VMALLOC32, NUMA_NO_NODE,
+			__builtin_return_address(0));
 }
 EXPORT_SYMBOL(vmalloc_32);
 

_

author maintainer
#113 lore raw

PATCH 111/128 mm: remove both instances of __vmalloc_node_flags

In reply to Andrew Morton

From: Christoph Hellwig <[email protected]>
Subject: mm: remove both instances of __vmalloc_node_flags

The real version just had a few callers that can open code it and remove one layer of indirection. The nommu stub was public but only had a single caller, so remove it and avoid a CONFIG_MMU ifdef in vmalloc.h.

Cc Christian Borntraeger <[email protected]>
Cc Christophe Leroy <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc David Airlie <[email protected]>
Cc Gao Xiang <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Haiyang Zhang <[email protected]>
Cc Johannes Weiner <[email protected]>
Cc "K. Y. Srinivasan" <[email protected]>
Cc Laura Abbott <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Michael Kelley <[email protected]>
Cc Minchan Kim <[email protected]>
Cc Nitin Gupta <[email protected]>
Cc Robin Murphy <[email protected]>
Cc Sakari Ailus <[email protected]>
Cc Stephen Hemminger <[email protected]>
Cc Sumit Semwal <[email protected]>
Cc Wei Liu <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Heiko Carstens <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Vasily Gorbik <[email protected]>
Cc Will Deacon <[email protected]>

---

 include/linux/vmalloc.h |    9 ---------
 mm/nommu.c              |    3 ++-
 mm/vmalloc.c            |   20 ++++++--------------
 3 files changed, 8 insertions(+), 24 deletions(-)
include/linux/vmalloc.h renamed from include/linux/vmalloc.h~mm-remove-both-instances-of-__vmalloc_node_flags +0 -9
@@ -115,17 +115,8 @@ extern void *__vmalloc_node_range(unsign
 			unsigned long start, unsigned long end, gfp_t gfp_mask,
 			pgprot_t prot, unsigned long vm_flags, int node,
 			const void *caller);
-#ifndef CONFIG_MMU
-extern void *__vmalloc_node_flags(unsigned long size, int node, gfp_t flags);
-static inline void *__vmalloc_node_flags_caller(unsigned long size, int node,
-						gfp_t flags, void *caller)
-{
-	return __vmalloc_node_flags(size, node, flags);
-}
-#else
 extern void *__vmalloc_node_flags_caller(unsigned long size,
 					 int node, gfp_t flags, void *caller);
-#endif
 
 extern void vfree(const void *addr);
 extern void vfree_atomic(const void *addr);
mm/nommu.c renamed from mm/nommu.c~mm-remove-both-instances-of-__vmalloc_node_flags +2 -1
@@ -150,7 +150,8 @@ void *__vmalloc(unsigned long size, gfp_
 }
 EXPORT_SYMBOL(__vmalloc);
 
-void *__vmalloc_node_flags(unsigned long size, int node, gfp_t flags)
+void *__vmalloc_node_flags_caller(unsigned long size, int node, gfp_t flags,
+		void *caller)
 {
 	return __vmalloc(size, flags);
 }
mm/vmalloc.c renamed from mm/vmalloc.c~mm-remove-both-instances-of-__vmalloc_node_flags +6 -14
@@ -2567,14 +2567,6 @@ void *__vmalloc(unsigned long size, gfp_
 }
 EXPORT_SYMBOL(__vmalloc);
 
-static inline void *__vmalloc_node_flags(unsigned long size,
-					int node, gfp_t flags)
-{
-	return __vmalloc_node(size, 1, flags, node,
-				__builtin_return_address(0));
-}
-
-
 void *__vmalloc_node_flags_caller(unsigned long size, int node, gfp_t flags,
 				  void *caller)
 {
@@ -2595,8 +2587,8 @@ void *__vmalloc_node_flags_caller(unsign
  */
 void *vmalloc(unsigned long size)
 {
-	return __vmalloc_node_flags(size, NUMA_NO_NODE,
-				    GFP_KERNEL);
+	return __vmalloc_node(size, 1, GFP_KERNEL, NUMA_NO_NODE,
+				__builtin_return_address(0));
 }
 EXPORT_SYMBOL(vmalloc);
 
@@ -2615,8 +2607,8 @@ EXPORT_SYMBOL(vmalloc);
  */
 void *vzalloc(unsigned long size)
 {
-	return __vmalloc_node_flags(size, NUMA_NO_NODE,
-				GFP_KERNEL | __GFP_ZERO);
+	return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_ZERO, NUMA_NO_NODE,
+				__builtin_return_address(0));
 }
 EXPORT_SYMBOL(vzalloc);
 
@@ -2671,8 +2663,8 @@ EXPORT_SYMBOL(vmalloc_node);
  */
 void *vzalloc_node(unsigned long size, int node)
 {
-	return __vmalloc_node_flags(size, node,
-			 GFP_KERNEL | __GFP_ZERO);
+	return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_ZERO, node,
+				__builtin_return_address(0));
 }
 EXPORT_SYMBOL(vzalloc_node);
 

_

author maintainer
#114 lore raw

PATCH 112/128 mm: remove __vmalloc_node_flags_caller

In reply to Andrew Morton

From: Christoph Hellwig <[email protected]>
Subject: mm: remove __vmalloc_node_flags_caller

Just use __vmalloc_node instead which gets and extra argument. To be able to to use __vmalloc_node in all caller make it available outside of vmalloc and implement it in nommu.c.

[[email protected]: fix nommu build]
Cc Christian Borntraeger <[email protected]>
Cc Christophe Leroy <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc David Airlie <[email protected]>
Cc Gao Xiang <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Haiyang Zhang <[email protected]>
Cc Johannes Weiner <[email protected]>
Cc "K. Y. Srinivasan" <[email protected]>
Cc Laura Abbott <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Michael Kelley <[email protected]>
Cc Minchan Kim <[email protected]>
Cc Nitin Gupta <[email protected]>
Cc Robin Murphy <[email protected]>
Cc Sakari Ailus <[email protected]>
Cc Stephen Hemminger <[email protected]>
Cc Sumit Semwal <[email protected]>
Cc Wei Liu <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Heiko Carstens <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Vasily Gorbik <[email protected]>
Cc Will Deacon <[email protected]>
Cc Stephen Rothwell <[email protected]>

---

 include/linux/vmalloc.h |    4 ++--
 kernel/bpf/syscall.c    |    5 ++---
 mm/nommu.c              |    6 +++---
 mm/util.c               |    2 +-
 mm/vmalloc.c            |   10 +---------
 5 files changed, 9 insertions(+), 18 deletions(-)
include/linux/vmalloc.h renamed from include/linux/vmalloc.h~mm-remove-__vmalloc_node_flags_caller +2 -2
@@ -115,8 +115,8 @@ extern void *__vmalloc_node_range(unsign
 			unsigned long start, unsigned long end, gfp_t gfp_mask,
 			pgprot_t prot, unsigned long vm_flags, int node,
 			const void *caller);
-extern void *__vmalloc_node_flags_caller(unsigned long size,
-					 int node, gfp_t flags, void *caller);
+void *__vmalloc_node(unsigned long size, unsigned long align, gfp_t gfp_mask,
+		int node, const void *caller);
 
 extern void vfree(const void *addr);
 extern void vfree_atomic(const void *addr);
kernel/bpf/syscall.c renamed from kernel/bpf/syscall.c~mm-remove-__vmalloc_node_flags_caller +2 -3
@@ -299,9 +299,8 @@ static void *__bpf_map_area_alloc(u64 si
 		return vmalloc_user_node_flags(size, numa_node, GFP_KERNEL |
 					       __GFP_RETRY_MAYFAIL | flags);
 	}
-	return __vmalloc_node_flags_caller(size, numa_node,
-					   GFP_KERNEL | __GFP_RETRY_MAYFAIL |
-					   flags, __builtin_return_address(0));
+	return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_RETRY_MAYFAIL | flags,
+			      numa_node, __builtin_return_address(0));
 }
 
 void *bpf_map_area_alloc(u64 size, int numa_node)
mm/nommu.c renamed from mm/nommu.c~mm-remove-__vmalloc_node_flags_caller +3 -3
@@ -150,10 +150,10 @@ void *__vmalloc(unsigned long size, gfp_
 }
 EXPORT_SYMBOL(__vmalloc);
 
-void *__vmalloc_node_flags_caller(unsigned long size, int node, gfp_t flags,
-		void *caller)
+void *__vmalloc_node(unsigned long size, unsigned long align, gfp_t gfp_mask,
+		int node, const void *caller)
 {
-	return __vmalloc(size, flags);
+	return __vmalloc(size, gfp_mask);
 }
 
 static void *__vmalloc_user_flags(unsigned long size, gfp_t flags)
mm/util.c renamed from mm/util.c~mm-remove-__vmalloc_node_flags_caller +1 -1
@@ -580,7 +580,7 @@ void *kvmalloc_node(size_t size, gfp_t f
 	if (ret || size <= PAGE_SIZE)
 		return ret;
 
-	return __vmalloc_node_flags_caller(size, node, flags,
+	return __vmalloc_node(size, 1, flags, node,
 			__builtin_return_address(0));
 }
 EXPORT_SYMBOL(kvmalloc_node);
mm/vmalloc.c renamed from mm/vmalloc.c~mm-remove-__vmalloc_node_flags_caller +1 -8
@@ -2401,8 +2401,6 @@ void *vmap(struct page **pages, unsigned
 }
 EXPORT_SYMBOL(vmap);
 
-static void *__vmalloc_node(unsigned long size, unsigned long align,
-			    gfp_t gfp_mask, int node, const void *caller);
 static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
 				 pgprot_t prot, int node)
 {
@@ -2553,7 +2551,7 @@ EXPORT_SYMBOL_GPL(__vmalloc_node_range);
  *
  * Return: pointer to the allocated memory or %NULL on error
  */
-static void *__vmalloc_node(unsigned long size, unsigned long align,
+void *__vmalloc_node(unsigned long size, unsigned long align,
 			    gfp_t gfp_mask, int node, const void *caller)
 {
 	return __vmalloc_node_range(size, align, VMALLOC_START, VMALLOC_END,
@@ -2567,12 +2565,6 @@ void *__vmalloc(unsigned long size, gfp_
 }
 EXPORT_SYMBOL(__vmalloc);
 
-void *__vmalloc_node_flags_caller(unsigned long size, int node, gfp_t flags,
-				  void *caller)
-{
-	return __vmalloc_node(size, 1, flags, node, caller);
-}
author maintainer
#115 lore raw

PATCH 113/128 mm: switch the test_vmalloc module to use __vmalloc_node

In reply to Andrew Morton

From: Christoph Hellwig <[email protected]>
Subject: mm: switch the test_vmalloc module to use __vmalloc_node

No need to export the very low-level __vmalloc_node_range when the test module can use a slightly higher level variant.

[[email protected]: add missing `node' arg]
[[email protected]: fix riscv nommu build]
Cc Christian Borntraeger <[email protected]>
Cc Christophe Leroy <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc David Airlie <[email protected]>
Cc Gao Xiang <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Haiyang Zhang <[email protected]>
Cc Johannes Weiner <[email protected]>
Cc "K. Y. Srinivasan" <[email protected]>
Cc Laura Abbott <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Michael Kelley <[email protected]>
Cc Minchan Kim <[email protected]>
Cc Nitin Gupta <[email protected]>
Cc Robin Murphy <[email protected]>
Cc Sakari Ailus <[email protected]>
Cc Stephen Hemminger <[email protected]>
Cc Sumit Semwal <[email protected]>
Cc Wei Liu <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Heiko Carstens <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Vasily Gorbik <[email protected]>
Cc Will Deacon <[email protected]>

---

 arch/riscv/include/asm/pgtable.h |    4 ++--
 lib/test_vmalloc.c               |   26 +++++++-------------------
 mm/vmalloc.c                     |   17 ++++++++---------
 3 files changed, 17 insertions(+), 30 deletions(-)
arch/riscv/include/asm/pgtable.h renamed from arch/riscv/include/asm/pgtable.h~mm-switch-the-test_vmalloc-module-to-use-__vmalloc_node +2 -2
@@ -473,9 +473,9 @@ static inline int ptep_clear_flush_young
 #define PAGE_SHARED		__pgprot(0)
 #define PAGE_KERNEL		__pgprot(0)
 #define swapper_pg_dir		NULL
+#define TASK_SIZE		0xffffffffUL
 #define VMALLOC_START		0
-
-#define TASK_SIZE 0xffffffffUL
+#define VMALLOC_END		TASK_SIZE
 
 static inline void __kernel_map_pages(struct page *page, int numpages, int enable) {}
 
lib/test_vmalloc.c renamed from lib/test_vmalloc.c~mm-switch-the-test_vmalloc-module-to-use-__vmalloc_node +7 -19
@@ -91,12 +91,8 @@ static int random_size_align_alloc_test(
 		 */
 		size = ((rnd % 10) + 1) * PAGE_SIZE;
 
-		ptr = __vmalloc_node_range(size, align,
-		   VMALLOC_START, VMALLOC_END,
-		   GFP_KERNEL | __GFP_ZERO,
-		   PAGE_KERNEL,
-		   0, 0, __builtin_return_address(0));
-
+		ptr = __vmalloc_node(size, align, GFP_KERNEL | __GFP_ZERO, 0,
+				__builtin_return_address(0));
 		if (!ptr)
 			return -1;
 
@@ -118,12 +114,8 @@ static int align_shift_alloc_test(void)
 	for (i = 0; i < BITS_PER_LONG; i++) {
 		align = ((unsigned long) 1) << i;
 
-		ptr = __vmalloc_node_range(PAGE_SIZE, align,
-			VMALLOC_START, VMALLOC_END,
-			GFP_KERNEL | __GFP_ZERO,
-			PAGE_KERNEL,
-			0, 0, __builtin_return_address(0));
-
+		ptr = __vmalloc_node(PAGE_SIZE, align, GFP_KERNEL|__GFP_ZERO, 0,
+				__builtin_return_address(0));
 		if (!ptr)
 			return -1;
 
@@ -139,13 +131,9 @@ static int fix_align_alloc_test(void)
 	int i;
 
 	for (i = 0; i < test_loop_count; i++) {
-		ptr = __vmalloc_node_range(5 * PAGE_SIZE,
-			THREAD_ALIGN << 1,
-			VMALLOC_START, VMALLOC_END,
-			GFP_KERNEL | __GFP_ZERO,
-			PAGE_KERNEL,
-			0, 0, __builtin_return_address(0));
-
+		ptr = __vmalloc_node(5 * PAGE_SIZE, THREAD_ALIGN << 1,
+				GFP_KERNEL | __GFP_ZERO, 0,
+				__builtin_return_address(0));
 		if (!ptr)
 			return -1;
 
mm/vmalloc.c renamed from mm/vmalloc.c~mm-switch-the-test_vmalloc-module-to-use-__vmalloc_node +0 -8
@@ -2523,15 +2523,6 @@ fail:
 	return NULL;
 }
 
-/*
- * This is only for performance analysis of vmalloc and stress purpose.
- * It is required by vmalloc test module, therefore do not use it other
- * than that.
- */
-#ifdef CONFIG_TEST_VMALLOC_MODULE
-EXPORT_SYMBOL_GPL(__vmalloc_node_range);
-#endif
author maintainer
#116 lore raw

PATCH 114/128 mm: remove vmalloc_user_node_flags

In reply to Andrew Morton

From: Christoph Hellwig <[email protected]>
Subject: mm: remove vmalloc_user_node_flags

Open code it in __bpf_map_area_alloc, which is the only caller. Also clean up __bpf_map_area_alloc to have a single vmalloc call with slightly different flags instead of the current two different calls.

For this to compile for the nommu case add a __vmalloc_node_range stub to nommu.c.

[[email protected]: fix nommu.c build]
Cc Christian Borntraeger <[email protected]>
Cc Christophe Leroy <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc David Airlie <[email protected]>
Cc Gao Xiang <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Haiyang Zhang <[email protected]>
Cc "K. Y. Srinivasan" <[email protected]>
Cc Laura Abbott <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Michael Kelley <[email protected]>
Cc Minchan Kim <[email protected]>
Cc Nitin Gupta <[email protected]>
Cc Robin Murphy <[email protected]>
Cc Sakari Ailus <[email protected]>
Cc Stephen Hemminger <[email protected]>
Cc Sumit Semwal <[email protected]>
Cc Wei Liu <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Heiko Carstens <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Vasily Gorbik <[email protected]>
Cc Will Deacon <[email protected]>
Cc Stephen Rothwell <[email protected]>

---

 include/linux/vmalloc.h |    1 -
 kernel/bpf/syscall.c    |   24 ++++++++++++++----------
 mm/nommu.c              |   14 ++++++++------
 mm/vmalloc.c            |   20 --------------------
 4 files changed, 22 insertions(+), 37 deletions(-)
include/linux/vmalloc.h renamed from include/linux/vmalloc.h~mm-remove-vmalloc_user_node_flags +0 -1
@@ -106,7 +106,6 @@ extern void *vzalloc(unsigned long size)
 extern void *vmalloc_user(unsigned long size);
 extern void *vmalloc_node(unsigned long size, int node);
 extern void *vzalloc_node(unsigned long size, int node);
-extern void *vmalloc_user_node_flags(unsigned long size, int node, gfp_t flags);
 extern void *vmalloc_exec(unsigned long size);
 extern void *vmalloc_32(unsigned long size);
 extern void *vmalloc_32_user(unsigned long size);
kernel/bpf/syscall.c renamed from kernel/bpf/syscall.c~mm-remove-vmalloc_user_node_flags +14 -10
@@ -25,6 +25,7 @@
 #include <linux/nospec.h>
 #include <linux/audit.h>
 #include <uapi/linux/btf.h>
+#include <asm/pgtable.h>
 #include <linux/bpf_lsm.h>
 
 #define IS_FD_ARRAY(map) ((map)->map_type == BPF_MAP_TYPE_PERF_EVENT_ARRAY || \
@@ -281,26 +282,29 @@ static void *__bpf_map_area_alloc(u64 si
 	 * __GFP_RETRY_MAYFAIL to avoid such situations.
 	 */
 
-	const gfp_t flags = __GFP_NOWARN | __GFP_ZERO;
+	const gfp_t gfp = __GFP_NOWARN | __GFP_ZERO;
+	unsigned int flags = 0;
+	unsigned long align = 1;
 	void *area;
 
 	if (size >= SIZE_MAX)
 		return NULL;
 
 	/* kmalloc()'ed memory can't be mmap()'ed */
-	if (!mmapable && size <= (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER)) {
-		area = kmalloc_node(size, GFP_USER | __GFP_NORETRY | flags,
+	if (mmapable) {
+		BUG_ON(!PAGE_ALIGNED(size));
+		align = SHMLBA;
+		flags = VM_USERMAP;
+	} else if (size <= (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER)) {
+		area = kmalloc_node(size, gfp | GFP_USER | __GFP_NORETRY,
 				    numa_node);
 		if (area != NULL)
 			return area;
 	}
-	if (mmapable) {
-		BUG_ON(!PAGE_ALIGNED(size));
-		return vmalloc_user_node_flags(size, numa_node, GFP_KERNEL |
-					       __GFP_RETRY_MAYFAIL | flags);
-	}
-	return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_RETRY_MAYFAIL | flags,
-			      numa_node, __builtin_return_address(0));
+
+	return __vmalloc_node_range(size, align, VMALLOC_START, VMALLOC_END,
+			gfp | GFP_KERNEL | __GFP_RETRY_MAYFAIL, PAGE_KERNEL,
+			flags, numa_node, __builtin_return_address(0));
 }
 
 void *bpf_map_area_alloc(u64 size, int numa_node)
mm/nommu.c renamed from mm/nommu.c~mm-remove-vmalloc_user_node_flags +8 -6
@@ -150,6 +150,14 @@ void *__vmalloc(unsigned long size, gfp_
 }
 EXPORT_SYMBOL(__vmalloc);
 
+void *__vmalloc_node_range(unsigned long size, unsigned long align,
+		unsigned long start, unsigned long end, gfp_t gfp_mask,
+		pgprot_t prot, unsigned long vm_flags, int node,
+		const void *caller)
+{
+	return __vmalloc(size, gfp_mask);
+}
+
 void *__vmalloc_node(unsigned long size, unsigned long align, gfp_t gfp_mask,
 		int node, const void *caller)
 {
@@ -180,12 +188,6 @@ void *vmalloc_user(unsigned long size)
 }
 EXPORT_SYMBOL(vmalloc_user);
 
-void *vmalloc_user_node_flags(unsigned long size, int node, gfp_t flags)
-{
-	return __vmalloc_user_flags(size, flags | __GFP_ZERO);
-}
-EXPORT_SYMBOL(vmalloc_user_node_flags);
-
 struct page *vmalloc_to_page(const void *addr)
 {
 	return virt_to_page(addr);
mm/vmalloc.c renamed from mm/vmalloc.c~mm-remove-vmalloc_user_node_flags +0 -18
@@ -2660,26 +2660,6 @@ void *vzalloc_node(unsigned long size, i
 EXPORT_SYMBOL(vzalloc_node);
 
 /**
- * vmalloc_user_node_flags - allocate memory for userspace on a specific node
- * @size: allocation size
- * @node: numa node
- * @flags: flags for the page level allocator
- *
- * The resulting memory area is zeroed so it can be mapped to userspace
- * without leaking data.
- *
- * Return: pointer to the allocated memory or %NULL on error
- */
-void *vmalloc_user_node_flags(unsigned long size, int node, gfp_t flags)
-{
-	return __vmalloc_node_range(size, SHMLBA,  VMALLOC_START, VMALLOC_END,
-				    flags | __GFP_ZERO, PAGE_KERNEL,
-				    VM_USERMAP, node,
-				    __builtin_return_address(0));
-}
-EXPORT_SYMBOL(vmalloc_user_node_flags);
author maintainer
#117 lore raw

PATCH 115/128 arm64: use __vmalloc_node in arch_alloc_vmap_stack

In reply to Andrew Morton

From: Christoph Hellwig <[email protected]>
Subject: arm64: use __vmalloc_node in arch_alloc_vmap_stack

arch_alloc_vmap_stack can use a slightly higher level vmalloc function.

Cc Christian Borntraeger <[email protected]>
Cc Christophe Leroy <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc David Airlie <[email protected]>
Cc Gao Xiang <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Haiyang Zhang <[email protected]>
Cc Johannes Weiner <[email protected]>
Cc "K. Y. Srinivasan" <[email protected]>
Cc Laura Abbott <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Michael Kelley <[email protected]>
Cc Minchan Kim <[email protected]>
Cc Nitin Gupta <[email protected]>
Cc Robin Murphy <[email protected]>
Cc Sakari Ailus <[email protected]>
Cc Stephen Hemminger <[email protected]>
Cc Sumit Semwal <[email protected]>
Cc Wei Liu <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Heiko Carstens <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Vasily Gorbik <[email protected]>
Cc Will Deacon <[email protected]>

---

 arch/arm64/include/asm/vmap_stack.h |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
arch/arm64/include/asm/vmap_stack.h renamed from arch/arm64/include/asm/vmap_stack.h~arm64-use-__vmalloc_node-in-arch_alloc_vmap_stack +2 -4
@@ -19,10 +19,8 @@ static inline unsigned long *arch_alloc_
 {
 	BUILD_BUG_ON(!IS_ENABLED(CONFIG_VMAP_STACK));
 
-	return __vmalloc_node_range(stack_size, THREAD_ALIGN,
-				    VMALLOC_START, VMALLOC_END,
-				    THREADINFO_GFP, PAGE_KERNEL, 0, node,
-				    __builtin_return_address(0));
+	return __vmalloc_node(stack_size, THREAD_ALIGN, THREADINFO_GFP, node,
+			__builtin_return_address(0));
 }
 
 #endif /* __ASM_VMAP_STACK_H */

_

author maintainer
#118 lore raw

PATCH 116/128 powerpc: use __vmalloc_node in alloc_vm_stack

In reply to Andrew Morton

From: Christoph Hellwig <[email protected]>
Subject: powerpc: use __vmalloc_node in alloc_vm_stack

alloc_vm_stack can use a slightly higher level vmalloc function.

Cc Christian Borntraeger <[email protected]>
Cc Christophe Leroy <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc David Airlie <[email protected]>
Cc Gao Xiang <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Haiyang Zhang <[email protected]>
Cc Johannes Weiner <[email protected]>
Cc "K. Y. Srinivasan" <[email protected]>
Cc Laura Abbott <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Michael Kelley <[email protected]>
Cc Minchan Kim <[email protected]>
Cc Nitin Gupta <[email protected]>
Cc Robin Murphy <[email protected]>
Cc Sakari Ailus <[email protected]>
Cc Stephen Hemminger <[email protected]>
Cc Sumit Semwal <[email protected]>
Cc Wei Liu <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Heiko Carstens <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Vasily Gorbik <[email protected]>
Cc Will Deacon <[email protected]>

---

 arch/powerpc/kernel/irq.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
arch/powerpc/kernel/irq.c renamed from arch/powerpc/kernel/irq.c~powerpc-use-__vmalloc_node-in-alloc_vm_stack +2 -3
@@ -748,9 +748,8 @@ void do_IRQ(struct pt_regs *regs)
 
 static void *__init alloc_vm_stack(void)
 {
-	return __vmalloc_node_range(THREAD_SIZE, THREAD_ALIGN, VMALLOC_START,
-				    VMALLOC_END, THREADINFO_GFP, PAGE_KERNEL,
-				     0, NUMA_NO_NODE, (void*)_RET_IP_);
+	return __vmalloc_node(THREAD_SIZE, THREAD_ALIGN, THREADINFO_GFP,
+			      NUMA_NO_NODE, (void *)_RET_IP_);
 }
 
 static void __init vmap_irqstack_init(void)

_

author maintainer
#119 lore raw

PATCH 117/128 s390: use __vmalloc_node in stack_alloc

In reply to Andrew Morton

From: Christoph Hellwig <[email protected]>
Subject: s390: use __vmalloc_node in stack_alloc

stack_alloc can use a slightly higher level vmalloc function.

Cc "K. Y. Srinivasan" <[email protected]>
Cc Haiyang Zhang <[email protected]>
Cc Stephen Hemminger <[email protected]>
Cc Wei Liu <[email protected]>
Cc David Airlie <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Laura Abbott <[email protected]>
Cc Sumit Semwal <[email protected]>
Cc Sakari Ailus <[email protected]>
Cc Minchan Kim <[email protected]>
Cc Nitin Gupta <[email protected]>
Cc Robin Murphy <[email protected]>
Cc Christophe Leroy <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Gao Xiang <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Johannes Weiner <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Michael Kelley <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Heiko Carstens <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Vasily Gorbik <[email protected]>
Cc Will Deacon <[email protected]>

---

 arch/s390/kernel/setup.c |    9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
arch/s390/kernel/setup.c renamed from arch/s390/kernel/setup.c~s390-use-__vmalloc_node-in-stack_alloc +3 -6
@@ -305,12 +305,9 @@ void *restart_stack __section(.data);
 unsigned long stack_alloc(void)
 {
 #ifdef CONFIG_VMAP_STACK
-	return (unsigned long)
-		__vmalloc_node_range(THREAD_SIZE, THREAD_SIZE,
-				     VMALLOC_START, VMALLOC_END,
-				     THREADINFO_GFP,
-				     PAGE_KERNEL, 0, NUMA_NO_NODE,
-				     __builtin_return_address(0));
+	return (unsigned long)__vmalloc_node(THREAD_SIZE, THREAD_SIZE,
+			THREADINFO_GFP, NUMA_NO_NODE,
+			__builtin_return_address(0));
 #else
 	return __get_free_pages(GFP_KERNEL, THREAD_SIZE_ORDER);
 #endif

_

author maintainer
#120 lore raw

PATCH 118/128 mm: add functions to track page directory modifications

In reply to Andrew Morton

From: Joerg Roedel <[email protected]>
Subject: mm: add functions to track page directory modifications

Patch series "mm: Get rid of vmalloc_sync_(un)mappings()", v3.

After the recent issue with vmalloc and tracing code[1] on x86 and a long history of previous issues related to the vmalloc_sync_mappings() interface, I thought the time has come to remove it. Please see [2], [3], and [4] for some other issues in the past.

The patches add tracking of page-table directory changes to the vmalloc and ioremap code. Depending on which page-table levels changes have been made, a new per-arch function is called: arch_sync_kernel_mappings().

On x86-64 with 4-level paging, this function will not be called more than 64 times in a systems runtime (because vmalloc-space takes 64 PGD entries which are only populated, but never cleared).

As a side effect this also allows to get rid of vmalloc faults on x86, making it safe to touch vmalloc'ed memory in the page-fault handler. Note that this potentially includes per-cpu memory.

This patch (of 7):

Add page-table allocation functions which will keep track of changed directory entries. They are needed for new PGD, P4D, PUD, and PMD entries and will be used in vmalloc and ioremap code to decide whether any changes in the kernel mappings need to be synchronized between page-tables in the system.

Cc "H . Peter Anvin" <[email protected]>
Cc Dave Hansen <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Steven Rostedt (VMware) <[email protected]>
Cc Vlastimil Babka <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Matthew Wilcox (Oracle) <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Christoph Hellwig <[email protected]>

---

 include/asm-generic/5level-fixup.h |    5 +-
 include/asm-generic/pgtable.h      |   23 +++++++++++++
 include/linux/mm.h                 |   46 +++++++++++++++++++++++++++
 3 files changed, 72 insertions(+), 2 deletions(-)
include/asm-generic/5level-fixup.h renamed from include/asm-generic/5level-fixup.h~mm-add-functions-to-track-page-directory-modifications +3 -2
@@ -17,8 +17,9 @@
 	((unlikely(pgd_none(*(p4d))) && __pud_alloc(mm, p4d, address)) ? \
 		NULL : pud_offset(p4d, address))
 
-#define p4d_alloc(mm, pgd, address)	(pgd)
-#define p4d_offset(pgd, start)		(pgd)
+#define p4d_alloc(mm, pgd, address)		(pgd)
+#define p4d_alloc_track(mm, pgd, address, mask)	(pgd)
+#define p4d_offset(pgd, start)			(pgd)
 
 #ifndef __ASSEMBLY__
 static inline int p4d_none(p4d_t p4d)
include/asm-generic/pgtable.h renamed from include/asm-generic/pgtable.h~mm-add-functions-to-track-page-directory-modifications +23 -0
@@ -1213,6 +1213,29 @@ static inline bool arch_has_pfn_modify_c
 # define PAGE_KERNEL_EXEC PAGE_KERNEL
 #endif
 
+/*
+ * Page Table Modification bits for pgtbl_mod_mask.
+ *
+ * These are used by the p?d_alloc_track*() set of functions an in the generic
+ * vmalloc/ioremap code to track at which page-table levels entries have been
+ * modified. Based on that the code can better decide when vmalloc and ioremap
+ * mapping changes need to be synchronized to other page-tables in the system.
+ */
+#define		__PGTBL_PGD_MODIFIED	0
+#define		__PGTBL_P4D_MODIFIED	1
+#define		__PGTBL_PUD_MODIFIED	2
+#define		__PGTBL_PMD_MODIFIED	3
+#define		__PGTBL_PTE_MODIFIED	4
+
+#define		PGTBL_PGD_MODIFIED	BIT(__PGTBL_PGD_MODIFIED)
+#define		PGTBL_P4D_MODIFIED	BIT(__PGTBL_P4D_MODIFIED)
+#define		PGTBL_PUD_MODIFIED	BIT(__PGTBL_PUD_MODIFIED)
+#define		PGTBL_PMD_MODIFIED	BIT(__PGTBL_PMD_MODIFIED)
+#define		PGTBL_PTE_MODIFIED	BIT(__PGTBL_PTE_MODIFIED)
+
+/* Page-Table Modification Mask */
+typedef unsigned int pgtbl_mod_mask;
+
 #endif /* !__ASSEMBLY__ */
 
 #ifndef io_remap_pfn_range
include/linux/mm.h renamed from include/linux/mm.h~mm-add-functions-to-track-page-directory-modifications +46 -0

65 lines not on this page · raw message

_

author maintainer
#121 lore raw

PATCH 119/128 mm/vmalloc: track which page-table levels were modified

In reply to Andrew Morton

From: Joerg Roedel <[email protected]>
Subject: mm/vmalloc: track which page-table levels were modified

Track at which levels in the page-table entries were modified by vmap/vunmap. After the page-table has been modified, use that information do decide whether the new arch_sync_kernel_mappings() needs to be called.

[[email protected]: map_kernel_range_noflush() needs the arch_sync_kernel_mappings() call]
Cc Arnd Bergmann <[email protected]>
Cc Christoph Hellwig <[email protected]>
Cc Dave Hansen <[email protected]>
Cc "H . Peter Anvin" <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Matthew Wilcox (Oracle) <[email protected]>
Cc Michal Hocko <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
Cc Steven Rostedt (VMware) <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Vlastimil Babka <[email protected]>

---

 include/linux/vmalloc.h |   16 ++++++
 mm/vmalloc.c            |   95 +++++++++++++++++++++++++++-----------
 2 files changed, 85 insertions(+), 26 deletions(-)
include/linux/vmalloc.h renamed from include/linux/vmalloc.h~mm-vmalloc-track-which-page-table-levels-were-modified +16 -0
@@ -134,6 +134,22 @@ void vmalloc_sync_mappings(void);
 void vmalloc_sync_unmappings(void);
 
 /*
+ * Architectures can set this mask to a combination of PGTBL_P?D_MODIFIED values
+ * and let generic vmalloc and ioremap code know when arch_sync_kernel_mappings()
+ * needs to be called.
+ */
+#ifndef ARCH_PAGE_TABLE_SYNC_MASK
+#define ARCH_PAGE_TABLE_SYNC_MASK 0
+#endif
+
+/*
+ * There is no default implementation for arch_sync_kernel_mappings(). It is
+ * relied upon the compiler to optimize calls out if ARCH_PAGE_TABLE_SYNC_MASK
+ * is 0.
+ */
+void arch_sync_kernel_mappings(unsigned long start, unsigned long end);
+
+/*
  *	Lowlevel-APIs (not for driver use!)
  */
 
mm/vmalloc.c renamed from mm/vmalloc.c~mm-vmalloc-track-which-page-table-levels-were-modified +69 -26

242 lines not on this page · raw message

_

author maintainer
#122 lore raw

PATCH 120/128 mm/ioremap: track which page-table levels were modified

In reply to Andrew Morton

From: Joerg Roedel <[email protected]>
Subject: mm/ioremap: track which page-table levels were modified

Track at which levels in the page-table entries were modified by ioremap_page_range(). After the page-table has been modified, use that information do decide whether the new arch_sync_kernel_mappings() needs to be called. The iounmap path re-uses vunmap(), which has already been taken care of.

Cc Arnd Bergmann <[email protected]>
Cc Christoph Hellwig <[email protected]>
Cc Dave Hansen <[email protected]>
Cc "H . Peter Anvin" <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Matthew Wilcox (Oracle) <[email protected]>
Cc Michal Hocko <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
Cc Steven Rostedt (VMware) <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Vlastimil Babka <[email protected]>

---

 lib/ioremap.c |   46 +++++++++++++++++++++++++++++++---------------
 1 file changed, 31 insertions(+), 15 deletions(-)
lib/ioremap.c renamed from lib/ioremap.c~mm-ioremap-track-which-page-table-levels-were-modified +31 -15
@@ -61,13 +61,14 @@ static inline int ioremap_pmd_enabled(vo
 #endif	/* CONFIG_HAVE_ARCH_HUGE_VMAP */
 
 static int ioremap_pte_range(pmd_t *pmd, unsigned long addr,
-		unsigned long end, phys_addr_t phys_addr, pgprot_t prot)
+		unsigned long end, phys_addr_t phys_addr, pgprot_t prot,
+		pgtbl_mod_mask *mask)
 {
 	pte_t *pte;
 	u64 pfn;
 
 	pfn = phys_addr >> PAGE_SHIFT;
-	pte = pte_alloc_kernel(pmd, addr);
+	pte = pte_alloc_kernel_track(pmd, addr, mask);
 	if (!pte)
 		return -ENOMEM;
 	do {
@@ -75,6 +76,7 @@ static int ioremap_pte_range(pmd_t *pmd,
 		set_pte_at(&init_mm, addr, pte, pfn_pte(pfn, prot));
 		pfn++;
 	} while (pte++, addr += PAGE_SIZE, addr != end);
+	*mask |= PGTBL_PTE_MODIFIED;
 	return 0;
 }
 
@@ -101,21 +103,24 @@ static int ioremap_try_huge_pmd(pmd_t *p
 }
 
 static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
-		unsigned long end, phys_addr_t phys_addr, pgprot_t prot)
+		unsigned long end, phys_addr_t phys_addr, pgprot_t prot,
+		pgtbl_mod_mask *mask)
 {
 	pmd_t *pmd;
 	unsigned long next;
 
-	pmd = pmd_alloc(&init_mm, pud, addr);
+	pmd = pmd_alloc_track(&init_mm, pud, addr, mask);
 	if (!pmd)
 		return -ENOMEM;
 	do {
 		next = pmd_addr_end(addr, end);
 
-		if (ioremap_try_huge_pmd(pmd, addr, next, phys_addr, prot))
+		if (ioremap_try_huge_pmd(pmd, addr, next, phys_addr, prot)) {
+			*mask |= PGTBL_PMD_MODIFIED;
 			continue;
+		}
 
-		if (ioremap_pte_range(pmd, addr, next, phys_addr, prot))
+		if (ioremap_pte_range(pmd, addr, next, phys_addr, prot, mask))
 			return -ENOMEM;
 	} while (pmd++, phys_addr += (next - addr), addr = next, addr != end);
 	return 0;
@@ -144,21 +149,24 @@ static int ioremap_try_huge_pud(pud_t *p
 }
 
 static inline int ioremap_pud_range(p4d_t *p4d, unsigned long addr,
-		unsigned long end, phys_addr_t phys_addr, pgprot_t prot)
+		unsigned long end, phys_addr_t phys_addr, pgprot_t prot,
+		pgtbl_mod_mask *mask)
 {
 	pud_t *pud;
 	unsigned long next;
 
-	pud = pud_alloc(&init_mm, p4d, addr);
+	pud = pud_alloc_track(&init_mm, p4d, addr, mask);
 	if (!pud)
 		return -ENOMEM;
 	do {
 		next = pud_addr_end(addr, end);
 
-		if (ioremap_try_huge_pud(pud, addr, next, phys_addr, prot))
+		if (ioremap_try_huge_pud(pud, addr, next, phys_addr, prot)) {
+			*mask |= PGTBL_PUD_MODIFIED;
 			continue;
+		}
 
-		if (ioremap_pmd_range(pud, addr, next, phys_addr, prot))
+		if (ioremap_pmd_range(pud, addr, next, phys_addr, prot, mask))
 			return -ENOMEM;
 	} while (pud++, phys_addr += (next - addr), addr = next, addr != end);
 	return 0;
@@ -187,21 +195,24 @@ static int ioremap_try_huge_p4d(p4d_t *p
 }
 
 static inline int ioremap_p4d_range(pgd_t *pgd, unsigned long addr,
-		unsigned long end, phys_addr_t phys_addr, pgprot_t prot)
+		unsigned long end, phys_addr_t phys_addr, pgprot_t prot,
+		pgtbl_mod_mask *mask)
 {
 	p4d_t *p4d;
 	unsigned long next;
 
-	p4d = p4d_alloc(&init_mm, pgd, addr);
+	p4d = p4d_alloc_track(&init_mm, pgd, addr, mask);
 	if (!p4d)
 		return -ENOMEM;
 	do {
 		next = p4d_addr_end(addr, end);
 
-		if (ioremap_try_huge_p4d(p4d, addr, next, phys_addr, prot))
+		if (ioremap_try_huge_p4d(p4d, addr, next, phys_addr, prot)) {
+			*mask |= PGTBL_P4D_MODIFIED;
 			continue;
+		}
 
-		if (ioremap_pud_range(p4d, addr, next, phys_addr, prot))
+		if (ioremap_pud_range(p4d, addr, next, phys_addr, prot, mask))
 			return -ENOMEM;
 	} while (p4d++, phys_addr += (next - addr), addr = next, addr != end);
 	return 0;
@@ -214,6 +225,7 @@ int ioremap_page_range(unsigned long add
 	unsigned long start;
 	unsigned long next;
 	int err;
+	pgtbl_mod_mask mask = 0;
 
 	might_sleep();
 	BUG_ON(addr >= end);
@@ -222,13 +234,17 @@ int ioremap_page_range(unsigned long add
 	pgd = pgd_offset_k(addr);
 	do {
 		next = pgd_addr_end(addr, end);
-		err = ioremap_p4d_range(pgd, addr, next, phys_addr, prot);
+		err = ioremap_p4d_range(pgd, addr, next, phys_addr, prot,
+					&mask);
 		if (err)
 			break;
 	} while (pgd++, phys_addr += (next - addr), addr = next, addr != end);
 
 	flush_cache_vmap(start, end);
 
+	if (mask & ARCH_PAGE_TABLE_SYNC_MASK)
+		arch_sync_kernel_mappings(start, end);
+
 	return err;
 }
 

_

author maintainer
#123 lore raw

PATCH 121/128 x86/mm/64: implement arch_sync_kernel_mappings()

In reply to Andrew Morton

From: Joerg Roedel <[email protected]>
Subject: x86/mm/64: implement arch_sync_kernel_mappings()

Implement the function to sync changes in vmalloc and ioremap ranges to all page-tables.

Cc Arnd Bergmann <[email protected]>
Cc Christoph Hellwig <[email protected]>
Cc Dave Hansen <[email protected]>
Cc "H . Peter Anvin" <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Matthew Wilcox (Oracle) <[email protected]>
Cc Michal Hocko <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
Cc Steven Rostedt (VMware) <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Vlastimil Babka <[email protected]>

---

 arch/x86/include/asm/pgtable_64_types.h |    2 ++
 arch/x86/mm/init_64.c                   |    5 +++++
 2 files changed, 7 insertions(+)
arch/x86/include/asm/pgtable_64_types.h renamed from arch/x86/include/asm/pgtable_64_types.h~x86-mm-64-implement-arch_sync_kernel_mappings +2 -0
@@ -159,4 +159,6 @@ extern unsigned int ptrs_per_p4d;
 
 #define PGD_KERNEL_START	((PAGE_SIZE / 2) / sizeof(pgd_t))
 
+#define ARCH_PAGE_TABLE_SYNC_MASK	(pgtable_l5_enabled() ?	PGTBL_PGD_MODIFIED : PGTBL_P4D_MODIFIED)
+
 #endif /* _ASM_X86_PGTABLE_64_DEFS_H */
arch/x86/mm/init_64.c renamed from arch/x86/mm/init_64.c~x86-mm-64-implement-arch_sync_kernel_mappings +5 -0
@@ -218,6 +218,11 @@ void sync_global_pgds(unsigned long star
 		sync_global_pgds_l4(start, end);
 }
 
+void arch_sync_kernel_mappings(unsigned long start, unsigned long end)
+{
+	sync_global_pgds(start, end);
+}
+
 /*
  * NOTE: This function is marked __ref because it calls __init function
  * (alloc_bootmem_pages). It's safe to do it ONLY when after_bootmem == 0.

_

author maintainer
#124 lore raw

PATCH 122/128 x86/mm/32: implement arch_sync_kernel_mappings()

In reply to Andrew Morton

From: Joerg Roedel <[email protected]>
Subject: x86/mm/32: implement arch_sync_kernel_mappings()

Implement the function to sync changes in vmalloc and ioremap ranges to all page-tables.

Cc Arnd Bergmann <[email protected]>
Cc Christoph Hellwig <[email protected]>
Cc Dave Hansen <[email protected]>
Cc "H . Peter Anvin" <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Matthew Wilcox (Oracle) <[email protected]>
Cc Michal Hocko <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
Cc Steven Rostedt (VMware) <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Vlastimil Babka <[email protected]>

---

 arch/x86/include/asm/pgtable-2level_types.h |    2 +
 arch/x86/include/asm/pgtable-3level_types.h |    2 +
 arch/x86/mm/fault.c                         |   25 +++++++++++-------
 3 files changed, 20 insertions(+), 9 deletions(-)
arch/x86/include/asm/pgtable-2level_types.h renamed from arch/x86/include/asm/pgtable-2level_types.h~x86-mm-32-implement-arch_sync_kernel_mappings +2 -0
@@ -20,6 +20,8 @@ typedef union {
 
 #define SHARED_KERNEL_PMD	0
 
+#define ARCH_PAGE_TABLE_SYNC_MASK	PGTBL_PMD_MODIFIED
+
 /*
  * traditional i386 two-level paging structure:
  */
arch/x86/include/asm/pgtable-3level_types.h renamed from arch/x86/include/asm/pgtable-3level_types.h~x86-mm-32-implement-arch_sync_kernel_mappings +2 -0
@@ -27,6 +27,8 @@ typedef union {
 #define SHARED_KERNEL_PMD	(!static_cpu_has(X86_FEATURE_PTI))
 #endif
 
+#define ARCH_PAGE_TABLE_SYNC_MASK	(SHARED_KERNEL_PMD ? 0 : PGTBL_PMD_MODIFIED)
+
 /*
  * PGDIR_SHIFT determines what a top-level page table entry can map
  */
arch/x86/mm/fault.c renamed from arch/x86/mm/fault.c~x86-mm-32-implement-arch_sync_kernel_mappings +16 -9
@@ -190,16 +190,13 @@ static inline pmd_t *vmalloc_sync_one(pg
 	return pmd_k;
 }
 
-static void vmalloc_sync(void)
+void arch_sync_kernel_mappings(unsigned long start, unsigned long end)
 {
-	unsigned long address;
+	unsigned long addr;
 
-	if (SHARED_KERNEL_PMD)
-		return;
-
-	for (address = VMALLOC_START & PMD_MASK;
-	     address >= TASK_SIZE_MAX && address < VMALLOC_END;
-	     address += PMD_SIZE) {
+	for (addr = start & PMD_MASK;
+	     addr >= TASK_SIZE_MAX && addr < VMALLOC_END;
+	     addr += PMD_SIZE) {
 		struct page *page;
 
 		spin_lock(&pgd_lock);
@@ -210,13 +207,23 @@ static void vmalloc_sync(void)
 			pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
 
 			spin_lock(pgt_lock);
-			vmalloc_sync_one(page_address(page), address);
+			vmalloc_sync_one(page_address(page), addr);
 			spin_unlock(pgt_lock);
 		}
 		spin_unlock(&pgd_lock);
 	}
 }
 
+static void vmalloc_sync(void)
+{
+	unsigned long address;
+
+	if (SHARED_KERNEL_PMD)
+		return;
+
+	arch_sync_kernel_mappings(VMALLOC_START, VMALLOC_END);
+}
+
 void vmalloc_sync_mappings(void)
 {
 	vmalloc_sync();

_

author maintainer
#125 lore raw

PATCH 123/128 mm: remove vmalloc_sync_(un)mappings()

In reply to Andrew Morton

From: Joerg Roedel <[email protected]>
Subject: mm: remove vmalloc_sync_(un)mappings()

These functions are not needed anymore because the vmalloc and ioremap mappings are now synchronized when they are created or teared down.

Remove all callers and function definitions.

---

 arch/x86/mm/fault.c      |   37 -------------------------------------
 drivers/acpi/apei/ghes.c |    6 ------
 include/linux/vmalloc.h  |    2 --
 kernel/notifier.c        |    1 -
 kernel/trace/trace.c     |   12 ------------
 mm/nommu.c               |   12 ------------
 mm/vmalloc.c             |   21 ---------------------
 7 files changed, 91 deletions(-)
arch/x86/mm/fault.c renamed from arch/x86/mm/fault.c~mm-remove-vmalloc_sync_unmappings +0 -37
@@ -214,26 +214,6 @@ void arch_sync_kernel_mappings(unsigned
 	}
 }
 
-static void vmalloc_sync(void)
-{
-	unsigned long address;
-
-	if (SHARED_KERNEL_PMD)
-		return;
-
-	arch_sync_kernel_mappings(VMALLOC_START, VMALLOC_END);
-}
-
-void vmalloc_sync_mappings(void)
-{
-	vmalloc_sync();
-}
-
-void vmalloc_sync_unmappings(void)
-{
-	vmalloc_sync();
-}
-
 /*
  * 32-bit:
  *
@@ -336,23 +316,6 @@ out:
 
 #else /* CONFIG_X86_64: */
 
-void vmalloc_sync_mappings(void)
-{
-	/*
-	 * 64-bit mappings might allocate new p4d/pud pages
-	 * that need to be propagated to all tasks' PGDs.
-	 */
-	sync_global_pgds(VMALLOC_START & PGDIR_MASK, VMALLOC_END);
-}
-
-void vmalloc_sync_unmappings(void)
-{
-	/*
-	 * Unmappings never allocate or free p4d/pud pages.
-	 * No work is required here.
-	 */
-}
-
 /*
  * 64-bit:
  *
drivers/acpi/apei/ghes.c renamed from drivers/acpi/apei/ghes.c~mm-remove-vmalloc_sync_unmappings +0 -6
@@ -167,12 +167,6 @@ int ghes_estatus_pool_init(int num_ghes)
 	if (!addr)
 		goto err_pool_alloc;
 
-	/*
-	 * New allocation must be visible in all pgd before it can be found by
-	 * an NMI allocating from the pool.
-	 */
-	vmalloc_sync_mappings();
-
 	rc = gen_pool_add(ghes_estatus_pool, addr, PAGE_ALIGN(len), -1);
 	if (rc)
 		goto err_pool_add;
include/linux/vmalloc.h renamed from include/linux/vmalloc.h~mm-remove-vmalloc_sync_unmappings +0 -2
@@ -130,8 +130,6 @@ extern int remap_vmalloc_range_partial(s
 
 extern int remap_vmalloc_range(struct vm_area_struct *vma, void *addr,
 							unsigned long pgoff);
-void vmalloc_sync_mappings(void);
-void vmalloc_sync_unmappings(void);
 
 /*
  * Architectures can set this mask to a combination of PGTBL_P?D_MODIFIED values
kernel/notifier.c renamed from kernel/notifier.c~mm-remove-vmalloc_sync_unmappings +0 -1
@@ -519,7 +519,6 @@ NOKPROBE_SYMBOL(notify_die);
 
 int register_die_notifier(struct notifier_block *nb)
 {
-	vmalloc_sync_mappings();
 	return atomic_notifier_chain_register(&die_chain, nb);
 }
 EXPORT_SYMBOL_GPL(register_die_notifier);
kernel/trace/trace.c renamed from kernel/trace/trace.c~mm-remove-vmalloc_sync_unmappings +0 -12
@@ -8527,18 +8527,6 @@ static int allocate_trace_buffers(struct
 	allocate_snapshot = false;
 #endif
 
-	/*
-	 * Because of some magic with the way alloc_percpu() works on
-	 * x86_64, we need to synchronize the pgd of all the tables,
-	 * otherwise the trace events that happen in x86_64 page fault
-	 * handlers can't cope with accessing the chance that a
-	 * alloc_percpu()'d memory might be touched in the page fault trace
-	 * event. Oh, and we need to audit all other alloc_percpu() and vmalloc()
-	 * calls in tracing, because something might get triggered within a
-	 * page fault trace event!
-	 */
-	vmalloc_sync_mappings();
-
 	return 0;
 }
 
mm/nommu.c renamed from mm/nommu.c~mm-remove-vmalloc_sync_unmappings +0 -12
@@ -371,18 +371,6 @@ void vm_unmap_aliases(void)
 }
 EXPORT_SYMBOL_GPL(vm_unmap_aliases);
 
-/*
- * Implement a stub for vmalloc_sync_[un]mapping() if the architecture
- * chose not to have one.
- */
-void __weak vmalloc_sync_mappings(void)
-{
-}
-
-void __weak vmalloc_sync_unmappings(void)
-{
-}
-
 struct vm_struct *alloc_vm_area(size_t size, pte_t **ptes)
 {
 	BUG();
mm/vmalloc.c renamed from mm/vmalloc.c~mm-remove-vmalloc_sync_unmappings +0 -20
@@ -1354,12 +1354,6 @@ static bool __purge_vmap_area_lazy(unsig
 		return false;
 
 	/*
-	 * First make sure the mappings are removed from all page-tables
-	 * before they are freed.
-	 */
-	vmalloc_sync_unmappings();
-
-	/*
 	 * TODO: to calculate a flush range without looping.
 	 * The list can be up to lazy_max_pages() elements.
 	 */
@@ -3089,21 +3083,6 @@ int remap_vmalloc_range(struct vm_area_s
 }
 EXPORT_SYMBOL(remap_vmalloc_range);
 
-/*
- * Implement stubs for vmalloc_sync_[un]mappings () if the architecture chose
- * not to have one.
- *
- * The purpose of this function is to make sure the vmalloc area
- * mappings are identical in all page-tables in the system.
- */
-void __weak vmalloc_sync_mappings(void)
-{
-}
-
-void __weak vmalloc_sync_unmappings(void)
-{
-}
author maintainer
#126 lore raw

PATCH 124/128 x86/mm: remove vmalloc faulting

In reply to Andrew Morton

From: Joerg Roedel <[email protected]>
Subject: x86/mm: remove vmalloc faulting

Remove fault handling on vmalloc areas, as the vmalloc code now takes care of synchronizing changes to all page-tables in the system.

Cc Arnd Bergmann <[email protected]>
Cc Christoph Hellwig <[email protected]>
Cc Dave Hansen <[email protected]>
Cc "H . Peter Anvin" <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Matthew Wilcox (Oracle) <[email protected]>
Cc Michal Hocko <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
Cc Steven Rostedt (VMware) <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Vlastimil Babka <[email protected]>

---

 arch/x86/include/asm/switch_to.h |   23 ----
 arch/x86/kernel/setup_percpu.c   |    6 -
 arch/x86/mm/fault.c              |  134 -----------------------------
 arch/x86/mm/pti.c                |    8 -
 arch/x86/mm/tlb.c                |   37 --------
 5 files changed, 4 insertions(+), 204 deletions(-)
arch/x86/include/asm/switch_to.h renamed from arch/x86/include/asm/switch_to.h~x86-mm-remove-vmalloc-faulting +0 -23
@@ -12,27 +12,6 @@ struct task_struct *__switch_to_asm(stru
 __visible struct task_struct *__switch_to(struct task_struct *prev,
 					  struct task_struct *next);
 
-/* This runs runs on the previous thread's stack. */
-static inline void prepare_switch_to(struct task_struct *next)
-{
-#ifdef CONFIG_VMAP_STACK
-	/*
-	 * If we switch to a stack that has a top-level paging entry
-	 * that is not present in the current mm, the resulting #PF will
-	 * will be promoted to a double-fault and we'll panic.  Probe
-	 * the new stack now so that vmalloc_fault can fix up the page
-	 * tables if needed.  This can only happen if we use a stack
-	 * in vmap space.
-	 *
-	 * We assume that the stack is aligned so that it never spans
-	 * more than one top-level paging entry.
-	 *
-	 * To minimize cache pollution, just follow the stack pointer.
-	 */
-	READ_ONCE(*(unsigned char *)next->thread.sp);
-#endif
-}
-
 asmlinkage void ret_from_fork(void);
 
 /*
@@ -67,8 +46,6 @@ struct fork_frame {
 
 #define switch_to(prev, next, last)					\
 do {									\
-	prepare_switch_to(next);					\
-									\
 	((last) = __switch_to_asm((prev), (next)));			\
 } while (0)
 
arch/x86/kernel/setup_percpu.c renamed from arch/x86/kernel/setup_percpu.c~x86-mm-remove-vmalloc-faulting +3 -3
@@ -287,9 +287,9 @@ void __init setup_per_cpu_areas(void)
 	/*
 	 * Sync back kernel address range again.  We already did this in
 	 * setup_arch(), but percpu data also needs to be available in
-	 * the smpboot asm.  We can't reliably pick up percpu mappings
-	 * using vmalloc_fault(), because exception dispatch needs
-	 * percpu data.
+	 * the smpboot asm and arch_sync_kernel_mappings() doesn't sync to
+	 * swapper_pg_dir on 32-bit. The per-cpu mappings need to be available
+	 * there too.
 	 *
 	 * FIXME: Can the later sync in setup_cpu_entry_areas() replace
 	 * this call?
arch/x86/mm/fault.c renamed from arch/x86/mm/fault.c~x86-mm-remove-vmalloc-faulting +0 -134

152 lines not on this page · raw message

arch/x86/mm/pti.c renamed from arch/x86/mm/pti.c~x86-mm-remove-vmalloc-faulting +1 -7
@@ -448,13 +448,7 @@ static void __init pti_clone_user_shared
 		 * the sp1 and sp2 slots.
 		 *
 		 * This is done for all possible CPUs during boot to ensure
-		 * that it's propagated to all mms.  If we were to add one of
-		 * these mappings during CPU hotplug, we would need to take
-		 * some measure to make sure that every mm that subsequently
-		 * ran on that CPU would have the relevant PGD entry in its
-		 * pagetables.  The usual vmalloc_fault() mechanism would not
-		 * work for page faults taken in entry_SYSCALL_64 before RSP
-		 * is set up.
+		 * that it's propagated to all mms.
 		 */
 
 		unsigned long va = (unsigned long)&per_cpu(cpu_tss_rw, cpu);
arch/x86/mm/tlb.c renamed from arch/x86/mm/tlb.c~x86-mm-remove-vmalloc-faulting +0 -36
@@ -161,34 +161,6 @@ void switch_mm(struct mm_struct *prev, s
 	local_irq_restore(flags);
 }
 
-static void sync_current_stack_to_mm(struct mm_struct *mm)
-{
-	unsigned long sp = current_stack_pointer;
-	pgd_t *pgd = pgd_offset(mm, sp);
-
-	if (pgtable_l5_enabled()) {
-		if (unlikely(pgd_none(*pgd))) {
-			pgd_t *pgd_ref = pgd_offset_k(sp);
-
-			set_pgd(pgd, *pgd_ref);
-		}
-	} else {
-		/*
-		 * "pgd" is faked.  The top level entries are "p4d"s, so sync
-		 * the p4d.  This compiles to approximately the same code as
-		 * the 5-level case.
-		 */
-		p4d_t *p4d = p4d_offset(pgd, sp);
-
-		if (unlikely(p4d_none(*p4d))) {
-			pgd_t *pgd_ref = pgd_offset_k(sp);
-			p4d_t *p4d_ref = p4d_offset(pgd_ref, sp);
-
-			set_p4d(p4d, *p4d_ref);
-		}
-	}
-}
-
 static inline unsigned long mm_mangle_tif_spec_ib(struct task_struct *next)
 {
 	unsigned long next_tif = task_thread_info(next)->flags;
@@ -377,15 +349,6 @@ void switch_mm_irqs_off(struct mm_struct
 		 */
 		cond_ibpb(tsk);
 
-		if (IS_ENABLED(CONFIG_VMAP_STACK)) {
-			/*
-			 * If our current stack is in vmalloc space and isn't
-			 * mapped in the new pgd, we'll double-fault.  Forcibly
-			 * map it.
-			 */
-			sync_current_stack_to_mm(next);
-		}
author maintainer
#127 lore raw

PATCH 125/128 kasan: fix clang compilation warning due to stack protector

In reply to Andrew Morton

From: Andrey Konovalov <[email protected]>
Subject: kasan: fix clang compilation warning due to stack protector

KASAN uses a single cc-option invocation to disable both conserve-stack and stack-protector flags. The former flag is not present in Clang, which causes cc-option to fail, and results in stack-protector being enabled.

Fix by using separate cc-option calls for each flag. Also collect all flags in a variable to avoid calling cc-option multiple times for different files.

---

 mm/kasan/Makefile |   21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)
mm/kasan/Makefile renamed from mm/kasan/Makefile~kasan-fix-clang-compilation-warning-due-to-stack-protector +13 -8
@@ -15,14 +15,19 @@ CFLAGS_REMOVE_tags_report.o = $(CC_FLAGS
 
 # Function splitter causes unnecessary splits in __asan_load1/__asan_store1
 # see: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63533
-CFLAGS_common.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector) -DDISABLE_BRANCH_PROFILING
-CFLAGS_generic.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector) -DDISABLE_BRANCH_PROFILING
-CFLAGS_generic_report.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector) -DDISABLE_BRANCH_PROFILING
-CFLAGS_init.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector) -DDISABLE_BRANCH_PROFILING
-CFLAGS_quarantine.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector) -DDISABLE_BRANCH_PROFILING
-CFLAGS_report.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector) -DDISABLE_BRANCH_PROFILING
-CFLAGS_tags.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector) -DDISABLE_BRANCH_PROFILING
-CFLAGS_tags_report.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector) -DDISABLE_BRANCH_PROFILING
+CC_FLAGS_KASAN_RUNTIME := $(call cc-option, -fno-conserve-stack)
+CC_FLAGS_KASAN_RUNTIME += $(call cc-option, -fno-stack-protector)
+# Disable branch tracing to avoid recursion.
+CC_FLAGS_KASAN_RUNTIME += -DDISABLE_BRANCH_PROFILING
+
+CFLAGS_common.o := $(CC_FLAGS_KASAN_RUNTIME)
+CFLAGS_generic.o := $(CC_FLAGS_KASAN_RUNTIME)
+CFLAGS_generic_report.o := $(CC_FLAGS_KASAN_RUNTIME)
+CFLAGS_init.o := $(CC_FLAGS_KASAN_RUNTIME)
+CFLAGS_quarantine.o := $(CC_FLAGS_KASAN_RUNTIME)
+CFLAGS_report.o := $(CC_FLAGS_KASAN_RUNTIME)
+CFLAGS_tags.o := $(CC_FLAGS_KASAN_RUNTIME)
+CFLAGS_tags_report.o := $(CC_FLAGS_KASAN_RUNTIME)
 
 obj-$(CONFIG_KASAN) := common.o init.o report.o
 obj-$(CONFIG_KASAN_GENERIC) += generic.o generic_report.o quarantine.o

_

author maintainer
#128 lore raw

PATCH 126/128 ubsan: entirely disable alignment checks under UBSAN_TRAP

In reply to Andrew Morton

From: Kees Cook <[email protected]>
Subject: ubsan: entirely disable alignment checks under UBSAN_TRAP

Commit 8d58f222e85f ("ubsan: disable UBSAN_ALIGNMENT under COMPILE_TEST") tried to fix the pathological results of UBSAN_ALIGNMENT with UBSAN_TRAP (which objtool would rightly scream about), but it made an assumption about how COMPILE_TEST gets set (it is not set for randconfig). As a result, we need a bigger hammer here: just don't allow the alignment checks with the trap mode.

---

 lib/Kconfig.ubsan |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/Kconfig.ubsan renamed from lib/Kconfig.ubsan~ubsan-entirely-disable-alignment-checks-under-ubsan_trap +1 -1
@@ -63,7 +63,7 @@ config UBSAN_SANITIZE_ALL
 config UBSAN_ALIGNMENT
 	bool "Enable checks for pointers alignment"
 	default !HAVE_EFFICIENT_UNALIGNED_ACCESS
-	depends on !X86 || !COMPILE_TEST
+	depends on !UBSAN_TRAP
 	help
 	  This option enables the check of unaligned memory accesses.
 	  Enabling this option on architectures that support unaligned

_

author maintainer
#129 lore raw

PATCH 127/128 mm/mm_init.c: report kasan-tag information stored in page->flags

In reply to Andrew Morton

From: Jing Xia <[email protected]>
Subject: mm/mm_init.c: report kasan-tag information stored in page->flags

The pageflags_layout_usage shows incorrect message by means of mminit_loglevel when Kasan runs in the mode of software tag-based enabled with CONFIG_KASAN_SW_TAGS. This patch corrects it and reports kasan-tag information.

---

 mm/mm_init.c |   16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
mm/mm_init.c renamed from mm/mm_init.c~mm-init-report-kasan-tag-information-stored-in-page-flags +10 -6
@@ -67,26 +67,30 @@ void __init mminit_verify_pageflags_layo
 	unsigned long or_mask, add_mask;
 
 	shift = 8 * sizeof(unsigned long);
-	width = shift - SECTIONS_WIDTH - NODES_WIDTH - ZONES_WIDTH - LAST_CPUPID_SHIFT;
+	width = shift - SECTIONS_WIDTH - NODES_WIDTH - ZONES_WIDTH
+		- LAST_CPUPID_SHIFT - KASAN_TAG_WIDTH;
 	mminit_dprintk(MMINIT_TRACE, "pageflags_layout_widths",
-		"Section %d Node %d Zone %d Lastcpupid %d Flags %d\n",
+		"Section %d Node %d Zone %d Lastcpupid %d Kasantag %d Flags %d\n",
 		SECTIONS_WIDTH,
 		NODES_WIDTH,
 		ZONES_WIDTH,
 		LAST_CPUPID_WIDTH,
+		KASAN_TAG_WIDTH,
 		NR_PAGEFLAGS);
 	mminit_dprintk(MMINIT_TRACE, "pageflags_layout_shifts",
-		"Section %d Node %d Zone %d Lastcpupid %d\n",
+		"Section %d Node %d Zone %d Lastcpupid %d Kasantag %d\n",
 		SECTIONS_SHIFT,
 		NODES_SHIFT,
 		ZONES_SHIFT,
-		LAST_CPUPID_SHIFT);
+		LAST_CPUPID_SHIFT,
+		KASAN_TAG_WIDTH);
 	mminit_dprintk(MMINIT_TRACE, "pageflags_layout_pgshifts",
-		"Section %lu Node %lu Zone %lu Lastcpupid %lu\n",
+		"Section %lu Node %lu Zone %lu Lastcpupid %lu Kasantag %lu\n",
 		(unsigned long)SECTIONS_PGSHIFT,
 		(unsigned long)NODES_PGSHIFT,
 		(unsigned long)ZONES_PGSHIFT,
-		(unsigned long)LAST_CPUPID_PGSHIFT);
+		(unsigned long)LAST_CPUPID_PGSHIFT,
+		(unsigned long)KASAN_TAG_PGSHIFT);
 	mminit_dprintk(MMINIT_TRACE, "pageflags_layout_nodezoneid",
 		"Node/Zone ID: %lu -> %lu\n",
 		(unsigned long)(ZONEID_PGOFF + ZONEID_SHIFT),

_

author maintainer
#130 lore raw

PATCH 128/128 kasan: move kasan_report() into report.c

In reply to Andrew Morton

From: Andrey Konovalov <[email protected]>
Subject: kasan: move kasan_report() into report.c

The kasan_report() functions belongs to report.c, as it's a common functions that does error reporting.

---

 mm/kasan/common.c |   19 -------------------
 mm/kasan/report.c |   22 ++++++++++++++++++++--
 2 files changed, 20 insertions(+), 21 deletions(-)
mm/kasan/common.c renamed from mm/kasan/common.c~kasan-move-kasan_report-into-reportc +0 -19
@@ -33,7 +33,6 @@
 #include <linux/types.h>
 #include <linux/vmalloc.h>
 #include <linux/bug.h>
-#include <linux/uaccess.h>
 
 #include <asm/cacheflush.h>
 #include <asm/tlbflush.h>
@@ -613,24 +612,6 @@ void kasan_free_shadow(const struct vm_s
 }
 #endif
 
-extern void __kasan_report(unsigned long addr, size_t size, bool is_write, unsigned long ip);
-extern bool report_enabled(void);
-
-bool kasan_report(unsigned long addr, size_t size, bool is_write, unsigned long ip)
-{
-	unsigned long flags = user_access_save();
-	bool ret = false;
-
-	if (likely(report_enabled())) {
-		__kasan_report(addr, size, is_write, ip);
-		ret = true;
-	}
-
-	user_access_restore(flags);
-
-	return ret;
-}
-
 #ifdef CONFIG_MEMORY_HOTPLUG
 static bool shadow_mapped(unsigned long addr)
 {
mm/kasan/report.c renamed from mm/kasan/report.c~kasan-move-kasan_report-into-reportc +20 -2
@@ -29,6 +29,7 @@
 #include <linux/kasan.h>
 #include <linux/module.h>
 #include <linux/sched/task_stack.h>
+#include <linux/uaccess.h>
 
 #include <asm/sections.h>
 
@@ -454,7 +455,7 @@ static void print_shadow_for_address(con
 	}
 }
 
-bool report_enabled(void)
+static bool report_enabled(void)
 {
 	if (current->kasan_depth)
 		return false;
@@ -479,7 +480,8 @@ void kasan_report_invalid_free(void *obj
 	end_report(&flags);
 }
 
-void __kasan_report(unsigned long addr, size_t size, bool is_write, unsigned long ip)
+static void __kasan_report(unsigned long addr, size_t size, bool is_write,
+				unsigned long ip)
 {
 	struct kasan_access_info info;
 	void *tagged_addr;
@@ -518,6 +520,22 @@ void __kasan_report(unsigned long addr,
 	end_report(&flags);
 }
 
+bool kasan_report(unsigned long addr, size_t size, bool is_write,
+			unsigned long ip)
+{
+	unsigned long flags = user_access_save();
+	bool ret = false;
+
+	if (likely(report_enabled())) {
+		__kasan_report(addr, size, is_write, ip);
+		ret = true;
+	}
+
+	user_access_restore(flags);
+
+	return ret;
+}
+
 #ifdef CONFIG_KASAN_INLINE
 /*
  * With CONFIG_KASAN_INLINE, accesses to bogus pointers (outside the high

_

author maintainer tree notice
#131 lore raw

+ maccess-unexport-probe_kernel_write-and-probe_user_write-fix.patch added to -mm tree

In reply to Andrew Morton
The patch titled Subject: turns out that probe_user_write is used in modular code has been added to the -mm tree. Its filename is maccess-unexport-probe_kernel_write-and-probe_user_write-fix.patch

The patch titled
Subject: turns out that probe_user_write is used in modular code
has been added to the -mm tree. Its filename is
maccess-unexport-probe_kernel_write-and-probe_user_write-fix.patch

This patch should soon appear at
http://ozlabs.org/~akpm/mmots/broken-out/maccess-unexport-probe_kernel_write-and-probe_user_write-fix.patch
and later at
http://ozlabs.org/~akpm/mmotm/broken-out/maccess-unexport-probe_kernel_write-and-probe_user_write-fix.patch

Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next and is updated there every 3-4 working days

------------------------------------------------------
From: Stephen Rothwell <[email protected]>
Subject: turns out that probe_user_write is used in modular code

---

 mm/maccess.c |    1 +
 1 file changed, 1 insertion(+)
mm/maccess.c renamed from mm/maccess.c~maccess-unexport-probe_kernel_write-and-probe_user_write-fix +1 -0
@@ -244,6 +244,7 @@ long strncpy_from_unsafe_user(char *dst,
 
 	return ret;
 }
+EXPORT_SYMBOL_GPL(probe_user_write);
 
 /**
  * strnlen_unsafe_user: - Get the size of a user string INCLUDING final NUL.

_

Patches currently in -mm which might be from [email protected] are

kernel-better-document-the-use_mm-unuse_mm-api-contract-v2-fix.patch kernel-better-document-the-use_mm-unuse_mm-api-contract-fix-2.patch maccess-unexport-probe_kernel_write-and-probe_user_write-fix.patch

author maintainer tree notice
#132 lore raw

[folded-merged] lib-make-a-test-module-with-get_count_order-long-fix.patch removed from -mm tree

In reply to Andrew Morton
The patch titled Subject: lib-make-a-test-module-with-get_count_order-long-fix has been removed from the -mm tree. Its filename was lib-make-a-test-module-with-get_count_order-long-fix.patch

The patch titled
Subject: lib-make-a-test-module-with-get_count_order-long-fix
has been removed from the -mm tree. Its filename was
lib-make-a-test-module-with-get_count_order-long-fix.patch

This patch was dropped because it was folded into lib-make-a-test-module-with-get_count_order-long.patch

------------------------------------------------------
From: Andrew Morton <[email protected]>
Subject: lib-make-a-test-module-with-get_count_order-long-fix

tweak Kconfig text

Cc Andy Shevchenko <[email protected]>
Cc Christian Brauner <[email protected]>
Cc Wei Yang <[email protected]>

---

 lib/Kconfig.debug |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/Kconfig.debug renamed from lib/Kconfig.debug~lib-make-a-test-module-with-get_count_order-long-fix +2 -2
@@ -2040,8 +2040,8 @@ config TEST_GETORDER
 	depends on m
 	help
 	  This builds the "test_getorder" module that is much like the
-	  TEST_LKM module except that it does a basic exercise of the
-	  get_count_order and get_count_order_long to make sure there are no
+	  TEST_LKM module except that it does a basic exercise of
+	  get_count_order() and get_count_order_long() to make sure there are no
 	  compiler warnings from C=1 sparse checker or -Wextra compilations.
 	  It has no dependencies and doesn't run or load unless explicitly
 	  requested by name. For example: modprobe test_getorder.

_

Patches currently in -mm which might be from [email protected] are

drivers-tty-serial-sh-scic-suppress-uninitialized-var-warning.patch mm.patch mm-free_area_init-allow-defining-max_zone_pfn-in-descending-order-fix-2-fix.patch mm-page_alloc-skip-waternark_boost-for-atomic-order-0-allocations-fix.patch arch-kunmap-remove-duplicate-kunmap-implementations-fix.patch arch-kmap_atomic-consolidate-duplicate-code-checkpatch-fixes.patch arch-kunmap_atomic-consolidate-duplicate-code-checkpatch-fixes.patch kmap-consolidate-kmap_prot-definitions-checkpatch-fixes.patch mm-add-debug_wx-support-fix.patch
riscv-support-debug_wx-fix.patch mm-replace-zero-length-array-with-flexible-array-member-fix.patch mm-hugetlb-fix-a-typo-in-comment-manitained-maintained-v2-checkpatch-fixes.patch lib-make-a-test-module-with-get_count_order-long.patch seq_file-introduce-define_seq_attribute-helper-macro-checkpatch-fixes.patch ipc-convert-ipcs_idr-to-xarray-update-fix.patch
linux-next-pre.patch
linux-next-rejects.patch
linux-next-git-rejects.patch
linux-next-post.patch
kernel-add-panic_on_taint-fix.patch mm-consolidate-pgd_index-and-pgd_offset_k-definitions-fix.patch mmap-locking-api-convert-mmap_sem-call-sites-missed-by-coccinelle-fix.patch mmap-locking-api-convert-mmap_sem-call-sites-missed-by-coccinelle-fix-fix.patch mmap-locking-api-convert-mmap_sem-call-sites-missed-by-coccinelle-fix-fix-fix.patch mmap-locking-api-rename-mmap_sem-to-mmap_lock-fix.patch mmap-locking-api-convert-mmap_sem-comments-fix.patch mmap-locking-api-convert-mmap_sem-comments-fix-fix.patch mmap-locking-api-convert-mmap_sem-comments-fix-fix-fix.patch mm-pass-task-and-mm-to-do_madvise.patch mm-introduce-external-memory-hinting-api-fix-2-fix.patch mm-support-vector-address-ranges-for-process_madvise-fix-fix-fix-fix-fix.patch maccess-unify-the-probe-kernel-arch-hooks-fix.patch bpf-bpf_seq_printf-handle-potentially-unsafe-format-string-better.patch maccess-always-use-strict-semantics-for-probe_kernel_read-fix.patch x86-use-non-set_fs-based-maccess-routines-checkpatch-fixes.patch doc-cgroup-update-note-about-conditions-when-oom-killer-is-invoked-fix.patch sh-convert-ins-outs-macros-to-inline-functions-checkpatch-fixes.patch kernel-forkc-export-kernel_thread-to-modules.patch

author maintainer tree notice
#133 lore raw

[to-be-updated] lib-make-a-test-module-with-get_count_order-long.patch removed from -mm tree

In reply to Andrew Morton
The patch titled Subject: lib: make a test module with get_count_order/long has been removed from the -mm tree. Its filename was lib-make-a-test-module-with-get_count_order-long.patch

The patch titled
Subject: lib: make a test module with get_count_order/long
has been removed from the -mm tree. Its filename was
lib-make-a-test-module-with-get_count_order-long.patch

This patch was dropped because an updated version will be merged

------------------------------------------------------
From: Wei Yang <[email protected]>
Subject: lib: make a test module with get_count_order/long

A test module to make sure get_count_order/long returns the correct result.

---

 lib/Kconfig.debug                  |   13 +++++
 lib/Makefile                       |    2 
 lib/test_getorder.c                |   64 +++++++++++++++++++++++++++
 tools/testing/selftests/lib/config |    1 
 4 files changed, 80 insertions(+)
lib/Kconfig.debug renamed from lib/Kconfig.debug~lib-make-a-test-module-with-get_count_order-long +13 -0
@@ -2028,6 +2028,19 @@ config TEST_LKM
 
 	  If unsure, say N.
 
+config TEST_GETORDER
+	tristate "Test module for compilation of get_count_order operations"
+	depends on m
+	help
+	  This builds the "test_getorder" module that is much like the
+	  TEST_LKM module except that it does a basic exercise of
+	  get_count_order() and get_count_order_long() to make sure there are no
+	  compiler warnings from C=1 sparse checker or -Wextra compilations.
+	  It has no dependencies and doesn't run or load unless explicitly
+	  requested by name. For example: modprobe test_getorder.
+
+	  If unsure, say N.
+
 config TEST_VMALLOC
 	tristate "Test module for stress/performance analysis of vmalloc allocator"
 	default n
lib/Makefile renamed from lib/Makefile~lib-make-a-test-module-with-get_count_order-long +2 -0
@@ -76,6 +76,8 @@ obj-$(CONFIG_TEST_SORT) += test_sort.o
 obj-$(CONFIG_TEST_USER_COPY) += test_user_copy.o
 obj-$(CONFIG_TEST_STATIC_KEYS) += test_static_keys.o
 obj-$(CONFIG_TEST_STATIC_KEYS) += test_static_key_base.o
+obj-$(CONFIG_TEST_GETORDER) += test_getorder.o
+CFLAGS_test_getorder.o += -Werror
 obj-$(CONFIG_TEST_PRINTF) += test_printf.o
 obj-$(CONFIG_TEST_BITMAP) += test_bitmap.o
 obj-$(CONFIG_TEST_STRSCPY) += test_strscpy.o
lib/test_getorder.c new file +64 -0

64 lines not on this page · raw message

tools/testing/selftests/lib/config renamed from tools/testing/selftests/lib/config~lib-make-a-test-module-with-get_count_order-long +1 -0
@@ -1,4 +1,5 @@
 CONFIG_TEST_PRINTF=m
 CONFIG_TEST_BITMAP=m
+CONFIG_TEST_GETORDER=m
 CONFIG_PRIME_NUMBERS=m
 CONFIG_TEST_STRSCPY=m

_

Patches currently in -mm which might be from [email protected] are

mm-page_allocc-bad_-is-not-necessary-when-pagehwpoison.patch mm-page_allocc-bad_flags-is-not-necessary-for-bad_page.patch mm-page_allocc-rename-free_pages_check_bad-to-check_free_page_bad.patch mm-page_allocc-rename-free_pages_check-to-check_free_page.patch mm-page_allocc-extract-check__page_bad-common-part-to-page_bad_reason.patch mm-page_allocc-use-node_mask_none-in-build_zonelists.patch mm-rename-gfpflags_to_migratetype-to-gfp_migratetype-for-same-convention.patch mm-vmscanc-use-update_lru_size-in-update_lru_sizes.patch bitops-simplify-get_count_order_long.patch bitops-use-the-same-mechanism-for-get_count_order.patch lib-test-get_count_order-long-in-test_bitopsc.patch

author maintainer tree notice
#134 lore raw

+ lib-test-get_count_order-long-in-test_bitopsc.patch added to -mm tree

In reply to Andrew Morton
The patch titled Subject: lib: test get_count_order/long in test_bitops.c has been added to the -mm tree. Its filename is lib-test-get_count_order-long-in-test_bitopsc.patch

The patch titled
Subject: lib: test get_count_order/long in test_bitops.c
has been added to the -mm tree. Its filename is
lib-test-get_count_order-long-in-test_bitopsc.patch

This patch should soon appear at
http://ozlabs.org/~akpm/mmots/broken-out/lib-test-get_count_order-long-in-test_bitopsc.patch
and later at
http://ozlabs.org/~akpm/mmotm/broken-out/lib-test-get_count_order-long-in-test_bitopsc.patch

Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next and is updated there every 3-4 working days

------------------------------------------------------
From: Wei Yang <[email protected]>
Subject: lib: test get_count_order/long in test_bitops.c

Add some test for get_count_order/long in test_bitops.c.

---

 lib/Kconfig.debug |   10 +++++-----
 lib/test_bitops.c |   40 ++++++++++++++++++++++++++++++++++++++--
 2 files changed, 43 insertions(+), 7 deletions(-)
lib/Kconfig.debug renamed from lib/Kconfig.debug~lib-test-get_count_order-long-in-test_bitopsc +5 -5
@@ -2029,15 +2029,15 @@ config TEST_LKM
 	  If unsure, say N.
 
 config TEST_BITOPS
-	tristate "Test module for compilation of clear_bit/set_bit operations"
+	tristate "Test module for compilation of bitops operations"
 	depends on m
 	help
 	  This builds the "test_bitops" module that is much like the
 	  TEST_LKM module except that it does a basic exercise of the
-	  clear_bit and set_bit macros to make sure there are no compiler
-	  warnings from C=1 sparse checker or -Wextra compilations. It has
-	  no dependencies and doesn't run or load unless explicitly requested
-	  by name.  for example: modprobe test_bitops.
+	  set/clear_bit macros and get_count_order/long to make sure there are
+	  no compiler warnings from C=1 sparse checker or -Wextra
+	  compilations. It has no dependencies and doesn't run or load unless
+	  explicitly requested by name.  for example: modprobe test_bitops.
 
 	  If unsure, say N.
 
lib/test_bitops.c renamed from lib/test_bitops.c~lib-test-get_count_order-long-in-test_bitopsc +38 -2
@@ -9,7 +9,11 @@
 #include <linux/module.h>
 #include <linux/printk.h>
 
-/* a tiny module only meant to test set/clear_bit */
+/* a tiny module only meant to test
+ *
+ *   set/clear_bit
+ *   get_count_order/long
+ */
 
 /* use an enum because thats the most common BITMAP usage */
 enum bitops_fun {
@@ -24,6 +28,26 @@ enum bitops_fun {
 
 static DECLARE_BITMAP(g_bitmap, BITOPS_LENGTH);
 
+unsigned int order_comb[][2] = {
+	{0x00000003,  2},
+	{0x00000004,  2},
+	{0x00001fff, 13},
+	{0x00002000, 13},
+	{0x50000000, 31},
+	{0x80000000, 31},
+	{0x80003000, 32},
+};
+
+unsigned long order_comb_long[][2] = {
+	{0x0000000300000000, 34},
+	{0x0000000400000000, 34},
+	{0x00001fff00000000, 45},
+	{0x0000200000000000, 45},
+	{0x5000000000000000, 63},
+	{0x8000000000000000, 63},
+	{0x8000300000000000, 64},
+};
+
 static int __init test_bitops_startup(void)
 {
 	pr_warn("Loaded test module\n");
@@ -32,6 +56,18 @@ static int __init test_bitops_startup(vo
 	set_bit(BITOPS_11, g_bitmap);
 	set_bit(BITOPS_31, g_bitmap);
 	set_bit(BITOPS_88, g_bitmap);
+
+	for (i = 0; i < ARRAY_SIZE(order_comb); i++) {
+		if (order_comb[i][1] != get_count_order(order_comb[i][0]))
+			pr_warn("get_count_order wrong for %x\n",
+				       order_comb[i][0]); }
+
+	for (i = 0; i < ARRAY_SIZE(order_comb_long); i++) {
+		if (order_comb_long[i][1] !=
+			       get_count_order_long(order_comb_long[i][0]))
+			pr_warn("get_count_order_long wrong for %lx\n",
+				       order_comb_long[i][0]); }
+
 	return 0;
 }
 
@@ -55,6 +91,6 @@ static void __exit test_bitops_unstartup
 module_init(test_bitops_startup);
 module_exit(test_bitops_unstartup);
 
-MODULE_AUTHOR("Jesse Brandeburg <[email protected]>");
+MODULE_AUTHOR("Jesse Brandeburg <[email protected]>, Wei Yang <[email protected]>");
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Bit testing module");

_

Patches currently in -mm which might be from [email protected] are

mm-page_allocc-bad_-is-not-necessary-when-pagehwpoison.patch mm-page_allocc-bad_flags-is-not-necessary-for-bad_page.patch mm-page_allocc-rename-free_pages_check_bad-to-check_free_page_bad.patch mm-page_allocc-rename-free_pages_check-to-check_free_page.patch mm-page_allocc-extract-check__page_bad-common-part-to-page_bad_reason.patch mm-page_allocc-use-node_mask_none-in-build_zonelists.patch mm-rename-gfpflags_to_migratetype-to-gfp_migratetype-for-same-convention.patch mm-vmscanc-use-update_lru_size-in-update_lru_sizes.patch bitops-simplify-get_count_order_long.patch bitops-use-the-same-mechanism-for-get_count_order.patch lib-test-get_count_order-long-in-test_bitopsc.patch

author maintainer tree notice
#135 lore raw

+ mm-page_allocc-add-missing-line-breaks.patch added to -mm tree

In reply to Andrew Morton
The patch titled Subject: mm/page_alloc.c: add missing newline has been added to the -mm tree. Its filename is mm-page_allocc-add-missing-line-breaks.patch

The patch titled
Subject: mm/page_alloc.c: add missing newline
has been added to the -mm tree. Its filename is
mm-page_allocc-add-missing-line-breaks.patch

This patch should soon appear at
http://ozlabs.org/~akpm/mmots/broken-out/mm-page_allocc-add-missing-line-breaks.patch
and later at
http://ozlabs.org/~akpm/mmotm/broken-out/mm-page_allocc-add-missing-line-breaks.patch

Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next and is updated there every 3-4 working days

------------------------------------------------------
From: Chen Tao <[email protected]>
Subject: mm/page_alloc.c: add missing newline

Add missing line breaks on pr_warn().

---

 mm/page_alloc.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/page_alloc.c renamed from mm/page_alloc.c~mm-page_allocc-add-missing-line-breaks +1 -1
@@ -7194,7 +7194,7 @@ static void __init find_zone_movable_pfn
 		}
 
 		if (mem_below_4gb_not_mirrored)
-			pr_warn("This configuration results in unmirrored kernel memory.");
+			pr_warn("This configuration results in unmirrored kernel memory.\n");
 
 		goto out2;
 	}

_

Patches currently in -mm which might be from [email protected] are

mm-page_allocc-add-missing-line-breaks.patch

author maintainer tree notice
#136 lore raw

+ mm-fold-and-remove-lru_cache_add_anon-and-lru_cache_add_file-fix.patch added to -mm tree

In reply to Andrew Morton
The patch titled Subject: mm-fold-and-remove-lru_cache_add_anon-and-lru_cache_add_file-fix has been added to the -mm tree. Its filename is…

The patch titled
Subject: mm-fold-and-remove-lru_cache_add_anon-and-lru_cache_add_file-fix
has been added to the -mm tree. Its filename is
mm-fold-and-remove-lru_cache_add_anon-and-lru_cache_add_file-fix.patch

This patch should soon appear at
http://ozlabs.org/~akpm/mmots/broken-out/mm-fold-and-remove-lru_cache_add_anon-and-lru_cache_add_file-fix.patch
and later at
http://ozlabs.org/~akpm/mmotm/broken-out/mm-fold-and-remove-lru_cache_add_anon-and-lru_cache_add_file-fix.patch

Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next and is updated there every 3-4 working days

------------------------------------------------------
From: Andrew Morton <[email protected]>
Subject: mm-fold-and-remove-lru_cache_add_anon-and-lru_cache_add_file-fix

fix it for local_lock changes

Cc Johannes Weiner <[email protected]>
Cc Joonsoo Kim <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Minchan Kim <[email protected]>
Cc Rik van Riel <[email protected]>

---

 mm/swap.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
mm/swap.c renamed from mm/swap.c~mm-fold-and-remove-lru_cache_add_anon-and-lru_cache_add_file-fix +4 -2
@@ -435,15 +435,17 @@ EXPORT_SYMBOL(mark_page_accessed);
  */
 void lru_cache_add(struct page *page)
 {
-	struct pagevec *pvec = &get_cpu_var(lru_add_pvec);
+	struct pagevec *pvec;
 
 	VM_BUG_ON_PAGE(PageActive(page) && PageUnevictable(page), page);
 	VM_BUG_ON_PAGE(PageLRU(page), page);
 
 	get_page(page);
+	local_lock(&lru_pvecs.lock);
+	pvec = this_cpu_ptr(&lru_pvecs.lru_add);
 	if (!pagevec_add(pvec, page) || PageCompound(page))
 		__pagevec_lru_add(pvec);
-	put_cpu_var(lru_add_pvec);
+	local_unlock(&lru_pvecs.lock);
 }
 EXPORT_SYMBOL(lru_cache_add);
 

_

Patches currently in -mm which might be from [email protected] are

mm-free_area_init-allow-defining-max_zone_pfn-in-descending-order-fix-2-fix.patch mm-fold-and-remove-lru_cache_add_anon-and-lru_cache_add_file-fix.patch mm-add-debug_wx-support-fix.patch
riscv-support-debug_wx-fix.patch drivers-tty-serial-sh-scic-suppress-uninitialized-var-warning.patch mm.patch mm-page_alloc-skip-waternark_boost-for-atomic-order-0-allocations-fix.patch arch-kunmap-remove-duplicate-kunmap-implementations-fix.patch arch-kmap_atomic-consolidate-duplicate-code-checkpatch-fixes.patch arch-kunmap_atomic-consolidate-duplicate-code-checkpatch-fixes.patch kmap-consolidate-kmap_prot-definitions-checkpatch-fixes.patch mm-replace-zero-length-array-with-flexible-array-member-fix.patch mm-hugetlb-fix-a-typo-in-comment-manitained-maintained-v2-checkpatch-fixes.patch seq_file-introduce-define_seq_attribute-helper-macro-checkpatch-fixes.patch ipc-convert-ipcs_idr-to-xarray-update-fix.patch
linux-next-pre.patch
linux-next-rejects.patch
linux-next-git-rejects.patch
linux-next-post.patch
kernel-add-panic_on_taint-fix.patch mm-consolidate-pgd_index-and-pgd_offset_k-definitions-fix.patch mmap-locking-api-convert-mmap_sem-call-sites-missed-by-coccinelle-fix.patch mmap-locking-api-convert-mmap_sem-call-sites-missed-by-coccinelle-fix-fix.patch mmap-locking-api-convert-mmap_sem-call-sites-missed-by-coccinelle-fix-fix-fix.patch mmap-locking-api-rename-mmap_sem-to-mmap_lock-fix.patch mmap-locking-api-convert-mmap_sem-comments-fix.patch mmap-locking-api-convert-mmap_sem-comments-fix-fix.patch mmap-locking-api-convert-mmap_sem-comments-fix-fix-fix.patch mm-pass-task-and-mm-to-do_madvise.patch mm-introduce-external-memory-hinting-api-fix-2-fix.patch mm-support-vector-address-ranges-for-process_madvise-fix-fix-fix-fix-fix.patch maccess-unify-the-probe-kernel-arch-hooks-fix.patch bpf-bpf_seq_printf-handle-potentially-unsafe-format-string-better.patch maccess-always-use-strict-semantics-for-probe_kernel_read-fix.patch x86-use-non-set_fs-based-maccess-routines-checkpatch-fixes.patch doc-cgroup-update-note-about-conditions-when-oom-killer-is-invoked-fix.patch sh-convert-ins-outs-macros-to-inline-functions-checkpatch-fixes.patch kernel-forkc-export-kernel_thread-to-modules.patch

author maintainer tree notice
#137 lore raw

[folded-merged] mm-gup-refactor-and-de-duplicate-gup_fast-code-fix.patch removed from -mm tree

In reply to Andrew Morton
The patch titled Subject: mm/gup: fixup gup.c for "mm/gup: refactor and de-duplicate gup_fast() code" has been removed from the -mm tree. Its filename was…

The patch titled
Subject: mm/gup: fixup gup.c for "mm/gup: refactor and de-duplicate gup_fast() code"
has been removed from the -mm tree. Its filename was
mm-gup-refactor-and-de-duplicate-gup_fast-code-fix.patch

This patch was dropped because it was folded into mm-gup-refactor-and-de-duplicate-gup_fast-code.patch

------------------------------------------------------
From: John Hubbard <[email protected]>
Subject: mm/gup: fixup gup.c for "mm/gup: refactor and de-duplicate gup_fast() code"

Include FOLL_FAST_ONLY in the list of flags to *not* WARN() on, in internal_get_user_pages_fast().

Cc Chris Wilson <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc David Airlie <[email protected]>
Cc Jani Nikula <[email protected]>
Cc "Joonas Lahtinen" <[email protected]>
Cc Matthew Auld <[email protected]>
Cc Matthew Wilcox <[email protected]>
Cc Rodrigo Vivi <[email protected]>
Cc Souptick Joarder <[email protected]>
Cc Tvrtko Ursulin <[email protected]>

---

 mm/gup.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
mm/gup.c renamed from mm/gup.c~mm-gup-refactor-and-de-duplicate-gup_fast-code-fix +2 -1
@@ -2719,7 +2719,8 @@ static int internal_get_user_pages_fast(
 	int nr_pinned = 0, ret = 0;
 
 	if (WARN_ON_ONCE(gup_flags & ~(FOLL_WRITE | FOLL_LONGTERM |
-				       FOLL_FORCE | FOLL_PIN | FOLL_GET)))
+				       FOLL_FORCE | FOLL_PIN | FOLL_GET |
+				       FOLL_FAST_ONLY)))
 		return -EINVAL;
 
 	start = untagged_addr(start) & PAGE_MASK;

_

Patches currently in -mm which might be from [email protected] are

mm-gup-move-__get_user_pages_fast-down-a-few-lines-in-gupc.patch mm-gup-refactor-and-de-duplicate-gup_fast-code.patch mm-gup-introduce-pin_user_pages_fast_only.patch drm-i915-convert-get_user_pages-pin_user_pages.patch mm-gup-might_lock_readmmap_sem-in-get_user_pages_fast.patch khugepaged-add-self-test-fix-3.patch rapidio-convert-get_user_pages-pin_user_pages.patch mm-gup-update-pin_user_pagesrst-for-case-3-mmu-notifiers.patch mm-gup-introduce-pin_user_pages_locked.patch mm-gup-introduce-pin_user_pages_locked-v2.patch mm-gup-frame_vector-convert-get_user_pages-pin_user_pages.patch mm-gup-documentation-fix-for-pin_user_pages-apis.patch docs-mm-gup-pin_user_pagesrst-add-a-case-5.patch vhost-convert-get_user_pages-pin_user_pages.patch

author maintainer tree notice
#138 lore raw

[folded-merged] kasan-stop-tests-being-eliminated-as-dead-code-with-fortify_source-v4.patch removed from -mm tree

In reply to Andrew Morton
The patch titled Subject: kasan-stop-tests-being-eliminated-as-dead-code-with-fortify_source-v4 has been removed from the -mm tree. Its filename was…

The patch titled
Subject: kasan-stop-tests-being-eliminated-as-dead-code-with-fortify_source-v4
has been removed from the -mm tree. Its filename was
kasan-stop-tests-being-eliminated-as-dead-code-with-fortify_source-v4.patch

This patch was dropped because it was folded into kasan-stop-tests-being-eliminated-as-dead-code-with-fortify_source.patch

------------------------------------------------------
From: Daniel Axtens <[email protected]>
Subject: kasan-stop-tests-being-eliminated-as-dead-code-with-fortify_source-v4

drop patch 3

Fixes 0c96350a2d2f ("lib/test_kasan.c: add tests for several string/memory API functions")
Cc Daniel Micay <[email protected]>
Cc Andrey Ryabinin <[email protected]>
Cc Alexander Potapenko <[email protected]>

---

 lib/test_kasan.c |    1 +
 1 file changed, 1 insertion(+)
lib/test_kasan.c renamed from lib/test_kasan.c~kasan-stop-tests-being-eliminated-as-dead-code-with-fortify_source-v4 +1 -0
@@ -645,6 +645,7 @@ static noinline void __init kasan_memcmp
 	if (!ptr)
 		return;
 
+	memset(arr, 0, sizeof(arr));
 	kasan_int_result = memcmp(ptr, arr, size + 1);
 	kfree(ptr);
 }

_

Patches currently in -mm which might be from [email protected] are

kasan-stop-tests-being-eliminated-as-dead-code-with-fortify_source.patch stringh-fix-incompatibility-between-fortify_source-and-kasan.patch relay-handle-alloc_percpu-returning-null-in-relay_open.patch

author maintainer tree notice
#139 lore raw

[folded-merged] mm-memmap_init-iterate-over-memblock-regions-rather-that-check-each-pfn-fix.patch removed from -mm tree

In reply to Andrew Morton
The patch titled Subject: mm-memmap_init-iterate-over-memblock-regions-rather-that-check-each-pfn-fix has been removed from the -mm tree. Its filename was…

The patch titled
Subject: mm-memmap_init-iterate-over-memblock-regions-rather-that-check-each-pfn-fix
has been removed from the -mm tree. Its filename was
mm-memmap_init-iterate-over-memblock-regions-rather-that-check-each-pfn-fix.patch

This patch was dropped because it was folded into mm-memmap_init-iterate-over-memblock-regions-rather-that-check-each-pfn.patch

------------------------------------------------------
From: Qian Cai <[email protected]>
Subject: mm-memmap_init-iterate-over-memblock-regions-rather-that-check-each-pfn-fix

fix a compilation warning from Clang

mm/page_alloc.c:5917:39: warning: unused function 'next_pfn' [-Wunused-function] static inline __meminit unsigned long next_pfn(unsigned long pfn)

---

 mm/page_alloc.c |   17 -----------------
 1 file changed, 17 deletions(-)
mm/page_alloc.c renamed from mm/page_alloc.c~mm-memmap_init-iterate-over-memblock-regions-rather-that-check-each-pfn-fix +0 -16
@@ -5948,23 +5948,6 @@ overlap_memmap_init(unsigned long zone,
 	return false;
 }
 
-#ifdef CONFIG_SPARSEMEM
-/* Skip PFNs that belong to non-present sections */
-static inline __meminit unsigned long next_pfn(unsigned long pfn)
-{
-	const unsigned long section_nr = pfn_to_section_nr(++pfn);
-
-	if (present_section_nr(section_nr))
-		return pfn;
-	return section_nr_to_pfn(next_present_section_nr(section_nr));
-}
-#else
-static inline __meminit unsigned long next_pfn(unsigned long pfn)
-{
-	return pfn++;
-}
-#endif
author maintainer tree notice
#140 lore raw

[folded-merged] mm-memmap_init-iterate-over-memblock-regions-rather-that-check-each-pfn-fix-2.patch removed from -mm tree

In reply to Andrew Morton
The patch titled Subject: mm/compaction: fix the incorrect hole in fast_isolate_freepages() has been removed from the -mm tree. Its filename was…

The patch titled
Subject: mm/compaction: fix the incorrect hole in fast_isolate_freepages()
has been removed from the -mm tree. Its filename was
mm-memmap_init-iterate-over-memblock-regions-rather-that-check-each-pfn-fix-2.patch

This patch was dropped because it was folded into mm-memmap_init-iterate-over-memblock-regions-rather-that-check-each-pfn.patch

------------------------------------------------------
From: Baoquan He <[email protected]>
Subject: mm/compaction: fix the incorrect hole in fast_isolate_freepages()

Qian reported that a crash happened in compaction.
http://lkml.kernel.org/r/[email protected]

LTP: starting swapping01 (swapping01 -i 5)
page:ffffea0000aa0000 refcount:1 mapcount:0 mapping:000000002243743b index:0x0
flags: 0x1fffe000001000(reserved)

raw: 001fffe000001000 ffffea0000aa0008 ffffea0000aa0008 0000000000000000
raw: 0000000000000000 0000000000000000 00000001ffffffff 0000000000000000
page dumped because: VM_BUG_ON_PAGE(!zone_spans_pfn(page_zone(page), pfn))
page_owner info is not present (never set?)
------------[ cut here ]------------
kernel BUG at mm/page_alloc.c:533!
...
CPU: 17 PID: 218 Comm: kcompactd0 Not tainted 5.7.0-rc2-next-20200423+ #7
...
RIP: 0010:set_pfnblock_flags_mask+0x150/0x210
...
RSP: 0018:ffffc900042ff858 EFLAGS: 00010282
RAX: 0000000000000000 RBX: 0000000000000001 RCX: ffffffff9a002382
RDX: 0000000000000000 RSI: 0000000000000008 RDI: ffff8884535b8e6c
RBP: ffffc900042ff8b8 R08: ffffed108a6b8459 R09: ffffed108a6b8459
R10: ffff8884535c22c7 R11: ffffed108a6b8458 R12: 000000000002a800
R13: ffffea0000aa0000 R14: ffff88847fff3000 R15: ffff88847fff3040
FS:  0000000000000000(0000) GS:ffff888453580000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fd1eb4a1000 CR3: 000000083154c000 CR4: 00000000003406e0
Call Trace:
 isolate_freepages+0xb20/0x1140
 ? isolate_freepages_block+0x730/0x730
 ? mark_held_locks+0x34/0xb0
 ? free_unref_page+0x7d/0x90
 ? free_unref_page+0x7d/0x90
 ? check_flags.part.28+0x86/0x220
 compaction_alloc+0xdd/0x100
 migrate_pages+0x304/0x17e0
 ? __ClearPageMovable+0x100/0x100
 ? isolate_freepages+0x1140/0x1140
 compact_zone+0x1249/0x1e90
 ? compaction_suitable+0x260/0x260
 kcompactd_do_work+0x231/0x650
 ? sysfs_compact_node+0x80/0x80
 ? finish_wait+0xe6/0x110
 kcompactd+0x162/0x490
 ? kcompactd_do_work+0x650/0x650
 ? finish_wait+0x110/0x110
 ? __kasan_check_read+0x11/0x20
 ? __kthread_parkme+0xd4/0xf0
 ? kcompactd_do_work+0x650/0x650
 kthread+0x1f7/0x220
 ? kthread_create_worker_on_cpu+0xc0/0xc0
 ret_from_fork+0x27/0x50

After investigation, it turns out that this is introduced by commit of
linux-next: commit f6edbdb71877 ("mm: memmap_init: iterate over memblock regions rather that check each PFN").

After investigation, it turns out that this is introduced by commit of linux-next, the patch subject is:
"mm: memmap_init: iterate over memblock regions rather that check each PFN".

Qian added debugging code. The debugging log shows that the fault page is 0x2a800000. From the system e820 map which is pasted at bottom, the page is in e820 reserved range:

	BIOS-e820: [mem 0x0000000029ffe000-0x000000002a80afff] reserved

And it's in section [0x28000000, 0x2fffffff]. In that secion, there are several usable ranges and some e820 reserved ranges.

For this kind of e820 reserved range, it won't be added to memblock allocator. However, init_unavailable_mem() will initialize to add them into node 0, zone 0. Before that commit, later, memmap_init() will add e820 reserved ranges into the zone where they are contained, because it can pass the checking of early_pfn_valid() and early_pfn_in_nid(). In this case, the e820 reserved range where fault page 0x2a800000 is located is added into DMA32 zone. After that commit, the e820 reserved rgions are kept in node 0, zone 0, since we iterate over memblock regions to iniatialize in memmap_init() instead, their node and zone won't be changed.

Now, fast_isolate_freepages() will use min mark directly as the migration target if no page is found from buddy. However, the min mark is not checked carefully, it could be in e820 reserved range, and trigger the VM_BUG_ON_PAGE(!zone_spans_pfn(page_zone(page), pfn)) when try to mark it as skip.

Here, let's call pageblock_pfn_to_page() to get page of min_pfn, since it will do careful checks and return NULL if the pfn is not qualified.

[    0.000000] BIOS-provided physical RAM map:
[    0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000008bfff] usable
[    0.000000] BIOS-e820: [mem 0x000000000008c000-0x000000000009ffff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000000e0000-0x00000000000fffff] reserved
[    0.000000] BIOS-e820: [mem 0x0000000000100000-0x0000000028328fff] usable
[    0.000000] BIOS-e820: [mem 0x0000000028329000-0x0000000028568fff] reserved
[    0.000000] BIOS-e820: [mem 0x0000000028569000-0x0000000028d85fff] usable
[    0.000000] BIOS-e820: [mem 0x0000000028d86000-0x0000000028ee5fff] reserved
[    0.000000] BIOS-e820: [mem 0x0000000028ee6000-0x0000000029a04fff] usable
[    0.000000] BIOS-e820: [mem 0x0000000029a05000-0x0000000029a08fff] reserved
[    0.000000] BIOS-e820: [mem 0x0000000029a09000-0x0000000029ee4fff] usable
[    0.000000] BIOS-e820: [mem 0x0000000029ee5000-0x0000000029ef2fff] ACPI data
[    0.000000] BIOS-e820: [mem 0x0000000029ef3000-0x0000000029f22fff] usable
[    0.000000] BIOS-e820: [mem 0x0000000029f23000-0x0000000029f23fff] ACPI data
[    0.000000] BIOS-e820: [mem 0x0000000029f24000-0x0000000029f24fff] usable
[    0.000000] BIOS-e820: [mem 0x0000000029f25000-0x0000000029f28fff] ACPI data
[    0.000000] BIOS-e820: [mem 0x0000000029f29000-0x0000000029f29fff] ACPI NVS
[    0.000000] BIOS-e820: [mem 0x0000000029f2a000-0x0000000029f2bfff] ACPI data
[    0.000000] BIOS-e820: [mem 0x0000000029f2c000-0x0000000029f2cfff] reserved
[    0.000000] BIOS-e820: [mem 0x0000000029f2d000-0x0000000029f2ffff] ACPI data
[    0.000000] BIOS-e820: [mem 0x0000000029f30000-0x0000000029ffdfff] usable
[    0.000000] BIOS-e820: [mem 0x0000000029ffe000-0x000000002a80afff] reserved
[    0.000000] BIOS-e820: [mem 0x000000002a80b000-0x000000002a80efff] ACPI NVS
[    0.000000] BIOS-e820: [mem 0x000000002a80f000-0x000000002a81ffff] reserved
[    0.000000] BIOS-e820: [mem 0x000000002a820000-0x000000002a822fff] ACPI NVS
[    0.000000] BIOS-e820: [mem 0x000000002a823000-0x0000000033a22fff] usable
[    0.000000] BIOS-e820: [mem 0x0000000033a23000-0x0000000033a32fff] reserved
[    0.000000] BIOS-e820: [mem 0x0000000033a33000-0x0000000033a42fff] ACPI NVS
[    0.000000] BIOS-e820: [mem 0x0000000033a43000-0x0000000033a52fff] ACPI data
[    0.000000] BIOS-e820: [mem 0x0000000033a53000-0x0000000077ffffff] usable
[    0.000000] BIOS-e820: [mem 0x0000000078000000-0x000000008fffffff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000fed80000-0x00000000fed80fff] reserved
[    0.000000] BIOS-e820: [mem 0x0000000100000000-0x000000087effffff] usable
[    0.000000] BIOS-e820: [mem 0x000000087f000000-0x000000087fffffff] reserved

---

 mm/compaction.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
mm/compaction.c renamed from mm/compaction.c~mm-memmap_init-iterate-over-memblock-regions-rather-that-check-each-pfn-fix-2 +3 -1
@@ -1418,7 +1418,9 @@ fast_isolate_freepages(struct compact_co
 				cc->free_pfn = highest;
 			} else {
 				if (cc->direct_compaction && pfn_valid(min_pfn)) {
-					page = pfn_to_page(min_pfn);
+					page = pageblock_pfn_to_page(min_pfn,
+						pageblock_end_pfn(min_pfn),
+						cc->zone);
 					cc->free_pfn = min_pfn;
 				}
 			}

_

Patches currently in -mm which might be from [email protected] are

mm-memmap_init-iterate-over-memblock-regions-rather-that-check-each-pfn.patch mm-remove-unused-free_bootmem_with_active_regions.patch mm-page_allocc-only-tune-sysctl_lowmem_reserve_ratio-value-once-when-changing-it.patch mm-page_allocc-clear-out-zone-lowmem_reserve-if-the-zone-is-empty.patch mm-vmstatc-do-not-show-lowmem-reserve-protection-information-of-empty-zone.patch

author maintainer tree notice
#141 lore raw

[folded-merged] mm-free_area_init-allow-defining-max_zone_pfn-in-descending-order-fix.patch removed from -mm tree

In reply to Andrew Morton
The patch titled Subject: Re: mm: free_area_init: allow defining max_zone_pfn in descending order has been removed from the -mm tree. Its filename was…

The patch titled
Subject: Re: mm: free_area_init: allow defining max_zone_pfn in descending order
has been removed from the -mm tree. Its filename was
mm-free_area_init-allow-defining-max_zone_pfn-in-descending-order-fix.patch

This patch was dropped because it was folded into mm-free_area_init-allow-defining-max_zone_pfn-in-descending-order.patch

------------------------------------------------------
From: Mike Rapoport <[email protected]>
Subject: Re: mm: free_area_init: allow defining max_zone_pfn in descending order

ARC fix

---

 arch/arc/mm/init.c |    5 +++++
 mm/page_alloc.c    |   20 +++++++++++---------
 2 files changed, 16 insertions(+), 9 deletions(-)
arch/arc/mm/init.c renamed from arch/arc/mm/init.c~mm-free_area_init-allow-defining-max_zone_pfn-in-descending-order-fix +5 -0
@@ -77,6 +77,11 @@ void __init early_init_dt_add_memory_arc
 		base, TO_MB(size), !in_use ? "Not used":"");
 }
 
+bool arch_has_descending_max_zone_pfns(void)
+{
+	return true;
+}
+
 /*
  * First memory setup routine called from setup_arch()
  * 1. setup swapper's mm @init_mm
mm/page_alloc.c renamed from mm/page_alloc.c~mm-free_area_init-allow-defining-max_zone_pfn-in-descending-order-fix +10 -1
@@ -7405,6 +7405,15 @@ static void check_for_memory(pg_data_t *
 	}
 }
 
+/*
+ * Some architecturs, e.g. ARC may have ZONE_HIGHMEM below ZONE_NORMAL. For
+ * such cases we allow max_zone_pfn sorted in the descending order
+ */
+bool __weak arch_has_descending_max_zone_pfns(void)
+{
+	return false;
+}
+
 /**
  * free_area_init - Initialise all pg_data_t and zone data
  * @max_zone_pfn: an array of max PFNs for each zone
@@ -7422,7 +7431,7 @@ void __init free_area_init(unsigned long
 {
 	unsigned long start_pfn, end_pfn;
 	int i, nid, zone;
-	bool descending = false;
+	bool descending;
 
 	/* Record where the zone boundaries are */
 	memset(arch_zone_lowest_possible_pfn, 0,
@@ -7431,14 +7440,7 @@ void __init free_area_init(unsigned long
 				sizeof(arch_zone_highest_possible_pfn));
 
 	start_pfn = find_min_pfn_with_active_regions();
author maintainer tree notice
#142 lore raw

[folded-merged] mm-free_area_init-allow-defining-max_zone_pfn-in-descending-order-fix-2.patch removed from -mm tree

In reply to Andrew Morton
The patch titled Subject: arc: free_area_init(): take into account PAE40 mode has been removed from the -mm tree. Its filename was…

The patch titled
Subject: arc: free_area_init(): take into account PAE40 mode
has been removed from the -mm tree. Its filename was
mm-free_area_init-allow-defining-max_zone_pfn-in-descending-order-fix-2.patch

This patch was dropped because it was folded into mm-free_area_init-allow-defining-max_zone_pfn-in-descending-order.patch

------------------------------------------------------
From: Mike Rapoport <[email protected]>
Subject: arc: free_area_init(): take into account PAE40 mode

The arch_has_descending_max_zone_pfns() does not take into account physical memory layout for PAE40 configuration.
With PAE40 enabled, the HIGHMEM is actually higher than NORMAL and arch_has_descending_max_zone_pfns() should return false in this case.

---

 arch/arc/mm/init.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arc/mm/init.c renamed from arch/arc/mm/init.c~mm-free_area_init-allow-defining-max_zone_pfn-in-descending-order-fix-2 +1 -1
@@ -79,7 +79,7 @@ void __init early_init_dt_add_memory_arc
 
 bool arch_has_descending_max_zone_pfns(void)
 {
-	return true;
+	return !IS_ENABLED(CONFIG_ARC_HAS_PAE40);
 }
 
 /*

_

Patches currently in -mm which might be from [email protected] are

mm-memblock-replace-dereferences-of-memblock_regionnid-with-api-calls.patch mm-make-early_pfn_to_nid-and-related-defintions-close-to-each-other.patch mm-remove-config_have_memblock_node_map-option.patch mm-free_area_init-use-maximal-zone-pfns-rather-than-zone-sizes.patch mm-use-free_area_init-instead-of-free_area_init_nodes.patch alpha-simplify-detection-of-memory-zone-boundaries.patch arm-simplify-detection-of-memory-zone-boundaries.patch arm64-simplify-detection-of-memory-zone-boundaries-for-uma-configs.patch csky-simplify-detection-of-memory-zone-boundaries.patch m68k-mm-simplify-detection-of-memory-zone-boundaries.patch parisc-simplify-detection-of-memory-zone-boundaries.patch sparc32-simplify-detection-of-memory-zone-boundaries.patch unicore32-simplify-detection-of-memory-zone-boundaries.patch xtensa-simplify-detection-of-memory-zone-boundaries.patch mm-remove-early_pfn_in_nid-and-config_nodes_span_other_nodes.patch mm-free_area_init-allow-defining-max_zone_pfn-in-descending-order.patch mm-rename-free_area_init_node-to-free_area_init_memoryless_node.patch mm-clean-up-free_area_init_node-and-its-helpers.patch mm-simplify-find_min_pfn_with_active_regions.patch docs-vm-update-memory-models-documentation.patch sparc32-register-memory-occupied-by-kernel-as-memblockmemory.patch h8300-remove-usage-of-__arch_use_5level_hack.patch arm-add-support-for-folded-p4d-page-tables.patch arm-add-support-for-folded-p4d-page-tables-fix.patch arm64-add-support-for-folded-p4d-page-tables.patch hexagon-remove-__arch_use_5level_hack.patch ia64-add-support-for-folded-p4d-page-tables.patch nios2-add-support-for-folded-p4d-page-tables.patch openrisc-add-support-for-folded-p4d-page-tables.patch powerpc-add-support-for-folded-p4d-page-tables.patch powerpc-add-support-for-folded-p4d-page-tables-fix-2.patch sh-drop-__pxd_offset-macros-that-duplicate-pxd_index-ones.patch sh-add-support-for-folded-p4d-page-tables.patch unicore32-remove-__arch_use_5level_hack.patch asm-generic-remove-pgtable-nop4d-hackh.patch mm-remove-__arch_has_5level_hack-and-include-asm-generic-5level-fixuph.patch mm-dont-include-asm-pgtableh-if-linux-mmh-is-already-included.patch mm-introduce-include-linux-pgtableh.patch mm-reorder-includes-after-introduction-of-linux-pgtableh.patch csky-replace-definitions-of-__pxd_offset-with-pxd_index.patch m68k-mm-motorola-move-comment-about-page-table-allocation-funcitons.patch m68k-mm-move-cachenocahe_page-definitions-close-to-their-user.patch x86-mm-simplify-init_trampoline-and-surrounding-logic.patch x86-mm-simplify-init_trampoline-and-surrounding-logic-fix.patch mm-pgtable-add-shortcuts-for-accessing-kernel-pmd-and-pte.patch mm-pgtable-add-shortcuts-for-accessing-kernel-pmd-and-pte-fix.patch mm-consolidate-pte_index-and-pte_offset_-definitions.patch mm-consolidate-pmd_index-and-pmd_offset-definitions.patch mm-consolidate-pud_index-and-pud_offset-definitions.patch mm-consolidate-pgd_index-and-pgd_offset_k-definitions.patch

author maintainer tree notice
#143 lore raw

[folded-merged] mm-free_area_init-allow-defining-max_zone_pfn-in-descending-order-fix-2-fix.patch removed from -mm tree

In reply to Andrew Morton
The patch titled Subject: mm-free_area_init-allow-defining-max_zone_pfn-in-descending-order-fix-2-fix has been removed from the -mm tree. Its filename was…

The patch titled
Subject: mm-free_area_init-allow-defining-max_zone_pfn-in-descending-order-fix-2-fix
has been removed from the -mm tree. Its filename was
mm-free_area_init-allow-defining-max_zone_pfn-in-descending-order-fix-2-fix.patch

This patch was dropped because it was folded into mm-free_area_init-allow-defining-max_zone_pfn-in-descending-order.patch

------------------------------------------------------
From: Andrew Morton <[email protected]>
Subject: mm-free_area_init-allow-defining-max_zone_pfn-in-descending-order-fix-2-fix

declare arch_has_descending_max_zone_pfns().

Cc Mike Rapoport <[email protected]>
Cc Vineet Gupta <[email protected]>

---

 include/linux/mm.h |    1 +
 1 file changed, 1 insertion(+)
include/linux/mm.h renamed from include/linux/mm.h~mm-free_area_init-allow-defining-max_zone_pfn-in-descending-order-fix-2-fix +1 -0
@@ -2477,6 +2477,7 @@ extern void setup_per_cpu_pageset(void);
 extern int min_free_kbytes;
 extern int watermark_boost_factor;
 extern int watermark_scale_factor;
+extern bool arch_has_descending_max_zone_pfns(void);
 
 /* nommu.c */
 extern atomic_long_t mmap_pages_allocated;

_

Patches currently in -mm which might be from [email protected] are

mm-free_area_init-allow-defining-max_zone_pfn-in-descending-order.patch mm-fold-and-remove-lru_cache_add_anon-and-lru_cache_add_file-fix.patch mm-add-debug_wx-support-fix.patch
riscv-support-debug_wx-fix.patch drivers-tty-serial-sh-scic-suppress-uninitialized-var-warning.patch mm.patch mm-page_alloc-skip-waternark_boost-for-atomic-order-0-allocations-fix.patch arch-kunmap-remove-duplicate-kunmap-implementations-fix.patch arch-kmap_atomic-consolidate-duplicate-code-checkpatch-fixes.patch arch-kunmap_atomic-consolidate-duplicate-code-checkpatch-fixes.patch kmap-consolidate-kmap_prot-definitions-checkpatch-fixes.patch mm-replace-zero-length-array-with-flexible-array-member-fix.patch mm-hugetlb-fix-a-typo-in-comment-manitained-maintained-v2-checkpatch-fixes.patch seq_file-introduce-define_seq_attribute-helper-macro-checkpatch-fixes.patch ipc-convert-ipcs_idr-to-xarray-update-fix.patch
linux-next-pre.patch
linux-next-rejects.patch
linux-next-git-rejects.patch
linux-next-post.patch
kernel-add-panic_on_taint-fix.patch mm-consolidate-pgd_index-and-pgd_offset_k-definitions-fix.patch mmap-locking-api-convert-mmap_sem-call-sites-missed-by-coccinelle-fix.patch mmap-locking-api-convert-mmap_sem-call-sites-missed-by-coccinelle-fix-fix.patch mmap-locking-api-convert-mmap_sem-call-sites-missed-by-coccinelle-fix-fix-fix.patch mmap-locking-api-rename-mmap_sem-to-mmap_lock-fix.patch mmap-locking-api-convert-mmap_sem-comments-fix.patch mmap-locking-api-convert-mmap_sem-comments-fix-fix.patch mmap-locking-api-convert-mmap_sem-comments-fix-fix-fix.patch mm-pass-task-and-mm-to-do_madvise.patch mm-introduce-external-memory-hinting-api-fix-2-fix.patch mm-support-vector-address-ranges-for-process_madvise-fix-fix-fix-fix-fix.patch maccess-unify-the-probe-kernel-arch-hooks-fix.patch bpf-bpf_seq_printf-handle-potentially-unsafe-format-string-better.patch maccess-always-use-strict-semantics-for-probe_kernel_read-fix.patch x86-use-non-set_fs-based-maccess-routines-checkpatch-fixes.patch doc-cgroup-update-note-about-conditions-when-oom-killer-is-invoked-fix.patch sh-convert-ins-outs-macros-to-inline-functions-checkpatch-fixes.patch kernel-forkc-export-kernel_thread-to-modules.patch

author maintainer tree notice
#144 lore raw

[folded-merged] mmpage_alloccma-conditionally-prefer-cma-pageblocks-for-movable-allocations-fix.patch removed from -mm tree

In reply to Andrew Morton
The patch titled Subject: mmpage_alloccma-conditionally-prefer-cma-pageblocks-for-movable-allocations-fix has been removed from the -mm tree. Its filename was…

The patch titled
Subject: mmpage_alloccma-conditionally-prefer-cma-pageblocks-for-movable-allocations-fix
has been removed from the -mm tree. Its filename was
mmpage_alloccma-conditionally-prefer-cma-pageblocks-for-movable-allocations-fix.patch

This patch was dropped because it was folded into mmpage_alloccma-conditionally-prefer-cma-pageblocks-for-movable-allocations.patch

------------------------------------------------------
From: Roman Gushchin <[email protected]>
Subject: mmpage_alloccma-conditionally-prefer-cma-pageblocks-for-movable-allocations-fix

ifdef the cma-specific code.

---

 mm/page_alloc.c |    2 ++
 1 file changed, 2 insertions(+)
mm/page_alloc.c renamed from mm/page_alloc.c~mmpage_alloccma-conditionally-prefer-cma-pageblocks-for-movable-allocations-fix +2 -0
@@ -2752,6 +2752,7 @@ __rmqueue(struct zone *zone, unsigned in
 {
 	struct page *page;
 
+#ifdef CONFIG_CMA
 	/*
 	 * Balance movable allocations between regular and CMA areas by
 	 * allocating from CMA when over half of the zone's free memory
@@ -2764,6 +2765,7 @@ __rmqueue(struct zone *zone, unsigned in
 		if (page)
 			return page;
 	}
+#endif
 retry:
 	page = __rmqueue_smallest(zone, order, migratetype);
 	if (unlikely(!page)) {

_

Patches currently in -mm which might be from [email protected] are

mmpage_alloccma-conditionally-prefer-cma-pageblocks-for-movable-allocations.patch

author maintainer tree notice
#145 lore raw

[folded-merged] mm-reset-numa-stats-for-boot-pagesets-v3.patch removed from -mm tree

In reply to Andrew Morton
The patch titled Subject: mm-reset-numa-stats-for-boot-pagesets-v3 has been removed from the -mm tree. Its filename was mm-reset-numa-stats-for-boot-pagesets-v3.patch

The patch titled
Subject: mm-reset-numa-stats-for-boot-pagesets-v3
has been removed from the -mm tree. Its filename was
mm-reset-numa-stats-for-boot-pagesets-v3.patch

This patch was dropped because it was folded into mm-reset-numa-stats-for-boot-pagesets.patch

------------------------------------------------------
From: Sandipan Das <[email protected]>
Subject: mm-reset-numa-stats-for-boot-pagesets-v3

Drop the redundant static key-based check to see if numa stats are enabled as suggested by Vlastimil.

---

 mm/page_alloc.c |   26 +++++++++++---------------
 1 file changed, 11 insertions(+), 15 deletions(-)
mm/page_alloc.c renamed from mm/page_alloc.c~mm-reset-numa-stats-for-boot-pagesets-v3 +11 -15
@@ -6247,26 +6247,22 @@ void __init setup_per_cpu_pageset(void)
 {
 	struct pglist_data *pgdat;
 	struct zone *zone;
+	int __maybe_unused cpu;
 
 	for_each_populated_zone(zone)
 		setup_zone_pageset(zone);
 
 #ifdef CONFIG_NUMA
-	if (static_branch_likely(&vm_numa_stat_key)) {
-		struct per_cpu_pageset *pcp;
-		int cpu;
-
-		/*
-		 * Unpopulated zones continue using the boot pagesets.
-		 * The numa stats for these pagesets need to be reset.
-		 * Otherwise, they will end up skewing the stats of
-		 * the nodes these zones are associated with.
-		 */
-		for_each_possible_cpu(cpu) {
-			pcp = &per_cpu(boot_pageset, cpu);
-			memset(pcp->vm_numa_stat_diff, 0,
-			       sizeof(pcp->vm_numa_stat_diff));
-		}
+	/*
+	 * Unpopulated zones continue using the boot pagesets.
+	 * The numa stats for these pagesets need to be reset.
+	 * Otherwise, they will end up skewing the stats of
+	 * the nodes these zones are associated with.
+	 */
+	for_each_possible_cpu(cpu) {
+		struct per_cpu_pageset *pcp = &per_cpu(boot_pageset, cpu);
+		memset(pcp->vm_numa_stat_diff, 0,
+		       sizeof(pcp->vm_numa_stat_diff));
 	}
 #endif
 

_

Patches currently in -mm which might be from [email protected] are

mm-reset-numa-stats-for-boot-pagesets.patch selftests-vm-pkeys-use-sane-types-for-pkey-register.patch selftests-vm-pkeys-add-helpers-for-pkey-bits.patch selftests-vm-pkeys-use-the-correct-huge-page-size.patch selftests-vm-pkeys-introduce-powerpc-support-fix.patch selftests-vm-pkeys-override-access-right-definitions-on-powerpc-fix.patch selftests-vm-pkeys-use-the-correct-page-size-on-powerpc.patch selftests-vm-pkeys-fix-multilib-builds-for-x86.patch

author maintainer tree notice
#146 lore raw

[folded-merged] khugepaged-add-self-test-fix.patch removed from -mm tree

In reply to Andrew Morton
The patch titled Subject: selftests: khugepaged: fix several spelling mistakes has been removed from the -mm tree. Its filename was khugepaged-add-self-test-fix.patch

The patch titled
Subject: selftests: khugepaged: fix several spelling mistakes
has been removed from the -mm tree. Its filename was
khugepaged-add-self-test-fix.patch

This patch was dropped because it was folded into khugepaged-add-self-test.patch

------------------------------------------------------
From: Colin Ian King <[email protected]>
Subject: selftests: khugepaged: fix several spelling mistakes

There a are several spelling mistakes in various messages. Fix these.

There are three spelling mistakes in various messages. Fix these.

---

 tools/testing/selftests/vm/khugepaged.c |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
tools/testing/selftests/vm/khugepaged.c renamed from tools/testing/selftests/vm/khugepaged.c~khugepaged-add-self-test-fix +6 -6
@@ -534,7 +534,7 @@ static void collapse_max_ptes_none(void)
 	p = alloc_mapping();
 
 	fill_memory(p, 0, (hpage_pmd_nr - max_ptes_none - 1) * page_size);
-	if (wait_for_scan("Do not collapse with max_ptes_none exeeded", p))
+	if (wait_for_scan("Do not collapse with max_ptes_none exceeded", p))
 		fail("Timeout");
 	else if (check_huge(p))
 		fail("Fail");
@@ -573,7 +573,7 @@ static void collapse_swapin_single_pte(v
 		goto out;
 	}
 
-	if (wait_for_scan("Collapse with swaping in single PTE entry", p))
+	if (wait_for_scan("Collapse with swapping in single PTE entry", p))
 		fail("Timeout");
 	else if (check_huge(p))
 		success("OK");
@@ -604,7 +604,7 @@ static void collapse_max_ptes_swap(void)
 		goto out;
 	}
 
-	if (wait_for_scan("Do not collapse with max_ptes_swap exeeded", p))
+	if (wait_for_scan("Do not collapse with max_ptes_swap exceeded", p))
 		fail("Timeout");
 	else if (check_huge(p))
 		fail("Fail");
@@ -651,14 +651,14 @@ static void collapse_single_pte_entry_co
 		fail("Fail");
 	madvise(p, hpage_pmd_size, MADV_NOHUGEPAGE);
 
-	printf("Split huge page leaving single PTE mapping compount page...");
+	printf("Split huge page leaving single PTE mapping compound page...");
 	madvise(p + page_size, hpage_pmd_size - page_size, MADV_DONTNEED);
 	if (!check_huge(p))
 		success("OK");
 	else
 		fail("Fail");
 
-	if (wait_for_scan("Collapse PTE table with single PTE mapping compount page", p))
+	if (wait_for_scan("Collapse PTE table with single PTE mapping compound page", p))
 		fail("Timeout");
 	else if (check_huge(p))
 		success("OK");
@@ -682,7 +682,7 @@ static void collapse_full_of_compound(vo
 	else
 		fail("Fail");
 
-	printf("Split huge page leaving single PTE page table full of compount pages...");
+	printf("Split huge page leaving single PTE page table full of compound pages...");
 	madvise(p, page_size, MADV_NOHUGEPAGE);
 	madvise(p, hpage_pmd_size, MADV_NOHUGEPAGE);
 	if (!check_huge(p))

_

Patches currently in -mm which might be from [email protected] are

khugepaged-add-self-test.patch khugepaged-introduce-max_ptes_shared-tunable-fix.patch

author maintainer tree notice
#147 lore raw

[folded-merged] khugepaged-add-self-test-fix-2.patch removed from -mm tree

In reply to Andrew Morton
The patch titled Subject: khugepaged: replace the usage of system(3) in the test has been removed from the -mm tree. Its filename was khugepaged-add-self-test-fix-2.patch

The patch titled
Subject: khugepaged: replace the usage of system(3) in the test
has been removed from the -mm tree. Its filename was
khugepaged-add-self-test-fix-2.patch

This patch was dropped because it was folded into khugepaged-add-self-test.patch

------------------------------------------------------
From: "Aneesh Kumar K.V" <[email protected]>
Subject: khugepaged: replace the usage of system(3) in the test

Some glibc version doesn't use CLONE_VM | CLONE_VFORK for system(3) implementation and on such system, we find the test case fails. This is due to fork() marking all the parent page table pages read-only to do a COW.

Avoid the usage of system(3) in the test.

---

 tools/testing/selftests/vm/khugepaged.c |  105 ++++++++++++++++------
 1 file changed, 77 insertions(+), 28 deletions(-)
tools/testing/selftests/vm/khugepaged.c renamed from tools/testing/selftests/vm/khugepaged.c~khugepaged-add-self-test-fix-2 +77 -28
@@ -21,6 +21,7 @@ static unsigned long page_size;
 static int hpage_pmd_nr;
 
 #define THP_SYSFS "/sys/kernel/mm/transparent_hugepage/"
+#define PID_SMAPS "/proc/self/smaps"
 
 enum thp_enabled {
 	THP_ALWAYS,
@@ -330,56 +331,104 @@ static void adjust_settings(void)
 	success("OK");
 }
 
-#define CHECK_HUGE_FMT "sed -ne " \
-	"'/^%lx/,/^AnonHugePages/{/^AnonHugePages:\\s*%ld kB/ q1}' " \
-	"/proc/%d/smaps"
+#define MAX_LINE_LENGTH 500
 
-static bool check_huge(void *p)
+static bool check_for_pattern(FILE *fp, char *pattern, char *buf)
 {
-	char *cmd;
+	while (fgets(buf, MAX_LINE_LENGTH, fp) != NULL) {
+		if (!strncmp(buf, pattern, strlen(pattern)))
+			return true;
+	}
+	return false;
+}
+
+static bool check_huge(char *addr)
+{
+	bool thp = false;
 	int ret;
+	FILE *fp;
+	char buffer[MAX_LINE_LENGTH];
+	char addr_pattern[MAX_LINE_LENGTH];
 
-	ret = asprintf(&cmd, CHECK_HUGE_FMT,
-			(unsigned long)p, hpage_pmd_size >> 10, getpid());
-	if (ret < 0) {
-		perror("asprintf(CHECK_FMT)");
+	ret = snprintf(addr_pattern, MAX_LINE_LENGTH, "%08llx-", addr);
+	if (ret >= MAX_LINE_LENGTH) {
+		printf("%s: Pattern is too long\n", __func__);
+		exit(EXIT_FAILURE);
+	}
+
+
+	fp = fopen(PID_SMAPS, "r");
+	if (!fp) {
+		printf("%s: Failed to open file %s\n", __func__, PID_SMAPS);
 		exit(EXIT_FAILURE);
 	}
+	if (!check_for_pattern(fp, addr_pattern, buffer))
+		goto err_out;
 
-	ret = system(cmd);
-	free(cmd);
-	if (ret < 0 || !WIFEXITED(ret)) {
-		perror("system(check_huge)");
+	ret = snprintf(addr_pattern, MAX_LINE_LENGTH, "AnonHugePages:%10lld kB", hpage_pmd_size >> 10);
+	if (ret >= MAX_LINE_LENGTH) {
+		printf("%s: Pattern is too long\n", __func__);
 		exit(EXIT_FAILURE);
 	}
+	/*
+	 * Fetch the AnonHugePages: in the same block and check whether it got
+	 * the expected number of hugeepages next.
+	 */
+	if (!check_for_pattern(fp, "AnonHugePages:", buffer))
+		goto err_out;
+
+	if (strncmp(buffer, addr_pattern, strlen(addr_pattern)))
+		goto err_out;
 
-	return WEXITSTATUS(ret);
+	thp = true;
+err_out:
+	fclose(fp);
+	return thp;
 }
 
-#define CHECK_SWAP_FMT "sed -ne " \
-	"'/^%lx/,/^Swap:/{/^Swap:\\s*%ld kB/ q1}' " \
-	"/proc/%d/smaps"
 
-static bool check_swap(void *p, unsigned long size)
+static bool check_swap(void *addr, unsigned long size)
 {
-	char *cmd;
+	bool swap = false;
 	int ret;
+	FILE *fp;
+	char buffer[MAX_LINE_LENGTH];
+	char addr_pattern[MAX_LINE_LENGTH];
 
-	ret = asprintf(&cmd, CHECK_SWAP_FMT,
-			(unsigned long)p, size >> 10, getpid());
-	if (ret < 0) {
-		perror("asprintf(CHECK_SWAP)");
+	ret = snprintf(addr_pattern, MAX_LINE_LENGTH, "%08llx-", addr);
+	if (ret >= MAX_LINE_LENGTH) {
+		printf("%s: Pattern is too long\n", __func__);
+		exit(EXIT_FAILURE);
+	}
+
+
+	fp = fopen(PID_SMAPS, "r");
+	if (!fp) {
+		printf("%s: Failed to open file %s\n", __func__, PID_SMAPS);
 		exit(EXIT_FAILURE);
 	}
+	if (!check_for_pattern(fp, addr_pattern, buffer))
+		goto err_out;
 
-	ret = system(cmd);
-	free(cmd);
-	if (ret < 0 || !WIFEXITED(ret)) {
-		perror("system(check_swap)");
+	ret = snprintf(addr_pattern, MAX_LINE_LENGTH, "Swap:%19lld kB", size >> 10);
+	if (ret >= MAX_LINE_LENGTH) {
+		printf("%s: Pattern is too long\n", __func__);
 		exit(EXIT_FAILURE);
 	}
+	/*
+	 * Fetch the Swap: in the same block and check whether it got
+	 * the expected number of hugeepages next.
+	 */
+	if (!check_for_pattern(fp, "Swap:", buffer))
+		goto err_out;
+
+	if (strncmp(buffer, addr_pattern, strlen(addr_pattern)))
+		goto err_out;
 
-	return WEXITSTATUS(ret);
+	swap = true;
+err_out:
+	fclose(fp);
+	return swap;
 }
 
 static void *alloc_mapping(void)

_

Patches currently in -mm which might be from [email protected] are

khugepaged-add-self-test.patch

author maintainer tree notice
#148 lore raw

[folded-merged] khugepaged-add-self-test-fix-2-fix.patch removed from -mm tree

In reply to Andrew Morton
The patch titled Subject: khugepaged-add-self-test-fix-2-fix has been removed from the -mm tree. Its filename was khugepaged-add-self-test-fix-2-fix.patch

The patch titled
Subject: khugepaged-add-self-test-fix-2-fix
has been removed from the -mm tree. Its filename was
khugepaged-add-self-test-fix-2-fix.patch

This patch was dropped because it was folded into khugepaged-add-self-test.patch

------------------------------------------------------
From: "Kirill A. Shutemov" <[email protected]>
Subject: khugepaged-add-self-test-fix-2-fix

fixup for issues I've noticed.

---

 tools/testing/selftests/vm/khugepaged.c |   14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
tools/testing/selftests/vm/khugepaged.c renamed from tools/testing/selftests/vm/khugepaged.c~khugepaged-add-self-test-fix-2-fix +9 -5
@@ -342,7 +342,7 @@ static bool check_for_pattern(FILE *fp,
 	return false;
 }
 
-static bool check_huge(char *addr)
+static bool check_huge(void *addr)
 {
 	bool thp = false;
 	int ret;
@@ -350,7 +350,8 @@ static bool check_huge(char *addr)
 	char buffer[MAX_LINE_LENGTH];
 	char addr_pattern[MAX_LINE_LENGTH];
 
-	ret = snprintf(addr_pattern, MAX_LINE_LENGTH, "%08llx-", addr);
+	ret = snprintf(addr_pattern, MAX_LINE_LENGTH, "%08lx-",
+		       (unsigned long) addr);
 	if (ret >= MAX_LINE_LENGTH) {
 		printf("%s: Pattern is too long\n", __func__);
 		exit(EXIT_FAILURE);
@@ -365,7 +366,8 @@ static bool check_huge(char *addr)
 	if (!check_for_pattern(fp, addr_pattern, buffer))
 		goto err_out;
 
-	ret = snprintf(addr_pattern, MAX_LINE_LENGTH, "AnonHugePages:%10lld kB", hpage_pmd_size >> 10);
+	ret = snprintf(addr_pattern, MAX_LINE_LENGTH, "AnonHugePages:%10ld kB",
+		       hpage_pmd_size >> 10);
 	if (ret >= MAX_LINE_LENGTH) {
 		printf("%s: Pattern is too long\n", __func__);
 		exit(EXIT_FAILURE);
@@ -395,7 +397,8 @@ static bool check_swap(void *addr, unsig
 	char buffer[MAX_LINE_LENGTH];
 	char addr_pattern[MAX_LINE_LENGTH];
 
-	ret = snprintf(addr_pattern, MAX_LINE_LENGTH, "%08llx-", addr);
+	ret = snprintf(addr_pattern, MAX_LINE_LENGTH, "%08lx-",
+		       (unsigned long) addr);
 	if (ret >= MAX_LINE_LENGTH) {
 		printf("%s: Pattern is too long\n", __func__);
 		exit(EXIT_FAILURE);
@@ -410,7 +413,8 @@ static bool check_swap(void *addr, unsig
 	if (!check_for_pattern(fp, addr_pattern, buffer))
 		goto err_out;
 
-	ret = snprintf(addr_pattern, MAX_LINE_LENGTH, "Swap:%19lld kB", size >> 10);
+	ret = snprintf(addr_pattern, MAX_LINE_LENGTH, "Swap:%19ld kB",
+		       size >> 10);
 	if (ret >= MAX_LINE_LENGTH) {
 		printf("%s: Pattern is too long\n", __func__);
 		exit(EXIT_FAILURE);

_

Patches currently in -mm which might be from [email protected] are

khugepaged-add-self-test.patch
mm-filemap-fix-a-data-race-in-filemap_fault.patch

author maintainer tree notice
#149 lore raw

[folded-merged] khugepaged-add-self-test-fix-3.patch removed from -mm tree

In reply to Andrew Morton
The patch titled Subject: khugepaged-add-self-test-fix-3 has been removed from the -mm tree. Its filename was khugepaged-add-self-test-fix-3.patch

The patch titled
Subject: khugepaged-add-self-test-fix-3
has been removed from the -mm tree. Its filename was
khugepaged-add-self-test-fix-3.patch

This patch was dropped because it was folded into khugepaged-add-self-test.patch

------------------------------------------------------
From: John Hubbard <[email protected]>
Subject: khugepaged-add-self-test-fix-3

Add khugepaged to .gitignore.

---

 tools/testing/selftests/vm/.gitignore |    1 +
 1 file changed, 1 insertion(+)
tools/testing/selftests/vm/.gitignore renamed from tools/testing/selftests/vm/.gitignore~khugepaged-add-self-test-fix-3 +1 -0
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0-only
 hugepage-mmap
 hugepage-shm
+khugepaged
 map_hugetlb
 map_populate
 thuge-gen

_

Patches currently in -mm which might be from [email protected] are

mm-gup-move-__get_user_pages_fast-down-a-few-lines-in-gupc.patch mm-gup-refactor-and-de-duplicate-gup_fast-code.patch mm-gup-introduce-pin_user_pages_fast_only.patch drm-i915-convert-get_user_pages-pin_user_pages.patch mm-gup-might_lock_readmmap_sem-in-get_user_pages_fast.patch khugepaged-add-self-test.patch rapidio-convert-get_user_pages-pin_user_pages.patch mm-gup-update-pin_user_pagesrst-for-case-3-mmu-notifiers.patch mm-gup-introduce-pin_user_pages_locked.patch mm-gup-introduce-pin_user_pages_locked-v2.patch mm-gup-frame_vector-convert-get_user_pages-pin_user_pages.patch mm-gup-documentation-fix-for-pin_user_pages-apis.patch docs-mm-gup-pin_user_pagesrst-add-a-case-5.patch vhost-convert-get_user_pages-pin_user_pages.patch

author maintainer tree notice
#150 lore raw

[folded-merged] khugepaged-allow-to-collapse-a-page-shared-across-fork-fix.patch removed from -mm tree

In reply to Andrew Morton
The patch titled Subject: mm: khugepaged: remove error message when checking external pins has been removed from the -mm tree. Its filename was…

The patch titled
Subject: mm: khugepaged: remove error message when checking external pins
has been removed from the -mm tree. Its filename was
khugepaged-allow-to-collapse-a-page-shared-across-fork-fix.patch

This patch was dropped because it was folded into khugepaged-allow-to-collapse-a-page-shared-across-fork.patch

------------------------------------------------------
From: Yang Shi <[email protected]>
Subject: mm: khugepaged: remove error message when checking external pins

When running khugepaged with higher frequency (for example, set scan_sleep_millisecs to 0), the below error message was reported:

khugepaged: expected_refcount (1024) > refcount (512) page:ffffd75784258000 count:511 mapcount:1 mapping:ffff968de06c7421 index:0x7fa288600
compound_mapcount: 0
flags: 0x17fffc00009003c(uptodate|dirty|lru|active|head|swapbacked)

 raw: 017fffc00009003c ffffd7578ba70788 ffffd7578bdb5148 ffff968de06c7421
 raw: 00000007fa288600 0000000000000000 000001ff00000000 ffff968e5e7d6000
 page dumped because: Unexpected refcount
 page->mem_cgroup:ffff968e5e7d6000

This is introduced by allowing collapsing fork shared and PTE-mapped THPs. The check may run into the below race:

Assuming parent process forked child process, then they do

	CPU A		CPU B			CPU C
	-----		-----			-----

Parent Child khugepaged

MADV_DONTNEED
split huge pmd
Double mapped
MADV_DONTNEED
zap_huge_pmd
remove_page_rmap
Clear double map
khugepaged_scan_pmd(parent)
check mapcount and refcount --> total_mapcount > refcount
dec mapcount

The issue can be reproduced by the below test program.

---8<---
void main()

{
        void *addr;
        int ret;
        pid_t pid;

        addr = memalign(ALIGN, 2 * 1024 * 1024);
        if (!addr) {
                printf("malloc failed
");
                return;
        }

        ret = madvise(addr, 2 * 1024 * 1024, MADV_HUGEPAGE);
        if (ret < 0) {
                printf("madvise failed
");
                return;
        }

        memset(addr, 0xdeadbeef, 2 * 1024 * 1024);

        pid = fork();

        if (pid == 0) {
                /* Child process */
                ret = madvise(addr + (2 * 1024 * 1024) - 4096, 4096, MADV_DONTNEED);
                if (ret < 0) {
                        printf("madvise failed in child
");
                        return;
                }
                sleep(120);
        } else if (pid > 0) {
                sleep(5);
                /* Parent process */
                ret = madvise(addr, 2 * 1024 * 1024, MADV_DONTNEED);
                if (ret < 0) {
                        printf("madvise failed in parent
");
                        return;
                }
        } else {
                printf("fork failed
");
                return;
        }

        sleep(120);
}

---8<---

So, total_mapcount > refcount seems not unexpected due to the inherent race. Removed the error message even though it is protected by CONFIG_VM_DEBUG since we have to live with the race and AFAIK some distros may have CONFIG_VM_DEBUG enabled dy default.

Since such case is ephemeral we could always try collapse the area again later, so it sounds not harmful. But, it might report false positive if the page has excessive GUP pins (i.e. 512), however it might be not that bad since the same check will be done later. I didn't figure out a simple way to prevent the false positive.

Added some notes to elaborate the race and the consequence as well.

---

 mm/khugepaged.c |   24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)
mm/khugepaged.c renamed from mm/khugepaged.c~khugepaged-allow-to-collapse-a-page-shared-across-fork-fix +17 -7
@@ -535,12 +535,6 @@ static bool is_refcount_suitable(struct
 	if (PageSwapCache(page))
 		expected_refcount += compound_nr(page);
 
-	if (IS_ENABLED(CONFIG_DEBUG_VM) && expected_refcount > refcount) {
-		pr_err("expected_refcount (%d) > refcount (%d)\n",
-				expected_refcount, refcount);
-		dump_page(page, "Unexpected refcount");
-	}
-
 	return page_count(page) == expected_refcount;
 }
 
@@ -1243,7 +1237,23 @@ static int khugepaged_scan_pmd(struct mm
 			goto out_unmap;
 		}
 
-		/* Check if the page has any GUP (or other external) pins */
+		/*
+		 * Check if the page has any GUP (or other external) pins.
+		 *
+		 * Here the check is racy it may see totmal_mapcount > refcount
+		 * in some cases.
+		 * For example, one process with one forked child process.
+		 * The parent has the PMD split due to MADV_DONTNEED, then
+		 * the child is trying unmap the whole PMD, but khugepaged
+		 * may be scanning the parent between the child has
+		 * PageDoubleMap flag cleared and dec the mapcount.  So
+		 * khugepaged may see total_mapcount > refcount.
+		 *
+		 * But such case is ephemeral we could always retry collapse
+		 * later.  However it may report false positive if the page
+		 * has excessive GUP pins (i.e. 512).  Anyway the same check
+		 * will be done again later the risk seems low.
+		 */
 		if (!is_refcount_suitable(page)) {
 			result = SCAN_PAGE_COUNT;
 			goto out_unmap;

_

Patches currently in -mm which might be from [email protected] are

khugepaged-allow-to-collapse-a-page-shared-across-fork.patch mm-thp-dont-need-drain-lru-cache-when-splitting-and-mlocking-thp.patch

author maintainer tree notice
#151 lore raw

[folded-merged] khugepaged-allow-to-collapse-a-page-shared-across-fork-fix-fix.patch removed from -mm tree

In reply to Andrew Morton
The patch titled Subject: khugepaged-allow-to-collapse-a-page-shared-across-fork-fix-fix has been removed from the -mm tree. Its filename was…

The patch titled
Subject: khugepaged-allow-to-collapse-a-page-shared-across-fork-fix-fix
has been removed from the -mm tree. Its filename was
khugepaged-allow-to-collapse-a-page-shared-across-fork-fix-fix.patch

This patch was dropped because it was folded into khugepaged-allow-to-collapse-a-page-shared-across-fork.patch

------------------------------------------------------
From: Qian Cai <[email protected]>
Subject: khugepaged-allow-to-collapse-a-page-shared-across-fork-fix-fix

fix set-but-not-used warning

---

 mm/khugepaged.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
mm/khugepaged.c renamed from mm/khugepaged.c~khugepaged-allow-to-collapse-a-page-shared-across-fork-fix-fix +1 -2
@@ -528,9 +528,8 @@ static void release_pte_pages(pte_t *pte
 
 static bool is_refcount_suitable(struct page *page)
 {
-	int expected_refcount, refcount;
+	int expected_refcount;
 
-	refcount = page_count(page);
 	expected_refcount = total_mapcount(page);
 	if (PageSwapCache(page))
 		expected_refcount += compound_nr(page);

_

Patches currently in -mm which might be from [email protected] are

khugepaged-allow-to-collapse-a-page-shared-across-fork.patch mm-deactivations-shouldnt-bias-the-lru-balance-fix.patch mm-kmemleak-silence-kcsan-splats-in-checksum.patch mm-frontswap-mark-various-intentional-data-races.patch mm-page_io-mark-various-intentional-data-races.patch mm-page_io-mark-various-intentional-data-races-v2.patch mm-swap_state-mark-various-intentional-data-races.patch mm-swapfile-fix-and-annotate-various-data-races.patch mm-swapfile-fix-and-annotate-various-data-races-v2.patch mm-page_counter-fix-various-data-races-at-memsw.patch mm-memcontrol-fix-a-data-race-in-scan-count.patch mm-list_lru-fix-a-data-race-in-list_lru_count_one.patch mm-mempool-fix-a-data-race-in-mempool_free.patch mm-util-annotate-an-data-race-at-vm_committed_as.patch mm-rmap-annotate-a-data-race-at-tlb_flush_batched.patch mm-annotate-a-data-race-in-page_zonenum.patch mm-swap-annotate-data-races-for-lru_rotate_pvecs.patch

author maintainer tree notice
#152 lore raw

[folded-merged] khugepaged-introduce-max_ptes_shared-tunable-fix.patch removed from -mm tree

In reply to Andrew Morton
The patch titled Subject: selftests: khugepaged: fix several spelling mistakes has been removed from the -mm tree. Its filename was khugepaged-introduce-max_ptes_shared-tunable-fix.patch

The patch titled
Subject: selftests: khugepaged: fix several spelling mistakes
has been removed from the -mm tree. Its filename was
khugepaged-introduce-max_ptes_shared-tunable-fix.patch

This patch was dropped because it was folded into khugepaged-introduce-max_ptes_shared-tunable.patch

------------------------------------------------------
From: Colin Ian King <[email protected]>
Subject: selftests: khugepaged: fix several spelling mistakes

There are three spelling mistakes in various messages. Fix these.

---

 tools/testing/selftests/vm/khugepaged.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/vm/khugepaged.c renamed from tools/testing/selftests/vm/khugepaged.c~khugepaged-introduce-max_ptes_shared-tunable-fix +1 -1
@@ -961,7 +961,7 @@ static void collapse_max_ptes_shared()
 		else
 			fail("Fail");
 
-		if (wait_for_scan("Do not collapse with max_ptes_shared exeeded", p))
+		if (wait_for_scan("Do not collapse with max_ptes_shared exceeded", p))
 			fail("Timeout");
 		else if (!check_huge(p))
 			success("OK");

_

Patches currently in -mm which might be from [email protected] are

khugepaged-introduce-max_ptes_shared-tunable.patch

author maintainer tree notice
#153 lore raw

[folded-merged] hugetlbfs-remove-hugetlb_add_hstate-warning-for-existing-hstate-fix.patch removed from -mm tree

In reply to Andrew Morton
The patch titled Subject: arm64/hugetlb: fix hugetlb initialization has been removed from the -mm tree. Its filename was hugetlbfs-remove-hugetlb_add_hstate-warning-for-existing-hstate-fix.patch

The patch titled
Subject: arm64/hugetlb: fix hugetlb initialization
has been removed from the -mm tree. Its filename was
hugetlbfs-remove-hugetlb_add_hstate-warning-for-existing-hstate-fix.patch

This patch was dropped because it was folded into hugetlbfs-remove-hugetlb_add_hstate-warning-for-existing-hstate.patch

------------------------------------------------------
From: Mike Kravetz <[email protected]>
Subject: arm64/hugetlb: fix hugetlb initialization

When calling hugetlb_add_hstate() to initialize a new hugetlb size, be sure to use correct huge pages size order.

Cc Mina Almasry <[email protected]>
Cc Albert Ou <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Christian Borntraeger <[email protected]>
Cc Christophe Leroy <[email protected]>
Cc Dave Hansen <[email protected]>
Cc David S. Miller <[email protected]>
Cc Heiko Carstens <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Jonathan Corbet <[email protected]>
Cc Longpeng <[email protected]>
Cc Nitesh Narayan Lal <[email protected]>
Cc Palmer Dabbelt <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Paul Walmsley <[email protected]>
Cc Peter Xu <[email protected]>
Cc Randy Dunlap <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Vasily Gorbik <[email protected]>
Cc Stephen Rothwell <[email protected]>
Cc "Aneesh Kumar K.V" <[email protected]>

---

 arch/arm64/mm/hugetlbpage.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/mm/hugetlbpage.c renamed from arch/arm64/mm/hugetlbpage.c~hugetlbfs-remove-hugetlb_add_hstate-warning-for-existing-hstate-fix +2 -2
@@ -448,9 +448,9 @@ static int __init hugetlbpage_init(void)
 #ifdef CONFIG_ARM64_4K_PAGES
 	hugetlb_add_hstate(PUD_SHIFT - PAGE_SHIFT);
 #endif
-	hugetlb_add_hstate(CONT_PMD_SHIFT - PAGE_SHIFT);
+	hugetlb_add_hstate((CONT_PMD_SHIFT + PMD_SHIFT) - PAGE_SHIFT);
 	hugetlb_add_hstate(PMD_SHIFT - PAGE_SHIFT);
-	hugetlb_add_hstate(CONT_PTE_SHIFT - PAGE_SHIFT);
+	hugetlb_add_hstate((CONT_PTE_SHIFT + PAGE_SHIFT) - PAGE_SHIFT);
 
 	return 0;
 }

_

Patches currently in -mm which might be from [email protected] are

hugetlbfs-add-arch_hugetlb_valid_size.patch hugetlbfs-move-hugepagesz=-parsing-to-arch-independent-code.patch hugetlbfs-remove-hugetlb_add_hstate-warning-for-existing-hstate.patch hugetlbfs-clean-up-command-line-processing.patch hugetlbfs-move-hugepagesz=-parsing-to-arch-independent-code-fix.patch

author maintainer tree notice
#154 lore raw

[folded-merged] mm-memcontrol-switch-to-native-nr_anon_thps-counter-fix.patch removed from -mm tree

In reply to Andrew Morton
The patch titled Subject: mm-memcontrol-switch-to-native-nr_anon_thps-counter-fix has been removed from the -mm tree. Its filename was mm-memcontrol-switch-to-native-nr_anon_thps-counter-fix.patch

The patch titled
Subject: mm-memcontrol-switch-to-native-nr_anon_thps-counter-fix
has been removed from the -mm tree. Its filename was
mm-memcontrol-switch-to-native-nr_anon_thps-counter-fix.patch

This patch was dropped because it was folded into mm-memcontrol-switch-to-native-nr_anon_thps-counter.patch

------------------------------------------------------
From: Johannes Weiner <[email protected]>
Subject: mm-memcontrol-switch-to-native-nr_anon_thps-counter-fix

The THP page size macros are CONFIG_TRANSPARENT_HUGEPAGE only.

We already ifdef most THP-related code in memcg, but not these particular stats. Memcg used to track the pages as they came in, and PageTransHuge() + hpage_nr_pages() work when THP is not compiled in.

Switching to native vmstat counters, memcg doesn't see the pages, it only gets a count of THPs. To translate that to bytes, it has to know how big the THPs are - and that's only available for CONFIG_THP.

Add the necessary ifdefs. /proc/meminfo, smaps etc. also don't show the THP counters when the feature is compiled out. The event counts (THP_FAULT_ALLOC, THP_COLLAPSE_ALLOC) were already conditional also.

Style touchup: HPAGE_PMD_NR * PAGE_SIZE is silly. Use HPAGE_PMD_SIZE.

---

 mm/memcontrol.c |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
mm/memcontrol.c renamed from mm/memcontrol.c~mm-memcontrol-switch-to-native-nr_anon_thps-counter-fix +9 -1
@@ -1401,9 +1401,11 @@ static char *memory_stat_format(struct m
 		       (u64)memcg_page_state(memcg, NR_WRITEBACK) *
 		       PAGE_SIZE);
 
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
 	seq_buf_printf(&s, "anon_thp %llu\n",
 		       (u64)memcg_page_state(memcg, NR_ANON_THPS) *
-		       HPAGE_PMD_NR * PAGE_SIZE);
+		       HPAGE_PMD_SIZE);
+#endif
 
 	for (i = 0; i < NR_LRU_LISTS; i++)
 		seq_buf_printf(&s, "%s %llu\n", lru_list_name(i),
@@ -3805,7 +3807,9 @@ static int memcg_numa_stat_show(struct s
 static const unsigned int memcg1_stats[] = {
 	NR_FILE_PAGES,
 	NR_ANON_MAPPED,
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
 	NR_ANON_THPS,
+#endif
 	NR_SHMEM,
 	NR_FILE_MAPPED,
 	NR_FILE_DIRTY,
@@ -3816,7 +3820,9 @@ static const unsigned int memcg1_stats[]
 static const char *const memcg1_stat_names[] = {
 	"cache",
 	"rss",
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
 	"rss_huge",
+#endif
 	"shmem",
 	"mapped_file",
 	"dirty",
@@ -3847,8 +3853,10 @@ static int memcg_stat_show(struct seq_fi
 		if (memcg1_stats[i] == MEMCG_SWAP && !do_memsw_account())
 			continue;
 		nr = memcg_page_state_local(memcg, memcg1_stats[i]);
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
 		if (memcg1_stats[i] == NR_ANON_THPS)
 			nr *= HPAGE_PMD_NR;
+#endif
 		seq_printf(m, "%s %lu\n", memcg1_stat_names[i], nr * PAGE_SIZE);
 	}
 

_

Patches currently in -mm which might be from [email protected] are

mm-fix-numa-node-file-count-error-in-replace_page_cache.patch mm-memcontrol-fix-stat-corrupting-race-in-charge-moving.patch mm-memcontrol-drop-compound-parameter-from-memcg-charging-api.patch mm-shmem-remove-rare-optimization-when-swapin-races-with-hole-punching.patch mm-memcontrol-move-out-cgroup-swaprate-throttling.patch mm-memcontrol-convert-page-cache-to-a-new-mem_cgroup_charge-api.patch mm-memcontrol-prepare-uncharging-for-removal-of-private-page-type-counters.patch mm-memcontrol-prepare-move_account-for-removal-of-private-page-type-counters.patch mm-memcontrol-prepare-cgroup-vmstat-infrastructure-for-native-anon-counters.patch mm-memcontrol-switch-to-native-nr_file_pages-and-nr_shmem-counters.patch mm-memcontrol-switch-to-native-nr_anon_mapped-counter.patch mm-memcontrol-switch-to-native-nr_anon_thps-counter.patch mm-memcontrol-convert-anon-and-file-thp-to-new-mem_cgroup_charge-api.patch mm-memcontrol-convert-anon-and-file-thp-to-new-mem_cgroup_charge-api-fix.patch mm-memcontrol-drop-unused-try-commit-cancel-charge-api.patch mm-memcontrol-prepare-swap-controller-setup-for-integration.patch mm-memcontrol-make-swap-tracking-an-integral-part-of-memory-control.patch mm-memcontrol-make-swap-tracking-an-integral-part-of-memory-control-fix-v2.patch mm-memcontrol-charge-swapin-pages-on-instantiation.patch mm-memcontrol-delete-unused-lrucare-handling.patch mm-memcontrol-update-page-mem_cgroup-stability-rules.patch mm-fix-lru-balancing-effect-of-new-transparent-huge-pages.patch mm-keep-separate-anon-and-file-statistics-on-page-reclaim-activity.patch mm-allow-swappiness-that-prefers-reclaiming-anon-over-the-file-workingset.patch mm-fold-and-remove-lru_cache_add_anon-and-lru_cache_add_file.patch mm-workingset-let-cache-workingset-challenge-anon.patch mm-remove-use-once-cache-bias-from-lru-balancing.patch mm-vmscan-drop-unnecessary-div0-avoidance-rounding-in-get_scan_count.patch mm-base-lru-balancing-on-an-explicit-cost-model.patch mm-deactivations-shouldnt-bias-the-lru-balance.patch mm-only-count-actual-rotations-as-lru-reclaim-cost.patch mm-balance-lru-lists-based-on-relative-thrashing.patch mm-vmscan-determine-anon-file-pressure-balance-at-the-reclaim-root.patch mm-vmscan-reclaim-writepage-is-io-cost.patch mm-vmscan-limit-the-range-of-lru-type-balancing.patch

author maintainer tree notice
#155 lore raw

[folded-merged] mm-memcontrol-convert-anon-and-file-thp-to-new-mem_cgroup_charge-api-fix.patch removed from -mm tree

In reply to Andrew Morton
The patch titled Subject: mm-memcontrol-convert-anon-and-file-thp-to-new-mem_cgroup_charge-api-fix has been removed from the -mm tree. Its filename was…

The patch titled
Subject: mm-memcontrol-convert-anon-and-file-thp-to-new-mem_cgroup_charge-api-fix
has been removed from the -mm tree. Its filename was
mm-memcontrol-convert-anon-and-file-thp-to-new-mem_cgroup_charge-api-fix.patch

This patch was dropped because it was folded into mm-memcontrol-convert-anon-and-file-thp-to-new-mem_cgroup_charge-api.patch

------------------------------------------------------
From: Johannes Weiner <[email protected]>
Subject: mm-memcontrol-convert-anon-and-file-thp-to-new-mem_cgroup_charge-api-fix

Fix crash. If you have CONFIG_NUMA and the allocation fails, *hpage could contain an ERR_PTR instead of being NULL.

---

 mm/khugepaged.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
mm/khugepaged.c renamed from mm/khugepaged.c~mm-memcontrol-convert-anon-and-file-thp-to-new-mem_cgroup_charge-api-fix +2 -2
@@ -1186,7 +1186,7 @@ static void collapse_huge_page(struct mm
 out_up_write:
 	up_write(&mm->mmap_sem);
 out_nolock:
-	if (*hpage)
+	if (!IS_ERR_OR_NULL(*hpage))
 		mem_cgroup_uncharge(*hpage);
 	trace_mm_collapse_huge_page(mm, isolated, result);
 	return;
@@ -1938,7 +1938,7 @@ xa_unlocked:
 	unlock_page(new_page);
 out:
 	VM_BUG_ON(!list_empty(&pagelist));
-	if (*hpage)
+	if (!IS_ERR_OR_NULL(*hpage))
 		mem_cgroup_uncharge(*hpage);
 	/* TODO: tracepoints */
 }

_

Patches currently in -mm which might be from [email protected] are

mm-fix-numa-node-file-count-error-in-replace_page_cache.patch mm-memcontrol-fix-stat-corrupting-race-in-charge-moving.patch mm-memcontrol-drop-compound-parameter-from-memcg-charging-api.patch mm-shmem-remove-rare-optimization-when-swapin-races-with-hole-punching.patch mm-memcontrol-move-out-cgroup-swaprate-throttling.patch mm-memcontrol-convert-page-cache-to-a-new-mem_cgroup_charge-api.patch mm-memcontrol-prepare-uncharging-for-removal-of-private-page-type-counters.patch mm-memcontrol-prepare-move_account-for-removal-of-private-page-type-counters.patch mm-memcontrol-prepare-cgroup-vmstat-infrastructure-for-native-anon-counters.patch mm-memcontrol-switch-to-native-nr_file_pages-and-nr_shmem-counters.patch mm-memcontrol-switch-to-native-nr_anon_mapped-counter.patch mm-memcontrol-switch-to-native-nr_anon_thps-counter.patch mm-memcontrol-convert-anon-and-file-thp-to-new-mem_cgroup_charge-api.patch mm-memcontrol-drop-unused-try-commit-cancel-charge-api.patch mm-memcontrol-prepare-swap-controller-setup-for-integration.patch mm-memcontrol-make-swap-tracking-an-integral-part-of-memory-control.patch mm-memcontrol-make-swap-tracking-an-integral-part-of-memory-control-fix-v2.patch mm-memcontrol-charge-swapin-pages-on-instantiation.patch mm-memcontrol-delete-unused-lrucare-handling.patch mm-memcontrol-update-page-mem_cgroup-stability-rules.patch mm-fix-lru-balancing-effect-of-new-transparent-huge-pages.patch mm-keep-separate-anon-and-file-statistics-on-page-reclaim-activity.patch mm-allow-swappiness-that-prefers-reclaiming-anon-over-the-file-workingset.patch mm-fold-and-remove-lru_cache_add_anon-and-lru_cache_add_file.patch mm-workingset-let-cache-workingset-challenge-anon.patch mm-remove-use-once-cache-bias-from-lru-balancing.patch mm-vmscan-drop-unnecessary-div0-avoidance-rounding-in-get_scan_count.patch mm-base-lru-balancing-on-an-explicit-cost-model.patch mm-deactivations-shouldnt-bias-the-lru-balance.patch mm-only-count-actual-rotations-as-lru-reclaim-cost.patch mm-balance-lru-lists-based-on-relative-thrashing.patch mm-vmscan-determine-anon-file-pressure-balance-at-the-reclaim-root.patch mm-vmscan-reclaim-writepage-is-io-cost.patch mm-vmscan-limit-the-range-of-lru-type-balancing.patch

author maintainer tree notice
#156 lore raw

[folded-merged] mm-memcontrol-drop-unused-try-commit-cancel-charge-api-fix.patch removed from -mm tree

In reply to Andrew Morton
The patch titled Subject: mm: memcontrol: fix an unused-function warning has been removed from the -mm tree. Its filename was mm-memcontrol-drop-unused-try-commit-cancel-charge-api-fix.patch

The patch titled
Subject: mm: memcontrol: fix an unused-function warning
has been removed from the -mm tree. Its filename was
mm-memcontrol-drop-unused-try-commit-cancel-charge-api-fix.patch

This patch was dropped because it was folded into mm-memcontrol-drop-unused-try-commit-cancel-charge-api.patch

------------------------------------------------------
From: Arnd Bergmann <[email protected]>
Subject: mm: memcontrol: fix an unused-function warning

On NOMMU kernels without CONFIG_MEMCG_KMEM, we now get a harmless warning about an unused function:

mm/memcontrol.c:2595:13: error: unused function 'cancel_charge' [-Werror,-Wunused-function]

Hide this function in a matching #ifdef.

Fixes 5bd144bf764c ("mm: memcontrol: drop unused try/commit/cancel charge API")

---

 mm/memcontrol.c |    2 ++
 1 file changed, 2 insertions(+)
mm/memcontrol.c renamed from mm/memcontrol.c~mm-memcontrol-drop-unused-try-commit-cancel-charge-api-fix +2 -0
@@ -2641,6 +2641,7 @@ done_restock:
 	return 0;
 }
 
+#if defined(CONFIG_MEMCG_KMEM) || defined(CONFIG_MMU)
 static void cancel_charge(struct mem_cgroup *memcg, unsigned int nr_pages)
 {
 	if (mem_cgroup_is_root(memcg))
@@ -2652,6 +2653,7 @@ static void cancel_charge(struct mem_cgr
 
 	css_put_many(&memcg->css, nr_pages);
 }
+#endif
 
 static void lock_page_lru(struct page *page, int *isolated)
 {

_

Patches currently in -mm which might be from [email protected] are

mm-memcontrol-drop-unused-try-commit-cancel-charge-api.patch drm-remove-drm-specific-kmap_atomic-code-fix.patch bitops-avoid-clang-shift-count-overflow-warnings.patch ubsan-fix-gcc-10-warnings.patch arm64-add-support-for-folded-p4d-page-tables-fix.patch

author maintainer tree notice
#157 lore raw

[folded-merged] mm-memcontrol-make-swap-tracking-an-integral-part-of-memory-control-fix-v2.patch removed from -mm tree

In reply to Andrew Morton
The patch titled Subject: Re: mm: mkfs.ext4 invoked oom-killer on i386 - pagecache_get_page has been removed from the -mm tree. Its filename was…

The patch titled
Subject: Re: mm: mkfs.ext4 invoked oom-killer on i386 - pagecache_get_page
has been removed from the -mm tree. Its filename was
mm-memcontrol-make-swap-tracking-an-integral-part-of-memory-control-fix-v2.patch

This patch was dropped because it was folded into mm-memcontrol-make-swap-tracking-an-integral-part-of-memory-control.patch

------------------------------------------------------
From: Johannes Weiner <[email protected]>
Subject: Re: mm: mkfs.ext4 invoked oom-killer on i386 - pagecache_get_page

Fix crash with cgroup_disable=memory:

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines

+ mkfs -t ext4 /dev/disk/by-id/ata-TOSHIBA_MG04ACA100N_Y8NRK0BPF6XF mke2fs 1.43.8 (1-Jan-2018)
Creating filesystem with 244190646 4k blocks and 61054976 inodes Filesystem UUID: 3bb1a285-2cb4-44b4-b6e8-62548f3ac620 Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 102400000, 214990848

Allocating group tables:    0/7453                           done
Writing inode tables:    0/7453                           done
Creating journal (262144 blocks): [   35.502102] BUG: kernel NULL
pointer dereference, address: 000000c8
[   35.508372] #PF: supervisor read access in kernel mode
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
[   35.513506] #PF: error_code(0x0000) - not-present page
[   35.518638] *pde = 00000000
[   35.521514] Oops: 0000 [#1] SMP
[   35.524652] CPU: 0 PID: 145 Comm: kswapd0 Not tainted
5.7.0-rc6-next-20200519+ #1
[   35.532121] Hardware name: Supermicro SYS-5019S-ML/X11SSH-F, BIOS
2.2 05/23/2018
[   35.539507] EIP: mem_cgroup_get_nr_swap_pages+0x28/0x60

Swap accounting used to be implied-disabled when the cgroup controller was disabled. Restore that for the new cgroup_memory_noswap, so that we bail out of this function instead of dereferencing a NULL memcg.

---

 mm/memcontrol.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
mm/memcontrol.c renamed from mm/memcontrol.c~mm-memcontrol-make-swap-tracking-an-integral-part-of-memory-control-fix-v2 +5 -1
@@ -7243,7 +7243,11 @@ static struct cftype memsw_files[] = {
 
 static int __init mem_cgroup_swap_init(void)
 {
-	if (mem_cgroup_disabled() || cgroup_memory_noswap)
+	/* No memory control -> no swap control */
+	if (mem_cgroup_disabled())
+		cgroup_memory_noswap = true;
+
+	if (cgroup_memory_noswap)
 		return 0;
 
 	WARN_ON(cgroup_add_dfl_cftypes(&memory_cgrp_subsys, swap_files));

_

Patches currently in -mm which might be from [email protected] are

mm-fix-numa-node-file-count-error-in-replace_page_cache.patch mm-memcontrol-fix-stat-corrupting-race-in-charge-moving.patch mm-memcontrol-drop-compound-parameter-from-memcg-charging-api.patch mm-shmem-remove-rare-optimization-when-swapin-races-with-hole-punching.patch mm-memcontrol-move-out-cgroup-swaprate-throttling.patch mm-memcontrol-convert-page-cache-to-a-new-mem_cgroup_charge-api.patch mm-memcontrol-prepare-uncharging-for-removal-of-private-page-type-counters.patch mm-memcontrol-prepare-move_account-for-removal-of-private-page-type-counters.patch mm-memcontrol-prepare-cgroup-vmstat-infrastructure-for-native-anon-counters.patch mm-memcontrol-switch-to-native-nr_file_pages-and-nr_shmem-counters.patch mm-memcontrol-switch-to-native-nr_anon_mapped-counter.patch mm-memcontrol-switch-to-native-nr_anon_thps-counter.patch mm-memcontrol-convert-anon-and-file-thp-to-new-mem_cgroup_charge-api.patch mm-memcontrol-drop-unused-try-commit-cancel-charge-api.patch mm-memcontrol-prepare-swap-controller-setup-for-integration.patch mm-memcontrol-make-swap-tracking-an-integral-part-of-memory-control.patch mm-memcontrol-charge-swapin-pages-on-instantiation.patch mm-memcontrol-delete-unused-lrucare-handling.patch mm-memcontrol-update-page-mem_cgroup-stability-rules.patch mm-fix-lru-balancing-effect-of-new-transparent-huge-pages.patch mm-keep-separate-anon-and-file-statistics-on-page-reclaim-activity.patch mm-allow-swappiness-that-prefers-reclaiming-anon-over-the-file-workingset.patch mm-fold-and-remove-lru_cache_add_anon-and-lru_cache_add_file.patch mm-workingset-let-cache-workingset-challenge-anon.patch mm-remove-use-once-cache-bias-from-lru-balancing.patch mm-vmscan-drop-unnecessary-div0-avoidance-rounding-in-get_scan_count.patch mm-base-lru-balancing-on-an-explicit-cost-model.patch mm-deactivations-shouldnt-bias-the-lru-balance.patch mm-only-count-actual-rotations-as-lru-reclaim-cost.patch mm-balance-lru-lists-based-on-relative-thrashing.patch mm-vmscan-determine-anon-file-pressure-balance-at-the-reclaim-root.patch mm-vmscan-reclaim-writepage-is-io-cost.patch mm-vmscan-limit-the-range-of-lru-type-balancing.patch

author maintainer tree notice
#158 lore raw

[folded-merged] mm-memcontrol-charge-swapin-pages-on-instantiation-fix.patch removed from -mm tree

In reply to Andrew Morton
The patch titled Subject: mm/swap: fix livelock in __read_swap_cache_async() has been removed from the -mm tree. Its filename was mm-memcontrol-charge-swapin-pages-on-instantiation-fix.patch

The patch titled
Subject: mm/swap: fix livelock in __read_swap_cache_async()
has been removed from the -mm tree. Its filename was
mm-memcontrol-charge-swapin-pages-on-instantiation-fix.patch

This patch was dropped because it was folded into mm-memcontrol-charge-swapin-pages-on-instantiation.patch

------------------------------------------------------
From: Hugh Dickins <[email protected]>
Subject: mm/swap: fix livelock in __read_swap_cache_async()

I've only seen this livelock on one machine (repeatably, but not to order), and not fully analyzed it - two processes seen looping around getting -EEXIST from swapcache_prepare(), I guess a third (at lower priority? but wanting the same cpu as one of the loopers? preemption or cond_resched() not enough to let it back in?) set SWAP_HAS_CACHE, then went off into direct reclaim, scheduled away, and somehow could not get back to add the page to swap cache and let them all complete.

Restore the page allocation in __read_swap_cache_async() to before the swapcache_prepare() call: "mm: memcontrol: charge swapin pages on instantiation" moved it outside the loop, which indeed looks much nicer, but exposed this weakness. We used to allocate new_page once and then keep it across all iterations of the loop: but I think that just optimizes for a rare case, and complicates the flow, so go with the new simpler structure, with allocate+free each time around (which is more considerate use of the memory too).

Fix the comment on the looping case, which has long been inaccurate: it's not a racing get_swap_page() that's the problem here.

Fix the add_to_swap_cache() and mem_cgroup_charge() error recovery: not swap_free(), but put_swap_page() to undo SWAP_HAS_CACHE, as was done before; but delete_from_swap_cache() already includes it.

And one more nit: I don't think it makes any difference in practice, but remove the "& GFP_KERNEL" mask from the mem_cgroup_charge() call:
add_to_swap_cache() needs that, to convert gfp_mask from user and page cache allocation (e.g. highmem) to radix node allocation (lowmem), but we don't need or usually apply that mask when charging mem_cgroup.

---

 mm/swap_state.c |   52 +++++++++++++++++++++++++---------------------
 1 file changed, 29 insertions(+), 23 deletions(-)
mm/swap_state.c renamed from mm/swap_state.c~mm-memcontrol-charge-swapin-pages-on-instantiation-fix +29 -23
@@ -393,56 +393,62 @@ struct page *__read_swap_cache_async(swp
 			return NULL;
 
 		/*
+		 * Get a new page to read into from swap.  Allocate it now,
+		 * before marking swap_map SWAP_HAS_CACHE, when -EEXIST will
+		 * cause any racers to loop around until we add it to cache.
+		 */
+		page = alloc_page_vma(gfp_mask, vma, addr);
+		if (!page)
+			return NULL;
+
+		/*
 		 * Swap entry may have been freed since our caller observed it.
 		 */
 		err = swapcache_prepare(entry);
 		if (!err)
 			break;
 
-		if (err == -EEXIST) {
-			/*
-			 * We might race against get_swap_page() and stumble
-			 * across a SWAP_HAS_CACHE swap_map entry whose page
-			 * has not been brought into the swapcache yet.
-			 */
-			cond_resched();
-			continue;
-		}
+		put_page(page);
+		if (err != -EEXIST)
+			return NULL;
 
-		return NULL;
+		/*
+		 * We might race against __delete_from_swap_cache(), and
+		 * stumble across a swap_map entry whose SWAP_HAS_CACHE
+		 * has not yet been cleared.  Or race against another
+		 * __read_swap_cache_async(), which has set SWAP_HAS_CACHE
+		 * in swap_map, but not yet added its page to swap cache.
+		 */
+		cond_resched();
 	}
 
 	/*
-	 * The swap entry is ours to swap in. Prepare a new page.
+	 * The swap entry is ours to swap in. Prepare the new page.
 	 */
 
-	page = alloc_page_vma(gfp_mask, vma, addr);
-	if (!page)
-		goto fail_free;
-
 	__SetPageLocked(page);
 	__SetPageSwapBacked(page);
 
 	/* May fail (-ENOMEM) if XArray node allocation failed. */
-	if (add_to_swap_cache(page, entry, gfp_mask & GFP_KERNEL))
+	if (add_to_swap_cache(page, entry, gfp_mask & GFP_KERNEL)) {
+		put_swap_page(page, entry);
 		goto fail_unlock;
+	}
 
-	if (mem_cgroup_charge(page, NULL, gfp_mask & GFP_KERNEL, false))
-		goto fail_delete;
+	if (mem_cgroup_charge(page, NULL, gfp_mask, false)) {
+		delete_from_swap_cache(page);
+		goto fail_unlock;
+	}
 
-	/* Initiate read into locked page */
+	/* Caller will initiate read into locked page */
 	SetPageWorkingset(page);
 	lru_cache_add_anon(page);
 	*new_page_allocated = true;
 	return page;
 
-fail_delete:
-	delete_from_swap_cache(page);
 fail_unlock:
 	unlock_page(page);
 	put_page(page);
-fail_free:
-	swap_free(entry);
 	return NULL;
 }
 

_

Patches currently in -mm which might be from [email protected] are

mm-memcontrol-charge-swapin-pages-on-instantiation.patch mm-vmstat-add-events-for-pmd-based-thp-migration-without-split-fix.patch

author maintainer tree notice
#159 lore raw

[folded-merged] mm-fold-and-remove-lru_cache_add_anon-and-lru_cache_add_file-fix.patch removed from -mm tree

In reply to Andrew Morton
The patch titled Subject: mm-fold-and-remove-lru_cache_add_anon-and-lru_cache_add_file-fix has been removed from the -mm tree. Its filename was…

The patch titled
Subject: mm-fold-and-remove-lru_cache_add_anon-and-lru_cache_add_file-fix
has been removed from the -mm tree. Its filename was
mm-fold-and-remove-lru_cache_add_anon-and-lru_cache_add_file-fix.patch

This patch was dropped because it was folded into mm-fold-and-remove-lru_cache_add_anon-and-lru_cache_add_file.patch

------------------------------------------------------
From: Andrew Morton <[email protected]>
Subject: mm-fold-and-remove-lru_cache_add_anon-and-lru_cache_add_file-fix

fix it for local_lock changes

Cc Johannes Weiner <[email protected]>
Cc Joonsoo Kim <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Minchan Kim <[email protected]>
Cc Rik van Riel <[email protected]>

---

 mm/swap.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
mm/swap.c renamed from mm/swap.c~mm-fold-and-remove-lru_cache_add_anon-and-lru_cache_add_file-fix +4 -2
@@ -435,15 +435,17 @@ EXPORT_SYMBOL(mark_page_accessed);
  */
 void lru_cache_add(struct page *page)
 {
-	struct pagevec *pvec = &get_cpu_var(lru_add_pvec);
+	struct pagevec *pvec;
 
 	VM_BUG_ON_PAGE(PageActive(page) && PageUnevictable(page), page);
 	VM_BUG_ON_PAGE(PageLRU(page), page);
 
 	get_page(page);
+	local_lock(&lru_pvecs.lock);
+	pvec = this_cpu_ptr(&lru_pvecs.lru_add);
 	if (!pagevec_add(pvec, page) || PageCompound(page))
 		__pagevec_lru_add(pvec);
-	put_cpu_var(lru_add_pvec);
+	local_unlock(&lru_pvecs.lock);
 }
 EXPORT_SYMBOL(lru_cache_add);
 

_

Patches currently in -mm which might be from [email protected] are

mm-fold-and-remove-lru_cache_add_anon-and-lru_cache_add_file.patch mm-add-debug_wx-support-fix.patch
riscv-support-debug_wx-fix.patch drivers-tty-serial-sh-scic-suppress-uninitialized-var-warning.patch mm.patch mm-page_alloc-skip-waternark_boost-for-atomic-order-0-allocations-fix.patch arch-kunmap-remove-duplicate-kunmap-implementations-fix.patch arch-kmap_atomic-consolidate-duplicate-code-checkpatch-fixes.patch arch-kunmap_atomic-consolidate-duplicate-code-checkpatch-fixes.patch kmap-consolidate-kmap_prot-definitions-checkpatch-fixes.patch mm-replace-zero-length-array-with-flexible-array-member-fix.patch mm-hugetlb-fix-a-typo-in-comment-manitained-maintained-v2-checkpatch-fixes.patch seq_file-introduce-define_seq_attribute-helper-macro-checkpatch-fixes.patch ipc-convert-ipcs_idr-to-xarray-update-fix.patch
linux-next-pre.patch
linux-next-rejects.patch
linux-next-git-rejects.patch
linux-next-post.patch
kernel-add-panic_on_taint-fix.patch mm-consolidate-pgd_index-and-pgd_offset_k-definitions-fix.patch mmap-locking-api-convert-mmap_sem-call-sites-missed-by-coccinelle-fix.patch mmap-locking-api-convert-mmap_sem-call-sites-missed-by-coccinelle-fix-fix.patch mmap-locking-api-convert-mmap_sem-call-sites-missed-by-coccinelle-fix-fix-fix.patch mmap-locking-api-rename-mmap_sem-to-mmap_lock-fix.patch mmap-locking-api-convert-mmap_sem-comments-fix.patch mmap-locking-api-convert-mmap_sem-comments-fix-fix.patch mmap-locking-api-convert-mmap_sem-comments-fix-fix-fix.patch mm-pass-task-and-mm-to-do_madvise.patch mm-introduce-external-memory-hinting-api-fix-2-fix.patch mm-support-vector-address-ranges-for-process_madvise-fix-fix-fix-fix-fix.patch maccess-unify-the-probe-kernel-arch-hooks-fix.patch bpf-bpf_seq_printf-handle-potentially-unsafe-format-string-better.patch maccess-always-use-strict-semantics-for-probe_kernel_read-fix.patch x86-use-non-set_fs-based-maccess-routines-checkpatch-fixes.patch doc-cgroup-update-note-about-conditions-when-oom-killer-is-invoked-fix.patch sh-convert-ins-outs-macros-to-inline-functions-checkpatch-fixes.patch kernel-forkc-export-kernel_thread-to-modules.patch

author maintainer tree notice
#160 lore raw

[folded-merged] mm-deactivations-shouldnt-bias-the-lru-balance-fix.patch removed from -mm tree

In reply to Andrew Morton
The patch titled Subject: mm-deactivations-shouldnt-bias-the-lru-balance-fix has been removed from the -mm tree. Its filename was mm-deactivations-shouldnt-bias-the-lru-balance-fix.patch

The patch titled
Subject: mm-deactivations-shouldnt-bias-the-lru-balance-fix
has been removed from the -mm tree. Its filename was
mm-deactivations-shouldnt-bias-the-lru-balance-fix.patch

This patch was dropped because it was folded into mm-deactivations-shouldnt-bias-the-lru-balance.patch

------------------------------------------------------
From: Qian Cai <[email protected]>
Subject: mm-deactivations-shouldnt-bias-the-lru-balance-fix

fix set-but-not-used warning

---

 mm/swap.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
mm/swap.c renamed from mm/swap.c~mm-deactivations-shouldnt-bias-the-lru-balance-fix +1 -2
@@ -472,7 +472,7 @@ void lru_cache_add_active_or_unevictable
 static void lru_deactivate_file_fn(struct page *page, struct lruvec *lruvec,
 			      void *arg)
 {
-	int lru, file;
+	int lru;
 	bool active;
 
 	if (!PageLRU(page))
@@ -486,7 +486,6 @@ static void lru_deactivate_file_fn(struc
 		return;
 
 	active = PageActive(page);
-	file = page_is_file_lru(page);
 	lru = page_lru_base_type(page);
 
 	del_page_from_lru_list(page, lruvec, lru + active);

_

Patches currently in -mm which might be from [email protected] are

mm-deactivations-shouldnt-bias-the-lru-balance.patch mm-kmemleak-silence-kcsan-splats-in-checksum.patch mm-frontswap-mark-various-intentional-data-races.patch mm-page_io-mark-various-intentional-data-races.patch mm-page_io-mark-various-intentional-data-races-v2.patch mm-swap_state-mark-various-intentional-data-races.patch mm-swapfile-fix-and-annotate-various-data-races.patch mm-swapfile-fix-and-annotate-various-data-races-v2.patch mm-page_counter-fix-various-data-races-at-memsw.patch mm-memcontrol-fix-a-data-race-in-scan-count.patch mm-list_lru-fix-a-data-race-in-list_lru_count_one.patch mm-mempool-fix-a-data-race-in-mempool_free.patch mm-util-annotate-an-data-race-at-vm_committed_as.patch mm-rmap-annotate-a-data-race-at-tlb_flush_batched.patch mm-annotate-a-data-race-in-page_zonenum.patch mm-swap-annotate-data-races-for-lru_rotate_pvecs.patch

author maintainer tree notice
#161 lore raw

[folded-merged] mm-thp-rename-pmd_mknotpresent-as-pmd_mkinvalid-v2.patch removed from -mm tree

In reply to Andrew Morton
The patch titled Subject: mm-thp-rename-pmd_mknotpresent-as-pmd_mkinvalid-v2 has been removed from the -mm tree. Its filename was mm-thp-rename-pmd_mknotpresent-as-pmd_mkinvalid-v2.patch

The patch titled
Subject: mm-thp-rename-pmd_mknotpresent-as-pmd_mkinvalid-v2
has been removed from the -mm tree. Its filename was
mm-thp-rename-pmd_mknotpresent-as-pmd_mkinvalid-v2.patch

This patch was dropped because it was folded into mm-thp-rename-pmd_mknotpresent-as-pmd_mknotvalid.patch

------------------------------------------------------
From: Anshuman Khandual <[email protected]>
Subject: mm-thp-rename-pmd_mknotpresent-as-pmd_mkinvalid-v2

chang pmd_mknotvalid() to pmd_mkinvalid() per Will

---

 arch/arc/include/asm/hugepage.h       |    2 +-
 arch/arm/include/asm/pgtable-3level.h |    2 +-
 arch/arm64/include/asm/pgtable.h      |    2 +-
 arch/mips/include/asm/pgtable.h       |    2 +-
 arch/x86/include/asm/pgtable.h        |    2 +-
 arch/x86/mm/kmmio.c                   |    2 +-
 mm/pgtable-generic.c                  |    2 +-
 7 files changed, 7 insertions(+), 7 deletions(-)
arch/arc/include/asm/hugepage.h renamed from arch/arc/include/asm/hugepage.h~mm-thp-rename-pmd_mknotpresent-as-pmd_mkinvalid-v2 +1 -1
@@ -26,7 +26,7 @@ static inline pmd_t pte_pmd(pte_t pte)
 #define pmd_mkold(pmd)		pte_pmd(pte_mkold(pmd_pte(pmd)))
 #define pmd_mkyoung(pmd)	pte_pmd(pte_mkyoung(pmd_pte(pmd)))
 #define pmd_mkhuge(pmd)		pte_pmd(pte_mkhuge(pmd_pte(pmd)))
-#define pmd_mknotvalid(pmd)	pte_pmd(pte_mknotpresent(pmd_pte(pmd)))
+#define pmd_mkinvalid(pmd)	pte_pmd(pte_mknotpresent(pmd_pte(pmd)))
 #define pmd_mkclean(pmd)	pte_pmd(pte_mkclean(pmd_pte(pmd)))
 
 #define pmd_write(pmd)		pte_write(pmd_pte(pmd))
arch/arm64/include/asm/pgtable.h renamed from arch/arm64/include/asm/pgtable.h~mm-thp-rename-pmd_mknotpresent-as-pmd_mkinvalid-v2 +1 -1
@@ -366,7 +366,7 @@ static inline int pmd_protnone(pmd_t pmd
 #define pmd_mkclean(pmd)	pte_pmd(pte_mkclean(pmd_pte(pmd)))
 #define pmd_mkdirty(pmd)	pte_pmd(pte_mkdirty(pmd_pte(pmd)))
 #define pmd_mkyoung(pmd)	pte_pmd(pte_mkyoung(pmd_pte(pmd)))
-#define pmd_mknotvalid(pmd)	(__pmd(pmd_val(pmd) & ~PMD_SECT_VALID))
+#define pmd_mkinvalid(pmd)	(__pmd(pmd_val(pmd) & ~PMD_SECT_VALID))
 
 #define pmd_thp_or_huge(pmd)	(pmd_huge(pmd) || pmd_trans_huge(pmd))
 
arch/arm/include/asm/pgtable-3level.h renamed from arch/arm/include/asm/pgtable-3level.h~mm-thp-rename-pmd_mknotpresent-as-pmd_mkinvalid-v2 +1 -1
@@ -221,7 +221,7 @@ PMD_BIT_FUNC(mkyoung,   |= PMD_SECT_AF);
 #define pmdp_establish generic_pmdp_establish
 
 /* represent a notpresent pmd by faulting entry, this is used by pmdp_invalidate */
-static inline pmd_t pmd_mknotvalid(pmd_t pmd)
+static inline pmd_t pmd_mkinvalid(pmd_t pmd)
 {
 	return __pmd(pmd_val(pmd) & ~L_PMD_SECT_VALID);
 }
arch/mips/include/asm/pgtable.h renamed from arch/mips/include/asm/pgtable.h~mm-thp-rename-pmd_mknotpresent-as-pmd_mkinvalid-v2 +1 -1
@@ -631,7 +631,7 @@ static inline pmd_t pmd_modify(pmd_t pmd
 	return pmd;
 }
 
-static inline pmd_t pmd_mknotvalid(pmd_t pmd)
+static inline pmd_t pmd_mkinvalid(pmd_t pmd)
 {
 	pmd_val(pmd) &= ~(_PAGE_PRESENT | _PAGE_VALID | _PAGE_DIRTY);
 
arch/x86/include/asm/pgtable.h renamed from arch/x86/include/asm/pgtable.h~mm-thp-rename-pmd_mknotpresent-as-pmd_mkinvalid-v2 +1 -1
@@ -624,7 +624,7 @@ static inline pud_t pfn_pud(unsigned lon
 	return __pud(pfn | check_pgprot(pgprot));
 }
 
-static inline pmd_t pmd_mknotvalid(pmd_t pmd)
+static inline pmd_t pmd_mkinvalid(pmd_t pmd)
 {
 	return pfn_pmd(pmd_pfn(pmd),
 		      __pgprot(pmd_flags(pmd) & ~(_PAGE_PRESENT|_PAGE_PROTNONE)));
arch/x86/mm/kmmio.c renamed from arch/x86/mm/kmmio.c~mm-thp-rename-pmd_mknotpresent-as-pmd_mkinvalid-v2 +1 -1
@@ -130,7 +130,7 @@ static void clear_pmd_presence(pmd_t *pm
 	pmdval_t v = pmd_val(*pmd);
 	if (clear) {
 		*old = v;
-		new_pmd = pmd_mknotvalid(*pmd);
+		new_pmd = pmd_mkinvalid(*pmd);
 	} else {
 		/* Presume this has been called with clear==true previously */
 		new_pmd = __pmd(*old);
mm/pgtable-generic.c renamed from mm/pgtable-generic.c~mm-thp-rename-pmd_mknotpresent-as-pmd_mkinvalid-v2 +1 -1
@@ -194,7 +194,7 @@ pgtable_t pgtable_trans_huge_withdraw(st
 pmd_t pmdp_invalidate(struct vm_area_struct *vma, unsigned long address,
 		     pmd_t *pmdp)
 {
-	pmd_t old = pmdp_establish(vma, address, pmdp, pmd_mknotvalid(*pmdp));
+	pmd_t old = pmdp_establish(vma, address, pmdp, pmd_mkinvalid(*pmdp));
 	flush_pmd_tlb_range(vma, address, address + HPAGE_PMD_SIZE);
 	return old;
 }

_

Patches currently in -mm which might be from [email protected] are

mm-page_alloc-restrict-and-formalize-compound_page_dtors.patch arm64-mm-drop-__have_arch_huge_ptep_get.patch mm-hugetlb-define-a-generic-fallback-for-is_hugepage_only_range.patch mm-hugetlb-define-a-generic-fallback-for-arch_clear_hugepage_flags.patch powerpc-mm-drop-platform-defined-pmd_mknotpresent.patch mm-thp-rename-pmd_mknotpresent-as-pmd_mknotvalid.patch mm-vmstat-add-events-for-pmd-based-thp-migration-without-split.patch mm-vmstat-add-events-for-pmd-based-thp-migration-without-split-update.patch x86-mm-define-mm_p4d_folded.patch mm-debug-add-tests-validating-architecture-page-table-helpers.patch mm-debug-add-tests-validating-architecture-page-table-helpers-v17.patch mm-debug-add-tests-validating-architecture-page-table-helpers-v18.patch

author maintainer tree notice
#162 lore raw

[folded-merged] drivers-base-memoryc-cache-memory-blocks-in-xarray-to-accelerate-lookup-fix.patch removed from -mm tree

In reply to Andrew Morton
The patch titled Subject: drivers-base-memoryc-cache-memory-blocks-in-xarray-to-accelerate-lookup-fix has been removed from the -mm tree. Its filename was…

The patch titled
Subject: drivers-base-memoryc-cache-memory-blocks-in-xarray-to-accelerate-lookup-fix
has been removed from the -mm tree. Its filename was
drivers-base-memoryc-cache-memory-blocks-in-xarray-to-accelerate-lookup-fix.patch

This patch was dropped because it was folded into drivers-base-memoryc-cache-memory-blocks-in-xarray-to-accelerate-lookup.patch

------------------------------------------------------
From: David Hildenbrand <[email protected]>
Subject: drivers-base-memoryc-cache-memory-blocks-in-xarray-to-accelerate-lookup-fix

document the locking

Cc Scott Cheloha <[email protected]>
Cc David Hildenbrand <[email protected]>
Cc Nathan Lynch <[email protected]>
Cc Michal Hocko <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Rick Lindsley <[email protected]>

---

 drivers/base/memory.c |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/base/memory.c renamed from drivers/base/memory.c~drivers-base-memoryc-cache-memory-blocks-in-xarray-to-accelerate-lookup-fix +10 -1
@@ -497,7 +497,11 @@ int __weak arch_get_memory_phys_device(u
 	return 0;
 }
 
-/* A reference for the returned memory block device is acquired. */
+/*
+ * A reference for the returned memory block device is acquired.
+ *
+ * Called under device_hotplug_lock.
+ */
 static struct memory_block *find_memory_block_by_id(unsigned long block_id)
 {
 	struct memory_block *mem;
@@ -508,6 +512,9 @@ static struct memory_block *find_memory_
 	return mem;
 }
 
+/*
+ * Called under device_hotplug_lock.
+ */
 struct memory_block *find_memory_block(struct mem_section *section)
 {
 	unsigned long block_id = base_memory_block_id(__section_nr(section));
@@ -761,6 +768,8 @@ void __init memory_dev_init(void)
  *
  * In case func() returns an error, walking is aborted and the error is
  * returned.
+ *
+ * Called under device_hotplug_lock.
  */
 int walk_memory_blocks(unsigned long start, unsigned long size,
 		       void *arg, walk_memory_blocks_func_t func)

_

Patches currently in -mm which might be from [email protected] are

drivers-base-memoryc-cache-memory-blocks-in-xarray-to-accelerate-lookup.patch powerpc-pseries-hotplug-memory-stop-checking-is_mem_section_removable.patch mm-memory_hotplug-remove-is_mem_section_removable.patch mm-memory_hotplug-set-node_start_pfn-of-hotadded-pgdat-to-0.patch mm-memory_hotplug-handle-memblocks-only-with-config_arch_keep_memblock.patch mm-memory_hotplug-introduce-add_memory_driver_managed.patch kexec_file-dont-place-kexec-images-on-ioresource_mem_driver_managed.patch device-dax-add-memory-via-add_memory_driver_managed.patch

author maintainer tree notice
#163 lore raw

[folded-merged] mm-add-debug_wx-support-fix.patch removed from -mm tree

In reply to Andrew Morton
The patch titled Subject: mm-add-debug_wx-support-fix has been removed from the -mm tree. Its filename was mm-add-debug_wx-support-fix.patch

The patch titled
Subject: mm-add-debug_wx-support-fix
has been removed from the -mm tree. Its filename was
mm-add-debug_wx-support-fix.patch

This patch was dropped because it was folded into mm-add-debug_wx-support.patch

------------------------------------------------------
From: Andrew Morton <[email protected]>
Subject: mm-add-debug_wx-support-fix

reword text, per Will Deacon & Zong Li

---

 mm/Kconfig.debug |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
mm/Kconfig.debug renamed from mm/Kconfig.debug~mm-add-debug_wx-support-fix +2 -2
@@ -128,8 +128,8 @@ config DEBUG_WX
 	help
 	  Generate a warning if any W+X mappings are found at boot.
 
-	  This is useful for discovering cases where the kernel is leaving
-	  W+X mappings after applying NX, as such mappings are a security risk.
+	  This is useful for discovering cases where the kernel is leaving W+X
+	  mappings after applying NX, as such mappings are a security risk.
 	  This check also includes UXN, which should be set on all kernel
 	  mappings.
 

_

Patches currently in -mm which might be from [email protected] are

mm-add-debug_wx-support.patch
riscv-support-debug_wx-fix.patch drivers-tty-serial-sh-scic-suppress-uninitialized-var-warning.patch mm.patch mm-page_alloc-skip-waternark_boost-for-atomic-order-0-allocations-fix.patch arch-kunmap-remove-duplicate-kunmap-implementations-fix.patch arch-kmap_atomic-consolidate-duplicate-code-checkpatch-fixes.patch arch-kunmap_atomic-consolidate-duplicate-code-checkpatch-fixes.patch kmap-consolidate-kmap_prot-definitions-checkpatch-fixes.patch mm-replace-zero-length-array-with-flexible-array-member-fix.patch mm-hugetlb-fix-a-typo-in-comment-manitained-maintained-v2-checkpatch-fixes.patch seq_file-introduce-define_seq_attribute-helper-macro-checkpatch-fixes.patch ipc-convert-ipcs_idr-to-xarray-update-fix.patch
linux-next-pre.patch
linux-next-rejects.patch
linux-next-git-rejects.patch
linux-next-post.patch
kernel-add-panic_on_taint-fix.patch mm-consolidate-pgd_index-and-pgd_offset_k-definitions-fix.patch mmap-locking-api-convert-mmap_sem-call-sites-missed-by-coccinelle-fix.patch mmap-locking-api-convert-mmap_sem-call-sites-missed-by-coccinelle-fix-fix.patch mmap-locking-api-convert-mmap_sem-call-sites-missed-by-coccinelle-fix-fix-fix.patch mmap-locking-api-rename-mmap_sem-to-mmap_lock-fix.patch mmap-locking-api-convert-mmap_sem-comments-fix.patch mmap-locking-api-convert-mmap_sem-comments-fix-fix.patch mmap-locking-api-convert-mmap_sem-comments-fix-fix-fix.patch mm-pass-task-and-mm-to-do_madvise.patch mm-introduce-external-memory-hinting-api-fix-2-fix.patch mm-support-vector-address-ranges-for-process_madvise-fix-fix-fix-fix-fix.patch maccess-unify-the-probe-kernel-arch-hooks-fix.patch bpf-bpf_seq_printf-handle-potentially-unsafe-format-string-better.patch maccess-always-use-strict-semantics-for-probe_kernel_read-fix.patch x86-use-non-set_fs-based-maccess-routines-checkpatch-fixes.patch doc-cgroup-update-note-about-conditions-when-oom-killer-is-invoked-fix.patch sh-convert-ins-outs-macros-to-inline-functions-checkpatch-fixes.patch kernel-forkc-export-kernel_thread-to-modules.patch

author maintainer tree notice
#164 lore raw

[folded-merged] mm-add-debug_wx-support-fix-2.patch removed from -mm tree

In reply to Andrew Morton
The patch titled Subject: mm: remove the specific name of arm64 has been removed from the -mm tree. Its filename was mm-add-debug_wx-support-fix-2.patch

The patch titled
Subject: mm: remove the specific name of arm64
has been removed from the -mm tree. Its filename was
mm-add-debug_wx-support-fix-2.patch

This patch was dropped because it was folded into mm-add-debug_wx-support.patch

------------------------------------------------------
From: Zong Li <[email protected]>
Subject: mm: remove the specific name of arm64

UXN is the name of arm64 page-table descriptors.

---

 mm/Kconfig.debug |    2 --
 1 file changed, 2 deletions(-)
mm/Kconfig.debug renamed from mm/Kconfig.debug~mm-add-debug_wx-support-fix-2 +0 -2
@@ -130,8 +130,6 @@ config DEBUG_WX
 
 	  This is useful for discovering cases where the kernel is leaving W+X
 	  mappings after applying NX, as such mappings are a security risk.
-	  This check also includes UXN, which should be set on all kernel
-	  mappings.
 
 	  Look for a message in dmesg output like this:
 

_

Patches currently in -mm which might be from [email protected] are

mm-add-debug_wx-support.patch mm-add-debug_wx-support-fix-3.patch riscv-support-debug_wx.patch x86-mm-use-arch_has_debug_wx-instead-of-arch-defined.patch arm64-mm-use-arch_has_debug_wx-instead-of-arch-defined.patch

author maintainer tree notice
#165 lore raw

[folded-merged] mm-add-debug_wx-support-fix-3.patch removed from -mm tree

In reply to Andrew Morton
The patch titled Subject: mm: add MMU dependency for DEBUG_WX has been removed from the -mm tree. Its filename was mm-add-debug_wx-support-fix-3.patch

The patch titled
Subject: mm: add MMU dependency for DEBUG_WX
has been removed from the -mm tree. Its filename was
mm-add-debug_wx-support-fix-3.patch

This patch was dropped because it was folded into mm-add-debug_wx-support.patch

------------------------------------------------------
From: Zong Li <[email protected]>
Subject: mm: add MMU dependency for DEBUG_WX

DEBUG_WX should be enabled on MMU system. It had got build error when enabling DEBUG_WX on NOMMU.

---

 mm/Kconfig.debug |    1 +
 1 file changed, 1 insertion(+)
mm/Kconfig.debug renamed from mm/Kconfig.debug~mm-add-debug_wx-support-fix-3 +1 -0
@@ -124,6 +124,7 @@ config ARCH_HAS_DEBUG_WX
 config DEBUG_WX
 	bool "Warn on W+X mappings at boot"
 	depends on ARCH_HAS_DEBUG_WX
+	depends on MMU
 	select PTDUMP_CORE
 	help
 	  Generate a warning if any W+X mappings are found at boot.

_

Patches currently in -mm which might be from [email protected] are

mm-add-debug_wx-support.patch riscv-support-debug_wx.patch x86-mm-use-arch_has_debug_wx-instead-of-arch-defined.patch arm64-mm-use-arch_has_debug_wx-instead-of-arch-defined.patch

author maintainer tree notice
#166 lore raw

[folded-merged] riscv-support-debug_wx-fix.patch removed from -mm tree

In reply to Andrew Morton
The patch titled Subject: riscv-support-debug_wx-fix has been removed from the -mm tree. Its filename was riscv-support-debug_wx-fix.patch

The patch titled
Subject: riscv-support-debug_wx-fix
has been removed from the -mm tree. Its filename was
riscv-support-debug_wx-fix.patch

This patch was dropped because it was folded into riscv-support-debug_wx.patch

------------------------------------------------------
From: Andrew Morton <[email protected]>
Subject: riscv-support-debug_wx-fix

replace macros with C

Cc Borislav Petkov <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Palmer Dabbelt <[email protected]>
Cc Paul Walmsley <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Will Deacon <[email protected]>
Cc Zong Li <[email protected]>

---

 arch/riscv/include/asm/ptdump.h |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
arch/riscv/include/asm/ptdump.h renamed from arch/riscv/include/asm/ptdump.h~riscv-support-debug_wx-fix +7 -2
@@ -9,9 +9,14 @@
 void ptdump_check_wx(void);
 
 #ifdef CONFIG_DEBUG_WX
-#define debug_checkwx() ptdump_check_wx()
+static inline void debug_checkwx(void)
+{
+	ptdump_check_wx();
+}
 #else
-#define debug_checkwx() do { } while (0)
+static inline void debug_checkwx(void)
+{
+}
 #endif
 
 #endif /* _ASM_RISCV_PTDUMP_H */

_

Patches currently in -mm which might be from [email protected] are

riscv-support-debug_wx.patch drivers-tty-serial-sh-scic-suppress-uninitialized-var-warning.patch mm.patch mm-page_alloc-skip-waternark_boost-for-atomic-order-0-allocations-fix.patch arch-kunmap-remove-duplicate-kunmap-implementations-fix.patch arch-kmap_atomic-consolidate-duplicate-code-checkpatch-fixes.patch arch-kunmap_atomic-consolidate-duplicate-code-checkpatch-fixes.patch kmap-consolidate-kmap_prot-definitions-checkpatch-fixes.patch mm-replace-zero-length-array-with-flexible-array-member-fix.patch mm-hugetlb-fix-a-typo-in-comment-manitained-maintained-v2-checkpatch-fixes.patch seq_file-introduce-define_seq_attribute-helper-macro-checkpatch-fixes.patch ipc-convert-ipcs_idr-to-xarray-update-fix.patch
linux-next-pre.patch
linux-next-rejects.patch
linux-next-git-rejects.patch
linux-next-post.patch
kernel-add-panic_on_taint-fix.patch mm-consolidate-pgd_index-and-pgd_offset_k-definitions-fix.patch mmap-locking-api-convert-mmap_sem-call-sites-missed-by-coccinelle-fix.patch mmap-locking-api-convert-mmap_sem-call-sites-missed-by-coccinelle-fix-fix.patch mmap-locking-api-convert-mmap_sem-call-sites-missed-by-coccinelle-fix-fix-fix.patch mmap-locking-api-rename-mmap_sem-to-mmap_lock-fix.patch mmap-locking-api-convert-mmap_sem-comments-fix.patch mmap-locking-api-convert-mmap_sem-comments-fix-fix.patch mmap-locking-api-convert-mmap_sem-comments-fix-fix-fix.patch mm-pass-task-and-mm-to-do_madvise.patch mm-introduce-external-memory-hinting-api-fix-2-fix.patch mm-support-vector-address-ranges-for-process_madvise-fix-fix-fix-fix-fix.patch maccess-unify-the-probe-kernel-arch-hooks-fix.patch bpf-bpf_seq_printf-handle-potentially-unsafe-format-string-better.patch maccess-always-use-strict-semantics-for-probe_kernel_read-fix.patch x86-use-non-set_fs-based-maccess-routines-checkpatch-fixes.patch doc-cgroup-update-note-about-conditions-when-oom-killer-is-invoked-fix.patch sh-convert-ins-outs-macros-to-inline-functions-checkpatch-fixes.patch kernel-forkc-export-kernel_thread-to-modules.patch