From patchwork Wed Dec 11 23:27:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalesh Singh X-Patchwork-Id: 13904389 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 BC2A0E7717D for ; Wed, 11 Dec 2024 23:28:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2D1306B0096; Wed, 11 Dec 2024 18:28:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 27CF36B0098; Wed, 11 Dec 2024 18:28:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 143AD6B0099; Wed, 11 Dec 2024 18:28:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id E96546B0096 for ; Wed, 11 Dec 2024 18:28:10 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 9847A1217E3 for ; Wed, 11 Dec 2024 23:28:10 +0000 (UTC) X-FDA: 82884267690.01.2B0ADC9 Received: from mail-pg1-f201.google.com (mail-pg1-f201.google.com [209.85.215.201]) by imf10.hostedemail.com (Postfix) with ESMTP id 7E3CBC0008 for ; Wed, 11 Dec 2024 23:27:58 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=gnkuJJkj; spf=pass (imf10.hostedemail.com: domain of 3ByBaZwsKCPAcSdWkZkafYZYggYdW.Ugedafmp-eecnSUc.gjY@flex--kaleshsingh.bounces.google.com designates 209.85.215.201 as permitted sender) smtp.mailfrom=3ByBaZwsKCPAcSdWkZkafYZYggYdW.Ugedafmp-eecnSUc.gjY@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=1733959677; 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=qH5hFVlZb/xpQlMxAKu7QZtletX8CELYGGCCA+g77Tw=; b=oncPsXv8gmDGMC7qk6Vgs8Cy/K2I7+tN7AfJDTi9ml1Ab2ab4yjeSkOKmE/YIXnpmEcJQ/ HWnzPY+8ZhIkEC5OlfoMAjLh3bzPuF1/c+QlqBpP93islGduMT3yZJ1796Eqf1eTUx65ey +gOctB0qAn1D2DVoCTnxofNql3NxLJk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733959677; a=rsa-sha256; cv=none; b=u7TKWzSaHqf4pCpMzjpLYeLJTVd5VWioZgfNqoslDraHvyWw7P+EcVpcQx07ZqiA/f7NO0 mHDq+HgLgbCSuxbz5vVEDNMM3GmI8iMHmeN4nOiBPEwmQjdoCn/fHW5v8BC0mxXZcYM5lY eVIQirKGo6KkucAG3IZbnFMVNDM+LW4= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=gnkuJJkj; spf=pass (imf10.hostedemail.com: domain of 3ByBaZwsKCPAcSdWkZkafYZYggYdW.Ugedafmp-eecnSUc.gjY@flex--kaleshsingh.bounces.google.com designates 209.85.215.201 as permitted sender) smtp.mailfrom=3ByBaZwsKCPAcSdWkZkafYZYggYdW.Ugedafmp-eecnSUc.gjY@flex--kaleshsingh.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-pg1-f201.google.com with SMTP id 41be03b00d2f7-7fd482c8de2so48528a12.0 for ; Wed, 11 Dec 2024 15:28:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733959687; x=1734564487; 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=qH5hFVlZb/xpQlMxAKu7QZtletX8CELYGGCCA+g77Tw=; b=gnkuJJkjaVA2BF8uT5OPh+HjGbJDAN1YhVFXIhyPd0hrl0hqG6Buipt3T+zL+iii9d 8o7vQS8JIb3+oJMYxZSmQuQLVraXaqfp3M14DEH2QrC/8sL7UidkEnaHp8sHoxhwHC1k 38hrmk7LSi7LTjKQbIBKRs8kg86aMiJUWK9j/bbNcWWzCt/sFSpFbYd6ogeXeFpmKDF3 /Vz114L/lkJ6vVKue2oDeC9ndDQKCVG8usGsWbYAUJJMoT2/NK4WJZPKFIw6Rf3z254U EklEGT7eYv7gMyRoJBacO7URQd2xkCD2Lj96A55SbvCZYBDatP86YM1zGNwO4L2Z6flY dsEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733959687; x=1734564487; 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=qH5hFVlZb/xpQlMxAKu7QZtletX8CELYGGCCA+g77Tw=; b=kvu0Za/gbgPnirk6HcAbhsX/2pxwwAE1tO1IiCnJmrkBFynu7hQI7AzWHJBDlF4Szv 8feQVwJ57VQzlpDKZsC41Uk+qfsS+0MR1KBTH1S24MwDndI5OI6A2IOuGppFq8yqVVIh XrylZa7RfIlVTiAjyv3isKQr2aLbuQcfF9fInCPLaH7XeS+KobAUiAe64+s0ZRzB41AQ qocCxDMM7pVUoXot0ltXwyozhC/Gy/ccft36C5KPpDcyujrX03rzbByHsMY/K6kcFgrJ jDiCgCjV5aS0bBZuYheeuZTq6YdzA8pTwv6jF1TaeycE+kd+5AxzECk9jUmPhSbOXrwi pFEw== X-Forwarded-Encrypted: i=1; AJvYcCX6X5NqD5ytHSZ8EYca3CSlzJY0RDyJEo+or+LBW1OhdHgTm50HiY2wNFZuNNyR/+oIFO1EcxnmoA==@kvack.org X-Gm-Message-State: AOJu0Yw9srkI9u5n2xxYDUzv61px0IYuHw+nMLMgkhHdAxVFGggJxIRO Od/tOP2C10Whi0H1YNzf5A/87Ulh+QlEY6aL8TLWbp0tfRIaMMmRFKiULMNhoWVw9VXh7SUAavT F47o2edn0JgiVQWHm+7cWwg== X-Google-Smtp-Source: AGHT+IE2HKYkuc89mtKU0bTUEVS1IdL7Se1Uvka0+Ku7HObHaGYamVyFYxuD0miLaBxiy9U265ART8wkxAXV/hrgFQ== X-Received: from pgbct5.prod.google.com ([2002:a05:6a02:2105:b0:7fd:356a:ef35]) (user=kaleshsingh job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:7288:b0:1e0:d848:9e83 with SMTP id adf61e73a8af0-1e1ceb1006dmr1536938637.25.1733959687513; Wed, 11 Dec 2024 15:28:07 -0800 (PST) Date: Wed, 11 Dec 2024 15:27:43 -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-6-kaleshsingh@google.com> Subject: [PATCH mm-unstable v2 05/16] mm: arc: 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: rspam10 X-Rspamd-Queue-Id: 7E3CBC0008 X-Stat-Signature: d88tbbktgje664dp616qh1ofjbza67y5 X-Rspam-User: X-HE-Tag: 1733959678-438482 X-HE-Meta: U2FsdGVkX18LenIhomjbUHOtAtmwTBOb7kzIP5UbRKclFHsVGjKnQz37mh4u65qa2tPBS3EKUwurBSA0FWBQcNDxFA94dL7+y5bUg5/opddpoh3QfSGnzYU5G5hVZ+GErVjdaIErmjRXe0kMTf8sy6CMTIBbwoc5vnpdbMiAZtgTyPDcaawy4IHlQSfXGyYvuOf3Y8Xyr7e6cEWBjeCJyeA1sZUiCPwCGhdh9ajM2ebF1vQJ9PWLdAiqDqoryfbSVyEF6W1omTZ6RbbKMFAvscRcNoq06eWuf/wqC+WWhvoyqDOiI7LAOzvmCWjsK21BETSes6tpOuZR4VEJPKzqOvfd1VCb9fRo7/muPEfViJEDQLAWNaQob/dzOzRtm0b4cCG8FIrCJj8uAR5KWaic/wvuOmM82qsOP01uK5YQ3YhiqO66clz7VM6B01/QfejMrE4UcH7LCF4UjLFmeldDnwZnm0Cjwy0In9FGdC00583/01ufw1vaKPaIRQmAh14ukgtEUgDHUAPDxKo5GOawp7HG0SRng41xdaMcAgEY6P8scg+U3Tt52GddhZFf1uNSLnJQxPVTu2P2q0osSezRV330uv4ubUh9Ih2Iqz8R3ZQi84Ha/pRgd4NWeonQpsboWky8MRN58yBrVElA0GOD4BjcdhFZ1ZCkAHZgRTNKwyq024DOmVNAhBZpgNfc0pWFs9IQLIuhaLzJBy3wqIAoFZj/UZir8mMJPSGqlnLX+jv+QP3q8TsnhB1nqrRMuuYg26IMHv908oRl+FxJnef5FHGm5CYvsyLzuVsFCg8qM9uZ44zT35M7BKCPJ/n08RYJYOhJbWHbj4haRE4f+FPBkDr3cR96/O26ckWb0P6bcMctjYOT9Vvf2VIbkwjwrzeo0MBIUPZFJ81FFt2qMPp8+n3JUAJVNhG/QC52n8Iq/MbGmSgXi+bWvqO0+dTqQD3h+GP2yiO1wv3vXFCGWWa MbtDEi+l NvH1wa9//dmDaufdWCO0glne+9gha2y/XxR5KRMl6IDxaGDwO3fWGShhsVdifYbT0fqm1LGu3OdzhYB2fSkKEbVP0QcCXWL6O6t42BvAvkAk02E/ULfJHZa5Y6Rcfw4k94uDJwrtc/PpYSflLMrDOOIZMixPV3rBl88WA0Fx5WYKvxocb+Du2UZcn5SEOtdHiSE4eVfZe8c9NJeqPf7ZQ2FofqCK0jt1SR/LvdsI4gIytQpNXZrRkTkMAE2VMsyBUhrxJwGYHW0KEK4FC4DaBNncJKuh2M3IXWIqoAOL5C7IkIkmcdLhJnSOAWz2t7+y4e6tmIRZLpf83gby4vI8y+k5gFtmpFXgA0Awh9Wf9esJamKQUjAhoCohbWnoaGj0d4doYcCiIe29Y1UmobM9GaK73CcezBcFIThRazkKCFTCdiz5kN2MtD68QnjiSy9SpgERfpQj3LlBwdel+rYgSdHP/elVlnPjxQQFk0Ypt/S/EAGBajGmN7yIbj28krrwpto1zaV+fzk7y2IOnEYJ2kFkWxEZ/z+/Bv13SUem9lNWi6tN1oruQJjZiPt0cfEB8Wb3N3huGJDpdyoi5aVfd83oPGwKdim+9+c7AYTSSV+7WKi3c1niTIQbXrG/s+llfT7N7 X-Bogosity: Ham, tests=bogofilter, spamicity=0.021085, 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 arc 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/arc/include/asm/pgtable.h | 1 + arch/arc/mm/mmap.c | 43 +++++++++++++++++----------------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/arch/arc/include/asm/pgtable.h b/arch/arc/include/asm/pgtable.h index 4cf45a99fd79..af3210ea4888 100644 --- a/arch/arc/include/asm/pgtable.h +++ b/arch/arc/include/asm/pgtable.h @@ -28,6 +28,7 @@ extern pgd_t swapper_pg_dir[] __aligned(PAGE_SIZE); /* to cope with aliasing VIPT cache */ #define HAVE_ARCH_UNMAPPED_AREA +#define HAVE_ARCH_MMAP_HINT #endif /* __ASSEMBLY__ */ diff --git a/arch/arc/mm/mmap.c b/arch/arc/mm/mmap.c index 2185afe8d59f..df01d4d9964b 100644 --- a/arch/arc/mm/mmap.c +++ b/arch/arc/mm/mmap.c @@ -14,6 +14,26 @@ #include +unsigned long arch_mmap_hint(struct file *filp, unsigned long addr, + unsigned long len, unsigned long pgoff, + unsigned long flags) +{ + if (len > TASK_SIZE) + return -ENOMEM; + + /* + * We enforce the MAP_FIXED case. + */ + if (flags & MAP_FIXED) { + if (flags & MAP_SHARED && + (addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)) + return -EINVAL; + return addr; + } + + return generic_mmap_hint(filp, addr, len, pgoff, flags); +} + /* * Ensure that shared mappings are correctly aligned to * avoid aliasing issues with VIPT caches. @@ -27,30 +47,11 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr, 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 = {}; - /* - * We enforce the MAP_FIXED case. - */ - if (flags & MAP_FIXED) { - if (flags & MAP_SHARED && - (addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)) - return -EINVAL; + addr = arch_mmap_hint(filp, addr, len, pgoff, flags); + if (addr) return addr; - } - - if (len > TASK_SIZE) - return -ENOMEM; - - if (addr) { - addr = PAGE_ALIGN(addr); - - vma = find_vma(mm, addr); - if (TASK_SIZE - len >= addr && - (!vma || addr + len <= vm_start_gap(vma))) - return addr; - } info.length = len; info.low_limit = mm->mmap_base;