From patchwork Tue Dec 10 02:41:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalesh Singh X-Patchwork-Id: 13900711 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 33314E7717D for ; Tue, 10 Dec 2024 02:41:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 131FE6B00FD; Mon, 9 Dec 2024 21:41:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0919D6B00FF; Mon, 9 Dec 2024 21:41:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DD6756B0100; Mon, 9 Dec 2024 21:41:46 -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 AE4E46B00FD for ; Mon, 9 Dec 2024 21:41:46 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 6C38B40F38 for ; Tue, 10 Dec 2024 02:41:46 +0000 (UTC) X-FDA: 82877497458.17.7089053 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) by imf20.hostedemail.com (Postfix) with ESMTP id 16C671C0002 for ; Tue, 10 Dec 2024 02:41:21 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=R+8liq4v; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf20.hostedemail.com: domain of 3Z6pXZwsKCFwE4F8MBMCHABAIIAF8.6IGFCHOR-GGEP46E.ILA@flex--kaleshsingh.bounces.google.com designates 209.85.216.74 as permitted sender) smtp.mailfrom=3Z6pXZwsKCFwE4F8MBMCHABAIIAF8.6IGFCHOR-GGEP46E.ILA@flex--kaleshsingh.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733798484; a=rsa-sha256; cv=none; b=a5McKuVoiuiSc12bY7J9Hu670tv1hvVFWUlgkbt3KMqTHA+QTIYeAv9Sk3GPYsxBKyBcHe L3Umrm7CQtQFua1KyqDR6AzQfVJmnpZZXlsSb/0MxnaYeVFz/MnyYFJhG6d76nDrqyvu/i gyFKEqvhZ2HPnv2RH85xpBFN4Nt4mzk= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=R+8liq4v; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf20.hostedemail.com: domain of 3Z6pXZwsKCFwE4F8MBMCHABAIIAF8.6IGFCHOR-GGEP46E.ILA@flex--kaleshsingh.bounces.google.com designates 209.85.216.74 as permitted sender) smtp.mailfrom=3Z6pXZwsKCFwE4F8MBMCHABAIIAF8.6IGFCHOR-GGEP46E.ILA@flex--kaleshsingh.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733798484; 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=1aDg6t/gxrjVFwoXlm7hf8uYmo33EMje8zgxFnq8ex8=; b=iaDUVRGKS2D93vUlWaUXLd1y78qbBqn/v77f5qgzG3x/yCfswIRL5zyMiPUhUyzTXY2eQI XMDZJ9osdsKcwfZvDl6MzKYzJ/uoW4WYr1Hy+hmz5+0FHz55E4JGnQE9aJ54w5iX68Q1sz 3eRz2QR95BMDTMsVN5kddM4URBnQIJ4= Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-2ef9e38b0cfso1874616a91.0 for ; Mon, 09 Dec 2024 18:41:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733798503; x=1734403303; 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=1aDg6t/gxrjVFwoXlm7hf8uYmo33EMje8zgxFnq8ex8=; b=R+8liq4vIztL1dji7E61IAk8cYOqV1iJRjZazMblnrdeNVCa+aQXUr61HaaDqgtvq0 Wf7cY/8119q57Rutf44kNMn3+8vGSlyPJ0tNEQai8mv0RIxwG66MprC4EggJ3DTO+sc2 3+0FyVVoOUhI8jeROZqAIRF0g5nwg6TjKZfDg0q9gxkMIYzZ4BxBpVJDqmnTkBuM7auW 1WeD+QhW94nYLkt1eq8ke5UllxmU6XxqPE7gJdr2ajGv6aYpaZu4IuETlsLXe/mOaMwf jwbHybFcdSo+2fS0JaVVpYFbfBVuVVmh8kxI2nUHP/r187u7+k/SHNMsn7MclUchXnFN +KMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733798503; x=1734403303; 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=1aDg6t/gxrjVFwoXlm7hf8uYmo33EMje8zgxFnq8ex8=; b=q6sfEmwg99v1TEvku4C7FMgtf0eOwZ0emC3HZU97OwkOoNCgwGBiKqdDLOFwuwfxhv +dkyAsYChTpzy75fVUYsWFMEjTGS/aR1ljuDTzo/Hph2GGvFEeT26DPZ6TZ7QA1RZh9b GjNs7IgTDPNFIwCK3WlloAEr5U62DLgZOVt3CZ+RTJYzr2fKhF3mjgiwccog7dBVUI3a ghn4nHkcPFwB6cTxQ498rguTIzUwOJ7ZhLTMhHoC98i6+IraWJTecZRfAOZEDUXV3ujs 30R1mCMdNGKu/5yV9SVrk3M1tSs7CdII+UJAo84H39VwtHfYBhuF3l1SNtXDP+aUtHdx Bquw== X-Forwarded-Encrypted: i=1; AJvYcCV7dFUMcHFNVXB/uU9tmRMfFbAu9oG9wbRSCDEJIBp5D3B5cWLsv0nj2zKhiQp8bmOl7uJuGYnSnQ==@kvack.org X-Gm-Message-State: AOJu0YwNzZskg/X/o9ADe22PznLsEds2e07I3TWYwSwTmU+Mk7lESjpY 08+yJRhIoNuhTJqW6vIrcmskx/bYv5AyhN1wpuGAlUyZshxxFAku+tO8QN9Fh5fosLron+aPbLg 29Qdb9lKTnWv/U0243b1ZFQ== X-Google-Smtp-Source: AGHT+IH7F6srMqCW64XkYJ4oxpvOqe9MgKa694plvhzavfksbdoDji5OgmDgGGH75PkB/XQatr5z5MeghIRL5RnGbg== X-Received: from pjbqc18.prod.google.com ([2002:a17:90b:2892:b0:2ee:4826:cae3]) (user=kaleshsingh job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:50:b0:2ee:c797:e27f with SMTP id 98e67ed59e1d1-2ef6ab296e5mr20079147a91.36.1733798503563; Mon, 09 Dec 2024 18:41:43 -0800 (PST) Date: Mon, 9 Dec 2024 18:41:13 -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-12-kaleshsingh@google.com> Subject: [PATCH mm-unstable 11/17] mm: sh: 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-Stat-Signature: ytz3ri9kfpf68zt4r1mykffyciprxwqj X-Rspam-User: X-Rspamd-Queue-Id: 16C671C0002 X-Rspamd-Server: rspam08 X-HE-Tag: 1733798481-781646 X-HE-Meta: U2FsdGVkX19HNkZaKEknrrFQSODyEiqSKUF5VEeW72/I72CkU/EW7RGIBLhccaZEbZNxQhZOwLMshiDcWStws39Dv0LpjgMmda4gawpHCCASmfwlzRWpKIm6fZXPoeszFIofofEwxBv/7TgE/I0LWpdF6xVPrF7erHCF7yeL2iCqc8XAgWxZcZ46OHPi+6aeUcFOsdvvQ27JtVhiUhaR7zWOgw+OvAj1AktljcsBKngGxXH5/zr47hXEE5msnym4ksQnsp9sAFw+aQRTNITxnH4JPUKLm6j/fxbebDs5uVoV3tHztnefySK6IzuBwi5j2DvUEmMwjC9Eldlk4t/RdkYG55MX+awu5QB48rk1hG+Q1jwI8wEhhghST7BxyFVUbSIhD4pLArFO7LuH8g4r7bCEAfiAxs+6BHng+Mjz/u8+BrKticpttc1IHaRwluxiNOLbNS32XkhoaBj58aUMirgMtWqYiGnj5ZY828MuTZx7VuM6W4kjiRs/4AJqga3cth9mdxOJwqPwgqwgQABZ3bWuxYojIsqLxvk7JZ+kEMLHgdRvJz6mTLFSuAXaSCH8MLfZdsVht6YisFHdsrR3l40KGUsnPzRw1cUJftauBYK/I7osUkGAPgsNovCIDkPdF4RiqjePTTByygogOeo6e5xI2EPq4DJ+X5MhrDN29jOJx9o3FMduAOHaUeibNaBqejvkCzd8LhKiplDkVbQ2enun4oB+aiR+GY5CJhj1MD9Qmi8nctJwRZSUBqqk3XrVVZ33T7n6Qrh/21/rrVPQMPzZt5NSEQguyiEXtEwpBhBfzDSvUpTVmROjjkkIhpLxCoPNSdkRJXbqSMFnxUxq8Q08LmLBgT+jL4ad0Yr+2xeJ4pb1AshdNMDgxy4Ogd18lmsCu73/bRhBFL4YffZTyoq+T//4JVYlg09QJKTOp9J6t79UO54EcsJc6Qf6w4VDR43osmIqXnNcia9Cc+y rTv9l4rx YQzEikzqZ+p9/CGl/Dsoo0R+3PYQt4fn2Id6mi1BaHnf9TKw+WeO0xHhtp1/1wP3ypWpfy8JOKU83Tt6cEQhfAJVH6B7YMitU1/UfnCxi59/Erl8+glhRrcixlakVALtInPWmuIt8Apk6nIpeZss877LDtpUDKgDptMWk6aB+7yiIExljfENaoXAipqMYAqVcvaOG3pl9dy9QbrYfDJSLoRmri5UBcPlx+3GPv3A6dL/i+zDmkubM5KEkMMdvB5/hVcwkmYBQs12NWDOY05NWZHTo5ZcVPS4mNAe5XjnxQmoeivhXd4RO7CGvi2pD7ZR4LPThX5nODdh4Er7isgxLKZ0picPo6ciafOVDrpOGN7Io0ClHBbHV7eOLJ6sLmSfeFQaIzlFnWEUTREw5s8E9WiKDH4MmvBNyZ4Qmd/TCM0dyo2tjACyphxJdniuBqeVDLKyDex2dZEyuZav45+YZAroAfwBCBpBBkFnCkpAuTG6kPKBeSWndrz0t9vVc3L6VJO8Om4vOGsGDyU/nmejaOx4AFO/BZeVHZhJ3dqTfAFtp8a9us1JFBcOnTLnStSJj0X1ph8EaRHpJjqWWccNCs2bsd6WoRxAExx3Ss98Bvl+Jn8RiPaxv5LrOvcO9T/6ny4lB X-Bogosity: Ham, tests=bogofilter, spamicity=0.209153, 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 sh 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/sh/include/asm/pgtable.h | 1 + arch/sh/mm/mmap.c | 48 +++++++++++++++++++---------------- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/arch/sh/include/asm/pgtable.h b/arch/sh/include/asm/pgtable.h index 729f5c6225fb..072dbe038808 100644 --- a/arch/sh/include/asm/pgtable.h +++ b/arch/sh/include/asm/pgtable.h @@ -149,5 +149,6 @@ static inline bool pte_access_permitted(pte_t pte, bool write) /* arch/sh/mm/mmap.c */ #define HAVE_ARCH_UNMAPPED_AREA #define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN +#define HAVE_ARCH_MMAP_HINT #endif /* __ASM_SH_PGTABLE_H */ diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c index c442734d9b0c..5c96055dd5f5 100644 --- a/arch/sh/mm/mmap.c +++ b/arch/sh/mm/mmap.c @@ -51,6 +51,26 @@ static inline unsigned long COLOUR_ALIGN(unsigned long addr, return base + off; } +unsigned long arch_mmap_hint(struct file *filp, unsigned long addr, + unsigned long len, unsigned long pgoff, + unsigned long flags) +{ + int do_color_align = 0; + + if (!addr) + return 0; + + if (filp || (flags & MAP_SHARED)) + do_color_align = 1; + + if (do_color_align) + 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) @@ -77,17 +97,9 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, if (filp || (flags & MAP_SHARED)) do_colour_align = 1; - if (addr) { - if (do_colour_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 = TASK_UNMAPPED_BASE; @@ -126,17 +138,9 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0, do_colour_align = 1; /* requesting a specific address */ - if (addr) { - if (do_colour_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;