mm: move drivers/char/mem.c to mm/char-mem.c

The memory character driver implements several mm-specific features and is
always compiled into the kernel, so move it to mm/ where it belongs.

Among other things the driver implements /dev/mem which provides raw access
to physical memory, and /dev/zero which either allows mapping of a shmem
region (if mapped with MAP_SHARED) or, uniquely, anonymous memory (if
mapped MAP_PRIVATE).

This change lays the foundations to allow MAP_PRIVATE-/dev/zero to be
mapped precisely the same as anonymous memory is mapped as currently it is
an edge case within mm.

Also update a couple of comments that reference 'drivers/char/mem.c' to
reference 'mm/char-mem.c'.

Link: https://lore.kernel.org/[email protected]
Signed-off-by: Lorenzo Stoakes (ARM) <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Acked-by: David Hildenbrand (Arm) <[email protected]>
Acked-by: Mike Rapoport (Microsoft) <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Liam R. Howlett <[email protected]>
Cc: Vlastimil Babka <[email protected]>
Cc: Jann Horn <[email protected]>
Cc: Pedro Falcato <[email protected]>
Cc: Suren Baghdasaryan <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: Hugh Dickins <[email protected]>
Cc: Baolin Wang <[email protected]>
Cc: Matthew Wilcox (Oracle) <[email protected]>
Cc: Jan Kara <[email protected]>
This commit is contained in:
Lorenzo Stoakes (ARM)
2026-10-08 22:55:00 -07:00
committed by Andrew Morton
parent 63a08a1124
commit 9ee6e52616
5 changed files with 7 additions and 6 deletions
+2 -2
View File
@@ -17269,7 +17269,7 @@ F: Documentation/ABI/testing/sysfs-kernel-mm-cma
F: Documentation/ABI/testing/sysfs-kernel-mm-numa
F: Documentation/admin-guide/mm/
F: Documentation/mm/
F: drivers/char/mem.c
F: mm/char-mem.c
F: include/linux/cma.h
F: include/linux/dmapool.h
F: include/linux/ioremap.h
@@ -17493,7 +17493,7 @@ L: [email protected]
S: Maintained
W: http://www.linux-mm.org
T: git git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
F: drivers/char/mem.c
F: mm/char-mem.c
F: include/trace/events/mmap.h
F: fs/proc/task_mmu.c
F: fs/proc/task_nommu.c
+1 -1
View File
@@ -3,7 +3,7 @@
# Makefile for the kernel character device drivers.
#
obj-y += mem.o random.o
obj-y += random.o
obj-$(CONFIG_TTY_PRINTK) += ttyprintk.o
obj-y += misc.o
obj-$(CONFIG_TEST_MISC_MINOR) += misc_minor_kunit.o
+2 -1
View File
@@ -55,7 +55,8 @@ obj-y := filemap.o mempool.o oom_kill.o fadvise.o \
mm_init.o percpu.o slab_common.o \
compaction.o show_mem.o \
interval_tree.o list_lru.o workingset.o \
debug.o gup.o mmap_lock.o vma_init.o $(mmu-y)
debug.o gup.o mmap_lock.o vma_init.o char-mem.o \
$(mmu-y)
# Give 'page_alloc' its own module-parameter namespace
page-alloc-y := page_alloc.o
+1 -1
View File
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
/*
* linux/drivers/char/mem.c
* mm/char-mem.c
*
* Copyright (C) 1991, 1992 Linus Torvalds
*
+1 -1
View File
@@ -2984,7 +2984,7 @@ unsigned long shmem_get_unmapped_area(struct file *file,
sb = file_inode(file)->i_sb;
} else {
/*
* Called directly from mm/mmap.c, or drivers/char/mem.c
* Called directly from mm/mmap.c, or mm/char-mem.c
* for "/dev/zero", to create a shared anonymous object.
*/
if (IS_ERR(shm_mnt))