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,