mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 11:56:58 +00:00
mm_get_unmapped_area() is a wrapper around arch_get_unmapped_area() / arch_get_unmapped_area_topdown(), both of which search current->mm for some free space. Neither take an mm_struct - they implicitly operate on current->mm. But the wrapper takes an mm_struct and uses it to decide whether to search bottom up or top down. All callers pass in current->mm for this, so everything is working consistently. But it feels like an accident waiting to happen; eventually someone will call that function with a different mm, expecting to find free space in it, but what gets returned is free space in the current mm. So let's simplify by removing the parameter and have the wrapper use current->mm to decide which end to start at. Now everything is consistent and self-documenting. Link: https://lkml.kernel.org/r/20251003155306.2147572-1-ryan.roberts@arm.com Signed-off-by: Ryan Roberts <ryan.roberts@arm.com> Acked-by: David Hildenbrand <david@redhat.com> Reviewed-by: Oscar Salvador <osalvador@suse.de> Reviewed-by: Dev Jain <dev.jain@arm.com> Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com> Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com> Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com> Cc: Liam Howlett <liam.howlett@oracle.com> Cc: Michal Hocko <mhocko@suse.com> Cc: Mike Rapoport <rppt@kernel.org> Cc: Suren Baghdasaryan <surenb@google.com> Cc: Vlastimil Babka <vbabka@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
56 lines
1.6 KiB
C
56 lines
1.6 KiB
C
/* file-mmu.c: ramfs MMU-based file operations
|
|
*
|
|
* Resizable simple ram filesystem for Linux.
|
|
*
|
|
* Copyright (C) 2000 Linus Torvalds.
|
|
* 2000 Transmeta Corp.
|
|
*
|
|
* Usage limits added by David Gibson, Linuxcare Australia.
|
|
* This file is released under the GPL.
|
|
*/
|
|
|
|
/*
|
|
* NOTE! This filesystem is probably most useful
|
|
* not as a real filesystem, but as an example of
|
|
* how virtual filesystems can be written.
|
|
*
|
|
* It doesn't get much simpler than this. Consider
|
|
* that this file implements the full semantics of
|
|
* a POSIX-compliant read-write filesystem.
|
|
*
|
|
* Note in particular how the filesystem does not
|
|
* need to implement any data structures of its own
|
|
* to keep track of the virtual data: using the VFS
|
|
* caches is sufficient.
|
|
*/
|
|
|
|
#include <linux/fs.h>
|
|
#include <linux/mm.h>
|
|
#include <linux/ramfs.h>
|
|
#include <linux/sched.h>
|
|
|
|
#include "internal.h"
|
|
|
|
static unsigned long ramfs_mmu_get_unmapped_area(struct file *file,
|
|
unsigned long addr, unsigned long len, unsigned long pgoff,
|
|
unsigned long flags)
|
|
{
|
|
return mm_get_unmapped_area(file, addr, len, pgoff, flags);
|
|
}
|
|
|
|
const struct file_operations ramfs_file_operations = {
|
|
.read_iter = generic_file_read_iter,
|
|
.write_iter = generic_file_write_iter,
|
|
.mmap_prepare = generic_file_mmap_prepare,
|
|
.fsync = noop_fsync,
|
|
.splice_read = filemap_splice_read,
|
|
.splice_write = iter_file_splice_write,
|
|
.llseek = generic_file_llseek,
|
|
.get_unmapped_area = ramfs_mmu_get_unmapped_area,
|
|
};
|
|
|
|
const struct inode_operations ramfs_file_inode_operations = {
|
|
.setattr = simple_setattr,
|
|
.getattr = simple_getattr,
|
|
};
|