From patchwork Wed Dec 11 23:27:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalesh Singh X-Patchwork-Id: 13904399 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 6400EE77182 for ; Wed, 11 Dec 2024 23:28:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BA68A6B00A8; Wed, 11 Dec 2024 18:28:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B57386B00A9; Wed, 11 Dec 2024 18:28:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9D0526B00AA; Wed, 11 Dec 2024 18:28: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 79FCE6B00A8 for ; Wed, 11 Dec 2024 18:28:29 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 2E2F8C183C for ; Wed, 11 Dec 2024 23:28:29 +0000 (UTC) X-FDA: 82884269076.16.E550461 Received: from mail-pf1-f201.google.com (mail-pf1-f201.google.com [209.85.210.201]) by imf19.hostedemail.com (Postfix) with ESMTP id 46D8B1A0012 for ; Wed, 11 Dec 2024 23:28:02 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="mTbL4E/C"; spf=pass (imf19.hostedemail.com: domain of 3GiBaZwsKCAUpfqjxmxnslmlttlqj.htrqnsz2-rrp0fhp.twl@flex--kaleshsingh.bounces.google.com designates 209.85.210.201 as permitted sender) smtp.mailfrom=3GiBaZwsKCAUpfqjxmxnslmlttlqj.htrqnsz2-rrp0fhp.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=1733959685; a=rsa-sha256; cv=none; b=CYLg0aZGJIKwKOpgNyLfGuSjmc05bv573dHRRJCU2MmckfzpxOD/i4Ska729mTGlUFAeR/ eKOPk3h0eY2G03Vg2mtKcwTNb0dcW2CBcFwT5rqzfDmcBISkyptP1zpQOSX1Ivu9n6NF2B /a9gg+wpaTJ5i8HMV0K6v8t6a3/g7aA= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="mTbL4E/C"; spf=pass (imf19.hostedemail.com: domain of 3GiBaZwsKCAUpfqjxmxnslmlttlqj.htrqnsz2-rrp0fhp.twl@flex--kaleshsingh.bounces.google.com designates 209.85.210.201 as permitted sender) smtp.mailfrom=3GiBaZwsKCAUpfqjxmxnslmlttlqj.htrqnsz2-rrp0fhp.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=1733959685; 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=mzI/WChqoEagnx9fXIUsiKk2yVJ1VLNiv4KjzJVNd2U=; b=h44ckj3HJB7RLWUyQ3xEisBvVL+ELd8vjADDMns5jbYq27WQ9yiKz2WX5pWjTZrc/XcqiF BiLYz5vwQKzMcmiLaDiDrApwiQ+ohIR1e0xqxKBFxslvJjMP5wWnuBYRlON0xIEYPwJWN8 LMvzI/o4q62P2mEBzIILs1cLHabQahE= Received: by mail-pf1-f201.google.com with SMTP id d2e1a72fcca58-728f1c4b95aso25749b3a.0 for ; Wed, 11 Dec 2024 15:28:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733959706; x=1734564506; 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=mzI/WChqoEagnx9fXIUsiKk2yVJ1VLNiv4KjzJVNd2U=; b=mTbL4E/C8AKGkS6dV3e9cUx1ni3xiEHvtNDg9iDB5i+Q6A/hjT0gpnmt77RijzHjkG 6Y6XyplEXkcsjPb/jIzbiRFUZMIPiIlV4GXxOaOiiqZkB+UqOcvPv7kqFpNYkCZmHP4d LoZKRM4r4uqcYA7vIOabbSanwOi2u73ptKRdP7jAed5Cd2BxQoB3qDfw8yXVRHYIxfYQ mwbTFjHxsFoOtnvlnuLCTfYDoPbI+0HFGtsnDe/CcxJq1KSkLR6KmKRi6i7HcATrdscB 6HzgCIhSxETmhw/0jukqtbeKm2poSmmzRfF/bD5RG37HWawfFghtVART2ZgdGwvrV4u+ 5afQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733959706; x=1734564506; 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=mzI/WChqoEagnx9fXIUsiKk2yVJ1VLNiv4KjzJVNd2U=; b=gi/Sqj/NzB/wWrzy4Mgjc9Cvwtt24WSA9r1rlXS1ox2M8eUHq6Uf6nbIlKquIzvHLB aT9uDDjUKdptSHp3RzxPJrtq3f5ALWsXSZBDiknJSN5wXFu4nVlke0SXuauGJcgHBzpb fjOMu/J/4HiYwsTuGSQTLtgrgjUDtL2tGMJyoeyKTr/LeurluKtMt+Tt8DpqzoKZptHj bOih7lHm665ltxMqqKqaBZ07ko1rYKqEXg4GsR/Gks7lnWyZoiRtsvbTsqwlsR1WbBzl SOXgwcboR9yCkwRlukpgUxfdI1yGQ8u8V5FjpadBMlmTXbvAA7GQwUbMuUXwYPcYIisZ hwLQ== X-Forwarded-Encrypted: i=1; AJvYcCVm6AHkoFMFifX/d4BIyPOSdIwIKawlH8Laq5YykPdx1U37bNU/glX9srPs/M0u1RSgNIwCJZ3p5g==@kvack.org X-Gm-Message-State: AOJu0Yz8kpzskttJV4SO01XvjE8zr8NSCWT1LGaq1ebhe5RAhL0GqDES xf043//+8CND5jsffGb5Z0GfxY/18ShjYve4TgEC2TG1oFABQGM9GGBsAPqt96KdTY003mDJ8u/ fJU1jZd2rm2YjX/HmAr75pA== X-Google-Smtp-Source: AGHT+IGnJnRJXQZ5IIc8W3PGTGxBtDfE/sIYeRjCrJpkHMTtOgcOp40OoEyKbTRESGUAjOdqxtzUpt2F+EP39npdAw== X-Received: from pfbcw14.prod.google.com ([2002:a05:6a00:450e:b0:728:e4d7:e3d3]) (user=kaleshsingh job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:a10d:b0:1e1:aef4:9cdd with SMTP id adf61e73a8af0-1e1cea82ca5mr1784516637.1.1733959706098; Wed, 11 Dec 2024 15:28:26 -0800 (PST) Date: Wed, 11 Dec 2024 15:27:53 -0800 In-Reply-To: <20241211232754.1583023-1-kaleshsingh@google.com> Mime-Version: 1.0 References: <20241211232754.1583023-1-kaleshsingh@google.com> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog Message-ID: <20241211232754.1583023-16-kaleshsingh@google.com> Subject: [PATCH mm-unstable v2 15/16] 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, minchan@kernel.org, jyescas@google.com Cc: linux@armlinux.org.uk, tsbogend@alpha.franken.de, James.Bottomley@HansenPartnership.com, ysato@users.sourceforge.jp, dalias@libc.org, glaubitz@physik.fu-berlin.de, davem@davemloft.net, andreas@gaisler.com, tglx@linutronix.de, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, chris@zankel.net, jcmvbkbc@gmail.com, bhelgaas@google.com, jason.andryuk@amd.com, leitao@debian.org, linux-alpha@vger.kernel.org, linux-kernel@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-csky@vger.kernel.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-mm@kvack.org, kernel-team@android.com, android-mm@google.com, Kalesh Singh X-Rspamd-Queue-Id: 46D8B1A0012 X-Stat-Signature: agm86kd6nrajd1yfxidkymz66amdx9qe X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-Tag: 1733959682-591475 X-HE-Meta: U2FsdGVkX1959ihlHC8+b5D/srfNT53N0b6Aogk0lbLoSAGpG+N2jUBZBLb1cQhk+k/nusgtjz/ykooZk7WGZp4zrfK/7AYDPjlsYJaXHvTEbmXhQsqRJfT0UoWVWw3dt6yctkmyfphr6yXkFaLX2pMPGBp3oVmnPdTvEJc4bgEtGR+kB3C25VACcSvc2w7xAUCXFEldiXl9sd2cMLCgbezStCjfnCs7biO6uf37NrtmAJfLViz0D7hMHHxljKGqD5eWcuK0HqNa2JXzdbQ7/H9xM6XJgo2qBPsQ3dxpylb2etnI6DhWWkXzhzsFfyENpD1tFHFeda8OaCJU+J2DHKyBMhYr8RK6q6ml4q7YDsUH7b2sWl+/xnivZ5uWTk6O9jukzD8fJ7YAIOIBpXl+f3WwRvkU2G2gPvWJQdMG36VcRV4roTs3aEWAbTy2j3zTQ7IQfLJcFYj6EkMw/8QjCOXLwOMK7JC98cpjbHCEJXtAz/inFm2hciIS0jr0Pv7HRXa9rKekjBPXhES8+xkv7WLO6gQ39KPZm1IrBBKNfI4BxKA5ZwxlnB2LVNqz1KO4xQc6lwDev/Lkc+q+F3EPKcrYkL7FQZ8oPatVB+kavHz2zflYQyuW3PqW7jFq9Uwd2wOnYmdmIHPDlnz6ZoaJhl2WEEUKhSCfNxuiZ5f8smmUyCRr+60j42i+ru8Mk8MtA7DA2STBoeJI0pB7aGpIHEciczz0A3zhw/i8MbDFGrv3cmxazDNSKwlry/Bcc4qzuzGRD8vK6obKqfOdwidiKzh8z1un2+PFoO5eGd1uQRTi23Yv/x9aCErBWlYFIkxjAiGjRJG/SHNcMG9l3H2oim3FRLUzypVJCUpKe38rbIIkMijRvx2dIHYTz6dVxuODYP1Blj75d7It+HnMJXUSbTRC43z/j/JSCCcCf3qN+ezQFqmfinzKZ8j3WN4YAcIFl05K6dF0XKYq/624Ut1 ghHlTszn oGeXweLCkwHTbmwudWdNQXCAVw/hIn8Xt5uWT9788HpTouyXt4QWtsuWPw0TbxUc7qs6q7ZCvR3CJZ7xYqn7bmxfGUYKF2WlFpoctJUrbXqFJKAxTTCbsD4mbcgp9S93ktR+xxYuyi8SL+JAJhBfDwtTxRss5z2HCAYqAUPFITakknqhV/ym2FG+HykuYXeli9cjp4QTmSoeuvT1jgXtfmI1vswoWZ/pBHTTHclKcfPShGUiW1DrUZPGhD2DF4rYnvxgc92UmK90Ktz37jWhbNLCgUYFuYxzpyKdmsrrwnnLZzf4PjCvjeTj8qLhpydbOS1mkg5HujSfpSdsljQaWFWW9mwBITfogWKZMVlEv7+F6VfweE0ugdr7luDhxQIDzVQLdgmJlvV8p3gTtuPywaVqBy8JkbMV/AyTwQ/E73ngrYyB9z8EnyTKfa/iM+pNO8FMbBYBGEh9dolfygJ/tWKQP6ZKosO1G9wBIivB2/KCrQFQuc1H5EZL8czeq14XScmSmf27C2LZKBGx4pQi+p+PwU+ILSksYpt0Cd6mwDSq5FOevPQnHK8XGH3/1jSZ3brJq9n0j1BcDP2Cxtsv25fAEEw4Hm1/SAkaiuYkOnY/408L/axjj0qmcgTFxOkB1LE3x X-Bogosity: Ham, tests=bogofilter, spamicity=0.426461, 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..b4067c57c778 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 hint_addr; + + return 0; +} + +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,