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: 13900769 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 991D3E7717D for ; Tue, 10 Dec 2024 02:53: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=1aDg6t/gxrjVFwoXlm7hf8uYmo33EMje8zgxFnq8ex8=; b=Y1wKS5MvdeRDCzHEUWKP50W/tr S0QGk5ZlpH/FYRZUb8icZogQpPoRmqamTL3V8eq+WMp1KGwfSkhQbqqEsOo000PuUlyr9JEu/CNAR YaTvD82YYYaYWdDrad1Y0K/IIyBF2iA5y5CbuobQ8XWSi9mmlW1INOir/fUs+TRI6ZW2jALAwtvbP zWUbhRhxvwVCiYiQdW/jCNnswJWdoUJ8yyX2ok1PPGTVkP1F/wjiIrtsyPNZBQnKNFRitSkiHI8PB Rt9AtE2dYWhkj6/mTAFURZs7GMF+LlMdeP64AR8O+XaIrfAmAlk4Py1vws/Hbh8xl7PuPrPQzF9Ck nZJYDdfA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tKqMx-0000000A2YG-0c5j; Tue, 10 Dec 2024 02:53:03 +0000 Received: from mail-pj1-x1049.google.com ([2607:f8b0:4864:20::1049]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tKqC0-00000009zk5-1saI for linux-arm-kernel@lists.infradead.org; Tue, 10 Dec 2024 02:41:45 +0000 Received: by mail-pj1-x1049.google.com with SMTP id 98e67ed59e1d1-2ee86953aeaso4931207a91.2 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=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=1aDg6t/gxrjVFwoXlm7hf8uYmo33EMje8zgxFnq8ex8=; b=iZQwT2sW8dLqLcHvpXwexLulr8eH+Y3KWJPGT0rHvn8M1+KoO5dy10b1tr8iuLnqiy amAaRSHaBL6VNelYb0CGwYtcpKryLsYB5RTMUUsorwOGNJYb/p06F7egsme10SpL6qR/ xzH7oHIPZo24VCCNPhNtY/osuJx7L/gltfIXuH3V0hd3MWa6I2aOsWocxK1Lf6TLqMc5 58EeH+1XOV1yDNGETSMwgFIccY95B6+S046jV/DJN551SOWiikLqRu6IlfMZdGjihPY8 HO0mCgaGzZfGOmyXlbfcbcayMK0hisMSKD25DFktMoH+RFaRtrLBPEeIDU7Qvkech2Rp iffA== 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=Y+eFiww7OMvF8NZCkAEoI+e6VKBR0/3Pz52JdPdk1w1I5dQl5oKaCNThhO6e1JzliD Y0IGAKckYTjMiLVxFC4v2HEo5j0LyyZZQVpSIo/GdYmIRTljpSt5Qawxws2808kkkUdm W69Vt1i4Fo/jm3qzxH/GteW6i0tgxEuGYjwYfik3ubd8xnbFLzaCDS7ONWxm5PW7ypB3 +AqKhMYJWmz8wxg7vdZJqe+QO2EaJ+3HnWEMV4/q6gqbW4MG5xmSrPbjFeOl7zNb7/rO mOgHEjL45AegHDd8H4YDFHXdMzzPmMy47K6LMSbAAKOaKsqROXAJeJ7cFiHU5qTrtiir lEcg== X-Forwarded-Encrypted: i=1; AJvYcCWtnxPc7kmoPtwjNjelCy/K77YQX80GVMC6jqGSk1VSNek5s+fXr8B1krtTNj8CI2ELPyJUej4t+vcBXI9NDG0O@lists.infradead.org X-Gm-Message-State: AOJu0YxFTwA5i/11irFoj6sin7fIn8L+cx5jOnPUmySyUc4Dv2Z5vXtU vT7WTg7FhY5kGKsLSTPFX8s1w8uf4O+0BMlWzffGHMJM5LtjiUmbiPKTEFBY9JhunHdEW7Ltiqi +/Dr2whOmvbTNamQfhXHGjQ== 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241209_184144_485824_5D7045CB X-CRM114-Status: GOOD ( 13.43 ) 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 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;