From patchwork Wed Dec 11 23:27:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalesh Singh X-Patchwork-Id: 13904394 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 5EC07E7717D for ; Wed, 11 Dec 2024 23:28:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F03AD6B00A0; Wed, 11 Dec 2024 18:28:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E654C6B00A1; Wed, 11 Dec 2024 18:28:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C3F276B00A2; Wed, 11 Dec 2024 18:28:20 -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 A32636B00A0 for ; Wed, 11 Dec 2024 18:28:20 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 69F53C1800 for ; Wed, 11 Dec 2024 23:28:20 +0000 (UTC) X-FDA: 82884268404.30.4BA42C2 Received: from mail-pf1-f202.google.com (mail-pf1-f202.google.com [209.85.210.202]) by imf10.hostedemail.com (Postfix) with ESMTP id 4AB8FC000A for ; Wed, 11 Dec 2024 23:28:08 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=m4suUJF7; spf=pass (imf10.hostedemail.com: domain of 3ESBaZwsKCPomcngujukpijiqqing.eqonkpwz-oomxcem.qti@flex--kaleshsingh.bounces.google.com designates 209.85.210.202 as permitted sender) smtp.mailfrom=3ESBaZwsKCPomcngujukpijiqqing.eqonkpwz-oomxcem.qti@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=1733959682; 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=6OFip67XXDkH1HTauBcRO/RiBVwg85LoldBpce5+fvY=; b=VwAS6qL23mVOF1PFBhpnNwM9TCfvZs5tBbgE+VySlFRy2Lz3mTRMSXFyrPbM1oyjC2+CJL OZX+oRgJMJCwv7FT3kuvUpBJsttkV8taf4Ii8MJewL6c1tOnldlK2nKZXPcpCPytwtUCjG LkKRD6mZmZCYBLeAT2ZhsXP5TI6zv1A= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=m4suUJF7; spf=pass (imf10.hostedemail.com: domain of 3ESBaZwsKCPomcngujukpijiqqing.eqonkpwz-oomxcem.qti@flex--kaleshsingh.bounces.google.com designates 209.85.210.202 as permitted sender) smtp.mailfrom=3ESBaZwsKCPomcngujukpijiqqing.eqonkpwz-oomxcem.qti@flex--kaleshsingh.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733959682; a=rsa-sha256; cv=none; b=4MH3cX1Ut7pzF3jRN7P+bfMY+hKodtef+DrgiB1+LvBYrA826UkBoFriXWhEHvSUiJV5Y1 9R0u83bkTavk7y0S0oiPym/Odom5fe36EW6Xe1r/P6+0XRDv3uhBBp5A6pYt2lniOcUokM 2e2Qo/qsw5/fiZNUzY/UsSzm64grON4= Received: by mail-pf1-f202.google.com with SMTP id d2e1a72fcca58-728e177bc36so23371b3a.3 for ; Wed, 11 Dec 2024 15:28:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733959697; x=1734564497; 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=6OFip67XXDkH1HTauBcRO/RiBVwg85LoldBpce5+fvY=; b=m4suUJF7ZMyn21SgENySC4opHSIHb7mGxv6Inm30gQvlYmwNaXHSGIoNwCtBFj00Zf 0gl9b+6SL//NR+y6hFDyVNyPu7E7JcoRnsUL3ORldgxC1hsHYKjhmhraX4wfDIf/VGO0 PCqCBHmisLsF0NaQBKDdsXSeIjXUixenE2koYSJixx5nj3CGNqIni6G9ZA1ImUIm6o4v JY4KQKGjAwRpSNYD/a3qbKn6qlGCQpIJcju62DApwL0o6IcrihhhmD8XJKcYT2B7DdVr HvRrLmU11XHhm+QQMaqzKbWwOO6Pc8QFUVJ6PyueHamA+zf8cX8LUSj3CqzbW9DqSUOG fUZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733959697; x=1734564497; 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=6OFip67XXDkH1HTauBcRO/RiBVwg85LoldBpce5+fvY=; b=hEZPGdB/uWckebPLWUN5ECv6G5g5gJQE6UfhQTP8oZhgpgAj0II+MkhRt5dUTC5ttj Y9uqy5zs7BI+Zx1HI6EBm9KmDo0IhL3Bd4LajSyKtWJEqqdLS1r6Sjedtjg9usxzsqcD eJuv/2x5gqFJpTaWno7BtlfD9TUCDx/U/GzgeY5IoTE1OEcxN45BoxVAwgFHIpr6qORv NITWC0Alra0eJo9xRG/6LRz+2pq1zucf/75JLSH+wdJWUZlx0u3hiBwEJUsIUJ2BvuV0 PnYTVNrUakjUr3d7hVUZE7PHRox0HfPJFbQKtzo6+fvqE743xuzfdOlQWEhmcjmD0ipO iMLw== X-Forwarded-Encrypted: i=1; AJvYcCUaqAZu6lqB7hVgmhU6XF2Kse0LDVnQuE6262RCf+L2HXIrrM81nrQIbFmErKCtl1NNgtcfWnvZLg==@kvack.org X-Gm-Message-State: AOJu0YwT5gmQCttj8xQyJ/0oZNV9LCazAzLmicOpBvp0DRcDF1MNWpVU u7nfwK63npbsfJ+CfCgRIJ6L7YVGZoo+VLzDZ0UBfYjGzzjFeuJVmdKlf1KdAqolM+uXB8wZxUV HpaA8ArNkbFwA8DbS7u/+YQ== X-Google-Smtp-Source: AGHT+IHidwQ3DrDPNLywyhRXMiEnGjaKCiBaEc5hXwYPZZjpJE9GCWopm3osDWhhLjTFzQGtE2yr4rptNlkPUN/bOw== X-Received: from pfbch7.prod.google.com ([2002:a05:6a00:2887:b0:725:e05b:5150]) (user=kaleshsingh job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:99f:b0:725:e015:909d with SMTP id d2e1a72fcca58-728faadfd6cmr1845767b3a.21.1733959697352; Wed, 11 Dec 2024 15:28:17 -0800 (PST) Date: Wed, 11 Dec 2024 15:27:48 -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-11-kaleshsingh@google.com> Subject: [PATCH mm-unstable v2 10/16] mm: s390: Use generic_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-Server: rspam05 X-Stat-Signature: otmdy7u69kzctk56hbi6uqbnwb94xymu X-Rspamd-Queue-Id: 4AB8FC000A X-Rspam-User: X-HE-Tag: 1733959688-848911 X-HE-Meta: U2FsdGVkX19HpiTDu4GsKd/2YA/ZQr4MNITWONsv+pd6QYtvLq/nLWX95Blg5rxERElolivW5WkiQaPDpLs4z6zYHP6KPckyzlcTytAxri61Zo8P1TBVgDH/uz3h4kMgzw/vbzCm1A5GBEU31ujQAHumJjr7bgRQtDyNE07KGqdqMoudjOCKOPNqaacJQ67uDH1dAsvJXI25DSV9IkKEJRneNWjJDv53fF8Io3z4bp1kq9Ez01ykSR4uV0mWxkS7ix2KfOw7sr6Ard6EdjUNJq5lmpHClxTX+g0c7pi/2yAqMNJO5RviS/Qd2meffZ69sz7sqCL6qGDE/CJk8v3EBcnY8BkJ7Oqo4/USZtck8P/dWP6YwPuwOPNURtCKWqD/Jd4ZLMN/qKULidZsdgvqHB+3IDJn97H4G47aZap3qg76rmHsAHhhlLMqCTcJyaxRswSq7F0iGUF/CLfJ0G8Gg0ax6uvQpGsLI7f3gY/bA80R+ELqCHedXcgma98RUy1ZzPjkzrbNkliI8P/2EAmGvxUfzfWINhAk/Is+lgCZabSx92mZ963oDzGkb/g6OjO4GKQNdRgOPk/jGmsJRbVFNNC/iC0lJjKCg93T0iJGQhoAS9V1I159SK80cJieA1Rwo3B+h/Y+Eto+nloEtI1Q2LN4DJtURQsmZ2JIFbLdsM3Yy/aYlyQ8ClwDp5EylDaY1KGLPhz42Nz/ZsxeuFdbRQ+ic0voqPuSL8zks9KkBeRdV4rlMI5je763fddJpXdkgEA78dNjP2ReLvYl4WfsBUEwc949j1IjGHhgWZaBd4+6MUIxiGp2jsjczwxabU/Q8j4d2MnnMWupkUGa53fy23am1jKgdJxZxZxri3qD2hFRs+0/9XCamOQqVG4ccc5ReMqQMxyOAgasup8Sj+Zz1hYcKKtXlhGe688WVLaTGGhG0NgXiVyPs+33YRHmaTdbDEZDb4/n1cshaO0TF/c 3sBOxYNK 1qd0qenNsyv/4sLsBmdPOpBWDkcXbIGJPC3sV7aegiKDoGJaHELW09lpDP6rZmr4xj+ENSUCPzieGRHybUruKU9fB3tBPJuXmOf7SkgDwd+dMonm/wV0U3wSHiVErPw263b/usH/xpvx00kE8XMAJ7hdeMnOPH4jllL0XH/CkUe8DW/M2HjW0UpUkStNTSrshCJRnAgRPB8zQRi8H7Vj3X48qZrYakQ6yLOR1IqWLeP5YLe5lQpjmvXJ9VhnONvODlCazTjpfn3ogG3PLjPrTM0M7WnrKxdTHSGrZQ/DFRWOe6wn0gessM+sTBnGO71zAxqLH/xDwcLrEYUGNph1h0hqBKp/4gQQ6WkD7JcILgGi9qD/nIdbRSRBb2gTg704J+KaLQvRWb4dj951EmlP7HADBw2sckKzRy0cb8l3bUL4Obh/bS1o9FSnlHZythqIhPMhgbxda64D60OWxhEUvM4fS+24NS1ynCo+MOMqqKMOaneoMYoP0RxOyvlE1rPZnUB2ejTYfLrtnc8PQzAYUkHUwoxBVmvnnWm43puEeGWOiV3o8r2G0ATGNCD01k4A7IR82+B+FEm8pGSvN8bXGbg5n84hkyPkAXKz7QI35HGjPe6BkHQqbComqRlJlnMWpEh6u X-Bogosity: Ham, tests=bogofilter, spamicity=0.006526, 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 --- Changes in v2: - MAP_FIXED case is also handled in arch_mmap_hint() since this is just a special case of the hint addr being "enforced", per Yang Shi. - Consolidate error handling in arch_mmap_hint(). arch/s390/include/asm/pgtable.h | 1 + arch/s390/mm/mmap.c | 51 +++++++++++++++------------------ 2 files changed, 24 insertions(+), 28 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..8afb046605c9 100644 --- a/arch/s390/mm/mmap.c +++ b/arch/s390/mm/mmap.c @@ -83,28 +83,33 @@ 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) +{ + /* requested length too big for entire address space */ + if (len > TASK_SIZE - mmap_min_addr) + return -ENOMEM; + + if (flags & MAP_FIXED) + return addr; + + 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) - return -ENOMEM; - - if (flags & MAP_FIXED) + addr = arch_mmap_hint(filp, addr, len, pgoff, flags); + if (IS_ERR_VALUE(addr)) + return addr; + if (addr) 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; - } - info.length = len; info.low_limit = mm->mmap_base; info.high_limit = TASK_SIZE; @@ -123,25 +128,15 @@ 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 = {}; - /* requested length too big for entire address space */ - if (len > TASK_SIZE - mmap_min_addr) - return -ENOMEM; - - if (flags & MAP_FIXED) - 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 (IS_ERR_VALUE(addr)) + return addr; + if (addr) + goto check_asce_limit; info.flags = VM_UNMAPPED_AREA_TOPDOWN; info.length = len;