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;