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: 13900762 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 272E9E7717D for ; Tue, 10 Dec 2024 02:45:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:Cc:To:From: Subject:Message-ID:References:Mime-Version:In-Reply-To:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=9mddCWXY13usRicsLw6OHZIF2x4MzWSWW8AsqT4vIgs=; b=tcqcJyUIypaDNeTWNUAZdxUV7T kOm0eUqSJ9rVWYvRzX7AB5DLA2KnsAbp5JvD777y/FChubZxS9407cZaRyZrMTuTGXntxovnnfz6n +3ZPQX0tncOljkWPOwskj1iD9lZ0M1G3pRuYZgM7onW8f/ESysm989DWSYWj2kMy5A5FUSlRzo7WY okH6gVPefPbDte2G38xdPknmMGj+Drmih2eqdMcRsVGnv9AEhJU8Wetz3v98NY+wnEFABJBkldxMK UIJSz5Wu5nUcEoMMfWilLu91fHe2+G37POCH79pEgPa5DChwUeBeMMfxl/TPCC/xuXaPDLKd/0eQl niDBo6Bg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tKqFp-0000000A1AS-2beK; Tue, 10 Dec 2024 02:45:41 +0000 Received: from mail-pl1-x64a.google.com ([2607:f8b0:4864:20::64a]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tKqBm-00000009zY5-2zfM for linux-arm-kernel@lists.infradead.org; Tue, 10 Dec 2024 02:41:32 +0000 Received: by mail-pl1-x64a.google.com with SMTP id d9443c01a7336-21655569152so13059275ad.2 for ; Mon, 09 Dec 2024 18:41:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733798489; x=1734403289; darn=lists.infradead.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=1HBJGkrTqr2i2wtz5px583Wzo7zP3XmDXwqqaZbRK7TaS07OcUmn3Duf3y7vXKP0CM jrC8Xi/VVsUKwL3mIkjxDmxyFg3LMHLitJpxZlDTcI5uwVk52fW1NX7afbSNKO8McDpg +nhsg4b0ncDgTSxPPhDuGlJNpzTgchimoXZfPTsUHXZEiHCdRRH3uO17Z22OAvpWtue2 1dd+PSvih7tcECaAe4kczV0+a14zd8arBLtzkj0yS52mq28rQBRK9RHr1rGjLeNZSkYZ O18Xjx2fe6blPbV9VdwW/kstc9HW2jXU6+bgRl4MmUi4RUzHKYghzxyXvQeXVdf5JjGx YR8w== 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=loNx6VbxLeXEyqVzUGw7N916nBfmIcXUDL9IAKt5DzgLOeZM+VXlHm+uqqbi8P87Sc PsDCCMkMcbOo2x6pbDLgaK7pQaBoWYa+Lk5c64Rexj+jcHYQligT2uvi9XCcx5y4zFaU q0jYBEiA2hRPC2nJSKODD5WhEdwuGcU3xWziN3ENCId43DkADLUvcNSw2pvrHkvGC6p2 zHVM2/xa8qJE/bKjtcBROK7afPFll4d/d6kPxSgF0zW3Dn6AgymR27RptEW9lSMfDeij QjtUpVRvM8qTiX0c9cwYGb7Y85LvjVJtUOGz/KaHnZN424svZBw8dzMZE80J7HjVlTV3 yvww== X-Forwarded-Encrypted: i=1; AJvYcCWyyFu5gS4KIfnWueRpVjDk1gM0QY3FQa6EEbGcAjCLJMFMBluWc8lfcjnO0iX/eX0hcmlDyu5AomEJbrmm8zVl@lists.infradead.org X-Gm-Message-State: AOJu0YyWspHPc2KUnmmfE9vAifu/n7vQtbprkn5WKGqGhv70jzxL5MtK AB9FrNT0jZCzpnTfSe61MlLyosm20dbjbu96bjK1b1fAOjl7c4Ql9XhBHVNnMZqC+OG4nnuYdHR q9JtatqqyNeXKF8vm3MhVGg== 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241209_184130_745548_EFD28BC2 X-CRM114-Status: GOOD ( 16.52 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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;