From patchwork Tue Dec 10 02:41:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalesh Singh X-Patchwork-Id: 13900708 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 A023EE77180 for ; Tue, 10 Dec 2024 02:41:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E9E3B6B00F6; Mon, 9 Dec 2024 21:41:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E29756B00F8; Mon, 9 Dec 2024 21:41:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C78E86B00F9; Mon, 9 Dec 2024 21:41:41 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id A51B46B00F6 for ; Mon, 9 Dec 2024 21:41:41 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 512C0120220 for ; Tue, 10 Dec 2024 02:41:41 +0000 (UTC) X-FDA: 82877498088.21.B3522AC Received: from mail-pf1-f201.google.com (mail-pf1-f201.google.com [209.85.210.201]) by imf21.hostedemail.com (Postfix) with ESMTP id D524E1C0003 for ; Tue, 10 Dec 2024 02:40:58 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=PwBLCeTs; spf=pass (imf21.hostedemail.com: domain of 3YqpXZwsKCFc9zA3H6H7C565DD5A3.1DBA7CJM-BB9Kz19.DG5@flex--kaleshsingh.bounces.google.com designates 209.85.210.201 as permitted sender) smtp.mailfrom=3YqpXZwsKCFc9zA3H6H7C565DD5A3.1DBA7CJM-BB9Kz19.DG5@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=1733798485; 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=dnsK0Z+Vsck1DKfgwLToYEVTibYJ9G64XT5/R8jJ9Xw=; b=TMHuwtDGrE65r8K9x/iJvUqWDKA69msuf9jNQPo4SO95Ms8RCSL8wyxe6kYfeAF0Jg5u5m zf6jl4CgXLjliqfRlYTdaA4AD+9WX/BVf97WdAAlBSmy8GnuIh3MfQ8xArXBymu7dYOnea +jKmkndHDGg2awdLfnjzr1ztocXANFU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733798485; a=rsa-sha256; cv=none; b=XL7/SoyZyUHi9sMUg+0DhJEawhaO/fDzPfD/xaNjoZzp1fDsZhk9ijmRyqvdk5FHiJuHzy pRxBapbCrAq4bLS/olktuetEYLQn8r3ZH8IKdj+GZscdQwNDXCOr7ZnfCf70kaNl5fpFxF woOAb76KtUnjk3dp+aTcq1fkjWuaah4= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=PwBLCeTs; spf=pass (imf21.hostedemail.com: domain of 3YqpXZwsKCFc9zA3H6H7C565DD5A3.1DBA7CJM-BB9Kz19.DG5@flex--kaleshsingh.bounces.google.com designates 209.85.210.201 as permitted sender) smtp.mailfrom=3YqpXZwsKCFc9zA3H6H7C565DD5A3.1DBA7CJM-BB9Kz19.DG5@flex--kaleshsingh.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-pf1-f201.google.com with SMTP id d2e1a72fcca58-725abd190d1so3531127b3a.3 for ; Mon, 09 Dec 2024 18:41:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733798498; x=1734403298; 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=dnsK0Z+Vsck1DKfgwLToYEVTibYJ9G64XT5/R8jJ9Xw=; b=PwBLCeTsX5IcnNkB2kjlN397iNUFv124wD/YIPKddKHzqoOAnTBkkAUTd3YjsLrspl GhK5u5QH0QY9BdpKqpPvyHk3/AJdRhY2HlcyiD3cbGIDX7lyk4zrCdq2BiUwJ6ZOAf/J R6Gg80BYu7vkO4NNGGoNeN1cfJO8EqcztMUAO7blZBh9HZdWAfe/QjRTZff+UqKJk+ma wY0guTwrt948G89Fpk3f7+GaQxcnJSNpF33Gzd508nfyNvuxSFRMRR960M4xSusRiYZK drx51FNzjwIJcbpcCC4pDYyJFMkoYyj/4GjcDrRb7bSmmOTsnSLyrrqem19dIE2zgKNj Dx9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733798498; x=1734403298; 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=dnsK0Z+Vsck1DKfgwLToYEVTibYJ9G64XT5/R8jJ9Xw=; b=WErMfxLrfvVORpWOgXjO/tUFEaHWf6Sb51QHCZWhBlGNPGyii+Pj26DGSkFDJIl+ES gp9LsDGiQs8s/jGQXHo9YXnd6M9d7IqR4FuXC6r/z2ymWLafNDx3Shzd2k43XMGp61R7 HWyJcPK+KSq8c+6WSBQEF6kmy/Kh2j/8wdwXqtDKiPy3c0HaWmSopGfEM+veCVjyZOjq Cw5gQK+uIlW6ChVPHLMg95D4zjOnTbSBw/n0CE2XpHM3tBatdVATS8QBNc25dOhloSgL zEfwM41yVpaRnFD1MSKDjpWsq6qia91q06MGMn93Yff38wHmXEF/4wUITogxrqitZHmE yUlw== X-Forwarded-Encrypted: i=1; AJvYcCUwTd+53yJAAodqNgF8FBx7MAwPKeRW8fURsnZrtICpKYEzrjTIUbua24B680BFxUVlt0SsGsERyg==@kvack.org X-Gm-Message-State: AOJu0YzsK6JvHeMXf2THhOlPm26hjNSzPKkJ80iOOPgQqy4A6ZkI21vv 70ci7kPxV6F7VR8DqA3U496Pni7Dbv2sIDpMlwsKxUjFnqTtX76qjWSUcaZH7ZF4EAR1zD38ZEh SYf0vsbVAGcFOqyuy2e/hsQ== X-Google-Smtp-Source: AGHT+IEQiVamF/zzJ8w1wfz7OIeUdP3OCsWBSWfXEHphl91Ep+NYy7TdX+lfoJ5W29b7fSm/JmmQj8+pvlj7NXOkkQ== X-Received: from pfbio2.prod.google.com ([2002:a05:6a00:8e02:b0:725:936f:c305]) (user=kaleshsingh job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:7283:b0:1e0:d380:fe71 with SMTP id adf61e73a8af0-1e1b19d4512mr4863730637.0.1733798498297; Mon, 09 Dec 2024 18:41:38 -0800 (PST) Date: Mon, 9 Dec 2024 18:41:10 -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-9-kaleshsingh@google.com> Subject: [PATCH mm-unstable 08/17] mm: mips: Introduce arch_align_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: rspam02 X-Rspamd-Queue-Id: D524E1C0003 X-Stat-Signature: 5bu56y399pacxe9ma9scm6fiforb657u X-Rspam-User: X-HE-Tag: 1733798458-909116 X-HE-Meta: U2FsdGVkX18YZEbmeeOzVBsEpbwQkMXGYcEuw27LGceyIjeZMz4ogQiXc+cFycSNWijq+5cgR6J6T8hrd/FJOABvZ2UOwNJXwS7eysxjsZrfsBadRlFxvN54DxmhB4PHbpMyrs8+tG2Z/9Dp9CWGTieTkEAhKeGQ9gQvxsbICVD8whEkzzHehNcxkj3cfV56XpTLK51IbH77iupwvkmZEKTDSL0Zcrv2T1T0i0lw7NVtmrBjGJSY4s2YGb/O6JDlpRV5wxDzExzrfFs5hrdNeARESisxf4ge9gMIp+dGN4tnco62RBS6f07pEdqld3BRcpmqTEarzJ2XsgA4FpPcE0w+qYzlywdfaiDa7Ze0OEKqhWmjdwjvFm+EdW/bDzuXMfrQ5Jykd3HYMDdmqsnDXoIHISlEMupzAscoJXwxnbpiC5K5Idhq2m4YDD/KsUwrNRjQbB1fVLYvn4Ha5+BxT3RXL8F7UfMb6QzUUnyS/AebU0NpFSOnDEbeL1aefjk5pTqTVwiOdZJqgcCPt26FaqEuJWXAOEFifEE/XlSoLAvxDYquxbmy4r/v9V0Y805Xsc75/sTmj12UnJdfHx6JH6WhIL5vJQ7vQ42OwSDJvojlLdgsrLxjom+oiUtNELXKP5u6X1x8E6zbbJyxKyuv5QqeO1EuwmFvWkLTk4Deau+gmibk3FTXBNfJNWaXLuunCc6qHdTkcBq6ZFw/YGTBMD9n0XdViG6fjZ8AN2JeV1qOSsbpqPhSt77FQI/buX5CQYkPiJVywVm310fm1yMmAjLfoMpxPE5sIdWO9jDOCb13QnPz4Hb7N5Kynr5+frVGyWV74ECs+WsRTn8rquwAnL6pPUg2VKKe8lYe26jntpoxwaYPs4DVELWi9pQ+I71H6Qfa+5ccZgMB3lELh7WtGJxogGUmH2fluegFBZ0ldF7975b1Sq4ueWWNytMgeUOWzFnas8HAruthqAntgp6 furRiA4u 2lsj5wQTQKKFBRL9rUte8a/wRHHDkyN0kHIIZ8vv2JetqdSdl/YRBXkWzkZ1CTYzV+DF9zfnxNKHVrCzZA1mD2gDZqN5e8Y9+JILXqlDAWayNrrFUlLQ/A2mz/m9j00ahJunHgKI8SQ4GEMKu6kJ3xJhMnzOkli69SrAKQ8plpT9uQEVDaAk0O06zFNAo9468ayCf9loKO8oMSwqwvhLIA/aKZBhibqd3rBIEIsa+Mjkt9LtClOI7LqoNfaEzcNHufeXbImo+n4WZEPnYlenDIqXRIp0aLK98bjxe+7xM3F25fL4cgJfZOdtN2e6q+1AVEJYg6q4IGyFbGg/1N+OwHy9kCYJUX30wFFKKL76ERxtI3l9vtq9zw0AfEoOtrjaApMj3ikuLqav7Aev3cvpmAV7fQEnsr4cIfBaUaqbMdiieMVsqcJSGVE0wORJpDI3TS15AW6mVR/uHTxP8hJaVmz08yDHCvWkz/1Yi3Ad0c0bdaFCcAAe7lZzBpPpxd+dC+z0O9nOZN1r9+8q2K97nEES3UX+vX5xUFaHFHPrM0Vr3dGfyai+mexWUal0F5JqicaIEYWfP6IhoJUCp7JU4Kf13VskgZYuqX8swb/qWuyOJ9sQJV5J4Aw/Aqc0yyew0fZMV X-Bogosity: Ham, tests=bogofilter, spamicity=0.155536, 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 mips 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/mips/include/asm/pgtable.h | 1 + arch/mips/mm/mmap.c | 39 +++++++++++++++++++++------------ 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/arch/mips/include/asm/pgtable.h b/arch/mips/include/asm/pgtable.h index c29a551eb0ca..837f25624369 100644 --- a/arch/mips/include/asm/pgtable.h +++ b/arch/mips/include/asm/pgtable.h @@ -766,5 +766,6 @@ static inline pmd_t pmdp_huge_get_and_clear(struct mm_struct *mm, */ #define HAVE_ARCH_UNMAPPED_AREA #define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN +#define HAVE_ARCH_MMAP_HINT #endif /* _ASM_PGTABLE_H */ diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c index 5d2a1225785b..cd09a933aad6 100644 --- a/arch/mips/mm/mmap.c +++ b/arch/mips/mm/mmap.c @@ -26,12 +26,31 @@ EXPORT_SYMBOL(shm_align_mask); enum mmap_allocation_direction {UP, DOWN}; +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); +} + static unsigned long arch_get_unmapped_area_common(struct file *filp, unsigned long addr0, unsigned long len, unsigned long pgoff, unsigned long flags, enum mmap_allocation_direction dir) { struct mm_struct *mm = current->mm; - struct vm_area_struct *vma; unsigned long addr = addr0; int do_color_align; struct vm_unmapped_area_info info = {}; @@ -54,23 +73,15 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp, return addr; } + /* requesting a specific address */ + addr = arch_mmap_hint(filp, addr, len, pgoff, flags); + if (addr) + return addr; + do_color_align = 0; if (filp || (flags & MAP_SHARED)) do_color_align = 1; - /* requesting a specific address */ - if (addr) { - if (do_color_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; - } - info.length = len; info.align_mask = do_color_align ? (PAGE_MASK & shm_align_mask) : 0; info.align_offset = pgoff << PAGE_SHIFT;