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: 13900704 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 D0AB7E77183 for ; Tue, 10 Dec 2024 02:41:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BDC7A6B00EE; Mon, 9 Dec 2024 21:41:34 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B652A6B00F0; Mon, 9 Dec 2024 21:41:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 969256B00F1; Mon, 9 Dec 2024 21:41:34 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 7370E6B00EE for ; Mon, 9 Dec 2024 21:41:34 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 3084C1601FF for ; Tue, 10 Dec 2024 02:41:34 +0000 (UTC) X-FDA: 82877496954.17.6B7C19A Received: from mail-pf1-f201.google.com (mail-pf1-f201.google.com [209.85.210.201]) by imf17.hostedemail.com (Postfix) with ESMTP id 04ECE4000C for ; Tue, 10 Dec 2024 02:41:15 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=HohL0Nth; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf17.hostedemail.com: domain of 3WqpXZwsKCE81r2v9y9z4xyx55x2v.t532z4BE-331Crt1.58x@flex--kaleshsingh.bounces.google.com designates 209.85.210.201 as permitted sender) smtp.mailfrom=3WqpXZwsKCE81r2v9y9z4xyx55x2v.t532z4BE-331Crt1.58x@flex--kaleshsingh.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733798472; a=rsa-sha256; cv=none; b=zzWmzQmR4YkQ8vp6REpAfdfbd1lF8+wZjtSdtObj5i3tIlMOJhF5HkajggiJCM/NES+4El 5mWID2NVgd/dhHZwH402+e2Y1QHfrZi3WVdsux19/NyQeSQXpelzlNFL5Soh7r1mgz3dZU DMjsmUsyz7b1ZqaWauZV+k5GSaq3zME= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=HohL0Nth; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf17.hostedemail.com: domain of 3WqpXZwsKCE81r2v9y9z4xyx55x2v.t532z4BE-331Crt1.58x@flex--kaleshsingh.bounces.google.com designates 209.85.210.201 as permitted sender) smtp.mailfrom=3WqpXZwsKCE81r2v9y9z4xyx55x2v.t532z4BE-331Crt1.58x@flex--kaleshsingh.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733798472; 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=68DM57EM10Oy1Phx/X5P68W7yQkXIjbCrTpN7G3wDA4=; b=HnPxotctb47ZnWWdA5P0rxTztn/hi9xHrFYrJKGUQa1Tki2yWZfYfYzNUflVOqRmuOKQWF 6WiVimcUouDLAWWHFyvpP8z3gHCnj5ow9ftWnVybJMy9AGDmOHlM4Iiyn32rjs+0mIgecN FJAZVkkBYOxZMge/Ec+4tbFHml4KEI4= Received: by mail-pf1-f201.google.com with SMTP id d2e1a72fcca58-725e3c6ad0dso3062005b3a.0 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=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=68DM57EM10Oy1Phx/X5P68W7yQkXIjbCrTpN7G3wDA4=; b=HohL0Nthvst4QE5AkUIsKqhaIbqxBsUJYngRtppNtbKzK4+R6Iq5GucsnJsRp0ZnHs gfT7T4iblG5LAyPK90EzMtakWdcNAd56KM9ZAFlw6x20anLmYh2yEOlLYWrvWMCq8nrX 85ZtyunNzEi3EaZOsboEO5BASzgTsfmGMidWDstu2GiAUQyHDbAR1DhPXke+lPBbGlIv beUB2UqSD5gS9RK0xiNXMhgsUKX5I5x0N/wdj3A+Xiw/cbtaOkkKN/tPbQsgx2dIyv+a T1DYUWZ/ODBJ8rjNApT9G5XGHjjnvDK3udBDo5q52i9WSg8AaOSl/7XVUhtz73p3FW3I CzEA== 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=a4ufCk9LM5U9RUdJuveNArTEBuyeOppdF/tyb22Q5W9wLaVhyX8wONzoT2MxczUrY6 oxtvo/gOu2npQXQVGTUXhpAIJVYjeaLKTh2/k/ZDRyZ72/a27KMp/BM7D1BH0HdAdVXt cvhOoCDXP+jR9bKLHks8R4XFiG8ggJwYiI3GXo0PwVjKjn+QLg1570kHxxbLdBmPEHIl f7sz+VEaxUzUafBFrezNwnDu6fpIOd04cD4eW4PrYSXzs72gPA/o+FfAYRPE8sM99Ih9 Zblts41TfWbNMwfmzdMiTY2li47tc7duZXQBchtvJKI5C7UgFDsA+RC4tmmbq3uxnQJe Jlyw== X-Forwarded-Encrypted: i=1; AJvYcCUeCri2OkyM3BU3aOXx2jaOMJeMUkUDfObOS8XW60P6WABDhDAOqTdxNiTqpA0r1o2w46eG2OA2dA==@kvack.org X-Gm-Message-State: AOJu0YxcKSOXLiTjg6goyDWoTmf/LhMczc18F9/V3Yh0ngblx1/4ZxNY MZ3GoOsq0qwqk2zne8ht5MdTTy3sRJfr0eXYNtBLmjbSAuCMaG72cGqmCnRwPN8EBh/sc/93rNK TVNuBLbYxzcBoYWTX+OOpPA== 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-Stat-Signature: h1hy4rixwwjdxe7po53ax5razheuw34i X-Rspam-User: X-Rspamd-Queue-Id: 04ECE4000C X-Rspamd-Server: rspam08 X-HE-Tag: 1733798475-417088 X-HE-Meta: U2FsdGVkX18DMWfrD3hSXuULnxR0sz4XcPonEsrToCS17UU0zYAJ5/S9euC277/+L1QyKY16jOl6s/m5/A5hJmzRr96bv7H1UYbV6eOMisqqkNJLs6NW/iYqa+t9+jDzJ0FZk8ZemfaH+Ikuw/rqRdWOp6YKk4PCiEXnuvOsPjmLiLcPs8Z7Fvfr+/zaVWpfkmcYkWEZFgjzdExwR/3PB26JrBc+ZQPmxRhulEOnATSARyrdnf7EMP99JCUgGtShqM+dD7guvR+K58MncpvSwxVpRpj4pCulVkS78wtytOxpxYgm/Wq5fk/YpU4mlh80Ajbni+EtftnUsnts+sJWEsRvEmKXUi8NLAkc/rSawsFjaalShUwL+wf2BfLSEEU3ebT9srUCES9fLW653w+gO7TcXvMVu5faVkyApSXd+KMBQmripc94w8YbZRK2e0AI/s5JgSCh4mjrb5yHtV89hwZfGp6pji65c6tGjnajzUNLtnGNMPbHO/C9jq3nYm34Y985dTGsD2F/AnYFZex2kagur/LHE+/H2/q1NUSwf0g+SL+IjE7Z5zW2ilGaSr+zGjCjs0xVUGWpNUGFZEzqk1a+/4G7hvZovzqAjEev1qrzQoq3Ev+V8ktyybk7iX8ItT/6z7aOOe01P3Bnowo/NKlDDZ9LmZ2YnHxhXnzQeuVSrB9SqyKnN6p1mi+TknNUDzsbmvPL8nC4L+LiL5utaC1bfmCOpSM7Qypl1UwdTbQdTE/eEAsWmdr/gynOATwPMDp8lPJPHXBBhMGAe5PDIEaWVJFyQZbP+8S1xjY34R1jxlY7GwpOPw49UGNWBJBLbuXHkISPQMz/IbQt4qlNh30UuWpGOsqexNV3fwpwNA4ZqK3R48YstgI7LOY33Bho6PA15X+XUb6qrf8ABG8Xb5YYsVAXQGvfU0GKTQ3qGhTCM73IS0UxcFt0OFV7Ln+Z3tBctQvNUOZZzHV3KeZ U7C9xDW0 P56KtGBZloqRD5MUB/241QOqqsckJALRH6PtW9ApOHtnsIOhFEYrRYHl2Qv7bcN1WB4vjpPpDg/zlPOmOS3FEl8m2BX9I9a5H2ZaSInGkr/cUHIrP4f60WqVDIbpGt81O1n7RSJkPrNVe737p8Mpgll8otw9XOXrBD+/FgrwMAaSyJnnb6Mez/Ye4+llsXN279ytNBxta3H0NUXWiT0yNqDhRZTInTRhu4N3AlfjBUjwuhCONoIv1kc2nSMTLsY0RMxIsZQcpXE+7mEKdGK8kqJBhetAp+vLYzgoS2F0/casVfy7hc6CJKpDSWtFBOQjChgoTkm5rF2Id9R2f2Ux27X4jzZCUPcB06Dl6ipPB0IOY2P/mhCh1H6I6vl7TkZ1cXnNL/dBW8sHQeWnMsTotFZlERTdq3hX2RHHrbakwPxErAtrhwWFaWekU0XUuCWzwF9+3TaZLmIBO+MGuim1iYzkfL98q2MWLKY+ZJSOJkflrR9gbar1mwS1M489qHSQguy12G4OuKRl79pSQOy4TbRH1Jy5hHf0MENUaeTDfwqf692ssapAXd07sUf3yqpgEyk/HFAo9OU6KFvN/2tx8IE2VoWl+3YDc5vtz44Dt28UEgErIa2pVOz0cCqPwPUgwhv00 X-Bogosity: Ham, tests=bogofilter, spamicity=0.144391, 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 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),