From patchwork Tue Dec 10 02:41:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalesh Singh X-Patchwork-Id: 13900703 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 909E1E7717D for ; Tue, 10 Dec 2024 02:41:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 217026B0092; Mon, 9 Dec 2024 21:41:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1A2016B00EE; Mon, 9 Dec 2024 21:41:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EBFE26B00EF; Mon, 9 Dec 2024 21:41:32 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id C2D3A6B0092 for ; Mon, 9 Dec 2024 21:41:32 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 4ED60ADB0D for ; Tue, 10 Dec 2024 02:41:32 +0000 (UTC) X-FDA: 82877496870.20.7CA66C3 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) by imf03.hostedemail.com (Postfix) with ESMTP id DA43020014 for ; Tue, 10 Dec 2024 02:41:20 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=ydIyl9ti; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf03.hostedemail.com: domain of 3WapXZwsKCE40q1u8x8y3wxw44w1u.s421y3AD-220Bqs0.47w@flex--kaleshsingh.bounces.google.com designates 209.85.214.202 as permitted sender) smtp.mailfrom=3WapXZwsKCE40q1u8x8y3wxw44w1u.s421y3AD-220Bqs0.47w@flex--kaleshsingh.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733798480; a=rsa-sha256; cv=none; b=AnZ9QCrRPCwOXjU5Jjl76fc+zBYX6ot1bLB44QYLBRSQbJrqm2f4reEz5lb9jZ1nMwz4tM rOoE4U3UcQi0I889JNeCunDAtV32v3aA2rzBCDwWEmhsjxKnfcF10WUM3ucl+Vykyalkbf /0mdyoqoExjaHLlZqnhnb6lAdsEdAQU= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=ydIyl9ti; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf03.hostedemail.com: domain of 3WapXZwsKCE40q1u8x8y3wxw44w1u.s421y3AD-220Bqs0.47w@flex--kaleshsingh.bounces.google.com designates 209.85.214.202 as permitted sender) smtp.mailfrom=3WapXZwsKCE40q1u8x8y3wxw44w1u.s421y3AD-220Bqs0.47w@flex--kaleshsingh.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733798480; 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-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=9mddCWXY13usRicsLw6OHZIF2x4MzWSWW8AsqT4vIgs=; b=eoyUQG1ryjEUZ0TnmREOGR3Ii7L7wHBZOk9MIi4bPjiuqGW2A3+ssDM488CSsb9MZSPUdY O5uWNYHs+7ALFjV20JHYk4s8lYlOXtwND5m16YM/GvryEOkI3VuYR6JcJGP8ahe2AlFBEQ BFy6M/QlCQ/d4nivgdprtT1fu6+PM9g= Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-2164fad3792so14033705ad.0 for ; Mon, 09 Dec 2024 18:41:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733798489; x=1734403289; darn=kvack.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=9mddCWXY13usRicsLw6OHZIF2x4MzWSWW8AsqT4vIgs=; b=ydIyl9tiBz8sttoTjJ/aKsA77sIbnyfyKQKKzgd2EY9evYf44Hzhe/A22rqLqeU7E8 IF939/wyLY/LpFytU3egvC7iG9dgJYu/rq1MBL80apXHtD7sCaBMruyT7Y2yeFIOv2vv hOxpTzCIJ85brRyPJ5R9s4GZTslv4q4SCPD4zf5ZOI/w+8+vDNsgBtgD3S/i0sg8mmRN N7gTORddFx9zQrqlOYhDVLekWsp4+i+JHmuspNCr4ZwPP9cRuxixJxggdfLLBvJm8d+3 UECDbeGIhu2nDxIExdS5N0ki6vQn/+0rYyTOV0ZwvQ10C+gMcZge8qiXIvou0rHBEPhC OE7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733798489; x=1734403289; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=9mddCWXY13usRicsLw6OHZIF2x4MzWSWW8AsqT4vIgs=; b=S2j+ITWBdUQ37Aq0sXJlToXtU+6uYUFRfDfi5gAApbBpcR3Ps1CzMFU2tUS2mMCsGz E+hRpecdV3XGyQXQUV8HCWDsg8ACgZbCpZEb9CrHfCRpl2OT/QfZh2y01Ad9NkIEDgoc ++TAug2ib8KoasNjcu+trn5q5IYwq3uAFnSN/T7BM/2abxGseLyc+B8UUqvU4QZGol8v gnLZRNCyQVbpkZIZPCknoDxMfn05sYmfd1MR4BCLyp56g6vuNs5J5djiy0lVY6Lyc6rt B2nqU2qmNFl60GJLY5ekrAYqVK8iluUjhf7/QWaHHYOl+kO4OK5qGPdoYefpYpx4CuWr SJnw== X-Forwarded-Encrypted: i=1; AJvYcCUpt/KcdLghfs/YqM7Zd83FFlaudEMiLyT2O4FgN7Rz7gKv+IRumF1XHmTxgbf8Kg+tT6sbPktiTQ==@kvack.org X-Gm-Message-State: AOJu0Yy9Pi0hZOVlyc0Rs/ogrbYhSI7UZyXqbV6R0sK8H4sQHuSuMStN 2GwxYFPFP4UcPFPVEYixyoFlAxtSYi98rvEkGYXsvhqjeja+mpBJvmUgrz8aB8Xc968YenZhNpE OErwmzukOrHCTKRYg4GcUeQ== X-Google-Smtp-Source: AGHT+IEX/qrAQlYORBGIb8q2yh1uBiUP2mFrR7GdG/oXvBxNhJUWo6MtAF8VWexbyJx8hsdTWhCnXlVlObdK7ssA3Q== X-Received: from plks10.prod.google.com ([2002:a17:903:2ca:b0:216:266b:5024]) (user=kaleshsingh job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:2349:b0:215:a039:738 with SMTP id d9443c01a7336-21669f993a8mr45319855ad.5.1733798489149; Mon, 09 Dec 2024 18:41:29 -0800 (PST) Date: Mon, 9 Dec 2024 18:41:05 -0800 In-Reply-To: <20241210024119.2488608-1-kaleshsingh@google.com> Mime-Version: 1.0 References: <20241210024119.2488608-1-kaleshsingh@google.com> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog Message-ID: <20241210024119.2488608-4-kaleshsingh@google.com> Subject: [PATCH mm-unstable 03/17] mm: arm: Introduce arch_mmap_hint() From: Kalesh Singh To: akpm@linux-foundation.org, vbabka@suse.cz, yang@os.amperecomputing.com, riel@surriel.com, david@redhat.com Cc: linux@armlinux.org.uk, tsbogend@alpha.franken.de, James.Bottomley@HansenPartnership.com, ysato@users.sourceforge.jp, dalias@libc.org, glaubitz@physik.fu-berlin.de, davem@davemloft.net, andreas@gaisler.com, tglx@linutronix.de, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, chris@zankel.net, jcmvbkbc@gmail.com, bhelgaas@google.com, jason.andryuk@amd.com, leitao@debian.org, linux-alpha@vger.kernel.org, linux-kernel@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-csky@vger.kernel.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-mm@kvack.org, kernel-team@android.com, android-mm@google.com, Kalesh Singh X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: DA43020014 X-Stat-Signature: 97fr3n3n9ihy31zw85emtkpmr4s5wr5w X-HE-Tag: 1733798480-451387 X-HE-Meta: U2FsdGVkX18vwboY6XGZzSaByQ32JQfh+Nzkr5gFB/jEFtGwLJaveHsmc/OdjYQjwDGs2URG3yfLxRW/H6AuwiAuCmAcU4H3QBQpODssz1rhPdiSwEGN95BNih31Ndtg+jdQ6sD09XJRkk9lEdeBgTKWvXUlMkFIZa8XPjPam9pIsPghtTQxp5iqhsLFyXnVtTdxxMAZr7TuDzlN1EZS9v9Tj9+UDrTuFLwwNnELQPB4QS2DUun/kuFrl16zzgzre7Zxr5AmqF6ZdUBd95ZTmDrY4CdC6j0tHIO8+qWN3jIae+bB9CnQ/f3R4qGziquT8qG+SIozy5puW1yxh5wIC1qD+K29lMoJJl1L46n6ZDZ9SmDJHj97SflzgfnJw1DfiqOridlAHHoPDktdl9k/DLMWt6s6WiDZTvIp8XMu1MpDOHsI3LlOtvDyFpbn7iaUpcGyFM7z2jMFY5crs2GhFdNqeuRG07cpGdlTT9sW1Bdb60EK5JvNcYREl0HU7unjU+lzB0hLk+ulEwgw23H8h+Ed50ngg+A8rddL32w0jiacrxo82xX/YA4yM1owetE8kgPO/pNzsjslqjLph1ZFELf8G78lxfBPdk5cihhQMqyLiTrR987JUQrAn8SJk6nabd5k6yv167IL3efH8sg1JSVgNB2njLtoIoLp3y23KNXnji2plohzmXU5OeQdKHLFd+egeeQ6b8yazytDbjtWzd+/mgzfu2cpGqu73+hQ+zjIMm+CCLRILZqwKSjXyTmxdsV489Iu7lE0XPz9CW7H6dwVYWFa8YWoq0Ih6x+OZU0nPUEkmbjUQNIhBZD7ihMd0htUr+XGHk8uLOH4BeJWXVYtNYiN9mdFblaXpzV/eSAcwWqWW95eDYRd+EgToWQnoicqmfXqyNyGfub/rsGiChHAuPA6mtC2ZLi/5EbU7QuR/rPP15IFuOKUltmgCIsVH+cLp6P0W8+qcO2HwJo 8/n78ENC XI3tcfLyxs8pUI2/WD5gB3rIm7ACcs0KP+ZT3O39/ts2RiuKwo6AqcyPvCaUm1y2c9iSCrLnpjE9p/O2Qwtr4mzdpBeSkeFUBUjfZwsHE26n/sEuRMhI7Igeq5kzW+BRgg2F8N9o3IESKTSZxgedMxAHhG3FzOWM9oW/a0mOhFY231nK2VagJ6xF5pGGqQtEoqMfJvA5Zpy0MvKITpOZUIurNpMCkiU3O0RmTyMR80phxtzjrlRfriGyPPYvypqsLxPeWAAmkPU2UCOpDl81vTudmoCeM7s3rkZ+7Bi4x85Ns9cUk3D9/y059EY9SYDGv1P9vGheYLZRvB+gYPioh2ZsRa8o90pis7FpYpakhkOLY/VPpa0qXDk2Uky9qX3JuIpjgtpA3Mgm36qDCB4PlMY6x35V+kqn+qxZo5wFDAHGQEUi3zSBh0oC2sz718U8MihTtGSWfVluR57Em/GdxpP4MgP5NydCGVxm8IYk6vmmzvIcO+llvSO17kqnaf/IAnAXbPqleP2pBV9yROCBmF+9bZfmlfRn8EwuID1Su7CSQp4Tc1hJC80mB9RJISUVsvGS4VPH4mLSc6kK0k0Pq5lXx4NsB3dyBNNc05vFjHtq68xr3TmCrO5tBYwW3hv9iG8AF X-Bogosity: Ham, tests=bogofilter, spamicity=0.069251, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Introduce arm arch_mmap_hint() and define HAVE_ARCH_MMAP_HINT. This is a preparatory patch, no functional change is introduced. Signed-off-by: Kalesh Singh --- arch/arm/include/asm/pgtable.h | 1 + arch/arm/mm/mmap.c | 54 +++++++++++++++++++--------------- 2 files changed, 32 insertions(+), 23 deletions(-) diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h index be91e376df79..1433b3ff4caa 100644 --- a/arch/arm/include/asm/pgtable.h +++ b/arch/arm/include/asm/pgtable.h @@ -330,6 +330,7 @@ static inline pte_t pte_swp_clear_exclusive(pte_t pte) */ #define HAVE_ARCH_UNMAPPED_AREA #define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN +#define HAVE_ARCH_MMAP_HINT #endif /* !__ASSEMBLY__ */ diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c index 3dbb383c26d5..c415410eb64a 100644 --- a/arch/arm/mm/mmap.c +++ b/arch/arm/mm/mmap.c @@ -17,6 +17,31 @@ ((((addr)+SHMLBA-1)&~(SHMLBA-1)) + \ (((pgoff)<mm; - struct vm_area_struct *vma; int do_align = 0; int aliasing = cache_is_vipt_aliasing(); struct vm_unmapped_area_info info = {}; @@ -57,17 +81,9 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr, if (len > TASK_SIZE) return -ENOMEM; - if (addr) { - if (do_align) - addr = COLOUR_ALIGN(addr, pgoff); - else - addr = PAGE_ALIGN(addr); - - vma = find_vma(mm, addr); - if (TASK_SIZE - len >= addr && - (!vma || addr + len <= vm_start_gap(vma))) - return addr; - } + addr = arch_mmap_hint(filp, addr, len, pgoff, flags); + if (addr) + return addr; info.length = len; info.low_limit = mm->mmap_base; @@ -82,7 +98,6 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0, const unsigned long len, const unsigned long pgoff, const unsigned long flags, vm_flags_t vm_flags) { - struct vm_area_struct *vma; struct mm_struct *mm = current->mm; unsigned long addr = addr0; int do_align = 0; @@ -108,16 +123,9 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0, } /* requesting a specific address */ - if (addr) { - if (do_align) - addr = COLOUR_ALIGN(addr, pgoff); - else - addr = PAGE_ALIGN(addr); - vma = find_vma(mm, addr); - if (TASK_SIZE - len >= addr && - (!vma || addr + len <= vm_start_gap(vma))) - return addr; - } + addr = arch_mmap_hint(filp, addr, len, pgoff, flags); + if (addr) + return addr; info.flags = VM_UNMAPPED_AREA_TOPDOWN; info.length = len;