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);