From patchwork Tue Dec 10 02:41:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalesh Singh X-Patchwork-Id: 13900770 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 3CC64E7717D for ; Tue, 10 Dec 2024 02:54:15 +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=1BAtlrJSVyRPOsQk5wSikGaGR3zqoYCpGFeQDDyhzvw=; b=k7oShMx1OxIeg0zHAOELIYS2je zmxOHACHRI4B9vHA467nSOiEF7m2cINb+lJ63p7o2bBWWHmj8XGPB/8mONl52feaIm9p3bpp9Z1vx 4VmHEXIb6wVK2l+Ro8X+sb4wwIfdZK6VFH1yWC3UTLfj+L2VLZMbC7zWoyMW6gRthAHyAJ8vJnIzS 4QUqucHxxyfcpVzg9rf6CQNunTIVtlR6nGAAYVluMdVp+O4mXxGY92HfoORnX/J2YcZTFJMWKNuNj E5vAugkMp2wQr5XKmUESpw41HyNFXnX7YrfaJM4Gguhy+cCcYfh23E9mUivzSFg4Eujz9RHmeEaPs UuMbB2Xw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tKqNx-0000000A2hS-2Xmu; Tue, 10 Dec 2024 02:54:05 +0000 Received: from mail-pj1-x104a.google.com ([2607:f8b0:4864:20::104a]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tKqC2-00000009zn8-36pr for linux-arm-kernel@lists.infradead.org; Tue, 10 Dec 2024 02:41:48 +0000 Received: by mail-pj1-x104a.google.com with SMTP id 98e67ed59e1d1-2efa74481fdso1782945a91.1 for ; Mon, 09 Dec 2024 18:41:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733798505; x=1734403305; 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=1BAtlrJSVyRPOsQk5wSikGaGR3zqoYCpGFeQDDyhzvw=; b=g/I/SjLMXNroKOwKUJDNmgkHwlpELxMxA6NehWXh9vVOd7iiVNyrqKCk7GnOmp3PvD eJ/85k7r0sWIzsGB2XTYJby6ICquVn+fAI2fuzzmUVnUPj16JIFFprLZ64fa/NOcAK0S ry98wNsaHQ16Lvb8tn2StuRScWQGkAM1j3BDaVqogY8IiGPjva0RoTL5/KJIKMTKxp5H OxOzYNPdNoci0wDy/S93omQYGYQEZuGIj2aRpdFArJytQmlrMIIYo8M1/km41b06xrOb AiMtIZHf5WfLROPBMPOVShkw9WNLxNU4E8w5VrJ2rIAjP0IsP3LPmYyQg7cir7xiAiMU EsfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733798505; x=1734403305; 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=1BAtlrJSVyRPOsQk5wSikGaGR3zqoYCpGFeQDDyhzvw=; b=jaPt4KkwM0qs5Qb6Ly/CEeSWIO8OXWsTapp6G8exxWWGoAX4YyTN75ZH/LQt7Z30OO MFI5yWbPuAugd8pboZ3tvImTvFGmZr+q0x8RsdMfYQl6IJ6xVSbKfE/EA+tgQmI4LHyg 5kpWxVX7MvWgslb2Clc2LCm9UKYv4aREmy0H6Fh1Q5EcuKkkqOAN1IULc9u7QKldcUTW 0wzBNJNTTuCAkB8EHKQJpcKim6r/QjzSe9FADT9NEhJP6AAOyptrDB1sLJBcNWh6fxe9 MBLjRoH3SrJdTqwPEprVZxkpH8PnwCXr0Q7vOK+YaOKiuMwnUBNLg6O2I9UlqHaBbOmc 30MQ== X-Forwarded-Encrypted: i=1; AJvYcCUICipfSPBkYjHYXnXVEi54KmkOWt9wHbkstzifmWUH7Kx7W2fqA1KNf+37bKnBbhb7jjE1dfkGk2GJsHr0D4fq@lists.infradead.org X-Gm-Message-State: AOJu0YzpiUj20IAidYQqv5RpVXoNz+PpATAyNzN2wUuh4hvmfxgD/jcY 7WNEuf8DPq+v7sphjMEkuVFf0VKnKaSzJBw2FOIeHXICxedo3aUp1j/WaiGLoiXB8XkTIDod9pp xhUd8w9LJKbl0nR1oR9iriw== X-Google-Smtp-Source: AGHT+IG3H2VSitmLlBO6Re0RjQMAvCNU6wOeSZb7FxqqgQkEm7xuddsNJr2NEUZE8SQmtflSqHbUwj9vfGvySeSwAw== X-Received: from pjbnr3.prod.google.com ([2002:a17:90b:2403:b0:2ef:6fb0:55fb]) (user=kaleshsingh job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:4a06:b0:2ee:9a82:5a93 with SMTP id 98e67ed59e1d1-2efcf138437mr4485348a91.14.1733798505429; Mon, 09 Dec 2024 18:41:45 -0800 (PST) Date: Mon, 9 Dec 2024 18:41:14 -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-13-kaleshsingh@google.com> Subject: [PATCH mm-unstable 12/17] mm: sparc32: 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_184146_774254_05175C07 X-CRM114-Status: GOOD ( 13.02 ) 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 sparc32 arch_mmap_hint() and define HAVE_ARCH_MMAP_HINT. If a sufficiently sized hole doesn't exist at the hint address, fallback to searching the entire valid VA space instead of only the VA space above the hint address. Signed-off-by: Kalesh Singh --- arch/sparc/include/asm/pgtable_32.h | 1 + arch/sparc/kernel/sys_sparc_32.c | 21 ++++++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h index 62bcafe38b1f..95084c4d0b01 100644 --- a/arch/sparc/include/asm/pgtable_32.h +++ b/arch/sparc/include/asm/pgtable_32.h @@ -437,6 +437,7 @@ static inline int io_remap_pfn_range(struct vm_area_struct *vma, /* We provide our own get_unmapped_area to cope with VA holes for userland */ #define HAVE_ARCH_UNMAPPED_AREA +#define HAVE_ARCH_MMAP_HINT #define pmd_pgtable(pmd) ((pgtable_t)__pmd_page(pmd)) diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c index fb31bc0c5b48..2d5065ee1a94 100644 --- a/arch/sparc/kernel/sys_sparc_32.c +++ b/arch/sparc/kernel/sys_sparc_32.c @@ -40,6 +40,19 @@ SYSCALL_DEFINE0(getpagesize) return PAGE_SIZE; /* Possibly older binaries want 8192 on sun4's? */ } +unsigned long arch_mmap_hint(struct file *filp, unsigned long addr, + unsigned long len, unsigned long pgoff, + unsigned long flags) +{ + if (!addr) + return 0; + + if (len > TASK_SIZE - PAGE_SIZE) + return 0; + + return generic_mmap_hint(filp, addr, len, pgoff, flags); +} + unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags, vm_flags_t vm_flags) { struct vm_unmapped_area_info info = {}; @@ -61,11 +74,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi /* See asm-sparc/uaccess.h */ if (len > TASK_SIZE - PAGE_SIZE) return -ENOMEM; - if (!addr) - addr = TASK_UNMAPPED_BASE; + + addr = arch_mmap_hint(filp, addr, len, pgoff, flags); + if (addr) + return addr; info.length = len; - info.low_limit = addr; + info.low_limit = TASK_UNMAPPED_BASE; info.high_limit = TASK_SIZE; if (!file_hugepage) { info.align_mask = (flags & MAP_SHARED) ?