From patchwork Tue Dec 10 02:41:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalesh Singh X-Patchwork-Id: 13900701 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 E441DE77181 for ; Tue, 10 Dec 2024 02:41:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8098C6B00E9; Mon, 9 Dec 2024 21:41:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 76B6F6B00EA; Mon, 9 Dec 2024 21:41:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5E5E16B00EB; Mon, 9 Dec 2024 21:41:29 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 369A76B00E9 for ; Mon, 9 Dec 2024 21:41:29 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id B356CADB35 for ; Tue, 10 Dec 2024 02:41:28 +0000 (UTC) X-FDA: 82877498088.29.365957F Received: from mail-pg1-f201.google.com (mail-pg1-f201.google.com [209.85.215.201]) by imf09.hostedemail.com (Postfix) with ESMTP id 65677140004 for ; Tue, 10 Dec 2024 02:41:12 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=lD51QISz; spf=pass (imf09.hostedemail.com: domain of 3VapXZwsKCEowmxq4t4uzsts00sxq.o0yxuz69-yyw7mow.03s@flex--kaleshsingh.bounces.google.com designates 209.85.215.201 as permitted sender) smtp.mailfrom=3VapXZwsKCEowmxq4t4uzsts00sxq.o0yxuz69-yyw7mow.03s@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=1733798477; 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=nXKIsvWsBBTYmcaRz8JoUa2+7Qpfg8xMl3r7PMmLvBk=; b=oOeBOi7s0eTSGNsq0suzbRMhCQ6WC7EO+dvQpLvMU11OSMwC0RgYA0XArqtAiYFlXbgMir Xnr8MG8AYc1Gmox+SN10DD422eJNWC481sxHV95aB7Z0nfJQJU+MBJsaPLBeeZWJ/CVDR4 JjB35Gur0I+2N1o9/xGHu3z5uz8j3JM= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=lD51QISz; spf=pass (imf09.hostedemail.com: domain of 3VapXZwsKCEowmxq4t4uzsts00sxq.o0yxuz69-yyw7mow.03s@flex--kaleshsingh.bounces.google.com designates 209.85.215.201 as permitted sender) smtp.mailfrom=3VapXZwsKCEowmxq4t4uzsts00sxq.o0yxuz69-yyw7mow.03s@flex--kaleshsingh.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733798477; a=rsa-sha256; cv=none; b=QcQzW0IxcWD6Cw1QofADbgLqFWsONp79wT5Po3QF+cjUFhJwVSQvctKLVfXqZuFVmXcV6q xHjPwjQHwJi8XcurqXQXLcHOrBozRPr8JDcQOy7ruYeBYX+UfuqVCSDHki67Le8mXRqOFT Jq0CtGmGX5uj/2ZBB7OgEWQXh6gCAeQ= Received: by mail-pg1-f201.google.com with SMTP id 41be03b00d2f7-7fb966ee0cdso3579482a12.1 for ; Mon, 09 Dec 2024 18:41:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733798486; x=1734403286; 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=nXKIsvWsBBTYmcaRz8JoUa2+7Qpfg8xMl3r7PMmLvBk=; b=lD51QISzu+qm1vrXD8cqpcqDYA2OaAek7u5rh2/geBuxKL33YhM6IRfu8CLZ3NO1xU cUFhPFTwmK2Uq9KW7wY+F/7WdOEZc3d6Wu2oLcPtITnW62bnNjEYNxxpqoa5kiFEkLok 3pjxOw6KULWoZdEiLTu4W7k/WVFG5/RLTtH5lvteeQzcpoCOWloF3ocFg3fEBaZJgOLt rfDKTQ6PGxLhSrAbZJiXxwoGM1L1rzozmRFRnqXo+K7NIM0Nc1U/pZ5gP8rlymFxPSqT m444oOaDzsYmb6mOvbOia5QulKxYKERFVjTA0uH5DZLDueo8BZf/gjdEsaE34bBG7v3d HZuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733798486; x=1734403286; 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=nXKIsvWsBBTYmcaRz8JoUa2+7Qpfg8xMl3r7PMmLvBk=; b=hsBA+Q0i4NU8+1BkAaAn4CxxE2G5LRpDl1qXiQZ/AdQv7aWf0XFKL55CL4vUAoe3PT 9TAMBzIc3RQuV189hVftLhls6M1BlwrSiLLLDfshW7TCHmToKEyAVfGB8QkcgKQY6Faf 4wR0s+mTkKN91FJQsPVrHDFysCCzlKUxeCiJa/t8Yd+ufhnFBMw4vI5tZdU7dONljbAJ i7FFfmNENJzZRsP47NR/X/slOl9WuRg+esPxE24qPnbGpvJ714YlegCxPmriGJiUGBRb 2LpveL44JHfUSjiNQN8ZcKo7stKGh8/fxsQh3cEHp0zI/9i0DBeT8YSTNa2WSJzL+WZZ e7Dg== X-Forwarded-Encrypted: i=1; AJvYcCUolS2QxeFCO+NK0KfgygoLT/uH3zseKWQSOVyhPQSmAHaVofNJOEQNpyhc7ZdQIBmLumjTpwq5hA==@kvack.org X-Gm-Message-State: AOJu0YzO8fM2XInpql4CMQWeaPBHow+SNqoSIh9DZNPUNAdOSetiuOQo 900ciA85GIcQ+HwHJyQ+Q2t2DPq5txL1JLV2Cz2syT05FDECtq1U2u3sPHHYO870oVoFQzjZjef 5OVxxTj3nXik7mP10u5ODGA== X-Google-Smtp-Source: AGHT+IEes4vFC8x7oz2PD6CyRh4s+tzg2fdn8MPTeQEnOJJBB4JDPOzOCc3jB91eMpzo0BdpMiIRvdYY+YmWIeDh+w== X-Received: from pfau15.prod.google.com ([2002:a05:6a00:aa8f:b0:728:2357:646a]) (user=kaleshsingh job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:7483:b0:1e1:adb8:c011 with SMTP id adf61e73a8af0-1e1b4435999mr2770722637.18.1733798485628; Mon, 09 Dec 2024 18:41:25 -0800 (PST) Date: Mon, 9 Dec 2024 18:41:03 -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-2-kaleshsingh@google.com> Subject: [PATCH mm-unstable 01/17] mm: Introduce generic_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-Queue-Id: 65677140004 X-Stat-Signature: iiqeggdm7qeczd1hmmbh38m8azm58gt5 X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1733798472-660330 X-HE-Meta: U2FsdGVkX18ckJe92NnNLGjJUFSFoqTGqU66/syo3aD32h8YiDmEzdNjVY+1/HljS7b1b0EAZZW8NEixWxzZYFXhgWZolW1fxkJPIKQcRX6iXyMUdXKTORFdRCAXaNzkfRGi6QVZlBvIVyxFVS9SMm6TlEHjY+21MR/Zq2Vvfh3+HXoZ+8r7aUNqPh2uebe+6gdJQYreIx8VtOn6PnNRQDojpNGesmABq0pPOkRrrbSAXpOI1qCyY4uea3XzpttIJw3+vlKk9hpGb0TN16zZIIXu8V2vZk5IFmHMs8hIwT9tU7BXx8R2c1cnP66Rtlwtzo103oFaML7U1EkN7dHOm1u3tAlSAO5KUw77gx3Yn+CkhgwK3wzO9kRtWkmJ7XmUIM6IsVSWTcV8GWRlG7/T1X7T7zJxAVv3aE7LuqJ/emynboTEDV6YQsJLAg+Y8gfman5B0nAF8vWVVNa0OLwprPfTmGSk9lMZm5+yPqzbf0LuQxKyX+vgvYitGMG+wjUWpPfPYGNKyQjVxuo4y8+yxflfbX29W3svTCovbVCafiYHttV4aXSAR4NLrOe/Qr/cMH25fzLMK8ufLQyajPSoEIauvInjFSbPg23ElqYwd4RAxYrq5viDsHaqrs4r05Hb1cOnec4OELj1c1yLOEmfmL17eIq4L+AZfzqoPDKHkwLEosKplxTCvNSyND1M41pBEuU2zbtoj6w3BmwV8IdyDzxSPV+shq0+I+xXMZNB/MFT3Jp/JZUeKQ/Fug25cgpbgp/n1fqt6W6CLoEiHfIBw/Myp7YIToLwrQwu3X9uXwH2JWJxZ8AAiI1g3a4+KjPJCGx4EtiT971OaDEGSBgr+y9CRgIfVjVZ0n9m7PcTO4CFzeKvNe451l6a1QKQj860DJaJR4qXUHEfTfbBY30U7sAGx8Quk7BwZPsYXGAaY6w2XCYjEnlL4EtjKU1Pe17bD8YO7plKBA8MiYj7Z4Q Aob+gmt+ QHhPkLaC6jQI8uk5ITRIyF8ohFFLQkcBIPRGpVzivgjuM/3s0wL6NHZbp9llrY4j5Xtd7jFH5Vc0litqWWR3Oj9bSETB8Wvu2KGDo48rAWGLALR8emSaqxPN3ouBik6sISwFiC/u6yZEsJb5xI+TMHFE7VZ2PYWuWEcSQk4jKUOG8SdULqlO5U93jUOOeWzrMQ2Fs1p9Vug0cYIu+KJa711Lc4AzRERz9XvehubUx/3f+/RH18ltHHeH5PYAaq2hOmMdEOG0NmBXbRDwWR7OA+gW3aV/Wj9865A+5FyuvtcHJ/Tpu+1fMwSxTjn6CUn/B+wV3Aqj5JMTYm0cq95+iWGlh3UHEEkWSDW3tfRRorlD8+uFxVSz/O4UV3AW54mAuUBIO5uilzCuePpfzbq9DjfukiwhbU0RSZsOxPHlmUs7RAP6zFx5Ggu1XN4em+EoUc4SsxB/Hne8PM1WRMX2uSx/uHHnTDoie44RSYBYD9xEMzDoXugbGFYRUez2dzheau11bbFLlaTIMD2sqdDurJ4jg1Tfwru97OenikNEo6o5A1TWWYfACaKObBBu2Z31TUH06JIzqLszhC3as227LEUt+X+l9MftzfvZUeCfPAMBy349rZvHsjBDgd7A6lmPbJ+ph+heaoQuLpCzreJJbdZX0ljTF0PXfcATa X-Bogosity: Ham, tests=bogofilter, spamicity=0.079646, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Consolidate the hint searches from both direcitons (topdown and bottomup) into generic_mmap_hint(). No functional change is introduced. Signed-off-by: Kalesh Singh --- include/linux/sched/mm.h | 4 ++++ mm/mmap.c | 45 ++++++++++++++++++++++++---------------- 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/include/linux/sched/mm.h b/include/linux/sched/mm.h index 928a626725e6..edeec19d1708 100644 --- a/include/linux/sched/mm.h +++ b/include/linux/sched/mm.h @@ -201,6 +201,10 @@ unsigned long mm_get_unmapped_area_vmflags(struct mm_struct *mm, unsigned long flags, vm_flags_t vm_flags); +unsigned long generic_mmap_hint(struct file *filp, unsigned long addr, + unsigned long len, unsigned long pgoff, + unsigned long flags); + unsigned long generic_get_unmapped_area(struct file *filp, unsigned long addr, unsigned long len, unsigned long pgoff, diff --git a/mm/mmap.c b/mm/mmap.c index df9154b15ef9..e97eb8bf4889 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -620,6 +620,27 @@ unsigned long vm_unmapped_area(struct vm_unmapped_area_info *info) return addr; } +unsigned long generic_mmap_hint(struct file *filp, unsigned long addr, + unsigned long len, unsigned long pgoff, + unsigned long flags) +{ + struct mm_struct *mm = current->mm; + struct vm_area_struct *vma, *prev; + const unsigned long mmap_end = arch_get_mmap_end(addr, len, flags); + + if (!addr) + return 0; + + addr = PAGE_ALIGN(addr); + vma = find_vma_prev(mm, addr, &prev); + if (mmap_end - len >= addr && addr >= mmap_min_addr && + (!vma || addr + len <= vm_start_gap(vma)) && + (!prev || addr >= vm_end_gap(prev))) + return addr; + + return 0; +} + /* Get an address range which is currently unmapped. * For shmat() with addr=0. * @@ -637,7 +658,6 @@ generic_get_unmapped_area(struct file *filp, unsigned long addr, unsigned long flags, vm_flags_t vm_flags) { struct mm_struct *mm = current->mm; - struct vm_area_struct *vma, *prev; struct vm_unmapped_area_info info = {}; const unsigned long mmap_end = arch_get_mmap_end(addr, len, flags); @@ -647,14 +667,9 @@ generic_get_unmapped_area(struct file *filp, unsigned long addr, if (flags & MAP_FIXED) return addr; - if (addr) { - addr = PAGE_ALIGN(addr); - vma = find_vma_prev(mm, addr, &prev); - if (mmap_end - len >= addr && addr >= mmap_min_addr && - (!vma || addr + len <= vm_start_gap(vma)) && - (!prev || addr >= vm_end_gap(prev))) - return addr; - } + addr = generic_mmap_hint(filp, addr, len, pgoff, flags); + if (addr) + return addr; info.length = len; info.low_limit = mm->mmap_base; @@ -685,7 +700,6 @@ generic_get_unmapped_area_topdown(struct file *filp, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags, vm_flags_t vm_flags) { - struct vm_area_struct *vma, *prev; struct mm_struct *mm = current->mm; struct vm_unmapped_area_info info = {}; const unsigned long mmap_end = arch_get_mmap_end(addr, len, flags); @@ -698,14 +712,9 @@ generic_get_unmapped_area_topdown(struct file *filp, unsigned long addr, return addr; /* requesting a specific address */ - if (addr) { - addr = PAGE_ALIGN(addr); - vma = find_vma_prev(mm, addr, &prev); - if (mmap_end - len >= addr && addr >= mmap_min_addr && - (!vma || addr + len <= vm_start_gap(vma)) && - (!prev || addr >= vm_end_gap(prev))) - return addr; - } + addr = generic_mmap_hint(filp, addr, len, pgoff, flags); + if (addr) + return addr; info.flags = VM_UNMAPPED_AREA_TOPDOWN; info.length = len; From patchwork Tue Dec 10 02:41:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalesh Singh X-Patchwork-Id: 13900702 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 7328DE77180 for ; Tue, 10 Dec 2024 02:41:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 02B7F6B0085; Mon, 9 Dec 2024 21:41:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 17F3B6B0092; Mon, 9 Dec 2024 21:41:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EC1346B0085; Mon, 9 Dec 2024 21:41:30 -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 B353E6B0082 for ; Mon, 9 Dec 2024 21:41:30 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 6870C40D0E for ; Tue, 10 Dec 2024 02:41:30 +0000 (UTC) X-FDA: 82877498130.14.EF1B497 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) by imf22.hostedemail.com (Postfix) with ESMTP id E3CF9C0009 for ; Tue, 10 Dec 2024 02:41:05 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=b+KFfHcm; spf=pass (imf22.hostedemail.com: domain of 3V6pXZwsKCEwyozs6v6w1uvu22uzs.q20zw18B-00y9oqy.25u@flex--kaleshsingh.bounces.google.com designates 209.85.216.74 as permitted sender) smtp.mailfrom=3V6pXZwsKCEwyozs6v6w1uvu22uzs.q20zw18B-00y9oqy.25u@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=1733798466; 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=2BgI/2JSXOfwO1cJ/ZJEscy7eN8JKVXEE4s6V/DqQoM=; b=oI842P1bxUCgNKmNW7hgy7eoaQe1thd2LRumn+dKSh+BWzlaey4cc3fR7mB2izS9cWMVdq rm16aASCnh23tWrk3ovQF1in9krGxGi+JestBOWmAYGoVG54koMlAyQItCLj0ysRT9dahz L1kvikKm+Cfqv+hDQnVjfnij9a+i2Cs= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733798466; a=rsa-sha256; cv=none; b=gAl8ZuLN5CGfBEzB3fmWewPhv8oTwN9YVL0H5NiKeuud57XK92l+ZFnQECJie0h6LNe4n0 PmOBrPmSJKq671RHLOqe4MGDDs2Fs2rSFpPpoLWi/otHUUW4wNkyTay7W4R8Wwq50QtO8q oqQ0aM8fx+DXWqI/4LFJHkMRk5GUkew= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=b+KFfHcm; spf=pass (imf22.hostedemail.com: domain of 3V6pXZwsKCEwyozs6v6w1uvu22uzs.q20zw18B-00y9oqy.25u@flex--kaleshsingh.bounces.google.com designates 209.85.216.74 as permitted sender) smtp.mailfrom=3V6pXZwsKCEwyozs6v6w1uvu22uzs.q20zw18B-00y9oqy.25u@flex--kaleshsingh.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-2ef79d9c692so4104459a91.0 for ; Mon, 09 Dec 2024 18:41:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733798487; x=1734403287; 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=2BgI/2JSXOfwO1cJ/ZJEscy7eN8JKVXEE4s6V/DqQoM=; b=b+KFfHcm1EbtUKvFcDBHiEqNzpgNM1WglGCj1I64FO6+fAu1FAYXeqLIcFcH0m7YRf 184vdYtDGdJgndUdYRJc/TNkWJU7yR4762p9XynzyTlAVrV0aFNM7/loYJsbGAEg/c+M d1Mmkf87qjjEQkjdXBFthbFIiteVrYnQTNEWIFmuOeoQMkvLQHX4L32nCcdOubtc6kSY uI+6u+KUJjlxl8paydElw3cWpQ6ZKODZZfgTP4k9UfCtt0zeBr9008Wa2md1AVk8wbTA GkSWI09owRWPNIpgWgJ9vu3ymjFhZVvZi7crIZyozLbqUqm8srJkb5coFhXIw//elwSG zICw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733798487; x=1734403287; 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=2BgI/2JSXOfwO1cJ/ZJEscy7eN8JKVXEE4s6V/DqQoM=; b=LJfHWN4cG7qZOQimDAiBJHlHeC9VIJH67JHFSmDlymCHc757Ooo3DDYWqfCjmPehP5 ZeMKOqaEEHPZVTZiEC8soIcypivYWtOR+GctOHXncHmhYN4yKV3jYCLWQ3oMTVfiCC4R 3LEDEZb2RDF9rQKQF0FlD11iWth5IYeGNZPzEJ6hbhLrZwGMsmKuP6dUFoiRagZEwX37 UOJn9sjkzBvi/k+l0KmHLMD4V3buYyBgF/WNe1Hh2tDCpNDpbOhmJ+dYtVxwcnksqhCS 0WkXl+U77Ka7bEMCW+johuVRNfTVjdgIsqnvUiU6MPgRnUO86/xGW7YRw0dPSVvaTM0N FPMQ== X-Forwarded-Encrypted: i=1; AJvYcCUUUfALBTlf9qXB/PJYP4OCbmV1EtJhUP6xdForTEKQhNdWLLNty7X7gCkJXOvHBw5STR+QjITvaQ==@kvack.org X-Gm-Message-State: AOJu0YzPxW2uo8Q5NS7XMzcvouokxVBLOa+VidfHTDRXDjuK8T8FlOId bgxJDduaIrQ72McaqBq5mbNTOSZT7uvq2fUCMy6dJVTVEdoqgBxxplfZ2WKb20pqUsZPZXJ+mVY mYehO1Kn3ZT5wkIL5QUMAWw== X-Google-Smtp-Source: AGHT+IHGMMlno4Vk4yfFbORjSDqS/i277l7+d9BxYohAoyJsB+e3g5dCRC4WlkbDRxt5bsVXivF+KHNj2TLxNR/xQA== X-Received: from pjbpd17.prod.google.com ([2002:a17:90b:1dd1:b0:2ef:d283:5089]) (user=kaleshsingh job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:2e43:b0:2ee:6d04:9dac with SMTP id 98e67ed59e1d1-2ef6ab27c90mr19454039a91.32.1733798487472; Mon, 09 Dec 2024 18:41:27 -0800 (PST) Date: Mon, 9 Dec 2024 18:41:04 -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-3-kaleshsingh@google.com> Subject: [PATCH mm-unstable 02/17] mm: x86: 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-Rspamd-Queue-Id: E3CF9C0009 X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: 4a3g5ne9haqa7u1zmme96wfpoh65waet X-HE-Tag: 1733798465-646307 X-HE-Meta: U2FsdGVkX19JBPZ4qxs4mLo85aBLhsHTdjxj+u2rtVx79R0GZLfGUVhRKEFZr9tp/IkLs5auWlJs3KgJ03lG8TqZI1y4LJa1qhyBV2t7q9D5NnqmOeua+hWqKwSCLHlG2nYQtzhben5xSkjmNmR7V4+7229E9nu1N714RS2fKCAHWUsZ5V7W/Jvh+py6klSpX+fSQqzNhH8WwMVsgyHoRX2BT3IxDhHmEjyZiNx9iInL/ZyCTMFftw/RGB1ne/kTI1VEoAqlwMUA19qqUkekHG9jZUC9Xa4R3V7p2z8I6mbPYqCjBaYXbtVY0gslHxjcEUwI927Q35svQ1zIjWFSLbbcXmqk/gLUOTkuZ2rA4J/9n4zxujNSY5Ki1PcQ4bMbR+d5hY98Nx2uD6mDYBvrP04/WjZKBIHdhTv3NebRd1u+xeFPy3QKaZHTa0gIMpJSuTyX6ZdQLHi98bu1/OeUQxgVokH/NReYpXrUtfZdbbMpXVb4rzvExdpd13m5qPaqvXtEC6oOIIghWCLfye71aUb6JLz/lzbDCNGTAh3G2qiAjSn2XUF2hYb3pRkuQVlgBLjFk3aNrMQtzqPM1BqP38wIqU3Q4q8QJC0G6aIUagUCAAmxYsUPtmcAswbVayNRtOOHQZBmZbvX2SlrwENw4r3SeH7NqniqqtlwGDFrzUC9fb7L5x6XObfpfTyKNrETfbNi/rBtfdF8LwaflBv9e64jMh4JaGoY88WzHTWMFLULPtaSXKYoXJ/jhKPxBe+FD4J6J1c8Ld2OxWaVJEdzaMea5y0O8JgxL0jZTB7cCSJX1pKsjLjcOlLJm2shD50P2d2fJTjMdcEeN698lwGcyamPx1y39I6O9bXmo7N7ifS9yyLzaJaDzwytr1UnWhJ38jzYaqe47Es5Za9fjAbt0MtGcoNbfd0m8HjKd8XpQZOpy2obWB7yC9zbnc4DHtaP3em+8ZY0nekHZy+Ulzg u0z1GSPk e+HvWO+rA10dUDLC9RKjKDTbKDBuuk4Tw5RYw6BSpZuURg2mdWFAtaxsUWz04FdtBL0ooIRAJxEBd0Od9Ja9jkFkhFMyZoV2qPe3IkBZxuh5jkZAM6UZR97NRuFqxySO8VVGPZ2t9FIa42AZrdd+MocIi/QtjcVQReGI3Qn+pNCLQdorcd1hd4pPIOKpAdbS3NOVlVaurFzfLRYixf/2ySU3gl8/zCKXTDN9EM0MVqnCeZOwMWWxY19rq/0REXUMXOVeYNlGWGdbe+EO/UhyTd5rqbt/Ot/QIr4/shZeba+1Yi2KyTicyFt+g+QTvxysvr7KvFk5zZT17OutZdaikFCObLMLLLXZ+dyCyy2lZrKKWWCbr6A1+xV1d26PevxcHESz9e4NgHcjFZMYoU/QRb3l24gRSwO2zQ2F7o6nF42MhNeTdcnj7g6E5Mzl51zvwB/m+pz3wO1P08AkIWoxo4lheCCcKVay/nt358uJ0GT4Y72/FKb+R7Nc/DEOprqWdtxltdiXvytNZbikCQpZMK0lp0MKIZisbGaIxLa7/rQpvzKRVuTEe92criWJiftoNh4PBAs+lGnZhjyiRXKcELZz6cNIhYJWuWq/6AqWi8ozTmJO2RaGa9avNCUYHHHGWSuIx X-Bogosity: Ham, tests=bogofilter, spamicity=0.224797, 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 x86 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/x86/include/asm/pgtable_64.h | 1 + arch/x86/kernel/sys_x86_64.c | 49 ++++++++++++++++++------------- include/linux/sched/mm.h | 4 +++ 3 files changed, 33 insertions(+), 21 deletions(-) diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h index d1426b64c1b9..4472fd0040c3 100644 --- a/arch/x86/include/asm/pgtable_64.h +++ b/arch/x86/include/asm/pgtable_64.h @@ -245,6 +245,7 @@ extern void cleanup_highmap(void); #define HAVE_ARCH_UNMAPPED_AREA #define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN +#define HAVE_ARCH_MMAP_HINT #define PAGE_AGP PAGE_KERNEL_NOCACHE #define HAVE_PAGE_AGP 1 diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c index 776ae6fa7f2d..95a39ef915b7 100644 --- a/arch/x86/kernel/sys_x86_64.c +++ b/arch/x86/kernel/sys_x86_64.c @@ -123,12 +123,32 @@ static inline unsigned long stack_guard_placement(vm_flags_t vm_flags) return 0; } +unsigned long arch_mmap_hint(struct file *filp, unsigned long addr, + unsigned long len, unsigned long pgoff, + unsigned long flags) +{ + unsigned long begin, end; + + if (!addr) + return 0; + + find_start_end(addr, flags, &begin, &end); + + addr = PAGE_ALIGN(addr); + + if (!mmap_address_hint_valid(addr, len)) + return 0; + + if (len > end) + 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, unsigned long flags, vm_flags_t vm_flags) { - struct mm_struct *mm = current->mm; - struct vm_area_struct *vma; struct vm_unmapped_area_info info = {}; unsigned long begin, end; @@ -140,13 +160,9 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr, unsigned long len, if (len > end) return -ENOMEM; - if (addr) { - addr = PAGE_ALIGN(addr); - vma = find_vma(mm, addr); - if (end - 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 = begin; @@ -168,8 +184,6 @@ arch_get_unmapped_area_topdown(struct file *filp, unsigned long addr0, unsigned long len, unsigned long pgoff, unsigned long flags, vm_flags_t vm_flags) { - struct vm_area_struct *vma; - struct mm_struct *mm = current->mm; unsigned long addr = addr0; struct vm_unmapped_area_info info = {}; @@ -186,16 +200,9 @@ arch_get_unmapped_area_topdown(struct file *filp, unsigned long addr0, goto bottomup; /* requesting a specific address */ - if (addr) { - addr &= PAGE_MASK; - if (!mmap_address_hint_valid(addr, len)) - goto get_unmapped_area; - - vma = find_vma(mm, addr); - if (!vma || addr + len <= vm_start_gap(vma)) - return addr; - } -get_unmapped_area: + addr = arch_mmap_hint(filp, addr, len, pgoff, flags); + if (addr) + return addr; info.flags = VM_UNMAPPED_AREA_TOPDOWN; info.length = len; diff --git a/include/linux/sched/mm.h b/include/linux/sched/mm.h index edeec19d1708..f12d094649f7 100644 --- a/include/linux/sched/mm.h +++ b/include/linux/sched/mm.h @@ -205,6 +205,10 @@ unsigned long generic_mmap_hint(struct file *filp, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags); +unsigned long arch_mmap_hint(struct file *filp, unsigned long addr, + unsigned long len, unsigned long pgoff, + unsigned long flags); + unsigned long generic_get_unmapped_area(struct file *filp, unsigned long addr, unsigned long len, unsigned long pgoff, From patchwork Tue Dec 10 02:41:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalesh Singh X-Patchwork-Id: 13900703 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 909E1E7717D for ; Tue, 10 Dec 2024 02:41:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 217026B0092; Mon, 9 Dec 2024 21:41:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1A2016B00EE; Mon, 9 Dec 2024 21:41:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EBFE26B00EF; Mon, 9 Dec 2024 21:41:32 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id C2D3A6B0092 for ; Mon, 9 Dec 2024 21:41:32 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 4ED60ADB0D for ; Tue, 10 Dec 2024 02:41:32 +0000 (UTC) X-FDA: 82877496870.20.7CA66C3 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) by imf03.hostedemail.com (Postfix) with ESMTP id DA43020014 for ; Tue, 10 Dec 2024 02:41:20 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=ydIyl9ti; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf03.hostedemail.com: domain of 3WapXZwsKCE40q1u8x8y3wxw44w1u.s421y3AD-220Bqs0.47w@flex--kaleshsingh.bounces.google.com designates 209.85.214.202 as permitted sender) smtp.mailfrom=3WapXZwsKCE40q1u8x8y3wxw44w1u.s421y3AD-220Bqs0.47w@flex--kaleshsingh.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733798480; a=rsa-sha256; cv=none; b=AnZ9QCrRPCwOXjU5Jjl76fc+zBYX6ot1bLB44QYLBRSQbJrqm2f4reEz5lb9jZ1nMwz4tM rOoE4U3UcQi0I889JNeCunDAtV32v3aA2rzBCDwWEmhsjxKnfcF10WUM3ucl+Vykyalkbf /0mdyoqoExjaHLlZqnhnb6lAdsEdAQU= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=ydIyl9ti; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf03.hostedemail.com: domain of 3WapXZwsKCE40q1u8x8y3wxw44w1u.s421y3AD-220Bqs0.47w@flex--kaleshsingh.bounces.google.com designates 209.85.214.202 as permitted sender) smtp.mailfrom=3WapXZwsKCE40q1u8x8y3wxw44w1u.s421y3AD-220Bqs0.47w@flex--kaleshsingh.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733798480; 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=9mddCWXY13usRicsLw6OHZIF2x4MzWSWW8AsqT4vIgs=; b=eoyUQG1ryjEUZ0TnmREOGR3Ii7L7wHBZOk9MIi4bPjiuqGW2A3+ssDM488CSsb9MZSPUdY O5uWNYHs+7ALFjV20JHYk4s8lYlOXtwND5m16YM/GvryEOkI3VuYR6JcJGP8ahe2AlFBEQ BFy6M/QlCQ/d4nivgdprtT1fu6+PM9g= Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-2164fad3792so14033705ad.0 for ; Mon, 09 Dec 2024 18:41:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733798489; x=1734403289; 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=9mddCWXY13usRicsLw6OHZIF2x4MzWSWW8AsqT4vIgs=; b=ydIyl9tiBz8sttoTjJ/aKsA77sIbnyfyKQKKzgd2EY9evYf44Hzhe/A22rqLqeU7E8 IF939/wyLY/LpFytU3egvC7iG9dgJYu/rq1MBL80apXHtD7sCaBMruyT7Y2yeFIOv2vv hOxpTzCIJ85brRyPJ5R9s4GZTslv4q4SCPD4zf5ZOI/w+8+vDNsgBtgD3S/i0sg8mmRN N7gTORddFx9zQrqlOYhDVLekWsp4+i+JHmuspNCr4ZwPP9cRuxixJxggdfLLBvJm8d+3 UECDbeGIhu2nDxIExdS5N0ki6vQn/+0rYyTOV0ZwvQ10C+gMcZge8qiXIvou0rHBEPhC OE7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733798489; x=1734403289; 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=9mddCWXY13usRicsLw6OHZIF2x4MzWSWW8AsqT4vIgs=; b=S2j+ITWBdUQ37Aq0sXJlToXtU+6uYUFRfDfi5gAApbBpcR3Ps1CzMFU2tUS2mMCsGz E+hRpecdV3XGyQXQUV8HCWDsg8ACgZbCpZEb9CrHfCRpl2OT/QfZh2y01Ad9NkIEDgoc ++TAug2ib8KoasNjcu+trn5q5IYwq3uAFnSN/T7BM/2abxGseLyc+B8UUqvU4QZGol8v gnLZRNCyQVbpkZIZPCknoDxMfn05sYmfd1MR4BCLyp56g6vuNs5J5djiy0lVY6Lyc6rt B2nqU2qmNFl60GJLY5ekrAYqVK8iluUjhf7/QWaHHYOl+kO4OK5qGPdoYefpYpx4CuWr SJnw== X-Forwarded-Encrypted: i=1; AJvYcCUpt/KcdLghfs/YqM7Zd83FFlaudEMiLyT2O4FgN7Rz7gKv+IRumF1XHmTxgbf8Kg+tT6sbPktiTQ==@kvack.org X-Gm-Message-State: AOJu0Yy9Pi0hZOVlyc0Rs/ogrbYhSI7UZyXqbV6R0sK8H4sQHuSuMStN 2GwxYFPFP4UcPFPVEYixyoFlAxtSYi98rvEkGYXsvhqjeja+mpBJvmUgrz8aB8Xc968YenZhNpE OErwmzukOrHCTKRYg4GcUeQ== X-Google-Smtp-Source: AGHT+IEX/qrAQlYORBGIb8q2yh1uBiUP2mFrR7GdG/oXvBxNhJUWo6MtAF8VWexbyJx8hsdTWhCnXlVlObdK7ssA3Q== X-Received: from plks10.prod.google.com ([2002:a17:903:2ca:b0:216:266b:5024]) (user=kaleshsingh job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:2349:b0:215:a039:738 with SMTP id d9443c01a7336-21669f993a8mr45319855ad.5.1733798489149; Mon, 09 Dec 2024 18:41:29 -0800 (PST) Date: Mon, 9 Dec 2024 18:41:05 -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-4-kaleshsingh@google.com> Subject: [PATCH mm-unstable 03/17] mm: arm: 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-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: DA43020014 X-Stat-Signature: 97fr3n3n9ihy31zw85emtkpmr4s5wr5w X-HE-Tag: 1733798480-451387 X-HE-Meta: U2FsdGVkX18vwboY6XGZzSaByQ32JQfh+Nzkr5gFB/jEFtGwLJaveHsmc/OdjYQjwDGs2URG3yfLxRW/H6AuwiAuCmAcU4H3QBQpODssz1rhPdiSwEGN95BNih31Ndtg+jdQ6sD09XJRkk9lEdeBgTKWvXUlMkFIZa8XPjPam9pIsPghtTQxp5iqhsLFyXnVtTdxxMAZr7TuDzlN1EZS9v9Tj9+UDrTuFLwwNnELQPB4QS2DUun/kuFrl16zzgzre7Zxr5AmqF6ZdUBd95ZTmDrY4CdC6j0tHIO8+qWN3jIae+bB9CnQ/f3R4qGziquT8qG+SIozy5puW1yxh5wIC1qD+K29lMoJJl1L46n6ZDZ9SmDJHj97SflzgfnJw1DfiqOridlAHHoPDktdl9k/DLMWt6s6WiDZTvIp8XMu1MpDOHsI3LlOtvDyFpbn7iaUpcGyFM7z2jMFY5crs2GhFdNqeuRG07cpGdlTT9sW1Bdb60EK5JvNcYREl0HU7unjU+lzB0hLk+ulEwgw23H8h+Ed50ngg+A8rddL32w0jiacrxo82xX/YA4yM1owetE8kgPO/pNzsjslqjLph1ZFELf8G78lxfBPdk5cihhQMqyLiTrR987JUQrAn8SJk6nabd5k6yv167IL3efH8sg1JSVgNB2njLtoIoLp3y23KNXnji2plohzmXU5OeQdKHLFd+egeeQ6b8yazytDbjtWzd+/mgzfu2cpGqu73+hQ+zjIMm+CCLRILZqwKSjXyTmxdsV489Iu7lE0XPz9CW7H6dwVYWFa8YWoq0Ih6x+OZU0nPUEkmbjUQNIhBZD7ihMd0htUr+XGHk8uLOH4BeJWXVYtNYiN9mdFblaXpzV/eSAcwWqWW95eDYRd+EgToWQnoicqmfXqyNyGfub/rsGiChHAuPA6mtC2ZLi/5EbU7QuR/rPP15IFuOKUltmgCIsVH+cLp6P0W8+qcO2HwJo 8/n78ENC XI3tcfLyxs8pUI2/WD5gB3rIm7ACcs0KP+ZT3O39/ts2RiuKwo6AqcyPvCaUm1y2c9iSCrLnpjE9p/O2Qwtr4mzdpBeSkeFUBUjfZwsHE26n/sEuRMhI7Igeq5kzW+BRgg2F8N9o3IESKTSZxgedMxAHhG3FzOWM9oW/a0mOhFY231nK2VagJ6xF5pGGqQtEoqMfJvA5Zpy0MvKITpOZUIurNpMCkiU3O0RmTyMR80phxtzjrlRfriGyPPYvypqsLxPeWAAmkPU2UCOpDl81vTudmoCeM7s3rkZ+7Bi4x85Ns9cUk3D9/y059EY9SYDGv1P9vGheYLZRvB+gYPioh2ZsRa8o90pis7FpYpakhkOLY/VPpa0qXDk2Uky9qX3JuIpjgtpA3Mgm36qDCB4PlMY6x35V+kqn+qxZo5wFDAHGQEUi3zSBh0oC2sz718U8MihTtGSWfVluR57Em/GdxpP4MgP5NydCGVxm8IYk6vmmzvIcO+llvSO17kqnaf/IAnAXbPqleP2pBV9yROCBmF+9bZfmlfRn8EwuID1Su7CSQp4Tc1hJC80mB9RJISUVsvGS4VPH4mLSc6kK0k0Pq5lXx4NsB3dyBNNc05vFjHtq68xr3TmCrO5tBYwW3hv9iG8AF X-Bogosity: Ham, tests=bogofilter, spamicity=0.069251, 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 arm 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/arm/include/asm/pgtable.h | 1 + arch/arm/mm/mmap.c | 54 +++++++++++++++++++--------------- 2 files changed, 32 insertions(+), 23 deletions(-) diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h index be91e376df79..1433b3ff4caa 100644 --- a/arch/arm/include/asm/pgtable.h +++ b/arch/arm/include/asm/pgtable.h @@ -330,6 +330,7 @@ static inline pte_t pte_swp_clear_exclusive(pte_t pte) */ #define HAVE_ARCH_UNMAPPED_AREA #define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN +#define HAVE_ARCH_MMAP_HINT #endif /* !__ASSEMBLY__ */ diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c index 3dbb383c26d5..c415410eb64a 100644 --- a/arch/arm/mm/mmap.c +++ b/arch/arm/mm/mmap.c @@ -17,6 +17,31 @@ ((((addr)+SHMLBA-1)&~(SHMLBA-1)) + \ (((pgoff)<mm; - struct vm_area_struct *vma; int do_align = 0; int aliasing = cache_is_vipt_aliasing(); struct vm_unmapped_area_info info = {}; @@ -57,17 +81,9 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr, if (len > TASK_SIZE) return -ENOMEM; - if (addr) { - if (do_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 = mm->mmap_base; @@ -82,7 +98,6 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0, const unsigned long len, const unsigned long pgoff, const unsigned long flags, vm_flags_t vm_flags) { - struct vm_area_struct *vma; struct mm_struct *mm = current->mm; unsigned long addr = addr0; int do_align = 0; @@ -108,16 +123,9 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0, } /* requesting a specific address */ - if (addr) { - if (do_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; 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), From patchwork Tue Dec 10 02:41:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalesh Singh X-Patchwork-Id: 13900705 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 583DCE7717D for ; Tue, 10 Dec 2024 02:41:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9E5646B00F0; Mon, 9 Dec 2024 21:41:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8A8186B00F2; Mon, 9 Dec 2024 21:41:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 635086B00F3; Mon, 9 Dec 2024 21:41:36 -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 2F84A6B00F0 for ; Mon, 9 Dec 2024 21:41:36 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id C7728C0229 for ; Tue, 10 Dec 2024 02:41:35 +0000 (UTC) X-FDA: 82877497752.13.F3262FA Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) by imf15.hostedemail.com (Postfix) with ESMTP id 371F4A0006 for ; Tue, 10 Dec 2024 02:41:12 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=tqRnqMXC; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf15.hostedemail.com: domain of 3XKpXZwsKCFE3t4xB0B16z0z77z4x.v75416DG-553Etv3.7Az@flex--kaleshsingh.bounces.google.com designates 209.85.216.74 as permitted sender) smtp.mailfrom=3XKpXZwsKCFE3t4xB0B16z0z77z4x.v75416DG-553Etv3.7Az@flex--kaleshsingh.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733798474; a=rsa-sha256; cv=none; b=UdjKCXKrQo+evrF/vtVb+KgalMTsy69GEYBmSe9nJbVeElYUv+fiIGDzBvSZhBFJdc3rBP JFZgd77YABhpHZjIaJ2gqEi1L5fzyPOynPmQVE7dASJ5kUirD8PYss3X3i60vz3q3UnQsK DQoaou+U761GNgD/uzwQVv96YXSedhk= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=tqRnqMXC; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf15.hostedemail.com: domain of 3XKpXZwsKCFE3t4xB0B16z0z77z4x.v75416DG-553Etv3.7Az@flex--kaleshsingh.bounces.google.com designates 209.85.216.74 as permitted sender) smtp.mailfrom=3XKpXZwsKCFE3t4xB0B16z0z77z4x.v75416DG-553Etv3.7Az@flex--kaleshsingh.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733798474; 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=plyHizQjFILOlGH5Iba1IrDdDMxWHhXvOcpLcYrtGxg=; b=NxnFEaB/zXYSbN2T5t0vib9ipTaHJjIzgw0xZcckbgoG6wHgVDzChQi3uK27UjEemujnii ZfD/og1EX5/MGr/vn2eoDRiRQcjwSgjtPFdiVpt03DTjdPE8Lhnk4hgjWWyykVpHoPr79j +T+U8XVS4BH+PLP/U3vbFfMHzSLeD8g= Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-2efc3292021so1880778a91.1 for ; Mon, 09 Dec 2024 18:41:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733798493; x=1734403293; 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=plyHizQjFILOlGH5Iba1IrDdDMxWHhXvOcpLcYrtGxg=; b=tqRnqMXCx4LOaB/P02yIiVdSoqCPe+OlCbrSCCMy4ReWmeTArfpzua00ef/Nj4d1O5 MmJAsOs74F9t+rq+NQZrwqhCqBZcnlFtRPj9DfpIeCGyJ/OPzsRIa/SuAJxQDD58bll0 E5han2vwutExxoalhNeJ2uy1gpu3PWMpCFV9WSyHtvgNW/RmON8cfFRD82bYa2Z/gDH9 tABGn3WAjuratCmVOccG7pfGzf/AHAjTSOUq7+k1ZOA1kat7U3pBh/kE7e4NWeD6opc4 5FKpfqG+k6hX3JrFUqAL4KaQRuvyGETZlAN0hfUzwzUUHKUnKmlrfCg1MZdN6ChINAOF 4uWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733798493; x=1734403293; 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=plyHizQjFILOlGH5Iba1IrDdDMxWHhXvOcpLcYrtGxg=; b=VytrwNIK06BB9HdH2jMFG6o0gTBvWKqaS/6tTdM1HMOvLRzm8p1GrwQzxeH7SMBcKH FtYhQjyJ0Prg2rgf9anCFedpn6qXv2Lbj7Gt7s9IRl3znlcm3rHa18NTDxw84NkS7U36 1nSJd+j2mBXHKi3T2JqhGrSZ6iSdE12kuTT7TzWoi2dBBS4CjpD0cIHa0iU/d0KV2IJQ rIRgsqkAUZCYZ/9zVRgbh/LJf6BdFLgws1CBnH/K7ydOA6XZggOCmbaoLBIKyYfBrpvb yhZ8rCRW2pPf2LkHSggLATsxLHQSgYMuOWcDk1K5CHPpqg5Fj+BF0ngQnMKUdJixdclG UCaA== X-Forwarded-Encrypted: i=1; AJvYcCWVF3F/sxSD1GE9FvIUkqBb9pPfN3OLndvqtdwRosmAyhSOPRTP8os6pynqgBLuDjG19oi6GoC9sQ==@kvack.org X-Gm-Message-State: AOJu0YwqB6yTb8cwV9XEKs7/V3MF1IBQxx8lPENiwQ0rvQLQz2YyRJpj Mods0Z/83lxj7SnUK7ZQfBjOH87CiPHEvmZLPf58Cw5RxzZ3WOf50pX6x6LVl6CJCiLQjbD9pBm BsnuDMM/Ghl97VXIb1w23SA== X-Google-Smtp-Source: AGHT+IHwTbEIW/FAeU1sg3ure6LNMbce1+qfNwJ7QwjwcLyYjZmtwQZSOt2eORyWNRKplpOxNs0RywA1YRSDvXTeEQ== X-Received: from pjbsd7.prod.google.com ([2002:a17:90b:5147:b0:2ea:5c73:542c]) (user=kaleshsingh job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:3c0f:b0:2ee:ad18:b309 with SMTP id 98e67ed59e1d1-2efcf1700c3mr4344722a91.3.1733798492790; Mon, 09 Dec 2024 18:41:32 -0800 (PST) Date: Mon, 9 Dec 2024 18:41:07 -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-6-kaleshsingh@google.com> Subject: [PATCH mm-unstable 05/17] mm: arc: Use generic_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: s9o1s35oi4k7dge9t1n41dkjx65t3r58 X-Rspam-User: X-Rspamd-Queue-Id: 371F4A0006 X-Rspamd-Server: rspam08 X-HE-Tag: 1733798471-664812 X-HE-Meta: U2FsdGVkX19WGViSPCG0nav9HHkOlfSZrGsqX6kTNPWXMe11Fgm8VQuu2BJ023+sGymgnQ/UbjkIVpDI7BPfZzlc9+6kRbqrC7qgkehGs6u8iHZvD0Z3oR0ZfEfS/9vwvs2OhX0c0YtpNeTBhV3HhcHSjTZ2ZNoV4INLaag58Jiyz9ouu/TFSST57BOdc54M/mwJJRpu+R5JodAv2rkZ2DaLR9S1dDs7GPgNy05PilJncaCV5U9KYSQ50KdrHDKYYw7/ySKUu+5IpmJrgPKVVjkQln5SbSz/0TI6EimIzSvZpBFgoTuEr41LXsQVXVCk8Yja71vM9qjg2SRAWxOpht309xfeG3ddtlzwJcdPUIoOiLOulr1nLX0UViPazhqrxpFh880oj2hot7LVR4B+pd5zOwOsBdDLpyABjKTrXI64U7IUvMyYy5U51RaPyDZTL+/0m0RgyC5A13f64ZP35E7Rda2OfIlbgy75DAgmU9yUjPvlZ3Dfx6Ft9m4wYVaBa9SHzKMQsA1QbaUTKtVAzNpCWaQQr53ZOgMuQq6WTSfTfQ1F0qivH+g42U44o/sFsaO1Qs12L3eJL4kiNlWc74SP8MSLa7B+B8Thrn3mIV2T4fMcUru1NwNBH3qRa3Sf/zXXW6txIzGFw7AW4rvBJGR26DOYRxTx+HPDKfBTzsIxY0FnFh4BTsDBRRcPDMRG16FVULH/bBgMesGUDhi+Lu9N8nE9YDJbepVDH41yjUfmRFFMQu0rlB/n41nQZtGcGhhr9ficWbOCLyow8K2B0qy2ecn918+fEDGe8cu9gXDn/tv/10XmPxJg6zE+c6bnjAqCHin/sS6LmxeqJsUO4XUg2ytzXZ44nkMiGohhlMKdAjB5qIWHW+18pWpAQhILRsrSacwHXuzn5KQwfmXSbFbyqdOQRBBaqP3y7eGz7pKLtI3LMnZgOBGH6kcxVxqQ7GiCuroAoYlZ5E6UQw1 MgJm38+B aaIMeRtel9YUD4fnWshmz5KaFGC9FZiA/8skt5MkY0uzZF6qJLXWTbU1/SMcGdwTF5hnaB5Z/+hO1A4CyKmyRska9Ry3U/MMkf6nT04EMxikGsO05b2YCwKZvqELUs5HZI43iCOJlb4DhmxJPcid8GB6e3xVmGubX24O/oC89CbsMGwq8akey9IDqlwBd+z2I4TTkP+M5JWbMAopX3/XFYkUMhOlEDCY8mn1jbf0lMCoATn5kJjG+zwzwR0lupC2qWDQP0MpUI/eglwxikPYMvGQPT9VLNVlFOzvuYDa7QycBMfTbDMV9r/rQP5CryIzOvdu3BIARlmY+80XSdaME/2G/8EePwqbU7XBntWGGkeKNNqD87g0ZtpjwgmryGR4bkGG+tr7heayQzG+x60vJKBWyEQ3bmKV5w+LfHl6Hyltxh9RsCaV/4ooRhLiVqun0F/gdoyc4MgKCgwRsHjNLdqs4WTI0jk0jiYUaCFiCiXsXACKhQXPLxVLC+bBDEPiDbjifL3m7aujZa82MAJF3nn9P0TB8SI5PBCHZoMAXD4UN9hQ8H90N2MR/GEp8bKBO5o5ItD5Kja+Xth83Ypq0DajWh2D/HlJ1XUKb5vrqutCX2NTP57YdzP9WLPOWl6bNj5bJAfhPcaWyK2GD2a9n6AfG+VQfhDHSBCPi X-Bogosity: Ham, tests=bogofilter, spamicity=0.243631, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Use generic_mmap_hint() in arch arch_get_unmapped_area(). Signed-off-by: Kalesh Singh --- arch/arc/mm/mmap.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/arch/arc/mm/mmap.c b/arch/arc/mm/mmap.c index 2185afe8d59f..6b1fcea06779 100644 --- a/arch/arc/mm/mmap.c +++ b/arch/arc/mm/mmap.c @@ -27,7 +27,6 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr, unsigned long flags, vm_flags_t vm_flags) { struct mm_struct *mm = current->mm; - struct vm_area_struct *vma; struct vm_unmapped_area_info info = {}; /* @@ -43,14 +42,9 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr, if (len > TASK_SIZE) return -ENOMEM; - if (addr) { - addr = PAGE_ALIGN(addr); - - vma = find_vma(mm, addr); - if (TASK_SIZE - len >= addr && - (!vma || addr + len <= vm_start_gap(vma))) - return addr; - } + addr = generic_mmap_hint(filp, addr, len, pgoff, flags); + if (addr) + return addr; info.length = len; info.low_limit = mm->mmap_base; From patchwork Tue Dec 10 02:41:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalesh Singh X-Patchwork-Id: 13900706 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 EE3C1E7717D for ; Tue, 10 Dec 2024 02:41:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 635196B00F2; Mon, 9 Dec 2024 21:41:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5BF486B00F4; Mon, 9 Dec 2024 21:41:38 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3EC706B00F5; Mon, 9 Dec 2024 21:41:38 -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 17C0A6B00F2 for ; Mon, 9 Dec 2024 21:41:38 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 941581A023E for ; Tue, 10 Dec 2024 02:41:37 +0000 (UTC) X-FDA: 82877497962.30.B586EA3 Received: from mail-oo1-f74.google.com (mail-oo1-f74.google.com [209.85.161.74]) by imf10.hostedemail.com (Postfix) with ESMTP id 83928C000A for ; Tue, 10 Dec 2024 02:41:26 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=C1FR8tmj; spf=pass (imf10.hostedemail.com: domain of 3XqpXZwsKCFM5v6zD2D381219916z.x97638FI-775Gvx5.9C1@flex--kaleshsingh.bounces.google.com designates 209.85.161.74 as permitted sender) smtp.mailfrom=3XqpXZwsKCFM5v6zD2D381219916z.x97638FI-775Gvx5.9C1@flex--kaleshsingh.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733798475; a=rsa-sha256; cv=none; b=B5RqHsG/e71h7knZ4wtCXUv/vkjDEE2bfiiGQhL7w5syC+wT5bbOtmm64K4XfeC6bjGkw3 8NY2k8WpHSeW0NmEfEzyeJooduzweu44gQTDBfgxSg5ZdzYnlhm1oz50lDAZlL6D0aQ0MG +q9tZbPHpuOcbKYDPAqJh4yeqfvVPUw= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=C1FR8tmj; spf=pass (imf10.hostedemail.com: domain of 3XqpXZwsKCFM5v6zD2D381219916z.x97638FI-775Gvx5.9C1@flex--kaleshsingh.bounces.google.com designates 209.85.161.74 as permitted sender) smtp.mailfrom=3XqpXZwsKCFM5v6zD2D381219916z.x97638FI-775Gvx5.9C1@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=1733798475; 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=10lySyzZTVvC+S5oM1O6pINxMohBlWGSJurdKiLL+/8=; b=eDoByV6q3QrQvDoOa7Xhiu9H2mG+QRn4XEzucE1eXXqiFvtK6JP2x9GLoJqI0gP5G/089H NxmHawVZRdmu5EFAQD5X2Au9QEpAO9y/+4GAH9O8SVBiPKTu8XhuYcNmg4TmgsYMsdYPls PTH6rc6yy7dUiM3PAJl89AK9e2FXi7s= Received: by mail-oo1-f74.google.com with SMTP id 006d021491bc7-5f29eb1c357so1575986eaf.3 for ; Mon, 09 Dec 2024 18:41:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733798495; x=1734403295; 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=10lySyzZTVvC+S5oM1O6pINxMohBlWGSJurdKiLL+/8=; b=C1FR8tmjGjljD0VKOfxnRKoAKb0TedSQcmdl0wU47VQbXih8WFSqlDLtmwpOcs/q89 Guuim4y/uZC40VoRSds8a2gtvOsUygsh4j+sH2yIl/TInaIruMQu1kc8WZZpndcPU8kT TRuyvlDS9FnCe00yOH9oAe6zZ6nCbq5zQbXT7dw/Hc1QDHXKMJxoFkexm9nhMcOzAnXY jIqUftE2GB/Wrn55sZTkO1UUk5MrwXo+2oRdkuCCXeRfsQTC2HOohtjEBz2yeVZOLm5p fDG+PKgYrk3e06IWkEE+KghXCNfC9h03sifTTOOJNrtyzUTULGhqqd6UpxtxHeV3b2uv oiYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733798495; x=1734403295; 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=10lySyzZTVvC+S5oM1O6pINxMohBlWGSJurdKiLL+/8=; b=MTIMTnk5VBOtWUj2F1Nt5FpIj6VwITe4CZUD+F6jH6OD3RcP2Y6n+EGHRTD23OnNOH yLn2ali9jm75BI51pD0pGSwXRvlPNc7QxFkuVNJDoE6UfaCQUbzVZR6UF+67M/E9OIfW zcPBZIelo2p83z0OQsq6ezYBzigLLl7ESgdcOraKJzUO9LfWtVYHPXS3hXc5Ejz8f9o9 vtcyyidYiUXbdG9+PzlvMrbuyFn6vTsPd7fUHwUwIYP6kR+FCnyCMGFSURAMtZZH1OSw 8T0lJsg8H46U+1FKLZBt+FuFs19ivrGfITGZnL3PVXllXHtf1SKb/LUsZhmjGY2j7XgV ACgA== X-Forwarded-Encrypted: i=1; AJvYcCXwYDlF9KTX/Q551qy/RXkzxIKvZV2FDdsLBjRGyQfq7ACno/0M6ha53vR6ACn+LO14yM/ict/+tw==@kvack.org X-Gm-Message-State: AOJu0YwLLeqT6n0+TrrCSg1fNkUhcc0CyCtMiJRyLk6klok6PLDrr7SS jFlgfRaeI82OXXqsi0aQCnByR8TBTSC4hKca4r/BPuncnakPOT1GwBdjB+7qGok6SLbD9fVmgVe facExcspPJIe/oY8GshbQCg== X-Google-Smtp-Source: AGHT+IGrVCmYvgbRZyJY6d84f+llUxgBN0sslSfR3tN174qad1011sAwn0+s/lhjeAWOT5E3i4gR4UE5Ru9TVnP2PA== X-Received: from oabfu21.prod.google.com ([2002:a05:6870:5d95:b0:29d:c6f7:1bb2]) (user=kaleshsingh job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6870:5a9c:b0:29f:f4af:dc34 with SMTP id 586e51a60fabf-29ff4b0889emr667703fac.7.1733798494636; Mon, 09 Dec 2024 18:41:34 -0800 (PST) Date: Mon, 9 Dec 2024 18:41:08 -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-7-kaleshsingh@google.com> Subject: [PATCH mm-unstable 06/17] mm: csky: 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-Rspamd-Queue-Id: 83928C000A X-Stat-Signature: xkk4eew34pt1n5nk7kd44sqziggsf99y X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-Tag: 1733798486-79596 X-HE-Meta: U2FsdGVkX1/I/nyPFgPgfHCKIDBnM3Bb9FABvlzMKiQO9m3BplMksTr59NYPCG11fU42Hf5ydbRn6eAxvVuV6nLcseeqva3/RuujyJ6Eud0LiaMDz9/sDdmsXIjrGzZWB1zQjNkYw2G3Eno3CxjzONyX0T8+oHGvZkloQwXl1ZBmymBFOTHzCadxJM8AaD2LZulJBQcOsmCvcKRJY6avr7zja9N1cIeCB5ehjMaIqn2UDpihBg4/SQOhjDuHJz4DCNLcPEGpsQIMpr13iKMXnPJmE/Dc5LXvvPtu5TJu26FHqWYJ2/BGlc8zRO4hTUauWeHUtNYxhtJepQEhpFjzvfzSl4qD3BxNJ9QOH1ZShMWeyDlWkfOlEP8XNrAnwhnnfvoM0Rg7C+YOiauWvuo0FmZQIGwbz+vqxWVfGYg/7UzwUuiTgT0lr7/P/ktI/iueTJx3mUZTiQqRCHwyHotkZiyeMdVTzWGBI/P7W7hT5XYfdZYOUFys2y9SFJ2CMVKtZgluhZiCYtozBaay2cphupciN98z7yIwGdsjiwFWXSlzreKk8oj1E58hO3pCge0d5iF5IQG+IkcNknaKJmJynIN24FsUPBbYroSOtJgCdg+7ka2qHDITDtTd4MAhUSXVUuRSHq2PCbHpzUajXzlN+x5DqKC5qJ5F9/BlwYIGfhYZx6K2QutZ+GNraJ61GxQTZHn9mws61GuSBJkWY7jZvzNeOvttJW/R4bZxauwkmayEVmpVmF1+AHKg6OquJvwxHybAHUb9vsb2LkUpMXyaQTECv4AyHRWBu96KhviL9cXBYayAKd6znjJTkxXgW14P2d+DzGaXIqhqTxz65GxWTraOFIU4v/AyUMnam1pLggXVL+BMx1YkEDaqN1lNBKG+NKzhdnTijVG+mV5iMeA0HJ6ZByxoN+ATfLkGoYYE5k1DN+NoVDjuqrEcmnoHD/R4PNk5jsqavc2NOeFKzRJ Bfr/1lwu OeNFkWlIIBJhoyDhaXQ2aNRF3Uk46TNCgxDwQ+EK5tlTiDtqXSGuEGFyNuzkSVyzvfD3u35EeyV67/svNj+4bmxqEY1lqQPlR4xKuQsv3ORMeF/H3QNd7MsoL1moAmqjqjciIfJFWghfHjWK5pN1I+0EstzatOLRzaMkF4Y6czH6fe5J8B9j7S4l0XOtjRLGp16bMVcFz4XiS1JTJBZ9sBXySUPSSwVXnZAGn1/SwPJXzsa/+O5F3oleUcItXkyBiyHweJKqSdb+PRvPJfTuqHsdJrig9PjAP7ZNv+LJyOMQSJv59lPPSimXtvEmFE1CRFCLRhb6ikqjk4OygM9KBt+EzI6oUJyGW5QW/fZmw6ocHHyYCbsSyHsm/4kHgYrdWnzLDNC1EktX3ulp33sjwqv+Pp6UtZahO8DwA6xG4weMRXOr694lJZADn3SLSSBjiGuMfsCyY6zaxs2FQ/Ehlrk6w/WYPPT8lF+OJ0yf9Y9gGSUaZQ433/QB+JVoPjoVHDq+Qb+lBkW2fEtI2fpUHMXYkNQwr5ivx5o9IKKSKFVDZpO14QXacXBjoKaH2/wxOeBmtkV9Ru5+txl5D4vvG8ckuFGJk9huPJ2oRP3eOoYnWdmH4JU/BDDLC9xJ60s6WAy9g X-Bogosity: Ham, tests=bogofilter, spamicity=0.165962, 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 csky 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/csky/abiv1/inc/abi/pgtable-bits.h | 1 + arch/csky/abiv1/mmap.c | 38 ++++++++++++++++++-------- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/arch/csky/abiv1/inc/abi/pgtable-bits.h b/arch/csky/abiv1/inc/abi/pgtable-bits.h index ae7a2f76dd42..c346a9fcb522 100644 --- a/arch/csky/abiv1/inc/abi/pgtable-bits.h +++ b/arch/csky/abiv1/inc/abi/pgtable-bits.h @@ -51,5 +51,6 @@ ((offset) << 10)}) #define HAVE_ARCH_UNMAPPED_AREA +#define HAVE_ARCH_MMAP_HINT #endif /* __ASM_CSKY_PGTABLE_BITS_H */ diff --git a/arch/csky/abiv1/mmap.c b/arch/csky/abiv1/mmap.c index 1047865e82a9..184921a73856 100644 --- a/arch/csky/abiv1/mmap.c +++ b/arch/csky/abiv1/mmap.c @@ -13,6 +13,29 @@ ((((addr)+SHMLBA-1)&~(SHMLBA-1)) + \ (((pgoff)<mm; - struct vm_area_struct *vma; int do_align = 0; struct vm_unmapped_area_info info = { .length = len, @@ -55,17 +77,9 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr, if (len > TASK_SIZE) return -ENOMEM; - if (addr) { - if (do_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.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0; return vm_unmapped_area(&info); From patchwork Tue Dec 10 02:41:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalesh Singh X-Patchwork-Id: 13900707 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 D0477E77180 for ; Tue, 10 Dec 2024 02:41:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0C25C6B00F4; Mon, 9 Dec 2024 21:41:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 040A66B00F6; Mon, 9 Dec 2024 21:41:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DD7B16B00F7; Mon, 9 Dec 2024 21:41:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id B88A16B00F4 for ; Mon, 9 Dec 2024 21:41:39 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 66B3516020A for ; Tue, 10 Dec 2024 02:41:39 +0000 (UTC) X-FDA: 82877498004.21.EEB714A Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) by imf20.hostedemail.com (Postfix) with ESMTP id 0A4361C0004 for ; Tue, 10 Dec 2024 02:41:14 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=3Ia+QuzM; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf20.hostedemail.com: domain of 3YKpXZwsKCFU7x81F4F5A343BB381.zB985AHK-997Ixz7.BE3@flex--kaleshsingh.bounces.google.com designates 209.85.216.73 as permitted sender) smtp.mailfrom=3YKpXZwsKCFU7x81F4F5A343BB381.zB985AHK-997Ixz7.BE3@flex--kaleshsingh.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733798487; a=rsa-sha256; cv=none; b=qsMNn/IlJK2BVrHfp0vQwY1NMiWHNmqgXAWvmgufC262CAjCHVh4LvO5Xl8+S1jUrQJjU3 kyZmcgu7Skk23+RR4t5g0B2wEYI9IOUpDBcWwW1gPyQ2TqIWe1N1Mpkauy8eHO4CNoLs0H lP23hkOy2XQq5wVDaGR18Lru8UkSs5E= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=3Ia+QuzM; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf20.hostedemail.com: domain of 3YKpXZwsKCFU7x81F4F5A343BB381.zB985AHK-997Ixz7.BE3@flex--kaleshsingh.bounces.google.com designates 209.85.216.73 as permitted sender) smtp.mailfrom=3YKpXZwsKCFU7x81F4F5A343BB381.zB985AHK-997Ixz7.BE3@flex--kaleshsingh.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733798487; 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=S88A34UwW99gwo3FHZNSbMidEba+jodHLuTGE22Alms=; b=gTATivq+BH44EpJT6RTp+3KzmpVT7INg/l62IXdE9dVCcrgbXDxgcfa3zOqlpMOB72DNFT +C1Mcq40XpuZf1yo4MU7lndRF6ETW+XQntcv3w3T1MQ4Mz795c7CLO2YdD+8G7OHEmxJRt pljK5X8LKYvXcagyiqtkTcnLT9K4AfM= Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-2ef728e36d5so3395144a91.3 for ; Mon, 09 Dec 2024 18:41:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733798496; x=1734403296; 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=S88A34UwW99gwo3FHZNSbMidEba+jodHLuTGE22Alms=; b=3Ia+QuzMsRn5QIdrPRbw0KAXziiGfP3zKxSf8ptqrxhbndwoUNM1mr9OY2Vey7b12x JoIAcH0+GlNBCn77mb098p1Sv1GFYZEpROGn87PbC9Er7A/JOt8zbq1BYPrixidNoMGc lqTBKfkJfG4FVULZ6iszOQYZQdZ0ebZ3tca81QKKIo2wX0Mz0IOnLCVVz9gt9aPzpxPF PFIRqsrnY9ch9nIaIq9LixbWtO0LSBgxcgHd2zNltLIGjbKvsBsXz7lY3qIOpKqZJ+4g Zt5XkdnmaVHrodqbLEsrPZFpY7hUkmcWTQ3vfNheK58ZzsONhwgEFCmZzNq1C23eAe02 cGgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733798496; x=1734403296; 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=S88A34UwW99gwo3FHZNSbMidEba+jodHLuTGE22Alms=; b=fIOEyi/5GJwTvZbTv+6cLcz+dDAWcXcaR6yAd6GR+A+Li6DMGcAwW9AMXMRxCHQHSy /0oAkiC/jdkmi/nqAgyiABa7DFA/6N0VkjwWgDyxv132iQFrcO3/pKGFzTgJXMqUc3NF weQNFGWPPFP51HnI7Altu4UV2wgPngzIhwnmOcdvh0Lin8rhxDYt3iqtF8cAY68xNi/m jxzJiSoEBFXnJFGe047LLHiSEn5fOym6sLF7Pa3XNO5B8icpi/H2w70tm0iR9cNajraR DbnpTo2T94wYq9i4bQNRi5jToRYKV15tN3o6fyAp0bQQe4mpMeiCSEAlWpanNZz/kRer rM+w== X-Forwarded-Encrypted: i=1; AJvYcCWyb2fw0nfJOGvzcHCVEjj6MlorxGaZ+VhG+7ZWbVnr7GZqGQtq8FYC3dk6vB6yyy9/KkMgE0GOFg==@kvack.org X-Gm-Message-State: AOJu0YwJTjjYerxHmfSGmnz/iu5v4FWUdHt1X7usyyYhqF76StqsyQPg EVPCWoK/le9EAILSk2eAtOHZ6mjVzwKSi0tb0tN4T3riuog4y2xvw2ixajcbfAGMpKoHe6u2upk F48kLaUXjfJiXBie6CwJRog== X-Google-Smtp-Source: AGHT+IGKFXSWCJqlNS2qFXMxzoG4Xb3NRDnkhhqp5lhhsQRnzkIpBXQqaaHYQ40OzOD6Dmlpa/x+DpWxNJUXLfVq7w== X-Received: from pjvb11.prod.google.com ([2002:a17:90a:d88b:b0:2ea:7d73:294e]) (user=kaleshsingh job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:1d0c:b0:2ee:ed07:d6d2 with SMTP id 98e67ed59e1d1-2ef6ab2888cmr21797074a91.37.1733798496370; Mon, 09 Dec 2024 18:41:36 -0800 (PST) Date: Mon, 9 Dec 2024 18:41:09 -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-8-kaleshsingh@google.com> Subject: [PATCH mm-unstable 07/17] mm: loongarch: 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-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 0A4361C0004 X-Stat-Signature: f91uu43wo3xqpspghyo5r1gg68x57crt X-HE-Tag: 1733798474-75217 X-HE-Meta: U2FsdGVkX1/KyWusfG4vVOHTr0jhoO2DzOsJrPXJar9R6vz8EPPkS4f62SJTXJmFQP3rVZYLG+xhI6x1YAyw9VV25bgTLvWYsYo5R1Kk9HjW2f7dht/l0pGtuOzoEgxZEEDlawjg89UUDWvTKRhkstgqLt8ZTpXyvjFkUdrw7FBuUHiq0lTR4GTB7YdPa0VIh/qyKggH69+l7QbP4VcEQyEoNhCHE61aI6aAQFnj/kqHrKbU+lrkZKVfkL+pLjrjflLoBHclQFtaeVpaMxt5DPGpJPuzRdH2e5Z9xcfpSov3KNzMu072w1TTmLxRZK5NBLK/66NZ7pKyb03GSPZ/HV08wm05QSUKwtY70Oq1DgrgYW/KJ4SI1efRnH5dKDUpzlY8un0y09WzgelYUDj1TsF/4bqajeOCuJuKgN1f5ZsJIUbE6vsTa+gJI9vEhinqkA6SZtE3HhhhiABUTCtXqBZCu2GMDKGWGCIM9ajT6re7d5h/cC0Etfxpt6CSgk+Q9mPbktfWw9KFKSEK8dLxBCo6erD2zdmSjFSPcWjBuEG3pxbIQhgdgLC6GZY3AtQzl44ywNtdXctCPdDFVt/XVizFOArFDG5eeJEhBx7krKMDLDMMFGq7H1EOQyTpEijsPpHgUbczfVamZTQlsqSzScT4YgjA+owc6oG3XfRCZ4C6SrpItQn4gRp6BnsDNMI2bOzZSwiTbP0uirRIbosGwJEPY0qCkaUjqTsL2kRXZNUd58FTkidUmgA3iEpUw/M3KqZyLR6ghXdm/82TLDku1nhEJ3t1KLJIOCjxl5nwRQMCcVMCqqNkWqKpH09RF8F9k316oVvnr6wm2Y6JpRjQSog4NGZkaWphkq1RtQHFDKawUo0U0KnIxonxCNLjOJoOSJq+HOtQDrMpa25HEiGlx9oiEOoemlm2b6EB6N/+d5J+Zfp1w3OdAnezR+RiftCmQf3wGsp+mQtMebmsztW 4TEYLlcb gxAYAqh3MJJFMiINsDlRa8BbdEja4EANF+HPkKKVRxpjooijfv2WdmDn44tq8IMJZWglPVGzMrc6/+RvYeAttHb/GNgC4r1bBY08zPetetwg13ZRSiI6e2ggJPq9d4zZzMLYx9iyAVK7aJNVfSFS9gaIbz0pL3Yhq1JPwyszTt04ryAVRD5OOOdZOKe97zCe5MS8vRSP2gsDTbFNfiRYBDDBrOqBwYMQOPtSZOrDToyqho1ufe9NU1dGNnC5Cfq6fTkBy3Z0D7qX6eBGe07B5buYLxavJucrEsf+v5JIGRfWB5QrFB+vCJ1YEh5Hk4DudIenl4Hc1lwczIjDYqf8mpXuoq4o0oukRScUYfEBNDhGPu/YY3DF3GslPQC+gwguy15JAt1/NMeMoVhRkEWH3O9VhWWqacC+1Ergh924R2xpNZv4K2ltR3Rr6pS+npUqdvfi1QocPj753JyfuhhM24BppbclBI4VvIwcFti3snfU8DVd2xVTqrO+dR8wm3vtHimzJKLo3AlSi0z7PsiAeH3X9nfIsN/QZ2/L5xX1aXtL9MGgysBSj6YkJyZ7spWIcWPu/xLJnuF7/gN/oQjLbHVFMn1S1aXu9qlH+Gd+Hy4Ej1O4YOC4jY3S2v84espCjjVaa X-Bogosity: Ham, tests=bogofilter, spamicity=0.167180, 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 loongarch 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/loongarch/include/asm/pgtable.h | 1 + arch/loongarch/mm/mmap.c | 40 ++++++++++++++++++---------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/arch/loongarch/include/asm/pgtable.h b/arch/loongarch/include/asm/pgtable.h index da346733a1da..326a6c4b7488 100644 --- a/arch/loongarch/include/asm/pgtable.h +++ b/arch/loongarch/include/asm/pgtable.h @@ -624,6 +624,7 @@ static inline long pmd_protnone(pmd_t pmd) */ #define HAVE_ARCH_UNMAPPED_AREA #define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN +#define HAVE_ARCH_MMAP_HINT #endif /* !__ASSEMBLY__ */ diff --git a/arch/loongarch/mm/mmap.c b/arch/loongarch/mm/mmap.c index 914e82ff3f65..b7db43fabca1 100644 --- a/arch/loongarch/mm/mmap.c +++ b/arch/loongarch/mm/mmap.c @@ -17,12 +17,32 @@ 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 = {}; @@ -45,23 +65,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; 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; From patchwork Tue Dec 10 02:41:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalesh Singh X-Patchwork-Id: 13900709 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 79D7DE77181 for ; Tue, 10 Dec 2024 02:41:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B8FB66B00F8; Mon, 9 Dec 2024 21:41:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B17646B00FB; Mon, 9 Dec 2024 21:41:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 91A656B00FC; Mon, 9 Dec 2024 21:41:43 -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 6C03D6B00F8 for ; Mon, 9 Dec 2024 21:41:43 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 17C251601BE for ; Tue, 10 Dec 2024 02:41:43 +0000 (UTC) X-FDA: 82877498046.13.48CB73F Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) by imf02.hostedemail.com (Postfix) with ESMTP id 923C280007 for ; Tue, 10 Dec 2024 02:41:00 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=Dbu50M4C; spf=pass (imf02.hostedemail.com: domain of 3ZKpXZwsKCFkB1C5J8J9E787FF7C5.3FDC9ELO-DDBM13B.FI7@flex--kaleshsingh.bounces.google.com designates 209.85.216.74 as permitted sender) smtp.mailfrom=3ZKpXZwsKCFkB1C5J8J9E787FF7C5.3FDC9ELO-DDBM13B.FI7@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=1733798491; 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=Mf1Z0F5Ql7IvXQrLTKqKwAEdrn6ngNUpJrr6RniRFlg=; b=N6+lSXk6oo6AHH1Ju4xWhJvu3GYmKLBQIOipgtL2S3OHNG7rNotv0QrYy32D1RFQtVvgpa gMLgAX9iNWSK0Zl2ziS1s+AOQAQy/pWcwoSBla+vpdRYiaWJ0AZnCRgtRJhhHQTGTE3+HW 0ZynuAdCVtBEXF0GkvWTsP/KvP2/T8I= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=Dbu50M4C; spf=pass (imf02.hostedemail.com: domain of 3ZKpXZwsKCFkB1C5J8J9E787FF7C5.3FDC9ELO-DDBM13B.FI7@flex--kaleshsingh.bounces.google.com designates 209.85.216.74 as permitted sender) smtp.mailfrom=3ZKpXZwsKCFkB1C5J8J9E787FF7C5.3FDC9ELO-DDBM13B.FI7@flex--kaleshsingh.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733798491; a=rsa-sha256; cv=none; b=zJP3F8aErj5PKn3qRT0s8xlwN7leNjY3MnIcs870TqC2cUKYP51310uRX8ElJjYXDsUtxd 6wWcVp2qedfWLC1RDqpytVoRIoZosMrBbcLhlk+53V6Ne8Ui0SplDLXGM9k3yZqm/cAwCP ex5dGQPPLJ+jeZXXtXk8agl2olwxHLE= Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-2ee5616e986so7906742a91.2 for ; Mon, 09 Dec 2024 18:41:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733798500; x=1734403300; 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=Mf1Z0F5Ql7IvXQrLTKqKwAEdrn6ngNUpJrr6RniRFlg=; b=Dbu50M4C27hB09kA3540TLhibBch5Ow7+tqnJMH1lj5K6q50TGHwi5BbjiTbxmTDz/ dm7ZS2ddCDmoUu12rW9hwUGmAkDQyLiUfQqJu7Zqe+MCNwFvGywiypJ8bogHrSmbjkXC UkIEV9sVHI5IGUhGMh8aiSRMIXHmha9vvjhtnQy4ZfL5fUs6KxZUkjxSEnxBaxIsFt/W mma5RDMbjVlYaNJVsJ6Oibqw0gMHzgB+v891GDQvzahv9zxa/0LGUPY7kMyzZSg7/KYZ p+OMAZxQmZA0eFr4zzZe5C5Cmp95uJhusxg9rEvwAGTqxHdd4GjlZmaELQ9doPqB4ySX 453w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733798500; x=1734403300; 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=Mf1Z0F5Ql7IvXQrLTKqKwAEdrn6ngNUpJrr6RniRFlg=; b=bojkLnZ4TbHn+CfSHOn0OdV7XvuR1p849tD5D46Cf5UAxmIPMFMRS0VgP5E02UhyTJ 2vCsr0Jf+wR1XxZTMYnKSI5yosbDI31DVbU2MkVQv7Shwj2MVKwsnb5v2gL35Z9y6a7t LNfYLa9Ukl//+xmUlNykGIyKQdVRJBJNUwA5Y0p2Ftxgu31IvKKV0VuFioEL91JAe58F 5eAnIuHd5Bmd8hgSkWQeJLINe9ChSDULUazYuAUh5yXjpce85S5P+JV79WXE4Q2Dgi1s 11dhjVI+A+/XyXbu7Fo7iMscqs/LiNEPmKRj/J2sk4FyvYtXJpzTl9Q6Lb37DU9ZysQH 9NuA== X-Forwarded-Encrypted: i=1; AJvYcCVW8e8yQ4MSn2vEnPDL3iVkuMFKIR8zlQVcBABWd6VuewaMWojmvkqkac9aMqREp6iQaCC2KU25Hw==@kvack.org X-Gm-Message-State: AOJu0YxQ0cgBzVIXrfbzpIXBlgQZCqLza6rlHdbvSnWK22Mrlz7CJKNP k3MhtlrrdzkIOn7iXq46k+4Gwr0OqmZFpXvWxV+/OSTG1iWLwDZfIwIyZsmp7GD7e1Md6NK1Vrm K6xWT3npog4ANkdTm1r1xjQ== X-Google-Smtp-Source: AGHT+IHck+gUbecP/UklvDvIRj3mcbH15c15qNgDIstF76hslPLb9WiX1BCJU02h3ccJwRMDSBhkm2vIDcdP4/ivvw== X-Received: from pjbpa5.prod.google.com ([2002:a17:90b:2645:b0:2ea:aa56:49c]) (user=kaleshsingh job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:4cc6:b0:2ee:8a5d:d520 with SMTP id 98e67ed59e1d1-2efcf29a264mr3977311a91.23.1733798500058; Mon, 09 Dec 2024 18:41:40 -0800 (PST) Date: Mon, 9 Dec 2024 18:41:11 -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-10-kaleshsingh@google.com> Subject: [PATCH mm-unstable 09/17] mm: parisc: 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-Queue-Id: 923C280007 X-Stat-Signature: 6ng34u67o6rrgadbc6sz3pdrembogkw8 X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1733798460-750346 X-HE-Meta: U2FsdGVkX1/jZXeBefeTjNLwPEaO44T5qzbwfXcJ7s7Ny+9fDphP05feXSePdVEghdDSWaQlk5LKSMBTk1GILgix+boRkVHZTcSJYmgAFIAs6TStCny/FgZgicxiGieQE9MF8uyqE+GDVloDcF9GbFi6Js9snYTiTMO1XW5Nj+ZNiPY/K5VUmRUmgnip5Ek1n1718DwypLhauCMex9zaJ4KdIZ35t3bug/CHcUP0Ke4uP5H5d67bw7QYh0a8nxqeIj8vWclp3fOX+kE+LHBuezPWprmKnSiVKjqyxqj9d3MHBHK95Zp01ZVDmlVHjVHzp4oTWAg57Qs816/k9jODaE1v5v5qvdCbWQ6X8z9RNW4K5kb+5Q4WdEf8NM2yjcgi3IpGk3Mh80XxdJzpKfrLVz12d+kFz52Jjs59sWfx7YK8E6ZKdUyS+zojanFOJvavoK59SZ8lMHRJKO+lZuqHgWXLd0fLpQIrk5CS2442rhY8E2VfsxDQF+KY+hnTvOyxFL/dvPgtObEM3/3H/UDGRh7RIWMVGRWVlkuiTXwJ4rFO6gZUzpviOEKAvm9FXRcw/7KZZNzPGEK3Tpnw9juqEoWbAThpzKo6p62zgV2O1nOV8TTgeBZT11VktxQpTv3C2xHU5lNmuyKmjaauhFQ9NyacmGZIt0g0Fmzbe9AAZCBEYDQ6QgF6OBHcFGTUzvJkVFLTHuzEv1o6tIhGYEFoK0K6acCG9MIhyDny7c2sk4S5ziIKs3QyupBi8DOBbRzGGKoAz7aXTSTNT66aB47iFjo3Md02BJpqggv14N82HQtX0MmGNjjnGdw09rxdOwzmP5K7tBQsFBkR9tooAtX1NT1nunFwkF1XR81wjrtCS/D4tFpg12FvvQ6ZN70QV9n3+9cssIwlG9Ca/t/vXsBC03bMiDskJ930+I5/JV5N/lR4ax1GtKGGRW8NKoIrjj/+/JLbup+pi5K2zxsmUiN slJZADlf H6DRo63e979k6hc96V1ecYhIjkuzSz3dtoCV4wH56tMm1GpWGEuoJcsD+qTDzqR/oYWlfOUWTwQ0jbzJBIRz1ADXBndEVfB9c8kukEmUdA+NYK5alMB28XsnCaZwBuv4+WKylwLAIs7mMPggAtZiLkzp0d2BVkX4AX05BzRHEnWbo88vLVFG9WwR1rZAD1RL+abu1wxM3zrEnTrzB0moyC2D9O6BWzIIGpd+KoG9QDTCKaZWeemj6GPYQ2BMRl0sLUvpchcihSwVsnWp4I7bwggBhBVT94OaOfVvB/Weeyce+NQKawXerSAmCoylR+REexYkAQmF8GY14UgZbY0+zQmhjJmi6Pfrch4Ky/7oFy+x8420T+bPBT5SkjwOOODXi80nggQpehOsDVORr7T6cSlfqv4QjJWbRjUDPTw+pxoa8DLJkSJbty9tTYlvLYNs+92rv8dW7U6JCiLVk6hWkAisaw378vx9A6Klb7LhCXMcGlPi6RF1Ldnza9bLt3MeeUs/LnF+HJkM3JyOLKpU8wiJMcCa2TX98xDX+VWrzyEEYR4oPShZMGXZHLfo36nTEht/fdOJ6MjRFb0anwzcPSJN2kXa/LhBYsaQijqc+r5Wo8k9sNkP3PmuOhA3FKfPNKW5C X-Bogosity: Ham, tests=bogofilter, spamicity=0.313205, 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 parisc 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/parisc/include/asm/pgtable.h | 1 + arch/parisc/kernel/sys_parisc.c | 37 ++++++++++++++++++++----------- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h index babf65751e81..73987357c78e 100644 --- a/arch/parisc/include/asm/pgtable.h +++ b/arch/parisc/include/asm/pgtable.h @@ -505,6 +505,7 @@ static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, #define HAVE_ARCH_UNMAPPED_AREA #define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN +#define HAVE_ARCH_MMAP_HINT #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG #define __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c index f852fe274abe..8ab05b29c505 100644 --- a/arch/parisc/kernel/sys_parisc.c +++ b/arch/parisc/kernel/sys_parisc.c @@ -96,12 +96,32 @@ unsigned long mmap_upper_limit(struct rlimit *rlim_stack) 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) +{ + unsigned long filp_pgoff = GET_FILP_PGOFF(filp); + int do_color_align = 0; + + if (!addr) + return 0; + + if (filp || (flags & MAP_SHARED)) + do_color_align = 1; + + if (do_color_align) + addr = COLOR_ALIGN(addr, filp_pgoff, 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 addr, 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, *prev; unsigned long filp_pgoff; int do_color_align; struct vm_unmapped_area_info info = { @@ -128,18 +148,9 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp, return addr; } - if (addr) { - if (do_color_align) - addr = COLOR_ALIGN(addr, filp_pgoff, pgoff); - else - addr = PAGE_ALIGN(addr); - - vma = find_vma_prev(mm, addr, &prev); - if (TASK_SIZE - len >= addr && - (!vma || addr + len <= vm_start_gap(vma)) && - (!prev || addr >= vm_end_gap(prev))) - return addr; - } + addr = arch_mmap_hint(filp, addr, len, pgoff, flags); + if (addr) + return addr; info.align_mask = do_color_align ? (PAGE_MASK & (SHM_COLOUR - 1)) : 0; info.align_offset = shared_align_offset(filp_pgoff, pgoff); From patchwork Tue Dec 10 02:41:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalesh Singh X-Patchwork-Id: 13900710 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 51B69E77181 for ; Tue, 10 Dec 2024 02:41:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5C1316B00FB; Mon, 9 Dec 2024 21:41:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 54FB36B00FD; Mon, 9 Dec 2024 21:41:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 300676B00FE; Mon, 9 Dec 2024 21:41:45 -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 0BBFA6B00FB for ; Mon, 9 Dec 2024 21:41:45 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id BA079C021D for ; Tue, 10 Dec 2024 02:41:44 +0000 (UTC) X-FDA: 82877497962.03.C5F83A4 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) by imf16.hostedemail.com (Postfix) with ESMTP id 311CD180005 for ; Tue, 10 Dec 2024 02:41:20 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="rEQ2/8Oj"; spf=pass (imf16.hostedemail.com: domain of 3ZapXZwsKCFoC2D6K9KAF898GG8D6.4GEDAFMP-EECN24C.GJ8@flex--kaleshsingh.bounces.google.com designates 209.85.216.74 as permitted sender) smtp.mailfrom=3ZapXZwsKCFoC2D6K9KAF898GG8D6.4GEDAFMP-EECN24C.GJ8@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=1733798480; 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=7OiWBktXHvnpSQLcvIs2hf981HtU8PP2N6UjUFZYaM8=; b=ZJQuB22KAhBnujTt8xP6wlzPyHcsILagW+pWJVVM4hnOiOxBtZxCD+Mm6SKwdhVfIkfN3V +WguTIL88DaLeM8DhEuCjsHBfoQ5dWtKW68+2knN4NFJPzgqscTD/I8T+XndnNefN3PoPZ ITBC+W/otNR8KixcQCvca5ZPbvM7xPA= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="rEQ2/8Oj"; spf=pass (imf16.hostedemail.com: domain of 3ZapXZwsKCFoC2D6K9KAF898GG8D6.4GEDAFMP-EECN24C.GJ8@flex--kaleshsingh.bounces.google.com designates 209.85.216.74 as permitted sender) smtp.mailfrom=3ZapXZwsKCFoC2D6K9KAF898GG8D6.4GEDAFMP-EECN24C.GJ8@flex--kaleshsingh.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733798480; a=rsa-sha256; cv=none; b=SnScNTug3U4c/LX8iHast65Ubq9WSo6JHtz4ffKdj3I97CGDRy+GRf1obEx0R/3FZXyP3Q YqAw6JL04mIL3sR0Ek1irWleUaD/TeMFE7hFu50cMY7gyjuCtesQsB11bwgCQs/irpFqY8 5kb63rWmI949vNOCKapYQZdXEc/69BU= Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-2ef775ec883so2673312a91.1 for ; Mon, 09 Dec 2024 18:41:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733798502; x=1734403302; 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=7OiWBktXHvnpSQLcvIs2hf981HtU8PP2N6UjUFZYaM8=; b=rEQ2/8OjQwI6jLQ00lsSGZEYBTLugwKlPPgQC9LZoExd++hhLcFLSPjGkxSid9e3s4 N2Sbgp9+M3DW+nwhoX5owiO/zjFdePbpT/R05pdidQxEB7rKcczYYOajuPL49BUZxnfy ym2y8gaHIZhqX0A8UoQSXsZiKfB6vFfuvImI5aEeXjeBw3gc9lyGQCeX4WIqvLwd+EFX PixnIuyhdfbtALgYlJZNhn2/KeMPNGAXVb4XIDxrPTsEw/lqORy6BzWEJaCtBkFSEINN Vwwqe040/ujbwqvtXsHkCHUMk+peXKUDUIWLnR4pTDuqzDduoVo4ADZrmWfriJQnZbbD n2nQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733798502; x=1734403302; 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=7OiWBktXHvnpSQLcvIs2hf981HtU8PP2N6UjUFZYaM8=; b=BGWH18MnIYT+8iEZ9D6T18JX+yb54MscEhD4b2HAHcG/UUIHaMWb7Zr5dDqLdRTvdd hWIK7QSA6PAATmPGQzAyoPKyL4mW48InSrCWpa25dT+Jp5l7LvMwBcm69Hm+lNzQ6NU/ LZnkokcR7aL7DG9tK7SiGY9Vb/MQeTq8HS7HuTA5DTMTtWDHg9LVjj+0GxQb3OyT2rfT /66Nfpcq3e+UuftezG/pT99xmeAADhe3hch6zBirRLxgM9D83+xKFhi5RJV8k1eKakFn pDu6VxvYLmbR88OGxOxErZbFCG6qCwNkhVp0ZNM6Os/xYXgAJ2Yi2iNRNXapppycfDfJ XJ4g== X-Forwarded-Encrypted: i=1; AJvYcCWC/Mj03nc/7KaythLTVJwKsHaJc93fcQvQlOjz8MU83Gwch5/iWcd+s8uA/z/vf8LeSl2RF+nG8Q==@kvack.org X-Gm-Message-State: AOJu0Yy/SVWXzujjHzEIHBr4Xes9iMdlJdiMr1DXNlaT1onknPgXLQKC 2WbNbgE/oXgl55ABhdtsCvT/t/xei6in5w/5vt5InvOb7GbjsQoXN+AqizBAxVGDDY9KshWyhZS gilJOUq0Mmxz2z7dO6aEPnw== X-Google-Smtp-Source: AGHT+IHGYo+0xZ93dmqZHCUo2fH2lASnlYW3/982jLUqUj3uy5rS3NmT8SEwDvEmCBiRAIKAMZxd1Te/85r8WkWevA== X-Received: from pjbqi10.prod.google.com ([2002:a17:90b:274a:b0:2ea:3a1b:f493]) (user=kaleshsingh job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:4a91:b0:2ea:a9ac:eee1 with SMTP id 98e67ed59e1d1-2efcf127449mr4419672a91.10.1733798501710; Mon, 09 Dec 2024 18:41:41 -0800 (PST) Date: Mon, 9 Dec 2024 18:41:12 -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-11-kaleshsingh@google.com> Subject: [PATCH mm-unstable 10/17] mm: s390: 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-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 311CD180005 X-Rspam-User: X-Stat-Signature: oybj4ry35n5mtd9edds6zimqd1e58tge X-HE-Tag: 1733798480-130263 X-HE-Meta: U2FsdGVkX1/koYAOCFKdsbWgr5fr337LQE2bcZqv6u/S8FbbANTbNbSJ3KM1vvIbTs6ao/655wkluwOULgOcySu65Esc+nrbSqKFStItjZGSX9FnPkjfTtLhCitDkSoN/c0+PlYLp4UZ3jMfF6hoxUODPHZi0LtHLE1mMHTLvuNMQx+Z8hCK8/XmUjrjjIef7hV9H+H4jEDSzMlMyc2iobc8xsJx7XVn794JT/z6gbMcDXBwEdNszBUz+zlMVOJi0GFqaqHZkJNpQbzal3TktwlywEjete8dL7MiCaTF+N9Brh3V9AkUaztcAkLFp0mihlrsaGMw2XA++pMSQdOtdYSmMKNHH/yoxugJUKsiXg2f9vjkyt7EWfmcs4uDpBkHqeFiqWZjQQ2PiITGmPkdzKLSUtEcAvOtehgiijgV+dYYTSKqv/onTzqalG3+Y1o8sTJhuEtbbQ75c9KyrAxyBtI2px1U46R1pXWkOlGik4sAcf8ET0aRHey6PgvDz9aA5zkdVMmjNapBpHBWXB5SkEwfW5+Ma8LcSx8mXfNel9Ns7mEYVifDZ09WUIsFtkuil0eqkN467clMp3hXug40vbGqGo0b67l+lAiB9xp5QQtUHhBPlKilny9LXjwKLOLwPe7D7MwTs0UG5l7lUeh91wNRWQpHGlWo/Bi3nNqJG27IV/a4N1ocXYrhoYyLxVPLFoDyfmjNMHWiqGuAPN/4FZdw2l2nM5VbjqROgWpNm/ryWEBRawhrBvYegbe0zfKBZO9cM0RFBtO5kbm2bhyK80b4p+J0HAijR90PNUXipRahyE9heOCD9JSpU5V3GN4WK9f5fUZ5ZnJmy0c34FM9ZyKARVmjosXlADFLfbfTtSEoKd44rZMbgsgquWXqgfP710veQ1w4oPIaBR5xc86dn9jqm+UzusS2HSQZxsP37pWwqQ2ApA1Rp3lJj4QMhHreLziqKzLv1g3euq7NdBM qI4SZWsM 9My2GeJ5xGZ+E3pPjXGpw93fcdnJC3Jfs7c6n4RGx0JTugNX6CQPkh2REvq+iSGP5TExX2KzJbddmb0OHRD3UDrjx+A3gUh+v4ToiqwZB925+j+SIIN5FtTu3IR2ut+SJfr9wd2nKKGK8Noq1c736ozQBnkj/jcGnyknN1Wy1eadRtozl4mDE8EQTNqNCAF2HoZNEC0lQ+BCQ7vStQ7ekNOBbsWnmReqsrX9CpJNJeZ5VWQrrHzfe+5WxCpmEwlq2fA28tsbv4iP3NaeCVUCS/9BueHxpD5e6AIaIWSVlTLo6f3LJDb57KpOqzqkPssby6w5bVYd5rmYqGVY30RdzoOmuHk6nYQmL3XadfaZlQnKBtFZE9M45pxZvrYQUDWHZX6Da8Ftsn+lo2erJjWEoIyCKT2DxAu+IaFSVhKCxsuKjqiNXOM4V76LR6YcejMar5zy9LW84HBo5U9ryc6Fy7z0MersgGjOzqcJOktm+dIeFFPZhH6iYCBhkMrV0W25NvaPQaS6mKIFLp51UEEFTHajvpa7YhUragWT2nvA3aBGIZ6Dsyla8sRBGwpBdnBVAr2MsyJFrNHLpW1o0RC5waHHne8MA6O7JzcS/8Z/1KDdHcWlrxrHes0zqRQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.218921, 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 s390 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/s390/include/asm/pgtable.h | 1 + arch/s390/mm/mmap.c | 32 ++++++++++++++++---------------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h index 48268095b0a3..eaecb558ab9b 100644 --- a/arch/s390/include/asm/pgtable.h +++ b/arch/s390/include/asm/pgtable.h @@ -1997,6 +1997,7 @@ extern void s390_reset_cmma(struct mm_struct *mm); /* s390 has a private copy of get unmapped area to deal with cache synonyms */ #define HAVE_ARCH_UNMAPPED_AREA #define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN +#define HAVE_ARCH_MMAP_HINT #define pmd_pgtable(pmd) \ ((pgtable_t)__va(pmd_val(pmd) & -sizeof(pte_t)*PTRS_PER_PTE)) diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c index 33f3504be90b..3f82401b77cd 100644 --- a/arch/s390/mm/mmap.c +++ b/arch/s390/mm/mmap.c @@ -83,12 +83,21 @@ static int get_align_mask(struct file *filp, unsigned long flags) return 0; } +unsigned long arch_mmap_hint(struct file *filp, unsigned long addr, + unsigned long len, unsigned long pgoff, + unsigned long flags) +{ + if (len > TASK_SIZE - mmap_min_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, unsigned long flags, vm_flags_t vm_flags) { struct mm_struct *mm = current->mm; - struct vm_area_struct *vma; struct vm_unmapped_area_info info = {}; if (len > TASK_SIZE - mmap_min_addr) @@ -97,13 +106,9 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, if (flags & MAP_FIXED) goto check_asce_limit; - if (addr) { - addr = PAGE_ALIGN(addr); - vma = find_vma(mm, addr); - if (TASK_SIZE - len >= addr && addr >= mmap_min_addr && - (!vma || addr + len <= vm_start_gap(vma))) - goto check_asce_limit; - } + addr = arch_mmap_hint(filp, addr, len, pgoff, flags); + if (addr) + goto check_asce_limit; info.length = len; info.low_limit = mm->mmap_base; @@ -123,7 +128,6 @@ unsigned long arch_get_unmapped_area_topdown(struct file *filp, unsigned long ad unsigned long len, unsigned long pgoff, unsigned long flags, vm_flags_t vm_flags) { - struct vm_area_struct *vma; struct mm_struct *mm = current->mm; struct vm_unmapped_area_info info = {}; @@ -135,13 +139,9 @@ unsigned long arch_get_unmapped_area_topdown(struct file *filp, unsigned long ad goto check_asce_limit; /* requesting a specific address */ - if (addr) { - addr = PAGE_ALIGN(addr); - vma = find_vma(mm, addr); - if (TASK_SIZE - len >= addr && addr >= mmap_min_addr && - (!vma || addr + len <= vm_start_gap(vma))) - goto check_asce_limit; - } + addr = arch_mmap_hint(filp, addr, len, pgoff, flags); + if (addr) + goto check_asce_limit; info.flags = VM_UNMAPPED_AREA_TOPDOWN; info.length = len; 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: 13900711 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 33314E7717D for ; Tue, 10 Dec 2024 02:41:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 131FE6B00FD; Mon, 9 Dec 2024 21:41:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0919D6B00FF; Mon, 9 Dec 2024 21:41:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DD6756B0100; Mon, 9 Dec 2024 21:41:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id AE4E46B00FD for ; Mon, 9 Dec 2024 21:41:46 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 6C38B40F38 for ; Tue, 10 Dec 2024 02:41:46 +0000 (UTC) X-FDA: 82877497458.17.7089053 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) by imf20.hostedemail.com (Postfix) with ESMTP id 16C671C0002 for ; Tue, 10 Dec 2024 02:41:21 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=R+8liq4v; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf20.hostedemail.com: domain of 3Z6pXZwsKCFwE4F8MBMCHABAIIAF8.6IGFCHOR-GGEP46E.ILA@flex--kaleshsingh.bounces.google.com designates 209.85.216.74 as permitted sender) smtp.mailfrom=3Z6pXZwsKCFwE4F8MBMCHABAIIAF8.6IGFCHOR-GGEP46E.ILA@flex--kaleshsingh.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733798484; a=rsa-sha256; cv=none; b=a5McKuVoiuiSc12bY7J9Hu670tv1hvVFWUlgkbt3KMqTHA+QTIYeAv9Sk3GPYsxBKyBcHe L3Umrm7CQtQFua1KyqDR6AzQfVJmnpZZXlsSb/0MxnaYeVFz/MnyYFJhG6d76nDrqyvu/i gyFKEqvhZ2HPnv2RH85xpBFN4Nt4mzk= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=R+8liq4v; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf20.hostedemail.com: domain of 3Z6pXZwsKCFwE4F8MBMCHABAIIAF8.6IGFCHOR-GGEP46E.ILA@flex--kaleshsingh.bounces.google.com designates 209.85.216.74 as permitted sender) smtp.mailfrom=3Z6pXZwsKCFwE4F8MBMCHABAIIAF8.6IGFCHOR-GGEP46E.ILA@flex--kaleshsingh.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733798484; 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=1aDg6t/gxrjVFwoXlm7hf8uYmo33EMje8zgxFnq8ex8=; b=iaDUVRGKS2D93vUlWaUXLd1y78qbBqn/v77f5qgzG3x/yCfswIRL5zyMiPUhUyzTXY2eQI XMDZJ9osdsKcwfZvDl6MzKYzJ/uoW4WYr1Hy+hmz5+0FHz55E4JGnQE9aJ54w5iX68Q1sz 3eRz2QR95BMDTMsVN5kddM4URBnQIJ4= Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-2ef9e38b0cfso1874616a91.0 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=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=1aDg6t/gxrjVFwoXlm7hf8uYmo33EMje8zgxFnq8ex8=; b=R+8liq4vIztL1dji7E61IAk8cYOqV1iJRjZazMblnrdeNVCa+aQXUr61HaaDqgtvq0 Wf7cY/8119q57Rutf44kNMn3+8vGSlyPJ0tNEQai8mv0RIxwG66MprC4EggJ3DTO+sc2 3+0FyVVoOUhI8jeROZqAIRF0g5nwg6TjKZfDg0q9gxkMIYzZ4BxBpVJDqmnTkBuM7auW 1WeD+QhW94nYLkt1eq8ke5UllxmU6XxqPE7gJdr2ajGv6aYpaZu4IuETlsLXe/mOaMwf jwbHybFcdSo+2fS0JaVVpYFbfBVuVVmh8kxI2nUHP/r187u7+k/SHNMsn7MclUchXnFN +KMQ== 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=q6sfEmwg99v1TEvku4C7FMgtf0eOwZ0emC3HZU97OwkOoNCgwGBiKqdDLOFwuwfxhv +dkyAsYChTpzy75fVUYsWFMEjTGS/aR1ljuDTzo/Hph2GGvFEeT26DPZ6TZ7QA1RZh9b GjNs7IgTDPNFIwCK3WlloAEr5U62DLgZOVt3CZ+RTJYzr2fKhF3mjgiwccog7dBVUI3a ghn4nHkcPFwB6cTxQ498rguTIzUwOJ7ZhLTMhHoC98i6+IraWJTecZRfAOZEDUXV3ujs 30R1mCMdNGKu/5yV9SVrk3M1tSs7CdII+UJAo84H39VwtHfYBhuF3l1SNtXDP+aUtHdx Bquw== X-Forwarded-Encrypted: i=1; AJvYcCV7dFUMcHFNVXB/uU9tmRMfFbAu9oG9wbRSCDEJIBp5D3B5cWLsv0nj2zKhiQp8bmOl7uJuGYnSnQ==@kvack.org X-Gm-Message-State: AOJu0YwNzZskg/X/o9ADe22PznLsEds2e07I3TWYwSwTmU+Mk7lESjpY 08+yJRhIoNuhTJqW6vIrcmskx/bYv5AyhN1wpuGAlUyZshxxFAku+tO8QN9Fh5fosLron+aPbLg 29Qdb9lKTnWv/U0243b1ZFQ== 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-Stat-Signature: ytz3ri9kfpf68zt4r1mykffyciprxwqj X-Rspam-User: X-Rspamd-Queue-Id: 16C671C0002 X-Rspamd-Server: rspam08 X-HE-Tag: 1733798481-781646 X-HE-Meta: U2FsdGVkX19HNkZaKEknrrFQSODyEiqSKUF5VEeW72/I72CkU/EW7RGIBLhccaZEbZNxQhZOwLMshiDcWStws39Dv0LpjgMmda4gawpHCCASmfwlzRWpKIm6fZXPoeszFIofofEwxBv/7TgE/I0LWpdF6xVPrF7erHCF7yeL2iCqc8XAgWxZcZ46OHPi+6aeUcFOsdvvQ27JtVhiUhaR7zWOgw+OvAj1AktljcsBKngGxXH5/zr47hXEE5msnym4ksQnsp9sAFw+aQRTNITxnH4JPUKLm6j/fxbebDs5uVoV3tHztnefySK6IzuBwi5j2DvUEmMwjC9Eldlk4t/RdkYG55MX+awu5QB48rk1hG+Q1jwI8wEhhghST7BxyFVUbSIhD4pLArFO7LuH8g4r7bCEAfiAxs+6BHng+Mjz/u8+BrKticpttc1IHaRwluxiNOLbNS32XkhoaBj58aUMirgMtWqYiGnj5ZY828MuTZx7VuM6W4kjiRs/4AJqga3cth9mdxOJwqPwgqwgQABZ3bWuxYojIsqLxvk7JZ+kEMLHgdRvJz6mTLFSuAXaSCH8MLfZdsVht6YisFHdsrR3l40KGUsnPzRw1cUJftauBYK/I7osUkGAPgsNovCIDkPdF4RiqjePTTByygogOeo6e5xI2EPq4DJ+X5MhrDN29jOJx9o3FMduAOHaUeibNaBqejvkCzd8LhKiplDkVbQ2enun4oB+aiR+GY5CJhj1MD9Qmi8nctJwRZSUBqqk3XrVVZ33T7n6Qrh/21/rrVPQMPzZt5NSEQguyiEXtEwpBhBfzDSvUpTVmROjjkkIhpLxCoPNSdkRJXbqSMFnxUxq8Q08LmLBgT+jL4ad0Yr+2xeJ4pb1AshdNMDgxy4Ogd18lmsCu73/bRhBFL4YffZTyoq+T//4JVYlg09QJKTOp9J6t79UO54EcsJc6Qf6w4VDR43osmIqXnNcia9Cc+y rTv9l4rx YQzEikzqZ+p9/CGl/Dsoo0R+3PYQt4fn2Id6mi1BaHnf9TKw+WeO0xHhtp1/1wP3ypWpfy8JOKU83Tt6cEQhfAJVH6B7YMitU1/UfnCxi59/Erl8+glhRrcixlakVALtInPWmuIt8Apk6nIpeZss877LDtpUDKgDptMWk6aB+7yiIExljfENaoXAipqMYAqVcvaOG3pl9dy9QbrYfDJSLoRmri5UBcPlx+3GPv3A6dL/i+zDmkubM5KEkMMdvB5/hVcwkmYBQs12NWDOY05NWZHTo5ZcVPS4mNAe5XjnxQmoeivhXd4RO7CGvi2pD7ZR4LPThX5nODdh4Er7isgxLKZ0picPo6ciafOVDrpOGN7Io0ClHBbHV7eOLJ6sLmSfeFQaIzlFnWEUTREw5s8E9WiKDH4MmvBNyZ4Qmd/TCM0dyo2tjACyphxJdniuBqeVDLKyDex2dZEyuZav45+YZAroAfwBCBpBBkFnCkpAuTG6kPKBeSWndrz0t9vVc3L6VJO8Om4vOGsGDyU/nmejaOx4AFO/BZeVHZhJ3dqTfAFtp8a9us1JFBcOnTLnStSJj0X1ph8EaRHpJjqWWccNCs2bsd6WoRxAExx3Ss98Bvl+Jn8RiPaxv5LrOvcO9T/6ny4lB X-Bogosity: Ham, tests=bogofilter, spamicity=0.209153, 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 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; From patchwork Tue Dec 10 02:41:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalesh Singh X-Patchwork-Id: 13900712 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 F1ECCE7717D for ; Tue, 10 Dec 2024 02:41:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 155046B00FF; Mon, 9 Dec 2024 21:41:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0DE286B0101; Mon, 9 Dec 2024 21:41:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E23CC6B0102; Mon, 9 Dec 2024 21:41:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id BAEEE6B00FF for ; Mon, 9 Dec 2024 21:41:48 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 86A0C1601FF for ; Tue, 10 Dec 2024 02:41:48 +0000 (UTC) X-FDA: 82877498634.05.B769F2F Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) by imf14.hostedemail.com (Postfix) with ESMTP id 204A9100006 for ; Tue, 10 Dec 2024 02:41:22 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=DWmCfhvx; spf=pass (imf14.hostedemail.com: domain of 3aapXZwsKCF4G6HAODOEJCDCKKCHA.8KIHEJQT-IIGR68G.KNC@flex--kaleshsingh.bounces.google.com designates 209.85.216.73 as permitted sender) smtp.mailfrom=3aapXZwsKCF4G6HAODOEJCDCKKCHA.8KIHEJQT-IIGR68G.KNC@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=1733798490; 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=1BAtlrJSVyRPOsQk5wSikGaGR3zqoYCpGFeQDDyhzvw=; b=k0Tx6U9QmtxhV8yFK3OtnOpAHW9oTw/ILbuaSoTNmvg6NDoxW4fgLfJUtlO0mFk+ul+6yk mbFqmQu3W59UkREM+18nt9rfZfSD7/3iYl/hCI48m0uav4UXuuvTBkZ+IdKHpVjuruZfWL hEXNsY6HQNmuP72nhPdTjWG1oYRzhsY= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=DWmCfhvx; spf=pass (imf14.hostedemail.com: domain of 3aapXZwsKCF4G6HAODOEJCDCKKCHA.8KIHEJQT-IIGR68G.KNC@flex--kaleshsingh.bounces.google.com designates 209.85.216.73 as permitted sender) smtp.mailfrom=3aapXZwsKCF4G6HAODOEJCDCKKCHA.8KIHEJQT-IIGR68G.KNC@flex--kaleshsingh.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733798490; a=rsa-sha256; cv=none; b=I59XQHTtf30XJOHfsupGw5OqTXoHoI/FYN5b22zW4fz3dFFkcIL4rw/sIjEZcT+DH3xP0b Uc5o/RbqyolC8ZELr3R+op8Qq3Qg3gPkP2t7jsH5wR+f5CuK/o1qHgNqWcf+GyOnxg4Pvm hLtZtMFF+P+DFDn9Ng6JTUmyK2dP0j0= Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-2efa74481fdso1782947a91.1 for ; Mon, 09 Dec 2024 18:41:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733798505; x=1734403305; 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=1BAtlrJSVyRPOsQk5wSikGaGR3zqoYCpGFeQDDyhzvw=; b=DWmCfhvx7QSKTuBLnSsQg7lyYPxCvkmCh54TbSv2EnafbpYGf+UIRZQIFInYktSCIV Ct5Q6sqLtlrkBLdRzhkkH5eY8YF4vFtp+hwB1oArOKfi9eYXI+0gj2P4qzsnvLJkZQqU EtIzuo9R4imZaKdWvh2qBZUzPZy1LpvD6dw0J8l+nFyjfluKPsoMCZhLFk9xhatG3g4J M9M7ssmgUoJmCeD2GNtz5H08Viw1Bzc0qtfPAThMwi6azFACkVnR8P9hG8DUUCU7Eua6 u+PK6F7aN+wjVKTMmvUVQN4paeRFwW5FqIbhcJVHo3fiAUFCVyk2za4d8cxeI50T3A5H GwdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733798505; x=1734403305; 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=1BAtlrJSVyRPOsQk5wSikGaGR3zqoYCpGFeQDDyhzvw=; b=Y5YD7ApneiS8o3AMODY2jBXUgtsWiGlCx9icKfXV6/Yf7A1euQPZNdxV2y1S9mQTT3 iRQCnFS7XDfTCbM04LZaK0R9APHm11I0xIGuN7BXJxFSSCf41nAgkTroLxrTJYzLvE1f Oq/YARFNL9HTlKjj9d5Oezs/qHXzlkuJ5/o8TuQQ5t/s0ra5k11/ST6NIRP8LFXhmRkA uAChnu72oiM1C1X93i99OmRVLOb3QxNFeOR50iAYQSmZcSbDpyth+nuprrnqHn8O3mVu SbG0zruOfVuyZGVKDxjDqQ3TKFT6ryAL2oGybfCI4qO6EkRY7rxOe2uh3LPtkY9+uo1j 87SA== X-Forwarded-Encrypted: i=1; AJvYcCWtSNudEbBKzbNekpnJHMCcnTNsGrI+kJ4wtkP210Y91JPsuNfZkC8HaspNF0cSK/xLBMxwQP8mtw==@kvack.org X-Gm-Message-State: AOJu0YwpVadtniuLbBpBwG3gPaR3spYq2e8XjnANDTN/FZrHPYEgAzCJ uhz5KOEwPWKoFYz7p1rDs4/U3GGMDV9Zpb2ZnslBzX9rJP8o4ZmtZGsna3sXK2Smj2au+P2EKzd 5RlvaQUDihBaqg0Xir4MSKw== X-Google-Smtp-Source: AGHT+IG3H2VSitmLlBO6Re0RjQMAvCNU6wOeSZb7FxqqgQkEm7xuddsNJr2NEUZE8SQmtflSqHbUwj9vfGvySeSwAw== X-Received: from pjbnr3.prod.google.com ([2002:a17:90b:2403:b0:2ef:6fb0:55fb]) (user=kaleshsingh job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:4a06:b0:2ee:9a82:5a93 with SMTP id 98e67ed59e1d1-2efcf138437mr4485348a91.14.1733798505429; Mon, 09 Dec 2024 18:41:45 -0800 (PST) Date: Mon, 9 Dec 2024 18:41:14 -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-13-kaleshsingh@google.com> Subject: [PATCH mm-unstable 12/17] mm: sparc32: 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-Rspamd-Queue-Id: 204A9100006 X-Rspamd-Server: rspam12 X-Stat-Signature: ijo9et39aho69dnqu16zjb5718qeraig X-Rspam-User: X-HE-Tag: 1733798482-772452 X-HE-Meta: U2FsdGVkX1/UUJXtCyH+bigky+CNl7SVNNd7dt1w6Wl15jN45m5oEvWKP/c/gyraFbp9L/cNtYBYBIHnht3c9SqfqZ79d2GNuWZHZob9wPwcLdQeeq1bjnLNwfNwRxEBijc7AeykEqzrWimUB3+uulYCYX9Gn6TI3CHTo+wL9s0CZTS43qEOvA1sZAq8JE9I9jcnOkMpjlcxPQWXcMHZF9G2VYjtOXbpZegLBgzKMjz9X88lXMO+6CHe1rWRlfzwUgfZS/kLo2ekikOohPz+96w7+TnOT4zyhett/Z0YFFGbB+gD2BKS5AR68NptmUO6VUEZdEToApnMNYpWSOTb+vHP8A6aY9ZmTtsGiY2Mt0Lmb9FyZQxSSEin4VDB7CvW8FNaB82VodpL7Fk4M5U2r5Vf8UIkHIWPI/cPRz4s60bNEf1QhRAyDtK1NQz/22GGP03Y6ljBNnkbaIHGw01FEbFV0u13tmOBFfjTCeot1xeecXoJK9QW3fIX7pciFwvrkci5bFh1gMUyM6c2R6DizLtK/L2VuhAL/9DxvQnlsXzsNvgyramT01s8j3dYTWIZjsnK/NqdTngbMXiz3xPK4uvzutonJNk2hkYAw9j4v3hmep4VWYh6VvKsi6VoSVfpq8wVSn5sOzIGsOKfOxsCb36s8vsPjcUTDtPNqnCDW8xQWflWELW6UcljrFt15JUHHHtnkwYwXKWAbGFIvOpFe2YHQj9h6PqjOTZGStnY5OdO1ES/DPvpt57xPdAJVA6L4GC0NPLDwmXUXiqWK3xiuQNWZLgCfiXDqurhZD9VEd2aX3W39saaoQwzr4R+7XNNS9geZZ0EgodurncsRX3fWXhtSOBkcxd2MVDyFavUlkvglhh4uZHJc/wytCyVH5K/ZKgKFjiKnhyKVvTmLTS7n88RseClQdbsI4LFHaEXSEDCDJjSpOd3UUre6KKj84BjkPOzUhhSdhfePBLyH5h jTDa9b+M yhRCXbUbWRay0hK18PB6WqS5pAzJqth/9UrtsfYrSb30chJ7RyPuJ/XQrV5WEBZ01SdL45d0grskE7P1Id8Q/9+5rfFAfHOVqgE37pnn8ed29KqMfkWlg6Q35VtBPSma2baXk6kppmcs2jlwz5linix884N8ppj8xwlZTIOO+60W7PelcmJfvwTgzeQ1SyDLjG/Xll6BEzY2PNhryxsxYr08OYJQpxRcYhuKhKuYSDAFxdoX6gXIUthXUbhMjHAawuoyni3ww67RghEOZOQerGsW/kD18uq42wBP4L6/6Fdt8g/YUncdyvma3sh6u6+3sP9IKq3aDLUEmhzBK2U9Zd9AMtwTNJGPX2DB1DFF9wm6b5+qyPOsIbj1KuU5PeCbr9f8CAT8iWW1GIjddfXN5o4TOWMx1+SNlPfwF5qxUWNnrOlNPzyf+WjuAvMLqEMBKWXRI1ex2Si7TqvE+BfdJUiKo/LdcqgUGOG7r3/ZLhGE+1rd2JCDkBByX2JKJJJ9REIAEiiQhe/5b8ESpdUZpPjQWdrI5JSUZzFbHz7yfnqanB5yUyPG912Prtm1/HIgIn0XBjB3OiDkAJD2QP1i+GUt0Acr2dha5P8foL8Cp4Lr7iAoNRvL90dc3mshU/aZX+RKX X-Bogosity: Ham, tests=bogofilter, spamicity=0.038973, 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 sparc32 arch_mmap_hint() and define HAVE_ARCH_MMAP_HINT. If a sufficiently sized hole doesn't exist at the hint address, fallback to searching the entire valid VA space instead of only the VA space above the hint address. Signed-off-by: Kalesh Singh --- arch/sparc/include/asm/pgtable_32.h | 1 + arch/sparc/kernel/sys_sparc_32.c | 21 ++++++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h index 62bcafe38b1f..95084c4d0b01 100644 --- a/arch/sparc/include/asm/pgtable_32.h +++ b/arch/sparc/include/asm/pgtable_32.h @@ -437,6 +437,7 @@ static inline int io_remap_pfn_range(struct vm_area_struct *vma, /* We provide our own get_unmapped_area to cope with VA holes for userland */ #define HAVE_ARCH_UNMAPPED_AREA +#define HAVE_ARCH_MMAP_HINT #define pmd_pgtable(pmd) ((pgtable_t)__pmd_page(pmd)) diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c index fb31bc0c5b48..2d5065ee1a94 100644 --- a/arch/sparc/kernel/sys_sparc_32.c +++ b/arch/sparc/kernel/sys_sparc_32.c @@ -40,6 +40,19 @@ SYSCALL_DEFINE0(getpagesize) return PAGE_SIZE; /* Possibly older binaries want 8192 on sun4's? */ } +unsigned long arch_mmap_hint(struct file *filp, unsigned long addr, + unsigned long len, unsigned long pgoff, + unsigned long flags) +{ + if (!addr) + return 0; + + if (len > TASK_SIZE - PAGE_SIZE) + 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, unsigned long flags, vm_flags_t vm_flags) { struct vm_unmapped_area_info info = {}; @@ -61,11 +74,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi /* See asm-sparc/uaccess.h */ if (len > TASK_SIZE - PAGE_SIZE) return -ENOMEM; - if (!addr) - addr = TASK_UNMAPPED_BASE; + + addr = arch_mmap_hint(filp, addr, len, pgoff, flags); + if (addr) + return addr; info.length = len; - info.low_limit = addr; + info.low_limit = TASK_UNMAPPED_BASE; info.high_limit = TASK_SIZE; if (!file_hugepage) { info.align_mask = (flags & MAP_SHARED) ? From patchwork Tue Dec 10 02:41:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalesh Singh X-Patchwork-Id: 13900713 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 B0136E7717D for ; Tue, 10 Dec 2024 02:42:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 093036B0101; Mon, 9 Dec 2024 21:41:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F35BC6B0103; Mon, 9 Dec 2024 21:41:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CEA7E6B0104; Mon, 9 Dec 2024 21:41:50 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id A01996B0101 for ; Mon, 9 Dec 2024 21:41:50 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 55491A0261 for ; Tue, 10 Dec 2024 02:41:50 +0000 (UTC) X-FDA: 82877498550.12.D8390BC Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) by imf29.hostedemail.com (Postfix) with ESMTP id 996B612000B for ; Tue, 10 Dec 2024 02:41:18 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="N4/v351a"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf29.hostedemail.com: domain of 3a6pXZwsKCGAI8JCQFQGLEFEMMEJC.AMKJGLSV-KKIT8AI.MPE@flex--kaleshsingh.bounces.google.com designates 209.85.216.73 as permitted sender) smtp.mailfrom=3a6pXZwsKCGAI8JCQFQGLEFEMMEJC.AMKJGLSV-KKIT8AI.MPE@flex--kaleshsingh.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733798488; a=rsa-sha256; cv=none; b=jR5iEd3v0VqNZkEgtxl6Vf+n/xOp2NWLkQvPUwnVaIoeSLiuVlZK2G1bs+xcx116ckdaW2 nZqdobYVTWR1EvmpDXXRGljcvrnE8qXReT8He2SUDt6u0mPpKQMcsJ/9Dx2Dzspm7Tks9/ EXmeMAFaxNAJjNQ92j5C028Ttwm8h8w= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="N4/v351a"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf29.hostedemail.com: domain of 3a6pXZwsKCGAI8JCQFQGLEFEMMEJC.AMKJGLSV-KKIT8AI.MPE@flex--kaleshsingh.bounces.google.com designates 209.85.216.73 as permitted sender) smtp.mailfrom=3a6pXZwsKCGAI8JCQFQGLEFEMMEJC.AMKJGLSV-KKIT8AI.MPE@flex--kaleshsingh.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733798488; 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=lD1y5M/92bgTaY6KXagZAGAzcvbsf/5mzkOXcooW0ho=; b=WyESZTRt4NBWLz8Cz+SMUSZa2zxlOGhntIdSXjcFjeFkbV7ePUC/lXg7NQduyHgVGYcZbL bNPp5ZdA3x6DfoAKW9uhxHUZrKlXYVfc9Tg3TcW3hDiRDN/S19AChiQ79m1a1J41t9mvbs 1QL3VJN7ySmnSIWfTZdPUtAeep8FCJs= Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-2ef909597d9so3594285a91.3 for ; Mon, 09 Dec 2024 18:41:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733798507; x=1734403307; 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=lD1y5M/92bgTaY6KXagZAGAzcvbsf/5mzkOXcooW0ho=; b=N4/v351aZ1sLYld2034x2pPb3NeZmt7xnQog8PemLt2xVD9ONdNccHYv3BgsbQzHrp 4hVwiMhOhYZHoGG3UIQYLH7tQ851WVBxp0GhNWmsyehHlbCje04raH0dZpKWOmCvNH21 XyIiz0YxSdrOBQxtdQkfIREgS9d6+B9mCN3HXI+Clt737Lo5OboDN4u9CgkOiQsTB8En UDrt0ZbtP7FBIiwol6+yzJxOTH0gEZCDI1km35LIiETQXs8SjSA7ENBePcecGqWdQaDQ 11LXYE1b/PymGpyK3iBVsrzDHhIKzpaWRJu49ILtE5/4aLpsnG7MfFuSrnbkgRgNo91L rOuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733798507; x=1734403307; 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=lD1y5M/92bgTaY6KXagZAGAzcvbsf/5mzkOXcooW0ho=; b=XouIn/SHQ3E16qbaeG9RcB1regWh95yXueZAyjRPE+wYnrKJmJtzTFk6U0aHcSZmwj 96d7IjfBHcM01VDtOWGaajlVKTaGl2tW9oUeAX03TAAmQVEeKEevzKpre18Rk2q2yf2/ cV2hBDCL9qA2qM0VlAwnpBLMOLEa/rKTtbcf3kwSz7nZHMy81m6Sx1sQDG/VXGUhISZU QL8kzH2ZnlrJ60VIpUrkA5YgslAhfEn1QNBDpkxxysOxSFG26/QsWzw9b9Nr6YiCKpYc 9QdjawlW5JohCc+J0l7eXWvkr8jVJZYmrSfBCt4GIzXrW/XOcxlV/ylF3MrtwgWxougo A+9A== X-Forwarded-Encrypted: i=1; AJvYcCVmWKybP13QyQXu8arssstxiK94+q0YwVJxTVcKBDJ1nT4QUR3bZIB+mHzD1ifsrggjI1d0wkoDJg==@kvack.org X-Gm-Message-State: AOJu0YxVoDHoIoOCTGcserFkrOLvJ8ZBJxP0UKZnshDxBf88Sfiavsik 7aXPwGPYggeNQkJfE/lPssJ7UobGhCpUInn0a7jfe3NO0CgEegJdoZMyECjzDxWIaos68F8o4tF 4oDdMK4U4H0bLQN2Uh8ttog== X-Google-Smtp-Source: AGHT+IEki7Ie5yO93OnRXKQVvZe4Tx9Zhtxszko37jcevo7YJZw67tf4QTtrn4drQ39DwCB2Qw8B/AwA/g2PTJdBkw== X-Received: from pjg15.prod.google.com ([2002:a17:90b:3f4f:b0:2e0:915d:d594]) (user=kaleshsingh job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:4a:b0:2ee:f80c:6892 with SMTP id 98e67ed59e1d1-2efcf136579mr4227892a91.3.1733798507341; Mon, 09 Dec 2024 18:41:47 -0800 (PST) Date: Mon, 9 Dec 2024 18:41:15 -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-14-kaleshsingh@google.com> Subject: [PATCH mm-unstable 13/17] mm: sparc64: 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-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 996B612000B X-Stat-Signature: 5twuziur19c8qpjdqxpzshryeym3jqm8 X-Rspam-User: X-HE-Tag: 1733798478-692159 X-HE-Meta: U2FsdGVkX1+R0Q0JjlM8HV63NvD6b/ul1GGRXpIEYXmWAxaBC2tnQgTCe1wjPgt6M6DtIXV/k1nkmxu57ZrNZu8j7YTlgloYQMSV8NXaWm6ycYK8D6e5MKF7SfEl99JNaFAVkr+7iqoTnZiuJUCMNU0whVlK+D4sksZBru+9GHwJIUU/lL9XqDFdb/XTVp8Hq1CdUDwx8MqHdQITD/NcMxAWA/XAJxROfiitFKFZnaQwnx2eGiSagf7ExE0uN+OhHeFKtXwX3i7hlbDiVYRbroqoGpe4Im/jSWeZcvAr+NwYIdf9UizwffgkRa7GMXPAAmo2sqJqlIf1uxbPoyV2nRzkqkk0Ypv/ec6xhw2MJFBkivx/lRJPcgakHaqWDsARr0j9tkdCcbUxW/HSk2WM/f9zhLQp5stKWOz4cfEWjWxtL/NjGxNuhrdE3KzEN8KL3UzVz5ArYSxjwDQ2EPi2gv5JncZvwUvGSwjGoUM3D2yY3HiPHpSgD+IgyQEGAepbj7FUOercNWsrNg2QwBcIa6nhFfBXLvddrJu6fpN6S6QDVx9ayCZpviL9bhQjZDnoZa08Rk7B+79cm5jz7CI5I9HIgn38olO7ctxO7aMX8h2wgGQ3cwvLZw1CMC1f/TV6iXHM770/NAF7NvqCiFXfuhWIMLv4+IS/3283qz8ofbdmvovAljH7EN95JRcOujQloxMTo51jCjwXdiXr274sLzIbN8nuCgtF25ESVvPitpUBzAircgqW3MSoolRwYfCY5l/RUtH//uJfZO7ggru7LpSAbLVKWH7ha5oYF8f0PHXKRt2FSjqoNFdLmbXgGJdXSWWtnXvmDOFM96KhOvCB7Aszi+z7t87b4IXKTGN3IUfYfXfIevOimk9VnXB73KQDt5U9ZHdW84VufQGAH6VvDJ51maAvy087Kqf1VPmqAMxL2M/MYLILSWdO5p4sWBRlRleEsqVfA6lt6b/Yicx 3Y9MeavC UqwUUA3QDR+Uyl3dg6RaemF04WW0OBJHn/s/nYWuDOizYGFkZE10Hq8lQCga3Rm66ahaaB77n+x8xAUX2/cM4XegAWXQdKu7EBm6YC9RZ81m6VkbjIOUcX432rjxMx+vM7ndxeCgU55B/MIJCrGCxD6FrxzJaVOcjR/p/R+cfnmUok0ogNBYrwCpquwlECnlo/Bhmx6y1T4qKqCjZcOm2LP3m57re4zspQJInrcvr/kikxzmwcE9eVIfvrukTMf1ZRUu+HTNlbw1CWt6WMCYQhYn6Yr/aa8MJYg6ZMvzwKtyfXxvhsvN5Rb1lJyqpWzUzr/hJkF3kdod4MtpyFlhWb02kddELr8jK7Gx9QQr3XeL3N+L1Zh3vlhPM19NcTHxtsK/sI2C26voAeuRhtmh8is6l1lsjwC3FCmvJjJ1rOSy7N6sojyR8prqCrLrkudc/Cpw2nxdVrRcFSwn99YSu74hU+HO703+hXvBUDnCk19P7dnCkPRD0N9j9U0+Z2lH+7vm9jT/R7HVEXOu9S8llLXV9tWuaEnXyZkbX7uP8gmQqRGNHNtZe1Q1kuOC9tsahDUEMagKF+JF2QK2GbeMaF9nm096sl0eaKSo1m0ItCKJWWzT3TlBswnQ6XBePzJ//uYWd X-Bogosity: Ham, tests=bogofilter, spamicity=0.045073, 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 sparc64 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/sparc/include/asm/pgtable_64.h | 1 + arch/sparc/kernel/sys_sparc_64.c | 47 +++++++++++++++++++++-------- 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/arch/sparc/include/asm/pgtable_64.h b/arch/sparc/include/asm/pgtable_64.h index 2b7f358762c1..f24a4eb2777b 100644 --- a/arch/sparc/include/asm/pgtable_64.h +++ b/arch/sparc/include/asm/pgtable_64.h @@ -1148,6 +1148,7 @@ static inline bool pte_access_permitted(pte_t pte, bool write) */ #define HAVE_ARCH_UNMAPPED_AREA #define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN +#define HAVE_ARCH_MMAP_HINT /* We provide a special get_unmapped_area for framebuffer mmaps to try and use * the largest alignment possible such that larget PTEs can be used. diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c index c5a284df7b41..a782696e98e0 100644 --- a/arch/sparc/kernel/sys_sparc_64.c +++ b/arch/sparc/kernel/sys_sparc_64.c @@ -98,10 +98,39 @@ static unsigned long get_align_mask(struct file *filp, unsigned long flags) return 0; } +unsigned long arch_mmap_hint(struct file *filp, unsigned long addr, + unsigned long len, unsigned long pgoff, + unsigned long flags) +{ + unsigned long task_size = TASK_SIZE; + bool file_hugepage = false; + int do_color_align = 0; + + if (!addr) + return 0; + + if (filp && is_file_hugepages(filp)) + file_hugepage = true; + + if ((filp || (flags & MAP_SHARED)) && !file_hugepage) + do_color_align = 1; + + if (test_thread_flag(TIF_32BIT)) + task_size = STACK_TOP32; + + if (unlikely(len > task_size || len >= VA_EXCLUDE_START)) + return 0; + + if (do_color_align) + addr = COLOR_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) { - struct mm_struct *mm = current->mm; - struct vm_area_struct * vma; unsigned long task_size = TASK_SIZE; int do_color_align; struct vm_unmapped_area_info info = {}; @@ -129,17 +158,9 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi if ((filp || (flags & MAP_SHARED)) && !file_hugepage) do_color_align = 1; - if (addr) { - if (do_color_align) - addr = COLOR_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; From patchwork Tue Dec 10 02:41:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalesh Singh X-Patchwork-Id: 13900714 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 718ADE77180 for ; Tue, 10 Dec 2024 02:42:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 91D208D0002; Mon, 9 Dec 2024 21:41:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8A5438D0001; Mon, 9 Dec 2024 21:41:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6D05A8D0002; Mon, 9 Dec 2024 21:41:52 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 462D98D0001 for ; Mon, 9 Dec 2024 21:41:52 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 09C431A0249 for ; Tue, 10 Dec 2024 02:41:52 +0000 (UTC) X-FDA: 82877498634.22.6255EDD Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) by imf26.hostedemail.com (Postfix) with ESMTP id 0634614000C for ; Tue, 10 Dec 2024 02:41:33 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="ne3/lk2T"; spf=pass (imf26.hostedemail.com: domain of 3bKpXZwsKCGEJ9KDRGRHMFGFNNFKD.BNLKHMTW-LLJU9BJ.NQF@flex--kaleshsingh.bounces.google.com designates 209.85.216.73 as permitted sender) smtp.mailfrom=3bKpXZwsKCGEJ9KDRGRHMFGFNNFKD.BNLKHMTW-LLJU9BJ.NQF@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=1733798500; 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=8RBi4d94aA8fGJb29BjAVbVAiuWgJzs9FAFEoE/Tcq4=; b=x9WCdJdmw4RoXmTbyMW+LQbF3cCe8THjV52HiWCpDDECBG9Js6WUhziD8BAudJsPy1VSrK qPhZcGqYA/OatmSU6/w961JXjz8qc2zwgiYLhBy4cM/Im1GguaXTntDodxBRp3feM6/qMW KhaHQqIKkEUoroe4z/tpclXNfwKXQDU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733798500; a=rsa-sha256; cv=none; b=gCAgiZ6TSCX9GB9fQSNeDGX4FBC4eVJUiNMZZUCzDOW1u9fTor0PWOOZYVsadqqWyLWXIT AhzOUFaBBhOBgQKiK7K3kccM8q3Ft8AJuu0aOTcOrpyr0PRETMB63FaMEph8cH/gEZFpkO IWPtZnE5qi2+uzSx5GbN968c+8rLTgs= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="ne3/lk2T"; spf=pass (imf26.hostedemail.com: domain of 3bKpXZwsKCGEJ9KDRGRHMFGFNNFKD.BNLKHMTW-LLJU9BJ.NQF@flex--kaleshsingh.bounces.google.com designates 209.85.216.73 as permitted sender) smtp.mailfrom=3bKpXZwsKCGEJ9KDRGRHMFGFNNFKD.BNLKHMTW-LLJU9BJ.NQF@flex--kaleshsingh.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-2eebfd6d065so6425754a91.3 for ; Mon, 09 Dec 2024 18:41:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733798509; x=1734403309; 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=8RBi4d94aA8fGJb29BjAVbVAiuWgJzs9FAFEoE/Tcq4=; b=ne3/lk2TybO3JP2gW8f8tVd9iEhpQlbrsTUV+Qpv0mgJKtoPGzSa2c4VtbanZjoG27 evxZiRi9P6RATlLqjAT8avvRiiJQwRcyj3LpDc7LABheNL2AXbVLiXN1MjyVeXFjFzT2 poJL3jbiqNo6XPyg9mtnY/uIDf4av0TrCkvDQoGdVxR5Zp/HHaNGTMnZYdwzw5C733G+ VUGaRBrbLHhY6wW8eXURMMaNiIivfWD1KYg6IznaN/Vy3tnkJMLLHQfue1Ro2Ggn9Co/ S7BXfJFk9tt8cPVBDyn9vuIYbG4++IDIcDV1/2h301o6sjfpCG3r1k4Xddpi/gI/uGOe IqAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733798509; x=1734403309; 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=8RBi4d94aA8fGJb29BjAVbVAiuWgJzs9FAFEoE/Tcq4=; b=d7uMq9urPG25KzWNeGdPkLe4U3r0VUEgNGWDVl6+Za2+mKUQ3A9nSIUgzLN/872InF CL9vA2wl3usuS27EAt6QKz6chdTmkAajr3hyKkyZVv4BiAMD019MDnogvNopO7cEP2VX KqJ/kZhB2W9lSlzzecDjhXuLl8K1VAx1mGr/F/z19SgvlbLyLbycvdeZ6/C1oulXUNOM LjzPI/7vDlvyhH3xnZCs6dsYlXDljWoqEMpRqDQ3rnf3COdBuf0o/bgA12IZrTg+W/+1 iJCagBIpHtiFdysFyh2lMWby0cu5WQJcX2AEMbN7Kj9vTcgxCm16wyz8FBRpWmiQEhX8 NSrQ== X-Forwarded-Encrypted: i=1; AJvYcCW40TMVUUW00xQ0Kbty4y8Mk8fA7F+UCPlb1Jtw5Uc4HqoHhbKwweaCrNw5eZDq8qErMBqvNEPysg==@kvack.org X-Gm-Message-State: AOJu0Ywbg/ilYyLSSgF9ojKyZe8Tosk0XXLX7fR0ZRpLCLk/DwNpezan eN3se4e0KO9yBLrHSTS+9gzIsveRhsaD0SjZpkDoY5mRlAvBHbxC/flwG4ZmUuEofpozvF13M1b ImwfiLGQA7xYiBRvzZlmvUQ== X-Google-Smtp-Source: AGHT+IEWnrN6kZ7CMoj0XPEY5LyEzTzu31G9SE2ukZ22eBNhBZBZVrxzEpEONDIVdXz8wv9Xu2tYcLSnTTgrFqyRgw== X-Received: from pjbsq5.prod.google.com ([2002:a17:90b:5305:b0:2ef:9866:6155]) (user=kaleshsingh job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:2544:b0:2ee:c918:cd42 with SMTP id 98e67ed59e1d1-2ef6a6c11b1mr19145935a91.22.1733798508962; Mon, 09 Dec 2024 18:41:48 -0800 (PST) Date: Mon, 9 Dec 2024 18:41:16 -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-15-kaleshsingh@google.com> Subject: [PATCH mm-unstable 14/17] mm: xtensa: 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-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 0634614000C X-Stat-Signature: deqn8g86z8h67rtohqk3i58xyjqdzh7i X-Rspam-User: X-HE-Tag: 1733798493-210092 X-HE-Meta: U2FsdGVkX1/VOYd2cPTNHzpKpWp/Moqo9p7sIsTz3Ho5yDFnRZO4FkXQRANAevdyZHlE9kfRibPyHWb6wjM7PETOKKqltiG1nv33esShjqPoMbUfcVRmiZh4DCXzgLBTQYWoeOKBDUjAqM6Wy4JdLT+oPz/jcNycVuqDTZE+9Ek75SO7zrjcpmmPKz+gcIMn/KiySTUei8BZb4fC0F69zzLTGgFPOXQlNf17ZDQ9LPQv5Z7hr8ppEXJ+rkwgBlYCWiBWRjRvsp5vh1fEvirJ1fAKMf1JBfcfg2Tb9LMIoJDamD0gd28TYXe/hjDh9RqHiOvIMsSDGHR+KjcKcdtZTPzbRgtOS1tyu0uaVD7NgtcuMoRl3axioIiZWA7Y7JHY/Sacz6lh2nsudk2hUgPjkgZ8nCspQlb8Hz6bRh9tIQXG52JieRsI463oiaFGj2p+uyQnvPmXHPdyiN05W05ODUMxdl2vAUk+kdQCz07KbsaJxLQ23MlA+ej82aa/3USD3toWW5fLFGDOaPpa0U8ystbYao3jfBxFjh1nXGgtm5YQwshnualYK32+kuTEKWP4zBAF6Y6E7MjWhaok9PYKGoXfei/CuKFqRhHQc6Jbn0CC1FDiTw8qAXTa+1sagil5uH2qPavIEPxzW2yEEp0pT0xI+E9UjwgIhCxOQW4EQe7DCXUbLUMSvfOySzijyftRpQytXi3y89MhKDSIqFtKlpA06KZMihcjNLSH4eLKgUSLEv9t84G3QynLlsY+AI4iwWSV4IXLRwI8vFbt05OT6fmZxCpE+Z2yQ38XGpgXXZWuw11i8HW1CbxvU2bogyRD1iTYVA2LK0PMHzpeuMZN6Z1x4NFgvVuLWe6XFYWgj4GxbC60DRcEay/BMoilMbjTUZ4CtrUwM/HL2YU4Bc4ScrkdKP3vtumjlMXjaQSkrO5il0Ayhl+SZ7UgIGSn3YgEjnPDrUqOCNYNlXEWNsk 61XOxE9o ZzPODXg1CWSCgbJ7aC2Zcac8q6ctN8bpuAUF0JeOBohNaP2/ZDQGjOHuFkbVdYDDVHwvToAb733ZfKQ3zChCmNiL2BKcTh79rCUuvlh90PqhT41aMOy4Z5wB184eFv/cl9voQ8Kmm1gUfA6eUXFPa2srwAL8AZ1a5YVtJTnFn8+f2EiedsdCBubuCeRofSWO81OcsmHEtX6lUQ7/1qnMAkjEsZfk8QU9+IhZBdtd/rfFBRehAySJf4DdKlU7RH1Gt+D2zvcrxikZaBhIkdGrnoMGLVYMWQojGmN40z9aZlkuQyOuuW76aFACC+Cn5ksSIBtUyWXAjUjL2nBJh0NEkfGA0BreDFg3ti4rBnmvjqkxRYwzUHgCY7nE5A8pXaSrmyundjgI2R0DbRaJmDRsm1cib3qkyE2ekE+J+CIjFp5yhUiY58brzZ/szTXnvQrRhlmFioieECjOwEeTWpTh4NN86aabzZtqeALHcEhOpfOvs91i9xohcyGuPT02ygtgBXeeRmLcv9pGl1JDAk3kdGwi+8CzvsTjRXvBs6bfChA0pa0dN0nDsWl1v6siyoZidKrvsb6gAsf8TwvznS1QG+N8Af4P8SV2mC319Fwx5Onhjrk1sQofdqJldJjG0XYHIQIGC X-Bogosity: Ham, tests=bogofilter, spamicity=0.025304, 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 xtensa arch_mmap_hint() and define HAVE_ARCH_MMAP_HINT. If a sufficiently sized hole doesn't exist at the hint address, fallback to searching the entire valid VA space instead of only the VA space above the hint address. Signed-off-by: Kalesh Singh --- arch/xtensa/include/asm/pgtable.h | 1 + arch/xtensa/kernel/syscall.c | 26 ++++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/arch/xtensa/include/asm/pgtable.h b/arch/xtensa/include/asm/pgtable.h index 1647a7cc3fbf..31b7da0805ec 100644 --- a/arch/xtensa/include/asm/pgtable.h +++ b/arch/xtensa/include/asm/pgtable.h @@ -425,5 +425,6 @@ void update_mmu_tlb_range(struct vm_area_struct *vma, * SHM area cache aliasing for userland. */ #define HAVE_ARCH_UNMAPPED_AREA +#define HAVE_ARCH_MMAP_HINT #endif /* _XTENSA_PGTABLE_H */ diff --git a/arch/xtensa/kernel/syscall.c b/arch/xtensa/kernel/syscall.c index dc54f854c2f5..353cce1ac9f1 100644 --- a/arch/xtensa/kernel/syscall.c +++ b/arch/xtensa/kernel/syscall.c @@ -54,6 +54,24 @@ asmlinkage long xtensa_fadvise64_64(int fd, int advice, } #ifdef CONFIG_MMU +unsigned long arch_mmap_hint(struct file *filp, unsigned long addr, + unsigned long len, unsigned long pgoff, + unsigned long flags) +{ + if (!addr) + return 0; + + if (len > TASK_SIZE) + return 0; + + if (flags & MAP_SHARED) + 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) @@ -73,8 +91,12 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, if (len > TASK_SIZE) return -ENOMEM; - if (!addr) - addr = TASK_UNMAPPED_BASE; + + addr = arch_mmap_hint(filp, addr, len, pgoff, flags); + if (addr) + return addr; + + addr = TASK_UNMAPPED_BASE; if (flags & MAP_SHARED) addr = COLOUR_ALIGN(addr, pgoff); From patchwork Tue Dec 10 02:41:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalesh Singh X-Patchwork-Id: 13900715 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 25317E77182 for ; Tue, 10 Dec 2024 02:42:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4D7EA8D0003; Mon, 9 Dec 2024 21:41:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4618F8D0001; Mon, 9 Dec 2024 21:41:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1C7D28D0003; Mon, 9 Dec 2024 21:41:54 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id E53968D0001 for ; Mon, 9 Dec 2024 21:41:53 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 96F9CA0261 for ; Tue, 10 Dec 2024 02:41:53 +0000 (UTC) X-FDA: 82877498340.08.5DA1B72 Received: from mail-oa1-f73.google.com (mail-oa1-f73.google.com [209.85.160.73]) by imf28.hostedemail.com (Postfix) with ESMTP id 4A6B9C0009 for ; Tue, 10 Dec 2024 02:41:27 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=kLnKtwrR; spf=pass (imf28.hostedemail.com: domain of 3bqpXZwsKCGMLBMFTITJOHIHPPHMF.DPNMJOVY-NNLWBDL.PSH@flex--kaleshsingh.bounces.google.com designates 209.85.160.73 as permitted sender) smtp.mailfrom=3bqpXZwsKCGMLBMFTITJOHIHPPHMF.DPNMJOVY-NNLWBDL.PSH@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=1733798501; 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=QfykOM1fOarLfySIdaHc0pH2J2Kgj1GMXq62gJs/y4s=; b=gayrsCoASQFdkrpsu+Xyca6Y3DuXtL63hDLYujdba/x48pnedD8/q5obVMp2yxfEsu+cWa LHqL6zyFYqqiMQCO/H8X1CREIdUJ9Metq0NlXrRdiePFyTPHTKMM7mVnxhHg7W3XkcxPe0 Rrf1agSQmp3qqFlgye3uZyxkmGgWnGw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733798501; a=rsa-sha256; cv=none; b=NLv6nCGrZRTNMfISqOk+c8R5NZKn+02qoi4el/S5WGih/DrmBIJH7pFO4By4vYsTQlK0YQ xTwOremkuTVdJ04Rxhg4GqKdAzjJsLkKNHyuVZiXIWJp0agT4EER6/4L5woBYmqa+gKAi+ zCFGEFk8p2h1XzkpPctHWRzxIMBkebs= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=kLnKtwrR; spf=pass (imf28.hostedemail.com: domain of 3bqpXZwsKCGMLBMFTITJOHIHPPHMF.DPNMJOVY-NNLWBDL.PSH@flex--kaleshsingh.bounces.google.com designates 209.85.160.73 as permitted sender) smtp.mailfrom=3bqpXZwsKCGMLBMFTITJOHIHPPHMF.DPNMJOVY-NNLWBDL.PSH@flex--kaleshsingh.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-oa1-f73.google.com with SMTP id 586e51a60fabf-29e82f6ba5eso6040472fac.2 for ; Mon, 09 Dec 2024 18:41:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733798511; x=1734403311; 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=QfykOM1fOarLfySIdaHc0pH2J2Kgj1GMXq62gJs/y4s=; b=kLnKtwrRq0s51qBB/P5pKoZU/6d/08dUzNFZIFRH8qHOZXWpWPymGhVEthSDANNE/9 b1kBSCuLKaQGUJRFw96P5vLl+8eBp5ODfmGQCAa6SuTcTC+wexqb/ggXz9tBs5iz71uY k6E9PbhmMgbqHr7KXuMaM4MHY1+eIJPpegC/gSkpZf9Mts4CV60yNsLraMsSGmIXbsPS Qu9Xz31W3DeV/Gefb9zIVgv2ndvu07yKI4FEfbfW9r9u8Tzl8/iu9LT/h4kTJaqtUaRe 90pu8og8MxaYR5+i8q/ANTPzQufQ7Dk8v4gD6PurLbFy+zIyoiikoGTOE1J9tFcP3Ggr +g7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733798511; x=1734403311; 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=QfykOM1fOarLfySIdaHc0pH2J2Kgj1GMXq62gJs/y4s=; b=EbMDrDawmSEtrkZEUdKstAIHBHLcaZeMZNeyl2rl3gPgagt/KqtYeGINd51i/QNV/c c6ModLwFsqVJj419zmfrXF0T/6WEzFU2GBZe0gNc7WIn6B5c8m72OeiTJ22X37mxBA6p 8d2LWS8FZ+F0t0Jf8D/W+/GUnsQD5CsCCMJ/WsjsGvMZxsxKEgGtFi/XyWT/qL/4o2g4 bG2868yaeMHzHzYdItgcxswxpRARNBNhAtZLl3CUwwT1E0R3ygXiubl7pCdHs7lT+JqP VCdVTc14c1tFCqpzLZ2cd51gMfDA4j50jlBnb+FTIyX8V9lezTAJA5fzLJxfRt9boiNV CP0w== X-Forwarded-Encrypted: i=1; AJvYcCXIzvHNobdOkHhPERRmZFnBnwrpzY3Zq7yNenXEXyPx6v6pbsMmMpR4PNj/v0k5eb9kHDLYaR4b3A==@kvack.org X-Gm-Message-State: AOJu0YxgD8ae6OIVJ0FmzSd43ZWfYGIiUpFkf+hmMbmO+4vFICDk67Xx 3qL4azQPUEyZKYHsSFq/6QZmTN/L5RSJix15iKXqBVcwQxxABcFVHuHmrhVoHCuIxjpnkMU9H6c /uBeyhYE60UEnFSvaequopg== X-Google-Smtp-Source: AGHT+IGyaGimLFtOc8xFMrBxHlvoKkgipEDRsXSRpIYCtUs3FtGiq87tnN7DOlflNQnY8+3VkwfOeHU4ERQxyW4QXg== X-Received: from oabps11.prod.google.com ([2002:a05:6870:9e0b:b0:296:5847:48e8]) (user=kaleshsingh job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6870:3108:b0:29e:287e:3706 with SMTP id 586e51a60fabf-29f732d630amr9859551fac.17.1733798510837; Mon, 09 Dec 2024 18:41:50 -0800 (PST) Date: Mon, 9 Dec 2024 18:41:17 -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-16-kaleshsingh@google.com> Subject: [PATCH mm-unstable 15/17] mm: powerpc: 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-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 4A6B9C0009 X-Stat-Signature: dwsgnp5xoqc3urfz8oppoqj5qt1539or X-Rspam-User: X-HE-Tag: 1733798487-622523 X-HE-Meta: U2FsdGVkX1/98QMRKe9SaQSYdX8a/LEA/ooMSxe7VbPKv8X2W5WuV/b+K7ztgpACPJjl4s5NyKq2t+zQiKOZXFRWwtSHvenSoEtLWy8cWYMNpkx0nz+KB4TiW/V5/DTQhkzKGpXilNAm/B308xbaunW2C+2rWsCnqyE4LJiZkDLkXM6z2d+ZSnI/tMQwqexIfSA1jrL+c6yN+c3x/ImpYQ5HJic5aMLkQH/4ldVMicfvLyfQe9pEPCyJIbq+AalUXRIS0354lbTIl/AR7/GJgNF5DcI/JeP9qR1cNdAOCs296YdL2HMRHGnwnQzkVBc3ZFUx2amNcP60So9NELlqcgtdRBMTOo99ekbkIjtVCHieyr4auZhdTqfXtMQCKNQWIUdh/49DAfq+m2wFD9lTyCRApAbbdCTuaPM2oJLR0lbPtyhrVwv+KM7+ROVnmBnw+1AWpp+sJzTBCnOD9jHttuOo0w61t4h+bGTW91uwvgwX9eO1O4BFKFbUodzX3wXUd8hahU3UnoVlflv9C/a+nFKkskH6RuoRhI7+OXlZn7BTLVzI6pHEOis15pStpBLLTp1S2gKbojqk6OQrWpZFtI+2K36NoL7qwkchXNyQjeOu/FEqYaJEILzDVbmwOF6CbJLgej31SjtTsjj+/p+TbC8Na/6nvNou9wWqWRKJNerUWU+YO/fkn5q3Uvsd3cZvQfSwv6MS4dWfmuKPfNCU7rVfi3HhD2ndEuCC8p5JjWUJ11EkGwWGnQ4WqeMbjxCQWQFkSd6ceSCl47b1nMa5UI6uKq8K+DcRhvaUhO37tLireS93dxagXOL7ofVpM7gKz3QoIUA8dtPzXNsBhCcxmLyhYDUprdi924tGqanYUmAPTdx7vTXUYHZ2ukT+vCTtcqs+73c78Ra/4cmlS42Azys+tmvRz7T/Fkkhc4Gb8jgvMX45ku1EacnooEJlZnO7Ipnp65sKKfsxE7qFecK robXGBsw Mf00pVbvkG5yQYtaNkt48k5sw4vaHmASPf2QhdxWTKZSEtt2uSo0qwq5O1VFtw+cP5FRHCq8UbLlCLIipyqPyZfZB8A0SqpuRBTOq5AbdJMpEMoMvIQ0zSMk29rHll6HDzFmiSc4xtVz/iPg/m5M5dWxXncXKWfd6ynyalS+2eZTcDF9JbPocc7NB5TqUrf3QkdJW6KJoQAMaFnXHsg0KJAYKjF8EolwFynNM8+98wHRK3yHR2ufR98zFyIzwadOxjK4f2f1v2iinBvLOFzCWve46Ju751Jwg6zCKD4ew3Ghu5pJEtxXF+nUJHvt1gTal3Ys2nbBW2uuKOEeaWhXXMLHPUcQ3/0EPR8MVMj6R2snMp+CQswK/UhyHU9vb4t+0zw3CEiQ/4T+ZmvaL0E8Qlgejw7ewlLkApz5rVl+rScmvOYbN5WiliMOFC45QpG1gB4R5Ecmw5hsuWasda+3ZjC9q3mWMsoXzjB8keZK/BMbzg6zLalOUfVcID9oZnUXzbAp0hkfEdlM7CeZCsRhHpGzh7qU8SbskdPVkAXGSKxPFN2J5QxxpqZJAzMEY/Po4i35/hwhj7SO4FR283G+bwEQcc2zbxxmnv/SAjgC1Z4C19+pnU6OZWzYG/JD8uqn8pNzT X-Bogosity: Ham, tests=bogofilter, spamicity=0.433267, 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 powerpc 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/powerpc/include/asm/book3s/64/slice.h | 1 + arch/powerpc/mm/book3s64/slice.c | 31 ++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/arch/powerpc/include/asm/book3s/64/slice.h b/arch/powerpc/include/asm/book3s/64/slice.h index 5fbe18544cbd..89f629080e90 100644 --- a/arch/powerpc/include/asm/book3s/64/slice.h +++ b/arch/powerpc/include/asm/book3s/64/slice.h @@ -10,6 +10,7 @@ #endif #define HAVE_ARCH_UNMAPPED_AREA #define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN +#define HAVE_ARCH_MMAP_HINT #endif #define SLICE_LOW_SHIFT 28 diff --git a/arch/powerpc/mm/book3s64/slice.c b/arch/powerpc/mm/book3s64/slice.c index bc9a39821d1c..70b95968301a 100644 --- a/arch/powerpc/mm/book3s64/slice.c +++ b/arch/powerpc/mm/book3s64/slice.c @@ -647,6 +647,37 @@ static int file_to_psize(struct file *file) } #endif +static unsigned long slice_mmap_hint(unsigned long addr, unsigned long len, + unsigned long flags, unsigned int psize) +{ + unsigned long hint_addr = slice_get_unmapped_area(addr, len, flags, psize, 0); + + if (IS_ERR_VALUE(hint_addr) || hint_addr != PAGE_ALIGN(addr)) + return 0; + + return hint_addr; +} + +unsigned long arch_mmap_hint(struct file *filp, unsigned long addr, + unsigned long len, unsigned long pgoff, + unsigned long flags) +{ + unsigned int psize; + + if (!addr) + return 0; + + if (radix_enabled()) + return generic_mmap_hint(filp, addr, len, pgoff, flags); + + if (filp && is_file_hugepages(filp)) + psize = file_to_psize(filp); + else + psize = mm_ctx_user_psize(¤t->mm->context); + + return slice_mmap_hint(addr, len, flags, psize); +} + unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsigned long len, From patchwork Tue Dec 10 02:41:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalesh Singh X-Patchwork-Id: 13900716 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 BD3A7E7717D for ; Tue, 10 Dec 2024 02:42:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 107198D0005; Mon, 9 Dec 2024 21:41:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 090C28D0001; Mon, 9 Dec 2024 21:41:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DFF1C8D0005; Mon, 9 Dec 2024 21:41:55 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id B9CF18D0001 for ; Mon, 9 Dec 2024 21:41:55 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 7FDEA120263 for ; Tue, 10 Dec 2024 02:41:55 +0000 (UTC) X-FDA: 82877498592.13.673E63C Received: from mail-pf1-f201.google.com (mail-pf1-f201.google.com [209.85.210.201]) by imf14.hostedemail.com (Postfix) with ESMTP id 2B062100011 for ; Tue, 10 Dec 2024 02:41:29 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=uIznGrYJ; spf=pass (imf14.hostedemail.com: domain of 3cKpXZwsKCGUNDOHVKVLQJKJRRJOH.FRPOLQXa-PPNYDFN.RUJ@flex--kaleshsingh.bounces.google.com designates 209.85.210.201 as permitted sender) smtp.mailfrom=3cKpXZwsKCGUNDOHVKVLQJKJRRJOH.FRPOLQXa-PPNYDFN.RUJ@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=1733798499; 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=PpJ3voZ2zpkCxNiGYJ7mZV4beiWEDuh5gW+cJghhtIw=; b=4rYSvTeEZtmsLtMSqY1rJb0ZAOvkfsvvZgGHqbd2KFHBKh2igK3h+zgBdC+/alEsNsTbV1 08Dy3470zOFQ+KMi1bEgt4CK/C5AsTOhYvWlWSyuXI4CZy1QSzFWVQfvUJ01Gtx9e+IYV7 0PLPmMqU7Q/wG9siH0wxD3qeaQqGShw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733798499; a=rsa-sha256; cv=none; b=ZiSDaflIe75rU2hk81ubbG4KDHjC7dZA4ieTkgHLPa+gM//Urr6KydgvGXYIe7/ThgNNXe t51s99lf9x8sPzS5uy2hkSZCa05/iDfqYRmTpUereGReYf7hqrhUE35Ol4nhiPRcnUCzF9 e4S2O4cJ/s6vcObpmbZ2Fq08n2PhTu8= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=uIznGrYJ; spf=pass (imf14.hostedemail.com: domain of 3cKpXZwsKCGUNDOHVKVLQJKJRRJOH.FRPOLQXa-PPNYDFN.RUJ@flex--kaleshsingh.bounces.google.com designates 209.85.210.201 as permitted sender) smtp.mailfrom=3cKpXZwsKCGUNDOHVKVLQJKJRRJOH.FRPOLQXa-PPNYDFN.RUJ@flex--kaleshsingh.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-pf1-f201.google.com with SMTP id d2e1a72fcca58-725eff499c0so1234828b3a.2 for ; Mon, 09 Dec 2024 18:41:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733798512; x=1734403312; 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=PpJ3voZ2zpkCxNiGYJ7mZV4beiWEDuh5gW+cJghhtIw=; b=uIznGrYJgaTxBWI8d7SmwwdTtzpoihl80GF+Jg8paOyBqwywqq231mJMmIxjOE/IaU Hg22oz9o5Wj+Rcu2YQ0LrO8yzBCklmGTzW5am1PJV1Qj8o0Afb9r1WCRBqx0K5jGC00r VqRkfqVTTcAtYO1U1PkTsHaL93s7gq9DXdTJxC4gkFW/oPFSpevVhWQ2ZFzGbLSreQFO T1dn7rxCqgPvPhqrM0gOij3FbO8QOdQqJLKGWZidaF/CAOMNhQ+f2gR3LBKr3OgSUf6R tu/6FgpavR8erGd4meHclBQi+31ttLiEmCeVCv0Iz+1AK11eRtld7sBg0sdYJKzAWh94 KFvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733798512; x=1734403312; 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=PpJ3voZ2zpkCxNiGYJ7mZV4beiWEDuh5gW+cJghhtIw=; b=hXh8xg1HBR8ygY62GqTt+tzmO0LryRlsVJQncu6e0F3oE8zkkVsomV+/lUzCJRv37J 25N5MzHRX7oxWa17bGwjPAuTLAhyvv6ZAK8RZehHKmCrmvwuqVW4eRLylhA1AKOqSFl9 gY/hner+OR60rXUh8RgnieAjKsxxB+Ucj2V2Llht2AhxmXY2cXXBCt//0tybAQkoQRue 5CpY52YhIfNud6hWYmiUxblhcHQpS3R0UOO9lq/MVKlJuMFKw1zo0qNZ4xLiI2+ZSQ18 PFOx+CchRlMuf3uV/8fugc7xp0TGsFAAP0W3Fv5zkBgr5BQFnYdsZ9mDBlkNlQYLwljZ wpGg== X-Forwarded-Encrypted: i=1; AJvYcCVR7Ohqw6FTM6Z6YhEGpDiu8TYYRZKY1mDkMR/X1X7t3ax4Gc+1a/C0QqWMCEzm/p2XI5rAKtvN9A==@kvack.org X-Gm-Message-State: AOJu0YwWz0bH9taC94/WHdDJZB7vjRK+dm494wQGOgFsCfgfzwp63dK6 V79Xa+zrortsKm1z1izvE7lF2bMyaJfav/syD6GGZtYjA1VKtdy6Ke94RXtC5tNIU19MMNrD1lk Wgu8JSAPxmCsxKJsgvRHu3w== X-Google-Smtp-Source: AGHT+IH+U5NNduIwURg0BoDlPsKnnOIwfCnZdS3eRXACF/uPNRGoE141bvOCCDVesMcVlUE6OG1mnMpg0Q9mT2r6sg== X-Received: from pfu5.prod.google.com ([2002:a05:6a00:a385:b0:725:f376:f548]) (user=kaleshsingh job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:3016:b0:725:c8ea:b320 with SMTP id d2e1a72fcca58-725c8eab756mr18454838b3a.14.1733798512543; Mon, 09 Dec 2024 18:41:52 -0800 (PST) Date: Mon, 9 Dec 2024 18:41:18 -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-17-kaleshsingh@google.com> Subject: [PATCH mm-unstable 16/17] mm: Fallback to generic_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: 2B062100011 X-Stat-Signature: 7onmnww6emieppq177f8tde3qi11qjpz X-Rspam-User: X-HE-Tag: 1733798489-472503 X-HE-Meta: U2FsdGVkX19IQuus+9snVGwkNxiq16KG5KXUHYpMVE2UEiBXiIv1l6YBVxFBKSM5x07605u1EA/l4Tdh1j08YQX825uEpgOXM0JFKcs5IX6kkrxbsp46NldP7nV77nXrIBCYrmmHCf1Qwcuy5vOQCnVNhbW3dg6MpFSog67wE399q5impSq142S+PVhyj2et/gCLB7TmeY+jVSFMrK38d6TJ769Yg+mawFulrXrT9Y2tEX1HXSwJIIAbpFOZcX8aejjyo90jvqAHlJacSAhBwg1rBfQimK7KH9FXI7w59DohO/zMKUAHxObriaKDK4Iw2fYvbwzvLQv4cJbCQo4B2WyvTgkffkcNpLw2rPw6ryudhtwV8ksy9ccWezg07p6ik8QdXgQ3cjvk6RbIJQ36iR926Z0lXdEB3uGxh0+xxyCKvnwD+c5hyibgOuZt5Uo3ACiRIhxLaWNrPFBSbfGYLmsLIZVY7FUo+zzaLLiVO+xMQrHpNJSyOK6MLLfForbrUt+oiB20iztfOwOZ+iLAkj3kj77uBSokD7J+nwkP8Qu81cP/APADf8tXJO5weOToYF/4dRZ5yvrijf9pXxcvVEejNBUXaFOI7Qhzb76kzJX1iYbvJ5TRLvBq3iixnUbkQmvvdmtCNACZJu5OoFph5W/lAm+GaXBOZEzvrkve1E8XuhJB32Agxm7Y1i00fF8RgGUvfjBu6OUzsZzWKWLd2fhj1svxkN0/tJIwOtz+/zWJSPH2DKdnt5OHZzjy8DeNbB0j4TIE+QktJvCZ1W+5QWNIQ8fnX1pvcM73I51yifbJ+dvQbzi9kuFQw1zHbjLfKFOLhy8YwZoEeMq0pVGp4rR6JIm9f6gFkHgavs/jEMpg+dU/62ujeKmjjrSADaH+5ajx4gyuOLzEL1Pu83CyLvT2JNxc9BSS9QyUG0bNXyBf6weZtSOMpRM9Hk5+utlHl6OLcAjolxm/pZ5vbPT qi6JVJsP PeggK+G237RatnGGLZ7QGS2U0DNVF5CiIYjjixQcCwuCR6whD54Q0FBGQFq2Xly8QMwJnhiIpPgtPEunCO103it9cQ2v1vFlQ9ZuPs/szrIbuY0JThq9aHvLOBfcW0JMeiV7safpXxYzpTTAdKleWrnGFjoiaYhjPBhOKZ3cCYTbtEyohF2V5s9IOAYc5MXK63iAaOukSsup4syt3s48YywuKqVg4Ic5FcjdE+Id1sseMf/vFCWhKDHVTngWkddFTEBiu0hlwJkO19Cw1+Orkb7HHyJuWIBKVXGysTdkb3kKXdWIAfJ/BkGw0HMapXPxTBHq3ISIElF+x3UQT0nzDROMhmE9115Dbna6UzCZhU/KHF0KsCUiQNEm1JkTSNEws+jlTtmQi94bUdclDcfYJgsApzOWDAH5OffQ+Ggx0E94KLSkmVDMwykTVeWE2ItybOi6QFOKqK0noqjUe7iwHZny8yHZJLDToEResKaMivs96kNs8McoWNgM8kbM9dBMv12A98DJZcRuxQ/zPiG18AdD4dn9Jhru4ytL0MdT5dlomrbYudkyoOAJZ2ur1/tUtjH4C9eTcn9wuFXkGfYsyr+l/0qSQpWFV/NzIadYDiXu4jm5udkuie0PhBg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.296719, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: If an architecture doesn't provide arch_mmap_hint() fallback to generic_mmap_hint(). Signed-off-by: Kalesh Singh --- mm/mmap.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mm/mmap.c b/mm/mmap.c index e97eb8bf4889..59bf7d127aa1 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -691,6 +691,15 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr, } #endif +#ifndef HAVE_ARCH_MMAP_HINT +unsigned long arch_mmap_hint(struct file *filp, unsigned long addr, + unsigned long len, unsigned long pgoff, + unsigned long flags) +{ + return generic_mmap_hint(filp, addr, len, pgoff, flags); +} +#endif + /* * This mmap-allocator allocates new areas top-down from below the * stack's low limit (the base): From patchwork Tue Dec 10 02:41:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalesh Singh X-Patchwork-Id: 13900717 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 CCB24E77181 for ; Tue, 10 Dec 2024 02:42:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 39FA66B0103; Mon, 9 Dec 2024 21:41:58 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 326AD6B0106; Mon, 9 Dec 2024 21:41:58 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0DD936B0103; Mon, 9 Dec 2024 21:41:58 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id DBF6A8D0001 for ; Mon, 9 Dec 2024 21:41:57 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 8A64E120257 for ; Tue, 10 Dec 2024 02:41:57 +0000 (UTC) X-FDA: 82877498802.10.C493283 Received: from mail-pf1-f201.google.com (mail-pf1-f201.google.com [209.85.210.201]) by imf13.hostedemail.com (Postfix) with ESMTP id 6AC4A20005 for ; Tue, 10 Dec 2024 02:41:34 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="Wk/cBUGe"; spf=pass (imf13.hostedemail.com: domain of 3cqpXZwsKCGcPFQJXMXNSLMLTTLQJ.HTRQNSZc-RRPaFHP.TWL@flex--kaleshsingh.bounces.google.com designates 209.85.210.201 as permitted sender) smtp.mailfrom=3cqpXZwsKCGcPFQJXMXNSLMLTTLQJ.HTRQNSZc-RRPaFHP.TWL@flex--kaleshsingh.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733798495; a=rsa-sha256; cv=none; b=GskBXaQABJ8P81fENgJlayduppjq6NpwL7hnCcTEsDRCdVHtpX4mHYkabD+qdtXPqBPL4U AAn8BqNSBcavVxByi/GK+BeM/xKrDkuiZS06lSOFFsiRaUt6PAgCZl8tGhsl7sZtoDcT0G bjQJa9D96nFhUWjdiGTqnMiC6QYvV78= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="Wk/cBUGe"; spf=pass (imf13.hostedemail.com: domain of 3cqpXZwsKCGcPFQJXMXNSLMLTTLQJ.HTRQNSZc-RRPaFHP.TWL@flex--kaleshsingh.bounces.google.com designates 209.85.210.201 as permitted sender) smtp.mailfrom=3cqpXZwsKCGcPFQJXMXNSLMLTTLQJ.HTRQNSZc-RRPaFHP.TWL@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=1733798495; 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=mJfesLSvigtPKLpc5l88d8L2TdNCPAh9XHgD9Aaia2I=; b=FcqeuM1pA0cESyEx1/MckEpOqI4SJNufkTyJvxDSPYUXtMpm+1ri6OWZFosDtZjQTNdi8x hz1tm4wewJtYTiGFVYQP+Ae6L5I9/ZfP8vvaqr/o9bwsIVjo8wJDL5A6oy+frCAx9Ca4Lj smTZwD3QRbMM3WWwWD4TO5NGq+s6f14= Received: by mail-pf1-f201.google.com with SMTP id d2e1a72fcca58-725e8775611so1558901b3a.1 for ; Mon, 09 Dec 2024 18:41:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733798514; x=1734403314; 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=mJfesLSvigtPKLpc5l88d8L2TdNCPAh9XHgD9Aaia2I=; b=Wk/cBUGejLwZaV97pR7grG1+howu9gNE+4AwntEN5D3qobC7f4uW8LT6/gEipy5fHj WKbPjkp4gbeNNB/d+RLv32CRte0ZmFiqpV36jAJ4ANsTisljJcu3ZfMA0g5xySlZVhy9 7A/Fr1F2VIbOZO+CS/iHe32q/RO0MUh+QYJF+73RZXQIpwyeWRsndJV1eXEpjd7uKAIX AFOZxhjrcP0IbDl9hWL3I+i6vOlaVnAYyFi72jxrOq21io5WgxzWpnXw1QxoA6ksVsKO oUFrvc0BdV0mN/Rr2iq/kyCvtX8v0gGFbk6YxelRWYkYshtY74F3A1mb7Q0XaWSfahqo fwFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733798514; x=1734403314; 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=mJfesLSvigtPKLpc5l88d8L2TdNCPAh9XHgD9Aaia2I=; b=r8zYTHfCLFfNqQqXxWJ6S98nAXxUgOt6JWCf1soFm3+cKdKc9X7XaA/zAhZkLZcWQ5 MRr6PgCuxRPGGVS3eUHFQuEQ0r0WCcbvCl7vunQbneDrL8QT7LO0ke83LqcJSahfnI5E Vp31Ixtpnk9W7cw9Q0+e6SSvU0SFRRHfWwJnZvh7IMcox1qAned2aVHnwFmpNFtU+Upm GzJ0XTxvz6J6x6Gn2vYgL2cDWSkBn/3mh32OL5uVZoRX4dDhcp/vBFmgxnvvD4Mjou2O 2t9cUg4C30LI+QLB7RSdPfGU46SGTpo6zu5G6JRelMNtGf6j7Xr01vA0bBpzQNE9+JRt t0tw== X-Forwarded-Encrypted: i=1; AJvYcCU63HuEJd+QDjhVqdg+zCpGwwSkzOOW+B/CI3ZQs/bUcaj/2x0Cz+iaVpV3SCKfcEWMwCzouo3r+w==@kvack.org X-Gm-Message-State: AOJu0Yxh6bRSHQOWeOjZfVJsVFhkBVRDgs+MdsC0wKwkZCVGOmJUsFuK F7P/DfPrPsSriDHfYPUZT5GJzhG44FAA71tstUnbmIj2qm02A154c8h/tBDFKn2mXl0pz18wPrg sUV2wlJji1bzYnG2JFJlSlg== X-Google-Smtp-Source: AGHT+IH7c/kAWkG1dgCDsYvw4E2EH4mgzAeRRpKy/JiEpi/blwtzY1No/+Nej6iG3SIgIjXbM8HkPN0PZclD3pT9zw== X-Received: from pfbf13.prod.google.com ([2002:a05:6a00:ad8d:b0:725:a760:4c72]) (user=kaleshsingh job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:14d3:b0:725:f097:ed21 with SMTP id d2e1a72fcca58-7273cb1d8c2mr3121572b3a.15.1733798514446; Mon, 09 Dec 2024 18:41:54 -0800 (PST) Date: Mon, 9 Dec 2024 18:41:19 -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-18-kaleshsingh@google.com> Subject: [PATCH mm-unstable 17/17] mm: Respect mmap hint before THP alignment if allocation is possible 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-Queue-Id: 6AC4A20005 X-Stat-Signature: 8ub7x673x9a43mc65tdmmy8nshzyggyo X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-Tag: 1733798494-746740 X-HE-Meta: U2FsdGVkX19g7BBB3mgc1xwrr5RqRsgM1lXnqGrr1i257XpMkGoAxQdfdQfLqCQKRjd9SlWO5pJ9l7Dm2Gw3BQBl/3MSkXqSNqlvYDqIq7h1FwAAi3zN2QvwMMzyKcyLAp0ap6hL8MCyubyrkthG2otrQXOjbtRtqDy5wvrc70WzjydQwanzRnFF8HSTPfw0TyiysP/QoPSictQiIvqWMFBTOSZbifiBfzycCBJ3TuLB+MmeEXA/66qrrpidxUgQ6mWBHgNMBXBCYHAx664q8W9NTDJscfUBKEyvEypvL9FcjohsmrLRgRzR7XfELBdIr0kevuTkxVQK8vfOMrkb3CCpAXuHPhKzxqpHTBZliHfLbF4cUwEcnFwFusr2wL7jzFGlVNz/qJtxhBUw3mgJADoqBPiThfdg7SW9wr7U1tmzKeKo60MqD4UMlSFe3tqc365b2gVTaAv9PQ/Nu+bDA6z8PbBn7BurHUBXliQzWpJp4uVYGSVcki9xBYieifY28YG7WgxY9STCpSe76Ql7LKKiPtEiyHgILPUMf4eBB7/qFHRMI6znQy353zj71Ic1bFadsvu/WZjvxiBODmvSa/p8AqUC68TljrANGlEaAnjsTAmNqR94aKnel5VfjRHsndA6EHCWhhpFj8r7892+7mgSWTNyldcmp0KDj51F9l0gfdgcuArkfXwQl6+me6TlOJAf9TZYYK9O7W2V6ojvEcVt3RJ8Z53dcFlLjQPuZvIeuMnRUYYWmE2BvifhIjjMimPwUcADeLmSfBXfNfWOQwEfCLejnNDJ7Rd7UnHhupapYJUBiCyYvaAzui66PHD8PEVU+KGjN/xJO+Fyn1hAFFNEssqvpikiko3mDB42qWNvS1l8mx7FZM4oF36FCKaJvZLY/Tx8kkSbgesum7y6KxrZVbEABBRMXDQQuLMB+4s+qpZ9h7CM/uEuiyQtYv7lWEsjidydmn2o51EgqGs IKis1ZzF a+kTTBEqV1WD7NzXEvSDiet5SXmyq5NUsZ51lIRhyoNYYywZNuuCBKyLstAJTgTZvxeQznOCnzJGYOwJsAFiKcNfalN/HYa/Q+vRaeZmQuWm1zRkU0eV2kHSpWXEtSmachXMCsFYVw7dzahf6hhhPaStwbg9bpiSY2C/d9BcJCTQ/81xKIrq82gneK858YcxSgSgGY3BJrJpqz/MkrJnZWXWdSPSI4M5r6srqCG5UKLbGrTdLvuo8cFMzo9SkFuKnCwA0urS+9Q9zJm3SCxjJmZPl5dxAx9zH4iVIbFiLliR3UOGdM4ExKJUD+1UYU0nS6VM6du7kYPlloaSuFtEoJPHHNpw+tvmxujOs/hEL4y+8DCJsCzF892zvSlMOoP65Rz56KeNHYzdSkgWFfZxsI0twOgpIsduUGgLfo+y82BPPsKDff3VuhrdHsvLFYjeZwPpvOj4oL5/a35fNhF2qoqaihyUmce9esds2Ic+cVkFrppCkxLmiXbrQYAO/sFmwJHkV1zHgjYeGA1ySzDCZ2JWTKz0Q0+oSSiZpGJR+VSk0PK+cgn5L4SyA/w9eGhAKtE6MAL+/gs/dU+oJ4jUsVUuLBA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.015945, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Commit 249608ee4713 ("mm: respect mmap hint address when aligning for THP") fallsback to PAGE_SIZE alignment instead of THP alignment for anonymous mapping as long as a hint address is provided by the user -- even if we weren't able to allocate the unmapped area at the hint address in the end. This was done to address the immediate regression in anonymous mappings where the hint address were being ignored in some cases; due to commit efa7df3e3bb5 ("mm: align larger anonymous mappings on THP boundaries"). It was later pointed out that this issue also existed for file-backed mappings from file systems that use thp_get_unmapped_area() for their .get_unmapped_area() file operation. The same fix was not applied for file-backed mappings since it would mean any mmap requests that provide a hint address would be only PAGE_SIZE-aligned regardless of whether allocation was successful at the hint address or not. Instead, use arch_mmap_hint() to first attempt allocation at the hint address and fallback to THP alignment if that fails. Signed-off-by: Kalesh Singh --- mm/huge_memory.c | 15 ++++++++------- mm/mmap.c | 1 - 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 137abeda8602..f070c89dafc9 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1097,6 +1097,14 @@ static unsigned long __thp_get_unmapped_area(struct file *filp, loff_t off_align = round_up(off, size); unsigned long len_pad, ret, off_sub; + /* + * If allocation at the address hint succeeds; respect the hint and + * don't try to align to THP boundary. + */ + addr = arch_mmap_hint(filp, addr, len, off, flags); + if (addr) + return addr; + if (!IS_ENABLED(CONFIG_64BIT) || in_compat_syscall()) return 0; @@ -1117,13 +1125,6 @@ static unsigned long __thp_get_unmapped_area(struct file *filp, if (IS_ERR_VALUE(ret)) return 0; - /* - * Do not try to align to THP boundary if allocation at the address - * hint succeeds. - */ - if (ret == addr) - return addr; - off_sub = (off - ret) & (size - 1); if (test_bit(MMF_TOPDOWN, ¤t->mm->flags) && !off_sub) diff --git a/mm/mmap.c b/mm/mmap.c index 59bf7d127aa1..6bfeec80152a 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -807,7 +807,6 @@ __get_unmapped_area(struct file *file, unsigned long addr, unsigned long len, if (get_area) { addr = get_area(file, addr, len, pgoff, flags); } else if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) && !file - && !addr /* no hint */ && IS_ALIGNED(len, PMD_SIZE)) { /* Ensures that larger anonymous mappings are THP aligned. */ addr = thp_get_unmapped_area_vmflags(file, addr, len,