From patchwork Tue Dec 10 02:41:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalesh Singh X-Patchwork-Id: 13900714 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 718ADE77180 for ; Tue, 10 Dec 2024 02:42:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 91D208D0002; Mon, 9 Dec 2024 21:41:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8A5438D0001; Mon, 9 Dec 2024 21:41:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6D05A8D0002; Mon, 9 Dec 2024 21:41:52 -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 462D98D0001 for ; Mon, 9 Dec 2024 21:41:52 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 09C431A0249 for ; Tue, 10 Dec 2024 02:41:52 +0000 (UTC) X-FDA: 82877498634.22.6255EDD Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) by imf26.hostedemail.com (Postfix) with ESMTP id 0634614000C for ; Tue, 10 Dec 2024 02:41:33 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="ne3/lk2T"; spf=pass (imf26.hostedemail.com: domain of 3bKpXZwsKCGEJ9KDRGRHMFGFNNFKD.BNLKHMTW-LLJU9BJ.NQF@flex--kaleshsingh.bounces.google.com designates 209.85.216.73 as permitted sender) smtp.mailfrom=3bKpXZwsKCGEJ9KDRGRHMFGFNNFKD.BNLKHMTW-LLJU9BJ.NQF@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=1733798500; 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=8RBi4d94aA8fGJb29BjAVbVAiuWgJzs9FAFEoE/Tcq4=; b=x9WCdJdmw4RoXmTbyMW+LQbF3cCe8THjV52HiWCpDDECBG9Js6WUhziD8BAudJsPy1VSrK qPhZcGqYA/OatmSU6/w961JXjz8qc2zwgiYLhBy4cM/Im1GguaXTntDodxBRp3feM6/qMW KhaHQqIKkEUoroe4z/tpclXNfwKXQDU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733798500; a=rsa-sha256; cv=none; b=gCAgiZ6TSCX9GB9fQSNeDGX4FBC4eVJUiNMZZUCzDOW1u9fTor0PWOOZYVsadqqWyLWXIT AhzOUFaBBhOBgQKiK7K3kccM8q3Ft8AJuu0aOTcOrpyr0PRETMB63FaMEph8cH/gEZFpkO IWPtZnE5qi2+uzSx5GbN968c+8rLTgs= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="ne3/lk2T"; spf=pass (imf26.hostedemail.com: domain of 3bKpXZwsKCGEJ9KDRGRHMFGFNNFKD.BNLKHMTW-LLJU9BJ.NQF@flex--kaleshsingh.bounces.google.com designates 209.85.216.73 as permitted sender) smtp.mailfrom=3bKpXZwsKCGEJ9KDRGRHMFGFNNFKD.BNLKHMTW-LLJU9BJ.NQF@flex--kaleshsingh.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-2eebfd6d065so6425754a91.3 for ; Mon, 09 Dec 2024 18:41:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733798509; x=1734403309; 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=8RBi4d94aA8fGJb29BjAVbVAiuWgJzs9FAFEoE/Tcq4=; b=ne3/lk2TybO3JP2gW8f8tVd9iEhpQlbrsTUV+Qpv0mgJKtoPGzSa2c4VtbanZjoG27 evxZiRi9P6RATlLqjAT8avvRiiJQwRcyj3LpDc7LABheNL2AXbVLiXN1MjyVeXFjFzT2 poJL3jbiqNo6XPyg9mtnY/uIDf4av0TrCkvDQoGdVxR5Zp/HHaNGTMnZYdwzw5C733G+ VUGaRBrbLHhY6wW8eXURMMaNiIivfWD1KYg6IznaN/Vy3tnkJMLLHQfue1Ro2Ggn9Co/ S7BXfJFk9tt8cPVBDyn9vuIYbG4++IDIcDV1/2h301o6sjfpCG3r1k4Xddpi/gI/uGOe IqAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733798509; x=1734403309; 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=8RBi4d94aA8fGJb29BjAVbVAiuWgJzs9FAFEoE/Tcq4=; b=d7uMq9urPG25KzWNeGdPkLe4U3r0VUEgNGWDVl6+Za2+mKUQ3A9nSIUgzLN/872InF CL9vA2wl3usuS27EAt6QKz6chdTmkAajr3hyKkyZVv4BiAMD019MDnogvNopO7cEP2VX KqJ/kZhB2W9lSlzzecDjhXuLl8K1VAx1mGr/F/z19SgvlbLyLbycvdeZ6/C1oulXUNOM LjzPI/7vDlvyhH3xnZCs6dsYlXDljWoqEMpRqDQ3rnf3COdBuf0o/bgA12IZrTg+W/+1 iJCagBIpHtiFdysFyh2lMWby0cu5WQJcX2AEMbN7Kj9vTcgxCm16wyz8FBRpWmiQEhX8 NSrQ== X-Forwarded-Encrypted: i=1; AJvYcCW40TMVUUW00xQ0Kbty4y8Mk8fA7F+UCPlb1Jtw5Uc4HqoHhbKwweaCrNw5eZDq8qErMBqvNEPysg==@kvack.org X-Gm-Message-State: AOJu0Ywbg/ilYyLSSgF9ojKyZe8Tosk0XXLX7fR0ZRpLCLk/DwNpezan eN3se4e0KO9yBLrHSTS+9gzIsveRhsaD0SjZpkDoY5mRlAvBHbxC/flwG4ZmUuEofpozvF13M1b ImwfiLGQA7xYiBRvzZlmvUQ== X-Google-Smtp-Source: AGHT+IEWnrN6kZ7CMoj0XPEY5LyEzTzu31G9SE2ukZ22eBNhBZBZVrxzEpEONDIVdXz8wv9Xu2tYcLSnTTgrFqyRgw== X-Received: from pjbsq5.prod.google.com ([2002:a17:90b:5305:b0:2ef:9866:6155]) (user=kaleshsingh job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:2544:b0:2ee:c918:cd42 with SMTP id 98e67ed59e1d1-2ef6a6c11b1mr19145935a91.22.1733798508962; Mon, 09 Dec 2024 18:41:48 -0800 (PST) Date: Mon, 9 Dec 2024 18:41:16 -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-15-kaleshsingh@google.com> Subject: [PATCH mm-unstable 14/17] mm: xtensa: 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-Server: rspam10 X-Rspamd-Queue-Id: 0634614000C X-Stat-Signature: deqn8g86z8h67rtohqk3i58xyjqdzh7i X-Rspam-User: X-HE-Tag: 1733798493-210092 X-HE-Meta: U2FsdGVkX1/VOYd2cPTNHzpKpWp/Moqo9p7sIsTz3Ho5yDFnRZO4FkXQRANAevdyZHlE9kfRibPyHWb6wjM7PETOKKqltiG1nv33esShjqPoMbUfcVRmiZh4DCXzgLBTQYWoeOKBDUjAqM6Wy4JdLT+oPz/jcNycVuqDTZE+9Ek75SO7zrjcpmmPKz+gcIMn/KiySTUei8BZb4fC0F69zzLTGgFPOXQlNf17ZDQ9LPQv5Z7hr8ppEXJ+rkwgBlYCWiBWRjRvsp5vh1fEvirJ1fAKMf1JBfcfg2Tb9LMIoJDamD0gd28TYXe/hjDh9RqHiOvIMsSDGHR+KjcKcdtZTPzbRgtOS1tyu0uaVD7NgtcuMoRl3axioIiZWA7Y7JHY/Sacz6lh2nsudk2hUgPjkgZ8nCspQlb8Hz6bRh9tIQXG52JieRsI463oiaFGj2p+uyQnvPmXHPdyiN05W05ODUMxdl2vAUk+kdQCz07KbsaJxLQ23MlA+ej82aa/3USD3toWW5fLFGDOaPpa0U8ystbYao3jfBxFjh1nXGgtm5YQwshnualYK32+kuTEKWP4zBAF6Y6E7MjWhaok9PYKGoXfei/CuKFqRhHQc6Jbn0CC1FDiTw8qAXTa+1sagil5uH2qPavIEPxzW2yEEp0pT0xI+E9UjwgIhCxOQW4EQe7DCXUbLUMSvfOySzijyftRpQytXi3y89MhKDSIqFtKlpA06KZMihcjNLSH4eLKgUSLEv9t84G3QynLlsY+AI4iwWSV4IXLRwI8vFbt05OT6fmZxCpE+Z2yQ38XGpgXXZWuw11i8HW1CbxvU2bogyRD1iTYVA2LK0PMHzpeuMZN6Z1x4NFgvVuLWe6XFYWgj4GxbC60DRcEay/BMoilMbjTUZ4CtrUwM/HL2YU4Bc4ScrkdKP3vtumjlMXjaQSkrO5il0Ayhl+SZ7UgIGSn3YgEjnPDrUqOCNYNlXEWNsk 61XOxE9o ZzPODXg1CWSCgbJ7aC2Zcac8q6ctN8bpuAUF0JeOBohNaP2/ZDQGjOHuFkbVdYDDVHwvToAb733ZfKQ3zChCmNiL2BKcTh79rCUuvlh90PqhT41aMOy4Z5wB184eFv/cl9voQ8Kmm1gUfA6eUXFPa2srwAL8AZ1a5YVtJTnFn8+f2EiedsdCBubuCeRofSWO81OcsmHEtX6lUQ7/1qnMAkjEsZfk8QU9+IhZBdtd/rfFBRehAySJf4DdKlU7RH1Gt+D2zvcrxikZaBhIkdGrnoMGLVYMWQojGmN40z9aZlkuQyOuuW76aFACC+Cn5ksSIBtUyWXAjUjL2nBJh0NEkfGA0BreDFg3ti4rBnmvjqkxRYwzUHgCY7nE5A8pXaSrmyundjgI2R0DbRaJmDRsm1cib3qkyE2ekE+J+CIjFp5yhUiY58brzZ/szTXnvQrRhlmFioieECjOwEeTWpTh4NN86aabzZtqeALHcEhOpfOvs91i9xohcyGuPT02ygtgBXeeRmLcv9pGl1JDAk3kdGwi+8CzvsTjRXvBs6bfChA0pa0dN0nDsWl1v6siyoZidKrvsb6gAsf8TwvznS1QG+N8Af4P8SV2mC319Fwx5Onhjrk1sQofdqJldJjG0XYHIQIGC X-Bogosity: Ham, tests=bogofilter, spamicity=0.025304, 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 xtensa 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/xtensa/include/asm/pgtable.h | 1 + arch/xtensa/kernel/syscall.c | 26 ++++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/arch/xtensa/include/asm/pgtable.h b/arch/xtensa/include/asm/pgtable.h index 1647a7cc3fbf..31b7da0805ec 100644 --- a/arch/xtensa/include/asm/pgtable.h +++ b/arch/xtensa/include/asm/pgtable.h @@ -425,5 +425,6 @@ void update_mmu_tlb_range(struct vm_area_struct *vma, * SHM area cache aliasing for userland. */ #define HAVE_ARCH_UNMAPPED_AREA +#define HAVE_ARCH_MMAP_HINT #endif /* _XTENSA_PGTABLE_H */ diff --git a/arch/xtensa/kernel/syscall.c b/arch/xtensa/kernel/syscall.c index dc54f854c2f5..353cce1ac9f1 100644 --- a/arch/xtensa/kernel/syscall.c +++ b/arch/xtensa/kernel/syscall.c @@ -54,6 +54,24 @@ asmlinkage long xtensa_fadvise64_64(int fd, int advice, } #ifdef CONFIG_MMU +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) + return 0; + + if (flags & MAP_SHARED) + addr = COLOUR_ALIGN(addr, pgoff); + else + addr = PAGE_ALIGN(addr); + + 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) @@ -73,8 +91,12 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, if (len > TASK_SIZE) return -ENOMEM; - if (!addr) - addr = TASK_UNMAPPED_BASE; + + addr = arch_mmap_hint(filp, addr, len, pgoff, flags); + if (addr) + return addr; + + addr = TASK_UNMAPPED_BASE; if (flags & MAP_SHARED) addr = COLOUR_ALIGN(addr, pgoff);