Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp237775rdb; Sun, 28 Jan 2024 23:56:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IGBBl8vFuCN81K4sUXzzNFW/TZ3TqlepV7sPxZMUhg1a3oDrdijv6wyJfrcLZq2gpDtNPvu X-Received: by 2002:ad4:5ecf:0:b0:685:edc7:6e71 with SMTP id jm15-20020ad45ecf000000b00685edc76e71mr5668665qvb.126.1706514994969; Sun, 28 Jan 2024 23:56:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706514994; cv=pass; d=google.com; s=arc-20160816; b=fVT9a7PYFfMPRHUAvvDNCMvlEF6JaltHPFIhCbG4JD5c3ATE7/7Ic1gBDdmkclokod 11uwVcNqLVFmD4591dWl5ss7NHejZm+S0SXkKxcm7pBeKNlw+R8lxlz55keFaWk4lEib io6B/dPTEkF1mZBPQ6MS1QnsVokF80Rz1SYL3n0wOUlnSW/rCcco3uTRfu+JbRi5zRF5 lbrp2X0s+qwHTQPxJ9d5YeOxi8fzUtVFoXdFApvejGRHpKPwAkG45OdfuP/BCEgEZVH5 7st/vNyIkz7nMd6KajX6T6sa6qjd76aKcq4yYZjAbVtJWgJr1tInljviqBF0qCgfwDxf g22w== 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=I5LyXm335j6PMvtoknG0DUGXbxAqHQBfeRBYbfkRtTU=; fh=9dbTP+8qiE15iWU0P8jOF7HnY3DYTAEp9+Z7q4CVW+M=; b=t0jW5gYkX3zSmpikbyu4y/wn3alUcncZYs0iM+I6papPhPcAIB6sKV+hQ7YRbNcBgq kqKcXcbKdia07Bam+o7uS6VjfQTKdYKwXz11IJOIXag9dUApQXiHJcxU0XnW86ivP0ZM S2aaMNWw6UAQhvvbd+Yhmxqrzn7gZ4TRE78452VHl9nicKQs7oSWZCEdWB8aSnj1+bWQ Ug8AjD5HacP7sANHTPSrMYcTCKbwf00awD7uLBkTI/TsHtUjUsq4cUMixC618+Vizevj qSIRC4s+kB9z1Dh70JHlbUnb0rITmMxP2W9YMjv8ncyU80NP1MxZhTWKfMIlM870ylYJ xDsg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=u2n9Trm7; 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-42310-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42310-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id o15-20020a0562140e4f00b00683a29421ddsi6890676qvc.458.2024.01.28.23.56.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jan 2024 23:56:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-42310-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=u2n9Trm7; 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-42310-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42310-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id B67F01C2372E for ; Mon, 29 Jan 2024 07:56:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AA94A57889; Mon, 29 Jan 2024 07:53:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="u2n9Trm7" Received: from out-176.mta0.migadu.com (out-176.mta0.migadu.com [91.218.175.176]) (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 1CE7E57887 for ; Mon, 29 Jan 2024 07:53:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706514808; cv=none; b=WeY4ze9MX0zkEfrbJrUkMScsZqj+bmHJsvT169pWMKQvA/q4qrfuz2ZVf+Jali8s9zV3mdGpNwocpZWI2A/eiAKfta3BatbHkx2ZBlBOYr7q4z1lB3lDi6d+/NTfiMfN/YWZiOsm+m3BTxnlwW2fs4NxVscXY8SFMbrJJgV/3pg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706514808; c=relaxed/simple; bh=C5/YmQiOYf1bM02I+5RvLMrUrx0MMswr/SIee6klngA=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=APT1QDrj5bOlSbDYhzR1TJ0I5+qTooTiDJyiGRROksN1RTe6HmONLVhTMM/f95Ps6ErzDGGJvrUeYkmF8ngJ9vQSfRy100wUnh43cZATOjkvLmqOpy5zxMw6ts2TjeLCZl02dVAA4l47Z7QmwCuQ04vWaLvkr6yuq/+E8IuQEIE= 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=u2n9Trm7; arc=none smtp.client-ip=91.218.175.176 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=1706514802; 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=I5LyXm335j6PMvtoknG0DUGXbxAqHQBfeRBYbfkRtTU=; b=u2n9Trm7n2i4J+PRhNgk8iG8hI5XnpXnhkuFrieEV9sNBZejxTSo82JR4PRVtmGiqlPpcW Qj0mFqBZQ8QtaLyOZWaebB42+wu8VdcG2P69tzf1AVuDTsIxAD3KBwYTa2ZYpjPKPaHReN P164ETp3VFij3UD+/bPw0MjgY5ZKAJI= 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: remove the mm parameter in vma_complete() Date: Mon, 29 Jan 2024 15:53:05 +0800 Message-Id: <20240129075305.3512138-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 There are vma_merge() and do_brk_flags() pass mm to vma_complete(), others would pass the vma->vm_mm. The following explains that the mm is the vma->vm_mm in vma_merge() and do_brk_flags(). All vma will point to the same mm struct if the vma_merge() is successful. So the mm and the vma->mm are the same. vm_brk_flags() and brk syscall will initialize vmi with current->mm, so the vma->vm_mm and the current->mm are the same if vma exists in do_brk_flags(). Remove the mm parameter in vma_complete() and get mm from the vma in vp. Signed-off-by: Yajun Deng --- mm/mmap.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index e97b9144c61a..9b968d1edf55 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -509,11 +509,11 @@ static inline void vma_prepare(struct vma_prepare *vp) * * @vp: The vma_prepare struct * @vmi: The vma iterator - * @mm: The mm_struct */ -static inline void vma_complete(struct vma_prepare *vp, - struct vma_iterator *vmi, struct mm_struct *mm) +static inline void vma_complete(struct vma_prepare *vp, struct vma_iterator *vmi) { + struct mm_struct *mm = vp->vma->vm_mm; + if (vp->file) { if (vp->adj_next) vma_interval_tree_insert(vp->adj_next, @@ -666,7 +666,7 @@ int vma_expand(struct vma_iterator *vmi, struct vm_area_struct *vma, vma_set_range(vma, start, end, pgoff); vma_iter_store(vmi, vma); - vma_complete(&vp, vmi, vma->vm_mm); + vma_complete(&vp, vmi); return 0; nomem: @@ -707,7 +707,7 @@ int vma_shrink(struct vma_iterator *vmi, struct vm_area_struct *vma, vma_iter_clear(vmi); vma_set_range(vma, start, end, pgoff); - vma_complete(&vp, vmi, vma->vm_mm); + vma_complete(&vp, vmi); return 0; } @@ -1030,7 +1030,7 @@ static struct vm_area_struct } } - vma_complete(&vp, vmi, mm); + vma_complete(&vp, vmi); khugepaged_enter_vma(res, vm_flags); return res; @@ -2377,7 +2377,7 @@ static int __split_vma(struct vma_iterator *vmi, struct vm_area_struct *vma, } /* vma_complete stores the new vma */ - vma_complete(&vp, vmi, vma->vm_mm); + vma_complete(&vp, vmi); /* Success. */ if (new_below) @@ -3145,7 +3145,7 @@ static int do_brk_flags(struct vma_iterator *vmi, struct vm_area_struct *vma, vm_flags_set(vma, VM_SOFTDIRTY); vma_iter_store(vmi, vma); - vma_complete(&vp, vmi, mm); + vma_complete(&vp, vmi); khugepaged_enter_vma(vma, flags); goto out; } -- 2.25.1