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: 13900712 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 F1ECCE7717D for ; Tue, 10 Dec 2024 02:41:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 155046B00FF; Mon, 9 Dec 2024 21:41:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0DE286B0101; Mon, 9 Dec 2024 21:41:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E23CC6B0102; Mon, 9 Dec 2024 21:41:48 -0500 (EST) 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 BAEEE6B00FF for ; Mon, 9 Dec 2024 21:41:48 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 86A0C1601FF for ; Tue, 10 Dec 2024 02:41:48 +0000 (UTC) X-FDA: 82877498634.05.B769F2F Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) by imf14.hostedemail.com (Postfix) with ESMTP id 204A9100006 for ; Tue, 10 Dec 2024 02:41:22 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=DWmCfhvx; spf=pass (imf14.hostedemail.com: domain of 3aapXZwsKCF4G6HAODOEJCDCKKCHA.8KIHEJQT-IIGR68G.KNC@flex--kaleshsingh.bounces.google.com designates 209.85.216.73 as permitted sender) smtp.mailfrom=3aapXZwsKCF4G6HAODOEJCDCKKCHA.8KIHEJQT-IIGR68G.KNC@flex--kaleshsingh.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733798490; 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=1BAtlrJSVyRPOsQk5wSikGaGR3zqoYCpGFeQDDyhzvw=; b=k0Tx6U9QmtxhV8yFK3OtnOpAHW9oTw/ILbuaSoTNmvg6NDoxW4fgLfJUtlO0mFk+ul+6yk mbFqmQu3W59UkREM+18nt9rfZfSD7/3iYl/hCI48m0uav4UXuuvTBkZ+IdKHpVjuruZfWL hEXNsY6HQNmuP72nhPdTjWG1oYRzhsY= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=DWmCfhvx; spf=pass (imf14.hostedemail.com: domain of 3aapXZwsKCF4G6HAODOEJCDCKKCHA.8KIHEJQT-IIGR68G.KNC@flex--kaleshsingh.bounces.google.com designates 209.85.216.73 as permitted sender) smtp.mailfrom=3aapXZwsKCF4G6HAODOEJCDCKKCHA.8KIHEJQT-IIGR68G.KNC@flex--kaleshsingh.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733798490; a=rsa-sha256; cv=none; b=I59XQHTtf30XJOHfsupGw5OqTXoHoI/FYN5b22zW4fz3dFFkcIL4rw/sIjEZcT+DH3xP0b Uc5o/RbqyolC8ZELr3R+op8Qq3Qg3gPkP2t7jsH5wR+f5CuK/o1qHgNqWcf+GyOnxg4Pvm hLtZtMFF+P+DFDn9Ng6JTUmyK2dP0j0= Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-2efa74481fdso1782947a91.1 for ; Mon, 09 Dec 2024 18:41:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733798505; x=1734403305; 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=1BAtlrJSVyRPOsQk5wSikGaGR3zqoYCpGFeQDDyhzvw=; b=DWmCfhvx7QSKTuBLnSsQg7lyYPxCvkmCh54TbSv2EnafbpYGf+UIRZQIFInYktSCIV Ct5Q6sqLtlrkBLdRzhkkH5eY8YF4vFtp+hwB1oArOKfi9eYXI+0gj2P4qzsnvLJkZQqU EtIzuo9R4imZaKdWvh2qBZUzPZy1LpvD6dw0J8l+nFyjfluKPsoMCZhLFk9xhatG3g4J M9M7ssmgUoJmCeD2GNtz5H08Viw1Bzc0qtfPAThMwi6azFACkVnR8P9hG8DUUCU7Eua6 u+PK6F7aN+wjVKTMmvUVQN4paeRFwW5FqIbhcJVHo3fiAUFCVyk2za4d8cxeI50T3A5H GwdA== 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=Y5YD7ApneiS8o3AMODY2jBXUgtsWiGlCx9icKfXV6/Yf7A1euQPZNdxV2y1S9mQTT3 iRQCnFS7XDfTCbM04LZaK0R9APHm11I0xIGuN7BXJxFSSCf41nAgkTroLxrTJYzLvE1f Oq/YARFNL9HTlKjj9d5Oezs/qHXzlkuJ5/o8TuQQ5t/s0ra5k11/ST6NIRP8LFXhmRkA uAChnu72oiM1C1X93i99OmRVLOb3QxNFeOR50iAYQSmZcSbDpyth+nuprrnqHn8O3mVu SbG0zruOfVuyZGVKDxjDqQ3TKFT6ryAL2oGybfCI4qO6EkRY7rxOe2uh3LPtkY9+uo1j 87SA== X-Forwarded-Encrypted: i=1; AJvYcCWtSNudEbBKzbNekpnJHMCcnTNsGrI+kJ4wtkP210Y91JPsuNfZkC8HaspNF0cSK/xLBMxwQP8mtw==@kvack.org X-Gm-Message-State: AOJu0YwpVadtniuLbBpBwG3gPaR3spYq2e8XjnANDTN/FZrHPYEgAzCJ uhz5KOEwPWKoFYz7p1rDs4/U3GGMDV9Zpb2ZnslBzX9rJP8o4ZmtZGsna3sXK2Smj2au+P2EKzd 5RlvaQUDihBaqg0Xir4MSKw== 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-Rspamd-Queue-Id: 204A9100006 X-Rspamd-Server: rspam12 X-Stat-Signature: ijo9et39aho69dnqu16zjb5718qeraig X-Rspam-User: X-HE-Tag: 1733798482-772452 X-HE-Meta: U2FsdGVkX1/UUJXtCyH+bigky+CNl7SVNNd7dt1w6Wl15jN45m5oEvWKP/c/gyraFbp9L/cNtYBYBIHnht3c9SqfqZ79d2GNuWZHZob9wPwcLdQeeq1bjnLNwfNwRxEBijc7AeykEqzrWimUB3+uulYCYX9Gn6TI3CHTo+wL9s0CZTS43qEOvA1sZAq8JE9I9jcnOkMpjlcxPQWXcMHZF9G2VYjtOXbpZegLBgzKMjz9X88lXMO+6CHe1rWRlfzwUgfZS/kLo2ekikOohPz+96w7+TnOT4zyhett/Z0YFFGbB+gD2BKS5AR68NptmUO6VUEZdEToApnMNYpWSOTb+vHP8A6aY9ZmTtsGiY2Mt0Lmb9FyZQxSSEin4VDB7CvW8FNaB82VodpL7Fk4M5U2r5Vf8UIkHIWPI/cPRz4s60bNEf1QhRAyDtK1NQz/22GGP03Y6ljBNnkbaIHGw01FEbFV0u13tmOBFfjTCeot1xeecXoJK9QW3fIX7pciFwvrkci5bFh1gMUyM6c2R6DizLtK/L2VuhAL/9DxvQnlsXzsNvgyramT01s8j3dYTWIZjsnK/NqdTngbMXiz3xPK4uvzutonJNk2hkYAw9j4v3hmep4VWYh6VvKsi6VoSVfpq8wVSn5sOzIGsOKfOxsCb36s8vsPjcUTDtPNqnCDW8xQWflWELW6UcljrFt15JUHHHtnkwYwXKWAbGFIvOpFe2YHQj9h6PqjOTZGStnY5OdO1ES/DPvpt57xPdAJVA6L4GC0NPLDwmXUXiqWK3xiuQNWZLgCfiXDqurhZD9VEd2aX3W39saaoQwzr4R+7XNNS9geZZ0EgodurncsRX3fWXhtSOBkcxd2MVDyFavUlkvglhh4uZHJc/wytCyVH5K/ZKgKFjiKnhyKVvTmLTS7n88RseClQdbsI4LFHaEXSEDCDJjSpOd3UUre6KKj84BjkPOzUhhSdhfePBLyH5h jTDa9b+M yhRCXbUbWRay0hK18PB6WqS5pAzJqth/9UrtsfYrSb30chJ7RyPuJ/XQrV5WEBZ01SdL45d0grskE7P1Id8Q/9+5rfFAfHOVqgE37pnn8ed29KqMfkWlg6Q35VtBPSma2baXk6kppmcs2jlwz5linix884N8ppj8xwlZTIOO+60W7PelcmJfvwTgzeQ1SyDLjG/Xll6BEzY2PNhryxsxYr08OYJQpxRcYhuKhKuYSDAFxdoX6gXIUthXUbhMjHAawuoyni3ww67RghEOZOQerGsW/kD18uq42wBP4L6/6Fdt8g/YUncdyvma3sh6u6+3sP9IKq3aDLUEmhzBK2U9Zd9AMtwTNJGPX2DB1DFF9wm6b5+qyPOsIbj1KuU5PeCbr9f8CAT8iWW1GIjddfXN5o4TOWMx1+SNlPfwF5qxUWNnrOlNPzyf+WjuAvMLqEMBKWXRI1ex2Si7TqvE+BfdJUiKo/LdcqgUGOG7r3/ZLhGE+1rd2JCDkBByX2JKJJJ9REIAEiiQhe/5b8ESpdUZpPjQWdrI5JSUZzFbHz7yfnqanB5yUyPG912Prtm1/HIgIn0XBjB3OiDkAJD2QP1i+GUt0Acr2dha5P8foL8Cp4Lr7iAoNRvL90dc3mshU/aZX+RKX X-Bogosity: Ham, tests=bogofilter, spamicity=0.038973, 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 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) ?