From patchwork Tue Dec 10 02:41:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalesh Singh X-Patchwork-Id: 13900763 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 2D1C4E7717D for ; Tue, 10 Dec 2024 02:46:56 +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=68DM57EM10Oy1Phx/X5P68W7yQkXIjbCrTpN7G3wDA4=; b=xnODSDlASJwW0fVQB/IEUew1t8 QSLPqLIDGJNrIQsRxEWjDWjWDWmzt9BX3bkAYVJWMP/KbCO+iWuWmHMSi5Mt7u/vNK/5yMAoYv3yN QftExVJLu5D+B5vYzJ58KCAnVv20H/X2aav0TRUznI9uR4sejz4kTo/fVx+UwJVmgTKN7onBvurBt CLpOVuRapCUlSxeTnFRj5/nEJBCHPwv99rJ7KsC20fGsHigbm3I2PhJvXnTAVd+343lhdN9vkd0QQ cOiYVGFn3UWm2m6oLKmyJw8V93lL794BuN+6XgmAuzQ+B/1RJmeztU1aVPUrgs31MFOa+ydH2baTm +nrF611Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tKqGq-0000000A1PU-0z0A; Tue, 10 Dec 2024 02:46:44 +0000 Received: from mail-pf1-x44a.google.com ([2607:f8b0:4864:20::44a]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tKqBo-00000009zZA-0bcH for linux-arm-kernel@lists.infradead.org; Tue, 10 Dec 2024 02:41:33 +0000 Received: by mail-pf1-x44a.google.com with SMTP id d2e1a72fcca58-726047a4bd1so1678758b3a.3 for ; Mon, 09 Dec 2024 18:41:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733798491; x=1734403291; 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=68DM57EM10Oy1Phx/X5P68W7yQkXIjbCrTpN7G3wDA4=; b=1FRVCv1Tm4eKXyzdSwII5gsqWub9pjq6yLM18fadr6P16c4zx/4hw/JnpDC8CUDvad +4YQpk02wK5y72nzQCEHfpUdy28iFYKp9uCO/bhp5LFpcYCACQfEYThWsp9T9DotQbB6 bzxfnu6wa6rfSccpzspKR4XmoWse9CpHYwJxezNW9eTHpnegoCK0vef0yxudTVuhLgK0 7DZ7ae12inhpeNNlMPaqFQK/KrNh80EVxSRlr57qvtSHP3eV/WpyrVklLyKgKQygT7Qc gAGqJSwmojp8uxwlmQPq9PvWxaqNveRVY0NEt2JjTpDVMJY/p7b3rBpjdJSVk85XgAwV OFmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733798491; x=1734403291; 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=68DM57EM10Oy1Phx/X5P68W7yQkXIjbCrTpN7G3wDA4=; b=cDAY+/P0Dk4fc78xjMKb1irMv1pAytnNLgOrSU2qP8PjNfIVcbN5EgB0K5wJGWVBFt gAt50Bm9tsuv9L2lXJyVWJYbaieTzm1DsBkTTgRi9ZwnLQ4s4+KQMoWRb8Xh7ySo0WeZ Vyd6DZs4pVvgmhjP5FD43zo3dmSWNkR3O0/SMBN3wXjHmDU/SQV/+LT+Bmds5KoP4O9B g4FMQZ+g1mx9Vv70L7y0pImb/V4nO4ryurMDENa5AvmMdtNeiqE6D4reG8hXpiIPRUGk gkuk9KYrODeILjE7ZTVdmqpnZC1wOa1f0ILZS91HiXMfE6ISAG8eBRtsPZpKgUWheAMJ pWrw== X-Forwarded-Encrypted: i=1; AJvYcCVXz25vm7e+5QOprIVlMeG5/YPZcsrp6FcveNnKRffF9wT46mPSj0saQZXDmGUq6BDaG92H0BPn2XBkCj2whHsy@lists.infradead.org X-Gm-Message-State: AOJu0YySomn9vW/CK1Jc2g+pzZB+aA29zAHRkxF98nXGRKwW4tlFhVev yX8a+xzc7tRpsF5U6gAUBikJxkRNkLC5vfcnDLD5QyKLL4xnOXYIRDDHe2jXt5pI4AL8SJXyO6A Q7qX8VypD2Etl0GKDxIZQPA== X-Google-Smtp-Source: AGHT+IEtrC2iviCeXWAtkatWkkbrcoIFQnKfltvUj9wZA43T/YasMAjSbDISIyM+Y3e/Wy24hv9IDhoi1rtLFpgStA== X-Received: from pfbcn3.prod.google.com ([2002:a05:6a00:3403:b0:725:db2d:370e]) (user=kaleshsingh job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:12c5:b0:1e0:d867:c875 with SMTP id adf61e73a8af0-1e1b1b5c646mr3881670637.36.1733798490862; Mon, 09 Dec 2024 18:41:30 -0800 (PST) Date: Mon, 9 Dec 2024 18:41:06 -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-5-kaleshsingh@google.com> Subject: [PATCH mm-unstable 04/17] mm: alpha: 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_184132_179881_73529BB5 X-CRM114-Status: GOOD ( 13.49 ) 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 alpha 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/alpha/include/asm/pgtable.h | 1 + arch/alpha/kernel/osf_sys.c | 29 ++++++++++++++++++++++++----- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/arch/alpha/include/asm/pgtable.h b/arch/alpha/include/asm/pgtable.h index 635f0a5f5bbd..372885a01abd 100644 --- a/arch/alpha/include/asm/pgtable.h +++ b/arch/alpha/include/asm/pgtable.h @@ -362,5 +362,6 @@ extern void paging_init(void); /* We have our own get_unmapped_area to cope with ADDR_LIMIT_32BIT. */ #define HAVE_ARCH_UNMAPPED_AREA +#define HAVE_ARCH_MMAP_HINT #endif /* _ALPHA_PGTABLE_H */ diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c index 86185021f75a..68e61dece537 100644 --- a/arch/alpha/kernel/osf_sys.c +++ b/arch/alpha/kernel/osf_sys.c @@ -1225,6 +1225,27 @@ arch_get_unmapped_area_1(unsigned long addr, unsigned long len, return vm_unmapped_area(&info); } +unsigned long arch_mmap_hint(struct file *filp, unsigned long addr, + unsigned long len, unsigned long pgoff, + unsigned long flags) +{ + unsigned long limit; + + if (!addr) + return 0; + + /* "32 bit" actually means 31 bit, since pointers sign extend. */ + if (current->personality & ADDR_LIMIT_32BIT) + limit = 0x80000000; + else + limit = TASK_SIZE; + + if (limit - len < addr) + 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, @@ -1254,11 +1275,9 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr, merely specific addresses, but regions of memory -- perhaps this feature should be incorporated into all ports? */ - if (addr) { - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(addr), len, limit); - if (addr != (unsigned long) -ENOMEM) - return addr; - } + addr = arch_mmap_hint(filp, addr, len, pgoff, flags); + if (addr) + return hint; /* Next, try allocating at TASK_UNMAPPED_BASE. */ addr = arch_get_unmapped_area_1 (PAGE_ALIGN(TASK_UNMAPPED_BASE),