From patchwork Mon May 6 16:07:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Edgecombe, Rick P" X-Patchwork-Id: 13655690 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5ABD6C25B5F for ; Mon, 6 May 2024 16:08:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E817C6B009E; Mon, 6 May 2024 12:08:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E303F6B009F; Mon, 6 May 2024 12:08:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CD3126B00A0; Mon, 6 May 2024 12:08:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id AE1646B009E for ; Mon, 6 May 2024 12:08:02 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 5B83316092E for ; Mon, 6 May 2024 16:08:02 +0000 (UTC) X-FDA: 82088452404.09.5930EC7 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) by imf01.hostedemail.com (Postfix) with ESMTP id BDF5340004 for ; Mon, 6 May 2024 16:07:59 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=hhFlzaQF; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf01.hostedemail.com: domain of rick.p.edgecombe@intel.com designates 192.198.163.9 as permitted sender) smtp.mailfrom=rick.p.edgecombe@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1715011680; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=MAoxt0uZorx92PZdarAVOJYbddRymllldjrncqelh4Y=; b=mksHJNmjdzTX4zQaMpFx9Z0KYEzL2qNbOeIXUdhqY7oSO8nPPtOnV2y+CLC4vmCg/wMBD9 WBbfAKPomc5QCFH2SbnTjXftMLRbH29a1E5hxDjyCalRPKSVu/LlettKrPyxD+fuWbSbo/ IFYYAtGEOsxy1aKrG/z6gvXUbFEaKgE= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=hhFlzaQF; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf01.hostedemail.com: domain of rick.p.edgecombe@intel.com designates 192.198.163.9 as permitted sender) smtp.mailfrom=rick.p.edgecombe@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1715011680; a=rsa-sha256; cv=none; b=FMkqOdneyYvkxMM4Vu7A+lfhTAH825VRhkge5R3A6uGBnTDewr/KF+pHvDRWE4YGUPw0Lw 6+7oLTzKQmbkBw3s3u3lNSdAKiw37xDgLaSYOVJTEtktTw/WfvI+wCdGvBrg7Sclojj3/N Z27ggDCq77nj1ek3tEtb09c9xaHdEYg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715011680; x=1746547680; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=2IOd66RSOqQqrKQkuMh3XogGiLvLLMV7lnIQ5ZnGbPE=; b=hhFlzaQFFEgRuBuLuYhI2B8vfsqHNs2TqzJyrOwuIDBMITIlOVWtL0SE dvP5suEV0SxBd1EvZNCbOzcLVdm0EhgOrbh693EfuFTlVg3dCzL8Nwsf2 b0euBUKsat0VeLD1fnfJIIXnH6X/KPDhxlPnl8/aoVcCf3u0D95E5K3EO YZ4r4eyd8boE9Wt4pR2cg+DNBHWx66datxyHn6Nl9J/CdMOJ5iYik/DkA 2q3II8SyKk6lcvA4N4mqaUWSW8ndUAlaMsINyHGiDp0/TJL0VwSa/g9XL 3SG0ZEwngAP5Ntj61SfQXYiKrsbNMXUgcdcuy16ixjsNyX/qIsB/Tmjzf Q==; X-CSE-ConnectionGUID: Fj6ZFccPTu+MaW1/tsvM8g== X-CSE-MsgGUID: eUB7k9JlS9iSNE7rlws5/w== X-IronPort-AV: E=McAfee;i="6600,9927,11065"; a="21440399" X-IronPort-AV: E=Sophos;i="6.07,258,1708416000"; d="scan'208";a="21440399" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 May 2024 09:07:58 -0700 X-CSE-ConnectionGUID: u2l7s34lSJ6s3YOUXNviqw== X-CSE-MsgGUID: +dIdv11yQnK7uo5bWilyRQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,258,1708416000"; d="scan'208";a="32705046" Received: from haabdall-mobl.amr.corp.intel.com (HELO rpedgeco-desk4.intel.com) ([10.209.82.8]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 May 2024 09:07:57 -0700 From: Rick Edgecombe To: akpm@linux-foundation.org Cc: rick.p.edgecombe@intel.com, Liam.Howlett@oracle.com, bp@alien8.de, bpf@vger.kernel.org, broonie@kernel.org, christophe.leroy@csgroup.eu, dan.j.williams@intel.com, dave.hansen@linux.intel.com, debug@rivosinc.com, hpa@zytor.com, io-uring@vger.kernel.org, keescook@chromium.org, kirill.shutemov@linux.intel.com, linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-s390@vger.kernel.org, linux-sgx@vger.kernel.org, luto@kernel.org, mingo@redhat.com, nvdimm@lists.linux.dev, peterz@infradead.org, sparclinux@vger.kernel.org, tglx@linutronix.de, x86@kernel.org Subject: [PATCH] mm: Remove mm argument from mm_get_unmapped_area() Date: Mon, 6 May 2024 09:07:47 -0700 Message-Id: <20240506160747.1321726-1-rick.p.edgecombe@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Rspamd-Server: rspam01 X-Stat-Signature: oxrz56o587j4hcjknhx7ka5199jyme45 X-Rspam-User: X-Rspamd-Queue-Id: BDF5340004 X-HE-Tag: 1715011679-450412 X-HE-Meta: U2FsdGVkX1+pynkaJSdbDsJvK7wX9kETIeCBqY4vC5mstKnuqi6Oe0jB9RfEN5dfnh0T+E6LJqYEy/rDDdMTBA9ZPeg2she98+3CjndyQzzR0sRJB+19n8OfD5UZHcsdajNFV2s8sbHn9+2do5g4V0p5ZM1ZAWerH3Kwz+AJePawoONXldhSGSAiD+xLTBpvZXZ0W59emltqrJ2is46WSvqitbtTqpFcN6SpZZ6e7jnaALyHP8MRZ7fj5cjNQJMmY6NXqDZYxCwg7eB1A4uvZLJMqa6SsrJU9nxK3OPX0lvLgC+gYPkIhNxmXLopQ26i839fDMZinGW7XrpHMzroGv/cXRgfQAkJzq/bvA5Y9YZ0gzZkEzKV1HY0iHxUoyVuRw5kjWvNMj/VpVeqmHZpS4achBTDt8i1QLwo2ZEnt/uRY9jxCZ5Xg2izmtwSZAnVtDPgOetRAKz3F7eN6+AwZCpcdaouH0bE14sBiq8kdHYTn3b1eAZN6Kw/Pbgtl2JhCgsD2crfrgmrGEFcXV+T2G463VMcu5+TD0+bqz3VNroXBonaKXy4aBZfH2fd6QEwnIk+b0ukOll2duJI74VC/2G2NIufiieF2DfQf7QtSw/xCNJZcs03w9LgPyBwz6YUBGeSoxGHvApfE2JZVbdRp/ifhxMXCfoPBpS4UTh467zx8cCQc+h/AQrDXHivfb9ZQUb5yfI0u91FdeqWAjutOOK+Eapt8Ad/b/y4ALIhoTbtcS/MrqWlLXjXraHdxGNerbDtRpQcEQI/zzmDpyx6fOYJSODL9k7tL7UufmOJhm52cuThd03YjiMun4nuhfTHIyRaL3JNCYcuQOMK2kA5rM9jpn+3xuiiY6ulRgqzWd0rmS1fChMSkXWnqW26dIItazPNUu1Hh0JyiXzmPqI003SHaolKxAS5i+cdpWTrr95QxpAFiVsj250vSrgZh5ZiTGLbJK7Fb8H+2fQ8qHF UhnS9yGJ 3BUvCKnpBAe1vWUpvqy52MjvK15XmUkcpj072cwdwqhHmmzWGpN45VABT1UmP9FS6C/O6PRed2KG489fXD1z7FqQmzSRzmoXQvDsSbm8S7gVTYb9CjlRAN+fFzH1nog+MjrX/gbRjX9mEooy/5QHErxAGsCgCEmHcFwe84Fs5NiKRvsOt1yFfjsUfROy2R2UUishGG4z2mosiMfB0XaIFLPloZCqRwK9JSlfP0KQLv6rycXsz0z8pJ0upI6/aDTe25P2evwUEsEzhxp8= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Recently the get_unmapped_area() pointer on mm_struct was removed in favor of direct callable function that can determines which of two handlers to call based on an mm flag. This function, mm_get_unmapped_area(), checks the flag of the mm passed as an argument. Dan Williams pointed out (see link) that all callers pass curret->mm, so the mm argument is unneeded. It could be conceivable for a caller to want to pass a different mm in the future, but in this case a new helper could easily be added. So remove the mm argument, and rename the function current_get_unmapped_area(). Fixes: 529ce23a764f ("mm: switch mm->get_unmapped_area() to a flag") Suggested-by: Dan Williams Signed-off-by: Rick Edgecombe Link: https://lore.kernel.org/lkml/6603bed6662a_4a98a2949e@dwillia2-mobl3.amr.corp.intel.com.notmuch/ Reviewed-by: Liam R. Howlett Reviewed-by: Jarkko Sakkinen --- Based on linux-next. --- arch/sparc/kernel/sys_sparc_64.c | 9 +++++---- arch/x86/kernel/cpu/sgx/driver.c | 2 +- drivers/char/mem.c | 2 +- drivers/dax/device.c | 6 +++--- fs/proc/inode.c | 2 +- fs/ramfs/file-mmu.c | 2 +- include/linux/sched/mm.h | 6 +++--- io_uring/memmap.c | 2 +- kernel/bpf/arena.c | 2 +- kernel/bpf/syscall.c | 2 +- mm/mmap.c | 11 +++++------ mm/shmem.c | 9 ++++----- 12 files changed, 27 insertions(+), 28 deletions(-) base-commit: 9221b2819b8a4196eecf5476d66201be60fbcf29 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c index d9c3b34ca744..cf0b4ace5bf9 100644 --- a/arch/sparc/kernel/sys_sparc_64.c +++ b/arch/sparc/kernel/sys_sparc_64.c @@ -220,7 +220,7 @@ unsigned long get_fb_unmapped_area(struct file *filp, unsigned long orig_addr, u if (flags & MAP_FIXED) { /* Ok, don't mess with it. */ - return mm_get_unmapped_area(current->mm, NULL, orig_addr, len, pgoff, flags); + return current_get_unmapped_area(NULL, orig_addr, len, pgoff, flags); } flags &= ~MAP_SHARED; @@ -233,8 +233,9 @@ unsigned long get_fb_unmapped_area(struct file *filp, unsigned long orig_addr, u align_goal = (64UL * 1024); do { - addr = mm_get_unmapped_area(current->mm, NULL, orig_addr, - len + (align_goal - PAGE_SIZE), pgoff, flags); + addr = current_get_unmapped_area(NULL, orig_addr, + len + (align_goal - PAGE_SIZE), + pgoff, flags); if (!(addr & ~PAGE_MASK)) { addr = (addr + (align_goal - 1UL)) & ~(align_goal - 1UL); break; @@ -252,7 +253,7 @@ unsigned long get_fb_unmapped_area(struct file *filp, unsigned long orig_addr, u * be obtained. */ if (addr & ~PAGE_MASK) - addr = mm_get_unmapped_area(current->mm, NULL, orig_addr, len, pgoff, flags); + addr = current_get_unmapped_area(NULL, orig_addr, len, pgoff, flags); return addr; } diff --git a/arch/x86/kernel/cpu/sgx/driver.c b/arch/x86/kernel/cpu/sgx/driver.c index 22b65a5f5ec6..5f7bfd9035f7 100644 --- a/arch/x86/kernel/cpu/sgx/driver.c +++ b/arch/x86/kernel/cpu/sgx/driver.c @@ -113,7 +113,7 @@ static unsigned long sgx_get_unmapped_area(struct file *file, if (flags & MAP_FIXED) return addr; - return mm_get_unmapped_area(current->mm, file, addr, len, pgoff, flags); + return current_get_unmapped_area(file, addr, len, pgoff, flags); } #ifdef CONFIG_COMPAT diff --git a/drivers/char/mem.c b/drivers/char/mem.c index 7c359cc406d5..a29c4bd506d5 100644 --- a/drivers/char/mem.c +++ b/drivers/char/mem.c @@ -546,7 +546,7 @@ static unsigned long get_unmapped_area_zero(struct file *file, } /* Otherwise flags & MAP_PRIVATE: with no shmem object beneath it */ - return mm_get_unmapped_area(current->mm, file, addr, len, pgoff, flags); + return current_get_unmapped_area(file, addr, len, pgoff, flags); #else return -ENOSYS; #endif diff --git a/drivers/dax/device.c b/drivers/dax/device.c index eb61598247a9..c379902307b7 100644 --- a/drivers/dax/device.c +++ b/drivers/dax/device.c @@ -329,14 +329,14 @@ static unsigned long dax_get_unmapped_area(struct file *filp, if ((off + len_align) < off) goto out; - addr_align = mm_get_unmapped_area(current->mm, filp, addr, len_align, - pgoff, flags); + addr_align = current_get_unmapped_area(filp, addr, len_align, + pgoff, flags); if (!IS_ERR_VALUE(addr_align)) { addr_align += (off - addr_align) & (align - 1); return addr_align; } out: - return mm_get_unmapped_area(current->mm, filp, addr, len, pgoff, flags); + return current_get_unmapped_area(filp, addr, len, pgoff, flags); } static const struct address_space_operations dev_dax_aops = { diff --git a/fs/proc/inode.c b/fs/proc/inode.c index d19434e2a58e..24a6aeac3de5 100644 --- a/fs/proc/inode.c +++ b/fs/proc/inode.c @@ -455,7 +455,7 @@ pde_get_unmapped_area(struct proc_dir_entry *pde, struct file *file, unsigned lo return pde->proc_ops->proc_get_unmapped_area(file, orig_addr, len, pgoff, flags); #ifdef CONFIG_MMU - return mm_get_unmapped_area(current->mm, file, orig_addr, len, pgoff, flags); + return current_get_unmapped_area(file, orig_addr, len, pgoff, flags); #endif return orig_addr; diff --git a/fs/ramfs/file-mmu.c b/fs/ramfs/file-mmu.c index b45c7edc3225..85f57de31102 100644 --- a/fs/ramfs/file-mmu.c +++ b/fs/ramfs/file-mmu.c @@ -35,7 +35,7 @@ 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(current->mm, file, addr, len, pgoff, flags); + return current_get_unmapped_area(file, addr, len, pgoff, flags); } const struct file_operations ramfs_file_operations = { diff --git a/include/linux/sched/mm.h b/include/linux/sched/mm.h index 91546493c43d..c67c7de05c7a 100644 --- a/include/linux/sched/mm.h +++ b/include/linux/sched/mm.h @@ -187,9 +187,9 @@ arch_get_unmapped_area_topdown(struct file *filp, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags); -unsigned long mm_get_unmapped_area(struct mm_struct *mm, struct file *filp, - unsigned long addr, unsigned long len, - unsigned long pgoff, unsigned long flags); +unsigned long current_get_unmapped_area(struct file *filp, unsigned long addr, + unsigned long len, unsigned long pgoff, + unsigned long flags); unsigned long arch_get_unmapped_area_vmflags(struct file *filp, unsigned long addr, diff --git a/io_uring/memmap.c b/io_uring/memmap.c index 4785d6af5fee..1aaea32c797c 100644 --- a/io_uring/memmap.c +++ b/io_uring/memmap.c @@ -305,7 +305,7 @@ unsigned long io_uring_get_unmapped_area(struct file *filp, unsigned long addr, #else addr = 0UL; #endif - return mm_get_unmapped_area(current->mm, filp, addr, len, pgoff, flags); + return current_get_unmapped_area(filp, addr, len, pgoff, flags); } #else /* !CONFIG_MMU */ diff --git a/kernel/bpf/arena.c b/kernel/bpf/arena.c index 4a1be699bb82..054486f7c453 100644 --- a/kernel/bpf/arena.c +++ b/kernel/bpf/arena.c @@ -314,7 +314,7 @@ static unsigned long arena_get_unmapped_area(struct file *filp, unsigned long ad return -EINVAL; } - ret = mm_get_unmapped_area(current->mm, filp, addr, len * 2, 0, flags); + ret = current_get_unmapped_area(filp, addr, len * 2, 0, flags); if (IS_ERR_VALUE(ret)) return ret; if ((ret >> 32) == ((ret + len - 1) >> 32)) diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index 2222c3ff88e7..d9ff2843f6ef 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -992,7 +992,7 @@ static unsigned long bpf_get_unmapped_area(struct file *filp, unsigned long addr if (map->ops->map_get_unmapped_area) return map->ops->map_get_unmapped_area(filp, addr, len, pgoff, flags); #ifdef CONFIG_MMU - return mm_get_unmapped_area(current->mm, filp, addr, len, pgoff, flags); + return current_get_unmapped_area(filp, addr, len, pgoff, flags); #else return addr; #endif diff --git a/mm/mmap.c b/mm/mmap.c index 83b4682ec85c..4e98a907c53d 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1901,16 +1901,15 @@ __get_unmapped_area(struct file *file, unsigned long addr, unsigned long len, return error ? error : addr; } -unsigned long -mm_get_unmapped_area(struct mm_struct *mm, struct file *file, - unsigned long addr, unsigned long len, - unsigned long pgoff, unsigned long flags) +unsigned long current_get_unmapped_area(struct file *file, unsigned long addr, + unsigned long len, unsigned long pgoff, + unsigned long flags) { - if (test_bit(MMF_TOPDOWN, &mm->flags)) + if (test_bit(MMF_TOPDOWN, ¤t->mm->flags)) return arch_get_unmapped_area_topdown(file, addr, len, pgoff, flags); return arch_get_unmapped_area(file, addr, len, pgoff, flags); } -EXPORT_SYMBOL(mm_get_unmapped_area); +EXPORT_SYMBOL(current_get_unmapped_area); /** * find_vma_intersection() - Look up the first VMA which intersects the interval diff --git a/mm/shmem.c b/mm/shmem.c index f5d60436b604..c0acd7db93c8 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2276,8 +2276,7 @@ unsigned long shmem_get_unmapped_area(struct file *file, if (len > TASK_SIZE) return -ENOMEM; - addr = mm_get_unmapped_area(current->mm, file, uaddr, len, pgoff, - flags); + addr = current_get_unmapped_area(file, uaddr, len, pgoff, flags); if (!IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE)) return addr; @@ -2334,8 +2333,8 @@ unsigned long shmem_get_unmapped_area(struct file *file, if (inflated_len < len) return addr; - inflated_addr = mm_get_unmapped_area(current->mm, NULL, uaddr, - inflated_len, 0, flags); + inflated_addr = current_get_unmapped_area(NULL, uaddr, + inflated_len, 0, flags); if (IS_ERR_VALUE(inflated_addr)) return addr; if (inflated_addr & ~PAGE_MASK) @@ -4799,7 +4798,7 @@ unsigned long shmem_get_unmapped_area(struct file *file, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags) { - return mm_get_unmapped_area(current->mm, file, addr, len, pgoff, flags); + return current_get_unmapped_area(file, addr, len, pgoff, flags); } #endif