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: 13900751 Received: from mail-oa1-f74.google.com (mail-oa1-f74.google.com [209.85.160.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C1D4B226190 for ; Tue, 10 Dec 2024 02:41:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733798514; cv=none; b=GFRq7rFduvuC91aSs7T2dT3XL0pQ/mekLwWRt2d1xXNlUlghU3bZ6MxFEdtCuNqZezCNVy6/z6Ghmzwg7t3cPM9p3Rfdwnbq+ML6Zpl+j2FbZFQvj994NOMqffjGSpZ339zu3QiP3DaToLCw3Tnktd6crv/XQAMJECAYlWDuZ6A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733798514; c=relaxed/simple; bh=3rw7IdVRCH81NY7IYEFDBonBrqPpECuYjHxmMdU8RfY=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Qhu9c24QZDXP4akmgOhsQUOCb/tehOavYWKARfCnaGzoYE6gWb1hFbEUqqsyyJC7mviqLFEymODzYFBbC/Hig5QAajNtzxOdQwyX2xNp7pxu7K/h5zXD5peru8077zuGXB/2fjLK9XKAll2Y2IR+Ku/S/ZbsZkDwD8yhEmt+O0w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--kaleshsingh.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=fThUyNP/; arc=none smtp.client-ip=209.85.160.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--kaleshsingh.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="fThUyNP/" Received: by mail-oa1-f74.google.com with SMTP id 586e51a60fabf-296e12a44c4so3976765fac.0 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=vger.kernel.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=fThUyNP/UJnjai8CUfhr6Bv80crvmwQOgz3zH9imuIAQ73KtCMOCZmbd/lNB3iFGaW aqBex5n5mF+HI+iyBVLcYHwSnjrUoOyvmgUGBh/HoJCfUXUTkV+B4KlaIsUNPkKEGkCY 0XW8DyAeScKtnQfHjrea6UZuXNNehxo8vZqY7nbeugA+2U306JlfYUNrzUCvHjZQMDmj BFNKOSQLAhm7AR/3Bngwp0VcX2THbEpHw0d+Ol9fiByRkv7lTaw0BKJy4I+VyVKmRWFQ /udEXz1cl74aEW0jGIn4mrgzYAQ5h/ZJDcN2PwFkiosTAAD18e2wuJBrHhZR6tDmVnpg q1ug== 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=n4hia56Q84+gec6tHQaipvqGcy0rVvP1MfYxPD7Lo03hYwZiO3eQz+3FOwCw7tRy+W XbRsDKyC0rM4qVWYdzOS1MGJZi6dpD7Pf2IopwprGkbiSOHFuACFksYkkRsqCyePIgWy NxljzcP3B2FlCrCDz1jtlGicAhRsA5prVB/DkU7rpNAZ9lTJkn8YlM3m8wgBdNpziV4d C1Wa1a18ybOnVsW5udaoHW9NnnFwH9cKSHvDXXZbI5nVNKK2Z20M8oHAExeuFnHajgMf dsYmNk2JeS2ca2O+R9sOGqzGH2rd1vPP0E+4sQPcyU+3tiRsws1VnDLwffKY9pxyf3QT DwDw== X-Forwarded-Encrypted: i=1; AJvYcCXFBa1wknvRFmnVyLwOFwp/SmYw/xuNLUAXcZzDdj4b0hjXNj6HTxjGAFKp9JlHLD7/SZKQdrvosQ==@vger.kernel.org X-Gm-Message-State: AOJu0YyyH0m1Idxf0iDdBfhq3gqPhW8xaymXnwYF8vII3FmussMz/UNj K1sgR4J+DMQGjuoyMDgqBPv/rKtBKtfZNZlCF0fuAiJuU8Ga6N5XGLNYzqK1cXZZ4blTRh/mzan dsO/ZtfRd3QQD62larPaxnQ== 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> Precedence: bulk X-Mailing-List: linux-sh@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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,