Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp1189398rdb; Fri, 2 Feb 2024 17:47:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IGSk05o9/PYRK7Dzio3BnsB33GmDyWAaZLnuXYePYzp19kDMtAiwJyN6pEDJ6Gx5w5gt5fD X-Received: by 2002:a17:907:7798:b0:a37:17f9:42be with SMTP id ky24-20020a170907779800b00a3717f942bemr2223851ejc.35.1706924828109; Fri, 02 Feb 2024 17:47:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706924828; cv=pass; d=google.com; s=arc-20160816; b=KRmIDlP0ZK2HiTVH0b1qpiZoGApfVcJvKGYA3wy5FVZK1RrOmRGYsxPPzG39B/cYZ0 zMYa8SJVXSS1X+RQ1KC6PlWlofvpR2xGjDFBEjLqHrlgPgcP9JxeBSuL2oOMSRDpFql5 jRLTw9NC8RgpxHhBAkd3tp49gNy5m9cnWrEBRt+nNTSolhlNttWXG5DeB8kBeyP4Fy8Q x5MgQEYymW+z/5X+5r5Tu6r7JHGeWRiD2I++SvkHSxw5b3QaKFjYHfryXznjIDfWQ+8e dnF6qH3UMN/bXUqDNsk+Ei+0VJG6S5Yx3p06bU+g1La9Zzua0beOSA9cJr5XDSGZ6cEt aNCw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=uQvZQX7CRf4lYHiNuYQqSkwD20GYoPXfurrH/TrfrDM=; fh=pCSirZJ5X+4U296D4GSpZnnQP8j2fgvBlqlEsdZRJlY=; b=j02lw3beFLgrAkG0r8cH8VWPsbHLOEsgO5KLtMHDWMNgD3M4/pcBxYqWC+AnpccOrs ImFHc9hMRT71Ghs8Khgi+cDvIL2l7ZtkHOhXleaFoZL8deV27JoU3Z8y7SbtxN9QRcsn hNh0vGemWTYHylwc9f4zX8iFWJVsjLClZROCzP0KorFn8MYG9YtBwf8DlicFSlD39zOE fv9Ibl9zZ29dZH8PT5AOuOEhoABcWGTH+Za1h3oLI0KR9GwTw5lkKoXvhrVfWHfZYKRu AwBp1DFFd0IOx3YWey8qrNAqnGKTTUWoH9tlYreS07WGbU3UOLK//Wuy9hFI2PqbLqnl 6Ojg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=p6EkLQZK; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-50814-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50814-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev X-Forwarded-Encrypted: i=1; AJvYcCX21IaqKucL9xF5JEzfMB91KgUtKiF+kyFwwn6uOc0AK5jGF59g63pezIAVx1f4QtublR58zoU6L5XSTilGF6wio42hxznNMve8X/VbJA== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id jt11-20020a170906dfcb00b00a3599c5ef01si1276693ejc.302.2024.02.02.17.47.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 17:47:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50814-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=p6EkLQZK; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-50814-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50814-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev 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 am.mirrors.kernel.org (Postfix) with ESMTPS id D8DB01F26B54 for ; Sat, 3 Feb 2024 01:47:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EADF15680; Sat, 3 Feb 2024 01:47:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="p6EkLQZK" Received: from out-181.mta0.migadu.com (out-181.mta0.migadu.com [91.218.175.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 89C4746A4 for ; Sat, 3 Feb 2024 01:46:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706924819; cv=none; b=mp9M2UQZ/JCNK49Ih0bbdK2PJwy7ISsjm5S4KKu5w0GpahScZFAemtva0jBx15v2pTIw6pOB56aR6JhypqRMV8YxJ9cUvoPwX53VyDYsXjB+6dtpNCZL+3JspHlOp2l0r6jIGry/G2kdWcPO3KZwlLJykNEAml4bN/y4nnOCY7c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706924819; c=relaxed/simple; bh=y0PZltIcM3KfU9KXXSkTCWDtDNbnTxYu5KdBQp9I7Sg=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=ndgVgowZkqLiOFmRruKx7Wa0USgFCOJgxHuQu034kLpx00MgwF1ZeVP+wG1HDDZ0sNR0aNn5jZRhrhU13UB9I22vGGBYvkX3o5z8c1L6cHXHSmJOXvQz9ifAaQ9/hELVCGRVCaoh8xFUGbLWcPamAPw1FP/lxdHkZHuIbQptd78= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=p6EkLQZK; arc=none smtp.client-ip=91.218.175.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=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=1706924814; 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=uQvZQX7CRf4lYHiNuYQqSkwD20GYoPXfurrH/TrfrDM=; b=p6EkLQZKrQJEwcsgDXE/fTmFVdRqB943qHykZbOyVKNKxwNukE2NC5ycHNeoh+pKu5DciD jCL1nM06SY/U4834ld1B8GqctQdCtx6eSxdVEpXPblqihAZISAe4MJdu4D7JWBjxfCn4aG zjyQ0wQ5bXKBGbnovzi/9l2nur7cCh4= 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 v3] mm/mmap: pass vma to vma_merge() Date: Sat, 3 Feb 2024 09:46:32 +0800 Message-Id: <20240203014632.2726545-1-yajun.deng@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT These vma_merge() callers will pass mm, anon_vma and file, they all from the same vma. There is no need to pass three parameters at the same time. Pass vma instead of mm, anon_vma and file to vma_merge(), so that it can save two parameters. Signed-off-by: Yajun Deng --- v3: resend the first patch again alone. v2: split it into two patches. v1: https://lore.kernel.org/all/20240118082312.2801992-1-yajun.deng@linux.dev/ --- mm/mmap.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index 485a6e1e4226..8f176027583c 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -860,13 +860,15 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags, * area is returned, or the function will return NULL */ static struct vm_area_struct -*vma_merge(struct vma_iterator *vmi, struct mm_struct *mm, - struct vm_area_struct *prev, unsigned long addr, unsigned long end, - unsigned long vm_flags, struct anon_vma *anon_vma, struct file *file, - pgoff_t pgoff, struct mempolicy *policy, +*vma_merge(struct vma_iterator *vmi, struct vm_area_struct *prev, + struct vm_area_struct *src, unsigned long addr, unsigned long end, + unsigned long vm_flags, pgoff_t pgoff, struct mempolicy *policy, struct vm_userfaultfd_ctx vm_userfaultfd_ctx, struct anon_vma_name *anon_name) { + struct mm_struct *mm = src->vm_mm; + struct anon_vma *anon_vma = src->anon_vma; + struct file *file = src->vm_file; struct vm_area_struct *curr, *next, *res; struct vm_area_struct *vma, *adjust, *remove, *remove2; struct vm_area_struct *anon_dup = NULL; @@ -2426,9 +2428,8 @@ struct vm_area_struct *vma_modify(struct vma_iterator *vmi, pgoff_t pgoff = vma->vm_pgoff + ((start - vma->vm_start) >> PAGE_SHIFT); struct vm_area_struct *merged; - merged = vma_merge(vmi, vma->vm_mm, prev, start, end, vm_flags, - vma->anon_vma, vma->vm_file, pgoff, policy, - uffd_ctx, anon_name); + merged = vma_merge(vmi, prev, vma, start, end, vm_flags, + pgoff, policy, uffd_ctx, anon_name); if (merged) return merged; @@ -2458,9 +2459,8 @@ static struct vm_area_struct struct vm_area_struct *vma, unsigned long start, unsigned long end, pgoff_t pgoff) { - return vma_merge(vmi, vma->vm_mm, prev, start, end, vma->vm_flags, - vma->anon_vma, vma->vm_file, pgoff, vma_policy(vma), - vma->vm_userfaultfd_ctx, anon_vma_name(vma)); + return vma_merge(vmi, prev, vma, start, end, vma->vm_flags, pgoff, + vma_policy(vma), vma->vm_userfaultfd_ctx, anon_vma_name(vma)); } /* @@ -2474,10 +2474,9 @@ struct vm_area_struct *vma_merge_extend(struct vma_iterator *vmi, pgoff_t pgoff = vma->vm_pgoff + vma_pages(vma); /* vma is specified as prev, so case 1 or 2 will apply. */ - return vma_merge(vmi, vma->vm_mm, vma, vma->vm_end, vma->vm_end + delta, - vma->vm_flags, vma->anon_vma, vma->vm_file, pgoff, - vma_policy(vma), vma->vm_userfaultfd_ctx, - anon_vma_name(vma)); + return vma_merge(vmi, vma, vma, vma->vm_end, vma->vm_end + delta, + vma->vm_flags, pgoff, vma_policy(vma), + vma->vm_userfaultfd_ctx, anon_vma_name(vma)); } /* -- 2.25.1