From patchwork Sun Feb 18 08:50:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yajun Deng X-Patchwork-Id: 13561759 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 175D5C4829E for ; Sun, 18 Feb 2024 08:50:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 81D706B006E; Sun, 18 Feb 2024 03:50:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7CC196B0071; Sun, 18 Feb 2024 03:50:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6BAA86B0072; Sun, 18 Feb 2024 03:50:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 5727D6B006E for ; Sun, 18 Feb 2024 03:50:48 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 235CE40119 for ; Sun, 18 Feb 2024 08:50:48 +0000 (UTC) X-FDA: 81804304176.16.EB3F311 Received: from out-183.mta0.migadu.com (out-183.mta0.migadu.com [91.218.175.183]) by imf09.hostedemail.com (Postfix) with ESMTP id 63C0E140005 for ; Sun, 18 Feb 2024 08:50:45 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=Njlk1OD0; spf=pass (imf09.hostedemail.com: domain of yajun.deng@linux.dev designates 91.218.175.183 as permitted sender) smtp.mailfrom=yajun.deng@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708246245; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=AEljPih4VKEaedgdPxkR+QTAZVEHkgRl9SR5WXdN/js=; b=alVcGx1VE3SQpinkqhw/ITp2aGmNHdlOT3rikQaV68kJ6pjoSpwvOGr47AfypaTxCtHxoz A47/AG6SMI24JyTgso/zbBSkcNUyJllAHsIwHq7k0dNrhJvTLqc/g3WfsB/ttak62OkcLf K4Aus76Nohf4M6Bsbq1PiCX1T0M/YSw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708246245; a=rsa-sha256; cv=none; b=Zgs/LVA3cee7PYpzfv9W883ZeSfaF3KiDZDx16tTYN0vYqtJf1nB/cQZJW95PLBbyN9F87 8SdP63kYkx0eRu19gH2aRJEB6qD1xBKODtNzKKxEHdzEEVCRrmVxyUyOB7UW47uvMisQAI VjbwZhcGGfpHpLZaA8N7JvQzxX9aIGQ= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=Njlk1OD0; spf=pass (imf09.hostedemail.com: domain of yajun.deng@linux.dev designates 91.218.175.183 as permitted sender) smtp.mailfrom=yajun.deng@linux.dev; dmarc=pass (policy=none) header.from=linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1708246243; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=AEljPih4VKEaedgdPxkR+QTAZVEHkgRl9SR5WXdN/js=; b=Njlk1OD0qYqxPkPOtxILtH6gC5FBCH55YfGbAwkVLzJv8DOR3Afi5Gl7doigiVCmVeWQ3i N92VXe+rl6TPn+I812AtuNGuFjL7llLIT/VEShOm7xQflwemEO3qeOwjGLdYTZV+AvmslC uYlKLV/sbWIRfdvhSWn6dX2snC8m69c= From: Yajun Deng To: akpm@linux-foundation.org Cc: Liam.Howlett@Oracle.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yajun Deng Subject: [PATCH] mm/mmap: Add case 9 in vma_merge() Date: Sun, 18 Feb 2024 16:50:28 +0800 Message-Id: <20240218085028.3294332-1-yajun.deng@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspamd-Queue-Id: 63C0E140005 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 4dxq5d3n8z9wg6pznpagb8ziesefnh1g X-HE-Tag: 1708246245-635835 X-HE-Meta: U2FsdGVkX1/L70Q5w8i/IQE35dsngBPGoLfTJkewZhUtcvqsTDePZcb3F5+fzrSXQS6Kumos75HfVsiahihHkSAvpf6kYspfSAT1gVI7J9a6zHyfQoK9K9WOY45SqttOj5X/eXTfoo7b53J0t2lnXunI2veLGYUGPvB9CDgunWLIay5pD15HkKF9kZiRzgRnYfKFOKmpv64/kCgo6ggeN7gpYDNstd5xcQ9tjf8sKPVBfPGE0ZlCv68qeOQzkkiwgYKfi7CR/2jF2Kq34QOO60U97dbniHjEwFkctv6w0WP/mt6CPMQmg22tKDa6YM90hzxUT1Xv3Nu+7KHVZI9j4kR/aZY0opFJIex6UqqpVdSEQphbGo8NmUaZAU83GROaOi5vBfpcyg2RifFRjUxd6GmxxYNAbbTEVvl0JKaOq68I0tz55nehUDIaF5QuPxgCCQwsu2t+7D7EwfH7wJi2MgQtRE2xJporAUJ48cKfSqC+Y6uKB1eE4GE8jXbGRI8Q4EeC1CfV7TQGgVNzsklLmFAmDvKbiBD03bq9GW2uxscdxlflF0Wc1N62oIWk3oK0uTDPBOy0b2qnJxayz9pQqQKJS5BRMTAdZN748g4rqtf7HciVjnK9vZrIVNBunfMIExQgY7PG8QI0u0gRPonuapzdt+GNSTc5wy5D/wRmQ/2/VrBrkNaPyU4nryMeLFbDZo/xKazShpyi5zQLLA0pCFxB2FaU5BVBPMqQtZTcd718djYrGZCG3ekjcf9mHLfyCAWHyd6wcDekspndZElOyQako+1RSg4t+yYsaJjenzyrVInrpeANwEp/cGuhsapYjAse1vRAjC08oPZ1luU0AXTm2nRz0dVzKzJUzYJeGwfzI1DHhtIsilZICKkcSha4 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000045, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: If the prev vma exists and the end is less than the end of prev, we can return NULL immediately. This reduces unnecessary operations. Signed-off-by: Yajun Deng --- mm/mmap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mm/mmap.c b/mm/mmap.c index 8f176027583c..b738849321c0 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -827,7 +827,7 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags, * * **** **** **** * PPPPPPNNNNNN PPPPPPNNNNNN PPPPPPCCCCCC - * cannot merge might become might become + * cannot merge 9 might become might become * PPNNNNNNNNNN PPPPPPPPPPCC * mmap, brk or case 4 below case 5 below * mremap move: @@ -890,6 +890,9 @@ static struct vm_area_struct if (vm_flags & VM_SPECIAL) return NULL; + if (prev && end < prev->vm_end) /* case 9 */ + return NULL; + /* Does the input range span an existing VMA? (cases 5 - 8) */ curr = find_vma_intersection(mm, prev ? prev->vm_end : 0, end);