From patchwork Wed Dec 11 23:27:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalesh Singh X-Patchwork-Id: 13904388 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 DA55AE77180 for ; Wed, 11 Dec 2024 23:28:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 677866B0095; Wed, 11 Dec 2024 18:28:09 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 594996B0096; Wed, 11 Dec 2024 18:28:09 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 404186B0098; Wed, 11 Dec 2024 18:28:09 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 1BC1A6B0095 for ; Wed, 11 Dec 2024 18:28:09 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id C83C3AFD18 for ; Wed, 11 Dec 2024 23:28:08 +0000 (UTC) X-FDA: 82884266976.17.006F425 Received: from mail-pf1-f202.google.com (mail-pf1-f202.google.com [209.85.210.202]) by imf17.hostedemail.com (Postfix) with ESMTP id 105A340010 for ; Wed, 11 Dec 2024 23:27:48 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=nthz16qL; spf=pass (imf17.hostedemail.com: domain of 3BSBaZwsKCO4aQbUiXiYdWXWeeWbU.SecbYdkn-ccalQSa.ehW@flex--kaleshsingh.bounces.google.com designates 209.85.210.202 as permitted sender) smtp.mailfrom=3BSBaZwsKCO4aQbUiXiYdWXWeeWbU.SecbYdkn-ccalQSa.ehW@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=1733959670; 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=vYJJcdIp4OFdB+jw/mn5ZasDVQdafEZmT3OPk14pFSA=; b=tK6yNUZIljyD/VeaVPDeIewOGG3ZSbe1DWa7ZfLOodkRv+zEWU2O/Fz+grBnwqDYzRddqm nE6+SrTUl/jFHV1dWG8czc1xmQaylXHBN3sMmUFFffqgVthCxM7z6Zh9x6rMiKOckPmFbL 3NNn8luBQtH9zhUrBR622wWHGiO565o= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=nthz16qL; spf=pass (imf17.hostedemail.com: domain of 3BSBaZwsKCO4aQbUiXiYdWXWeeWbU.SecbYdkn-ccalQSa.ehW@flex--kaleshsingh.bounces.google.com designates 209.85.210.202 as permitted sender) smtp.mailfrom=3BSBaZwsKCO4aQbUiXiYdWXWeeWbU.SecbYdkn-ccalQSa.ehW@flex--kaleshsingh.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733959671; a=rsa-sha256; cv=none; b=5PPQr2nB4U3vqPntmMFIMGU5kuZKosgM33zCNW5fYSbIDntzL5E3lzEeNB9veZkJjqwPrj 9JfeKTwNb2xY/1SFwbnp/7uRIRPpUYimdMkKpuk4/bSRgNM5QIlngjktVGz5L5QH9cy8T0 u+bn2JD5dVe0fU8Mc62NpgG5d5cI6Lw= Received: by mail-pf1-f202.google.com with SMTP id d2e1a72fcca58-725e8775611so21742b3a.1 for ; Wed, 11 Dec 2024 15:28:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733959686; x=1734564486; 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=vYJJcdIp4OFdB+jw/mn5ZasDVQdafEZmT3OPk14pFSA=; b=nthz16qLjxzKe7RaF/6uMRNdK+5GBbt1UkBUCi38ts8qyUBYHCClidRfX41ns6oTdp RuLraaWZ1k87ReI9i0rHMDGvkoSznYzC2iyR9m2cEiL4ZJLMrBNsCV5ewjVekTywV+OQ 4MiOC/EEB7UiyMIX264DAvyDGdHlD6Wpp8Os0LE1YyOt0MAb2KPK2N7JSRLx/7YipHSq bpIi8STnj7+pKrydmdErtXduvGWkxikfrEMxuaaJVRE7UYw01fbv+R3WRamq+ji0+gB2 O8K3cYQjATTPuYfjGuxG4CQXkI4AJ58C56gphlE+d/Xay6oDmPzssK4w0qp7rpA0S0rZ +vug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733959686; x=1734564486; 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=vYJJcdIp4OFdB+jw/mn5ZasDVQdafEZmT3OPk14pFSA=; b=hxWd2gX8ENh8V8PmKEMPpb104Ohr4v5kJnkqFdx/jDDEyT4ruva6e5FuLULUDz8Xuf 4SJ19twn0Xo6qitL2V//6+SpIFxZVn8O3m9y0b3usb1t9tBaQ8mnSYUfbOtnySJP4seC WUzF9k4O0afjEH0UZ7SkugAb8JKkvDBlQ/SWReJfs2p2CubV+JRb2JpG8ydfIls0c2XW 44g8LI0Oj4JHHdmPvGWu+ctQQ2EC8y7ItHPv0D2fvK0qpRlIamx5UOfmWkmPBIUp9wJ9 9F2MV1tbZ18FZ4YubbUZK+/2JrdtVvx4+vvTPUF38mQ1L7PH1yJvKgYd6gcVsZyvselM Vm2Q== X-Forwarded-Encrypted: i=1; AJvYcCVafvQzpDKMalt7d2h1GS/wKTQ/G/2lUzS/otrFqALtbda1mAXqtZ1Wl8+8pWTKdU2vSGgn/Fo68A==@kvack.org X-Gm-Message-State: AOJu0YwEjqPhhYaIDhp39L+j8PfFbz3HiAMdfCmA8OcqLFhYVs3xh1sO wqbzTVguBEFzycShn/9F+7ILarB2wYJ5NbIa/UfE6WfHxLJH+5YISzwmi9xDwMMTnfsYs4VkOJx I2DLch1s+4jY4RDd3dG4diw== X-Google-Smtp-Source: AGHT+IGKKVpJDJ1y2ylGaA50Z43wv3+APAJV0fjiCw5ytHmnD6GxlKgAyJQZQRFGHnrCD199ncZRE2+HH1UPCzOgAg== X-Received: from pgbfy22.prod.google.com ([2002:a05:6a02:2a96:b0:7fd:4739:79be]) (user=kaleshsingh job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:328c:b0:1e0:c56f:7db4 with SMTP id adf61e73a8af0-1e1cea71c6cmr1602899637.2.1733959685721; Wed, 11 Dec 2024 15:28:05 -0800 (PST) Date: Wed, 11 Dec 2024 15:27:42 -0800 In-Reply-To: <20241211232754.1583023-1-kaleshsingh@google.com> Mime-Version: 1.0 References: <20241211232754.1583023-1-kaleshsingh@google.com> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog Message-ID: <20241211232754.1583023-5-kaleshsingh@google.com> Subject: [PATCH mm-unstable v2 04/16] 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, minchan@kernel.org, jyescas@google.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: rspam05 X-Stat-Signature: n8w99qbf34uzcks7a669uidxftt9kb4b X-Rspamd-Queue-Id: 105A340010 X-Rspam-User: X-HE-Tag: 1733959668-592645 X-HE-Meta: U2FsdGVkX198G4rgzY9CEpAteJN3qmso6I/hFw6N+fHcHzO+GpUoYn3M2zWZGujVxyWi/q1Q9lTteI4vVlu5lPgu6sNLAGJL0JF75OuNtpiZkZpNaIFRc6+uh1bnfBKoJjEHFPTm+64shGg7As1d0zZQEeefMKb9KNf9usiexgQWm1Dd2UJXxC4r7hq3rsJsWn86T4GgBksIp9ih9dMkZMJTC+AGgjip632WqypnpHUaX007PDFTyo3J5Z3P27GJw4L2zBI5mAR1KsZDMj6bLH55F3BXS4I3pxm6/NqZjIO3f32gw1lcOi852uZGTB04A3OuTuh8+XmEMU8WQvGxJur439zCw4VyYysFUjUwqoqpGhYQIzFppMuYVaTR88qPAcF4c0VijL17Cvf1Po67nDdo+YUoE1+a7q3GH6R3i6wJow/6lFtf3CgIkRmoaujY4WRxptiwqRUkP4RAbhz/Gp8VZkuooG+fx+x3gJN4RwXaKiTukxbCY3ak1fzICZ5ySiCErYMeT4VbSxm3WwTKwXQPxR8TC77Ctq6PBcilwO7/GOn4XQwH+llCS3eWPE4CwCQyzrjq9oC92Ho1bV70hfA14HhMyuxpP6DokrzUWzzbfgEn+j0FNeaJ1FI7Xf1OOBYlgb/gxvhfZRzrSsZK84bZ6xGzL/ELCC0iTcp3iijPhR+JUYUv7dyQ7Vu0AOCKrFMu9o2AU9b6/6+DkOLZjEp1tGaWJy9DvC8M5nja9c5DUerwIPH/D31seHemXYcZdB1NX3iuXILpROt0mCynHCMFU4NwxCLOLEUG0SBoG0lQKCxkrA6xk+zyRkToJYmAN8CreTUNmJQQH2DWj+0xl8i/bVYJVU07sBJEnBtu8+LPgZUqPaAvUIGJdKp1KfwHAw5CTNcAdVa+q95Vf7dcUDetUFMS8w5VieXH6uP28tBZbTNT6+fFJNVnQ+M/1kVcnD0QYRIa5tUkfiini3e V2+fQvYe 1bR7jDxh6vNkYNCEZsKdK06LmX9xw7oALxARVHar647gRrFrAA1DLNbz47MQ5RSxp1w5R1xZ+Ntd5fLJi9A5L5xQ6mUYFvELGnH/KNqeQVr2eUbyoSPTWPVoOx2M3ypYQm+JGNI0Zl+Hl15AXrwZjJhHrkTqK3UdlW93ytU/A+ImkIKCzyad+iYrduuUn3QUfybYDwLrZm0D0RIZX+mnAVsS0xkhUJO8WGOkAq4ayHnkXwul7+2kdWfqKfNTHzs1q0qSe0BpTn/7Jfd9W9Mcu49sLhtxpFFdu5WKu0JKFIK8lJLL6K+BYz/imXY8JwRLKzVl8+JpiFSoy8tLZN4HwG7th8hIstzDsbnhi7ijRTl9hp0cp7Ekz6bzdWuVRlfeTzF5fDCsvWmaoFYsPYIVmznm8CcSzdW+eHT0VRGZhbXdpY/JXYjRhz9S8C4EB2GyClrAWAQGrAv3uV97jBlGaj7AaYrhDPuxbhDzfNUpcgPN2HQ12HE2j7dSQZeGHe3UKBKyULVvSEMwutXcdZRWSxnie384ZbL3TQ9E9uaR0jOJ8wXb2/f5x2XCVPbFa30jIUJyGUoqFAotpsEkixF9fM5GycIWUNxoh/4wZqEUrGXp87sMCOp0LfMyv4ht9O7mrqt9r X-Bogosity: Ham, tests=bogofilter, spamicity=0.242156, 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 --- Changes in v2: - Consolidate error handling in arch_mmap_hint(). arch/alpha/include/asm/pgtable.h | 1 + arch/alpha/kernel/osf_sys.c | 31 ++++++++++++++++++++----------- 2 files changed, 21 insertions(+), 11 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..308f832732dc 100644 --- a/arch/alpha/kernel/osf_sys.c +++ b/arch/alpha/kernel/osf_sys.c @@ -1225,10 +1225,9 @@ arch_get_unmapped_area_1(unsigned long addr, unsigned long len, return vm_unmapped_area(&info); } -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) +unsigned long arch_mmap_hint(struct file *filp, unsigned long addr, + unsigned long len, unsigned long pgoff, + unsigned long flags) { unsigned long limit; @@ -1241,8 +1240,15 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr, if (len > limit) return -ENOMEM; - if (flags & MAP_FIXED) - return 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) +{ + unsigned long limit; /* First, see if the given suggestion fits. @@ -1253,12 +1259,15 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr, That said, I can see the use in being able to suggest not merely specific addresses, but regions of memory -- perhaps this feature should be incorporated into all ports? */ + addr = arch_mmap_hint(filp, addr, len, pgoff, flags); + if (addr) + return addr; - if (addr) { - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(addr), len, limit); - if (addr != (unsigned long) -ENOMEM) - return addr; - } + /* "32 bit" actually means 31 bit, since pointers sign extend. */ + if (current->personality & ADDR_LIMIT_32BIT) + limit = 0x80000000; + else + limit = TASK_SIZE; /* Next, try allocating at TASK_UNMAPPED_BASE. */ addr = arch_get_unmapped_area_1 (PAGE_ALIGN(TASK_UNMAPPED_BASE),