From patchwork Tue Dec 10 21:30:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Geffon X-Patchwork-Id: 13902096 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 F0D45E7717F for ; Tue, 10 Dec 2024 21:31:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ED9968D0015; Tue, 10 Dec 2024 16:31:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E63498D000B; Tue, 10 Dec 2024 16:31:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C94018D0015; Tue, 10 Dec 2024 16:31:05 -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 9668D8D000B for ; Tue, 10 Dec 2024 16:31:05 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 4E34BC0E9F for ; Tue, 10 Dec 2024 21:31:05 +0000 (UTC) X-FDA: 82880343882.03.2B965F1 Received: from mail-qk1-f202.google.com (mail-qk1-f202.google.com [209.85.222.202]) by imf07.hostedemail.com (Postfix) with ESMTP id 1632840007 for ; Tue, 10 Dec 2024 21:30:39 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="jmLYT/oA"; spf=pass (imf07.hostedemail.com: domain of 3FrNYZwcKCCE8DBCCLKDLLDIB.9LJIFKRU-JJHS79H.LOD@flex--bgeffon.bounces.google.com designates 209.85.222.202 as permitted sender) smtp.mailfrom=3FrNYZwcKCCE8DBCCLKDLLDIB.9LJIFKRU-JJHS79H.LOD@flex--bgeffon.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=1733866239; 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=qLtQZxHfyZ3UG9LKxPNXk6qON+2equfYqBxEH3X/7vQ=; b=yMFHMHc9f04zfeJr3HOIdGgiA5hdedwXLx/01715DLF2yiQIfEdt27g+LcM3Ndv6z4dc+c ywOXZyTezdRdERq+zhlH9ePsL/FTBIj8PX2wpWgJag3rc1eYoUZGdYXpPTf6XE4t15jA1L CYmzwokHZJfBk0pJuld3YXHD6vQPuAY= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="jmLYT/oA"; spf=pass (imf07.hostedemail.com: domain of 3FrNYZwcKCCE8DBCCLKDLLDIB.9LJIFKRU-JJHS79H.LOD@flex--bgeffon.bounces.google.com designates 209.85.222.202 as permitted sender) smtp.mailfrom=3FrNYZwcKCCE8DBCCLKDLLDIB.9LJIFKRU-JJHS79H.LOD@flex--bgeffon.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733866239; a=rsa-sha256; cv=none; b=iXbGPjNa419npd0qoSOsv38Jig+JNtDjUbZ0O7jhjt/2IklvOdR3mt/DgLxRP49LCJ3a9x 8fo6MXwuFGqZNziqnlV/SBcPgQ0s/aK+YhKLPcvT01/1zVKNh6sv7DNRCD7BpkFMDHyiYY KYLVmYQUTijm866mu8id5966F7FIuRQ= Received: by mail-qk1-f202.google.com with SMTP id af79cd13be357-7b6e178d4f8so140873685a.3 for ; Tue, 10 Dec 2024 13:31:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733866262; x=1734471062; 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=qLtQZxHfyZ3UG9LKxPNXk6qON+2equfYqBxEH3X/7vQ=; b=jmLYT/oAeiNDk6WSHKhKTTeo4yeShsY01UvV1c8+lEyS7dWJhNwQUfP2ICniiT+vXi 5CWORhNdOPU3BJK9TLkZr3IO8pRq3VTF5PaLo6cSfxnu3gIOLCfkvJYSRwoxC7tduBDh BAoRIxBX6gdRLd3l5uGOp1SCyj3XXFHq2fla+dLpirXgtlp5TCwa7W2cnX3kJfCuE3AQ oG5gys4MbzH/Mj02S4NDKwSrIJglaW3X19ewNEGNs1QITebNhkdc2kWJ70sq9sCTiZRm 5wJvW8S3q8E/oABmORBQiKuVrCpFJvwW8KLgPgxzNRqtAgRvYrxgIVQGIp1Mzen6Yxrj tH6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733866262; x=1734471062; 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=qLtQZxHfyZ3UG9LKxPNXk6qON+2equfYqBxEH3X/7vQ=; b=hF4tydTfX4+3DIZL1EYlXKWz4T+D4Foc36qnNrTeHFBH4GN6t0UqY0gnpUTeDwE6Nn Uy0Mb+AHN+6QKk5mV3HTvq7I7RlyD0/2XSwIAE5NPYOIzxnMdWLAFXJa05PX7MEVxqHb iTUajLqP6oFpckzS7NF9t6bqDKgVRaePWKPJaqIJ0pZ/XxPoM4kkyOZnq9LTQIzNUqH4 O2/O9PJxCHwnmALByDRazCiw7hsu6VCQ3bAEHJp8DXvCzLzMmQyxAcp6UBOZVeVohzMZ /kk53t5CwnsOxaV7bZ5ZeQEKN4+MC38ZbYl5AVy3HhGttFkFF8HPNSqTZZ/81gxcBkVf J5yQ== X-Forwarded-Encrypted: i=1; AJvYcCUOkGmNXM0Z6WgEkKvfONc5WL/ktOHAZcSf0xn+WK+TyEX8ILXcqA6m/AAZtDX12vbkgB3P2etyjw==@kvack.org X-Gm-Message-State: AOJu0YwwBjzA3CUeaGXKU3S9mVFDEZePiCMbrsSfpL8mcFEnWdhCbKVv KDiggqR+btyqlXMv2P15GFShLtnSYeShinusGw3Mgwk26soBHcGWG9LUDNI6/DmuHRLJKBGdE9b KrnQ+9A== X-Google-Smtp-Source: AGHT+IH3NMWyVkk/B0e5FDWJt6ft3j8uGcZlVg76bwog9+Es+PKknkRKBnzr77X+s6jFQDjeJUd3QE5HwBLx X-Received: from qkkl16.prod.google.com ([2002:a37:f510:0:b0:7b6:cfce:56c5]) (user=bgeffon job=prod-delivery.src-stubby-dispatcher) by 2002:a05:620a:6181:b0:7b6:6c33:994e with SMTP id af79cd13be357-7b6eb433b8amr127896485a.6.1733866262599; Tue, 10 Dec 2024 13:31:02 -0800 (PST) Date: Tue, 10 Dec 2024 16:30:48 -0500 In-Reply-To: <20241210213050.2839638-1-bgeffon@google.com> Mime-Version: 1.0 References: <20241210213050.2839638-1-bgeffon@google.com> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog Message-ID: <20241210213050.2839638-4-bgeffon@google.com> Subject: [RFC PATCH 3/5] mm: mremap: Allow new_addr to be specified as a hint From: Brian Geffon To: Andrew Morton Cc: Lorenzo Stoakes , Jann Horn , Vlastimil Babka , "Liam R. Howlett" , linux-mm@kvack.org, Marco Vanotti , linux-kernel@vger.kernel.org, Brian Geffon X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 1632840007 X-Rspam-User: X-Stat-Signature: itsd9ru1rukamngrq6nbksu6kw1fnntp X-HE-Tag: 1733866239-559231 X-HE-Meta: U2FsdGVkX1/nkQBDvwjYqjV2fuFIOv75rIGKvpI09XOZebP1YUvYHu1M7ZWqBHq4NeSErQarcItGQAbPnqxnOOSPJSQ1OIppSL4fdwmoy3yoE7EVGau0tEY103IhdMRG2GmL20FKxr9j8pRn4Qa1AY65lCWead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51ECGliNqSgkN+ri0YTofwvO6b+/pIn1qh9eUwvGYtdupfR2oJ4dkRfTj+wCtHtix05JTVMvwAtHB6GYD+NcRExZmgTnDe3+hmmR74fpCsPNjLC7RuJF9H6MzzLDrzBdRzVhCgvF811ws7vwZbKPAqOGWTR8Ldsz8ZCJXKYqebnbMbiJ1F7XvnUKFLXGCy+eQ3UaCi44GjTQhRE9O+WWySuYuobqZFei3vBzGnD9eEB9VKYcQ378JGiUZ9s6+v939rpFTjhTBiyI2mdLkDF9zCJI9u3AwDhpfDvWeNvdG78yzMDK3egMuWLVZ86wB+u+vacRQghTACIb7B/LtPmb+5IUOh5ZQi33f8yvrVEIz4yeHgQm X-Bogosity: Ham, tests=bogofilter, spamicity=0.255066, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: When using MREMAP_MAYMOVE previously the new_addr was ignored unless the user specified MREMAP_FIXED. This change will allow it to be used as a hint in that situation similar to how mmap(2) behaves. get_unmapped_area() will handle page aligning the new address hint. Signed-off-by: Brian Geffon --- mm/mremap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/mremap.c b/mm/mremap.c index fdc1b0f1b38e..1d2522fba0ef 100644 --- a/mm/mremap.c +++ b/mm/mremap.c @@ -1205,7 +1205,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len, if (vma->vm_flags & VM_MAYSHARE) map_flags |= MAP_SHARED; - new_addr = get_unmapped_area(vma->vm_file, 0, new_len, + new_addr = get_unmapped_area(vma->vm_file, new_addr, new_len, vma->vm_pgoff + ((addr - vma->vm_start) >> PAGE_SHIFT), map_flags);