Message ID | 20241211232754.1583023-15-kaleshsingh@google.com |
---|---|
State | New |
Headers | show
Return-Path: <SRS0=UvNG=TE=vger.kernel.org=sparclinux+bounces-2815-patchwork-incoming=ozlabs.org@ozlabs.org> X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20230601 header.b=znlqGrEf; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org; envelope-from=srs0=uvng=te=vger.kernel.org=sparclinux+bounces-2815-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y7sKf4Rhyz1yRL for <incoming@patchwork.ozlabs.org>; Thu, 12 Dec 2024 10:30:46 +1100 (AEDT) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4Y7sKZ2xrbz4wc3 for <incoming@patchwork.ozlabs.org>; Thu, 12 Dec 2024 10:30:42 +1100 (AEDT) Received: by gandalf.ozlabs.org (Postfix) id 4Y7sKZ2tbJz4wcj; Thu, 12 Dec 2024 10:30:42 +1100 (AEDT) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip="2604:1380:45e3:2400::1" arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1733959842; cv=pass; b=Ek9PmWL6ubMOguBDFQCJadAenjI1RgqK7LpZ1sPzmijAUYj18xK6G8GXKjgPT6du/JPQxHt6pF8H1/a81uoFA4UsdB2EdnP6c0A6Hz5HW0f5JdZOuLbSNZBWiuk53uQO4ROgv8mIcNfYjp9VycQkERVII0Dydn2GsCfLOZ40zS3X0ejG/FeasXdD1CVZxnMd2NWcOJAyQ5FDxCCQlwxWFW7izDl5l7iMd+GkIuNFJdUkiJH0SUQcPkbHjUPDOpmZhgRWb7KltT/JZFpFk+aEzlc69EQMrH+Bb7yyOuueOye9jMKWjIRIfT9T52yV/pivmpL1r+TMHZ9yXEG2tW972w== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1733959842; c=relaxed/relaxed; bh=z6Hm5oOLdBb7ho6/nkMyyfkvkknoYZ/+aPdlC1ktc9c=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=mJXiQV0vX+wAyg9qYUJsBq4b6fIpvGzcMMDWvJmrfc2YSFWxvzEUdaGuzWWul8KUkKrO121fPdMKV5okTxhCKCxnkXicdmNNQ84T0H+mkdOCCv5bvghHZlzBOllsNW2sZ+GrSKcQzPg0xtRxDLK38WaVnnS26RMSSoICBcXPTyEbSEtmSOLrwhJ5HGvNAwnyrzsjyOyh9R4d21bKV+LoFydxvHS7t3P12l7G7+FWBtb/GNcmb3+bQ/Z58xwYN8hUpAey+XGv6YmC5Z4EFoYeDzCaV4JQIbF6gnJKsgELicVAm6R7eDjURdflj5zWwbODcDXtgaPLSl1IpgDRgqNDEA== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=reject dis=none) header.from=google.com; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20230601 header.b=znlqGrEf; dkim-atps=neutral; spf=pass (client-ip=2604:1380:45e3:2400::1; helo=sv.mirrors.kernel.org; envelope-from=sparclinux+bounces-2815-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20230601 header.b=znlqGrEf; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:45e3:2400::1; helo=sv.mirrors.kernel.org; envelope-from=sparclinux+bounces-2815-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org [IPv6:2604:1380:45e3:2400::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4Y7sKW0VFlz4wc3 for <patchwork-incoming@ozlabs.org>; Thu, 12 Dec 2024 10:30:39 +1100 (AEDT) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 36C6E2839B6 for <patchwork-incoming@ozlabs.org>; Wed, 11 Dec 2024 23:30:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3A9831FFC62; Wed, 11 Dec 2024 23:28:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="znlqGrEf" X-Original-To: sparclinux@vger.kernel.org Received: from mail-oa1-f73.google.com (mail-oa1-f73.google.com [209.85.160.73]) (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 3D57F1FF60F for <sparclinux@vger.kernel.org>; Wed, 11 Dec 2024 23:28:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733959708; cv=none; b=CG0gMoFt2/+XknW8sm0f+5jQ18tXfVXkotSW89C+HxefiEIJlNOg/M5NOrvCBFfBV+XiArW0hbTHCwNjWWJoBKf+M/sBulx6W/hS+vDwxZiyM2yjS8aJN5C0dOaoE4WaUrZ1/eIYltQSj9hLOyLhqDiuYE+4Jmc5G1HFDfrG6Wk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733959708; c=relaxed/simple; bh=IV94/17VU942v+SUppuhN1JByKB2U0oRaUQ8yQsFAy0=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=bJVKoPzDd+Ox4ipxSLpYhOEkG6fWQvl3oy2kUCEm6/1cM6I/CbcWSZ69WDVY4SxOhtoLccD67JsgKcJnE5TthOLwlPuzoaHc7vzh040P29jwtF3IRkFpZOnMaP/8IL8jFN8fLKfGHEHlvXly+sWXYudZ4P7Nudu15Yk96Wzq0iU= 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=znlqGrEf; arc=none smtp.client-ip=209.85.160.73 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 Received: by mail-oa1-f73.google.com with SMTP id 586e51a60fabf-29e5f045c93so13205fac.0 for <sparclinux@vger.kernel.org>; Wed, 11 Dec 2024 15:28:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733959704; x=1734564504; 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=z6Hm5oOLdBb7ho6/nkMyyfkvkknoYZ/+aPdlC1ktc9c=; b=znlqGrEfDteMQMEQMrHRT/VFZUJqKn13qlRAuc49AQewDWPfUKRhcvh6q8eYf00wJ8 7sPyjtrzDi+CxOXMp/duiSD3d1jY4DXH9ebxKojNVFDc3+SEwUfGE3OiMi+QP20FKEGt 2holzL4AGj+DC70nyIuNYc2N4lBHVQEi8aliBAlG7SZ0xqhHaeZOF9S2dg+catQMaPSK I84IL/pqaJlS2LFUpV8QkJUgiHNKSgRgGudxaAFuqH1EzEOWCe3h9LZIHxOpv6lxK2j2 7SR3zJN7xugwyWxp9T8sg59b3Ak2UEuJKzODXNmo9EEETb2BaBYdZuLWz6UNCRHgdPzm fwnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733959704; x=1734564504; 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=z6Hm5oOLdBb7ho6/nkMyyfkvkknoYZ/+aPdlC1ktc9c=; b=ZHDRlRg2oGVWDo+wqZrjlfDzavUC6W/6BgQKohre9DysyqBPPVa8in2FRrRgnKr47Q iS4/iwcF13J09iQC3NxC3fPyHSu1ZYfS1UfIiokEgMNp+SC4HAMAUoe5+eAHkwP2uqQk 4T1DMTyekO/4modpizPqsAb+UQJpx61BRcJZBkpPQ1hYMIClynuz6sTefDMf5Zf7dL7S kOP2hwFRcBsC2PS1tfT8f8wvyE2xoQvmgbqKbTwVMBuGB3Oh9uGUxz2mb6RvnY0Oqfz2 YSFNH7myTNsBzdvgdj2frKu18UYwAVfvBGAoilVTQbQ88KGiYVVQhDsnR4+LTYks5uSP 8Vfw== X-Forwarded-Encrypted: i=1; AJvYcCVsrYXCMbuxoiy2akJ+Y8aykMjwYu1qUV1+fD+PRXbXpKvDP3wP73v0e3C3dRvbkHFQcfK0L1wYqRn7@vger.kernel.org X-Gm-Message-State: AOJu0YxtibXDVUTq3nXzQWszjQiqzqiJLjIupKZm3LDyj1sxsvSSMFun npF9HRDms4EMZQMP4oi1q+WA2b7Nud8YNBOq0xvV8sX+RDwK/5L8CEw0917uZN/ntZpgQCfp0wU GybPTOBXKiJHywLw9xtn1Lw== X-Google-Smtp-Source: AGHT+IGQDLulfLF8RwhcJUV0HutTvJeMfbYLu8JUEjKppHvTG+7VWlPJjZzjhgEci5/4OsV71lgRhbIjtjk4C1ysLQ== X-Received: from oabrl17.prod.google.com ([2002:a05:6871:6511:b0:296:1589:4069]) (user=kaleshsingh job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6870:224d:b0:29e:f61:3b62 with SMTP id 586e51a60fabf-2a38236803dmr971354fac.7.1733959704488; Wed, 11 Dec 2024 15:28:24 -0800 (PST) Date: Wed, 11 Dec 2024 15:27:52 -0800 In-Reply-To: <20241211232754.1583023-1-kaleshsingh@google.com> Precedence: bulk X-Mailing-List: sparclinux@vger.kernel.org List-Id: <sparclinux.vger.kernel.org> List-Subscribe: <mailto:sparclinux+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:sparclinux+unsubscribe@vger.kernel.org> 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-15-kaleshsingh@google.com> Subject: [PATCH mm-unstable v2 14/16] mm: xtensa: Introduce arch_mmap_hint() From: Kalesh Singh <kaleshsingh@google.com> 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 <kaleshsingh@google.com> Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-10.7 required=5.0 tests=ARC_SIGNED,ARC_VALID, DKIMWL_WL_MED,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DMARC_PASS, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on gandalf.ozlabs.org |
Series |
mm: Introduce arch_mmap_hint()
|
expand
|
diff --git a/arch/xtensa/kernel/syscall.c b/arch/xtensa/kernel/syscall.c index dc54f854c2f5..6bbe10c2a633 100644 --- a/arch/xtensa/kernel/syscall.c +++ b/arch/xtensa/kernel/syscall.c @@ -54,12 +54,12 @@ asmlinkage long xtensa_fadvise64_64(int fd, int advice, } #ifdef CONFIG_MMU -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) +unsigned long arch_mmap_hint(struct file *filp, unsigned long addr, + unsigned long len, unsigned long pgoff, + unsigned long flags) { - struct vm_area_struct *vmm; - struct vma_iterator vmi; + if (len > TASK_SIZE) + return -ENOMEM; if (flags & MAP_FIXED) { /* We do not accept a shared mapping if it would violate @@ -71,16 +71,27 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, return addr; } - if (len > TASK_SIZE) - return -ENOMEM; - if (!addr) - addr = TASK_UNMAPPED_BASE; - if (flags & MAP_SHARED) addr = COLOUR_ALIGN(addr, pgoff); else addr = PAGE_ALIGN(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 vm_area_struct *vmm; + struct vma_iterator vmi; + + addr = arch_mmap_hint(filp, addr, len, pgoff, flags); + if (addr) + return addr; + + addr = TASK_UNMAPPED_BASE; + vma_iter_init(&vmi, current->mm, addr); for_each_vma(vmi, vmm) { /* At this point: (addr < vmm->vm_end). */
Introduce xtensa arch_mmap_hint() and define HAVE_ARCH_MMAP_HINT. If a sufficiently sized hole doesn't exist at the hint address, fallback to searching the entire valid VA space instead of only the VA space above the hint address. Signed-off-by: Kalesh Singh <kaleshsingh@google.com> --- 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/xtensa/kernel/syscall.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-)