Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp219052ybl; Tue, 13 Aug 2019 19:21:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqz+w/BEou0kmIagRqgjXTr2uPwhamO8Y9Uv3qGCLe9BQPOPnEMdelMJibkww3K1lFKYupHd X-Received: by 2002:a17:902:9688:: with SMTP id n8mr39434028plp.227.1565749272220; Tue, 13 Aug 2019 19:21:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565749272; cv=none; d=google.com; s=arc-20160816; b=egoQkaUlL/8g4rZJcEbZdHsjNImXOVV0Efy56tPU5+8LjD99q6BTgFWoiGwhn54rNH JevahnwIioiZkENtiyGgTYGCww6exe1N07rsR/2u2VbKIsyB6nY2KXIYVhObk0S0iM8o NMFQHG5azicvULQcYFJ7cXGTPXKPQY4E4zlI1u6ASFNGnF0/+JJyttf+N84HiNA0ucWJ NHgvupi3JfeXMV1AI+J2eIITkWPtgkEVEDxk9t6VV/NsVHjcj+x43i63v8C2gC4d0bii RKm3NNp1zOvdcFE8gir0DSGTTKkFN1UEdHdu0Tp0O/nXgr/OfTYaRx56NMgApJviiIAC IrLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=MRth/QMrzMF6lqLPIKYgCmnC8ZrgWPJV1bpNyD6Z4RA=; b=Q706T9LdNVxWvBVXh2/PgKeJe7NgRkekDPwYBWw1uZLgYv0GO0jU4zhheN068wcq+w UIZ5X3BkwXod3F7qlRuBjCRpp4yyx67bIvRRnVXP6gQFGfouVlwu2z2HVYesjVB7qAX/ MT/C3LVfbY4RMIUDi9jZGwk0s0PUe7oEPtChPgK3YGSpfLa3Mf7/cXvj9IBQmAnMe3b/ MXwkbTolBfqgrX/9hvojOjo5FGSWz7wY5Dk1kTmVfofAemHOyTDLER7qZVE2IDEYaExu nJEcPMUAlUekbx+WrHz2gMrKiAKNHjleEu0ls+VFxqQlwMAUj+SKZ89xzxFrjEknjvxv +CbQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c4si35770984pgk.257.2019.08.13.19.20.56; Tue, 13 Aug 2019 19:21:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728749AbfHNCS1 (ORCPT + 99 others); Tue, 13 Aug 2019 22:18:27 -0400 Received: from mga12.intel.com ([192.55.52.136]:4431 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728388AbfHNCSZ (ORCPT ); Tue, 13 Aug 2019 22:18:25 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Aug 2019 19:18:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,382,1559545200"; d="scan'208";a="181365548" Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by orsmga006.jf.intel.com with ESMTP; 13 Aug 2019 19:18:23 -0700 From: Wei Yang To: akpm@linux-foundation.org, mgorman@techsingularity.net, vbabka@suse.cz, osalvador@suse.de Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Wei Yang Subject: [PATCH 3/3] mm/mmap.c: extract __vma_unlink_list as counter part for __vma_link_list Date: Wed, 14 Aug 2019 10:17:55 +0800 Message-Id: <20190814021755.1977-3-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190814021755.1977-1-richardw.yang@linux.intel.com> References: <20190814021755.1977-1-richardw.yang@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Just make the code a little easy to read. Signed-off-by: Wei Yang --- Note: For nommu part, the code is not tested. --- mm/internal.h | 1 + mm/mmap.c | 12 +----------- mm/nommu.c | 8 +------- mm/util.c | 14 ++++++++++++++ 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/mm/internal.h b/mm/internal.h index 41a49574acc3..4736aeb37dae 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -291,6 +291,7 @@ static inline bool is_data_mapping(vm_flags_t flags) /* mm/util.c */ void __vma_link_list(struct mm_struct *mm, struct vm_area_struct *vma, struct vm_area_struct *prev); +void __vma_unlink_list(struct mm_struct *mm, struct vm_area_struct *vma); #ifdef CONFIG_MMU extern long populate_vma_page_range(struct vm_area_struct *vma, diff --git a/mm/mmap.c b/mm/mmap.c index 3fde0ec18554..aa66753b175e 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -677,18 +677,8 @@ static __always_inline void __vma_unlink_common(struct mm_struct *mm, struct vm_area_struct *vma, struct vm_area_struct *ignore) { - struct vm_area_struct *prev, *next; - vma_rb_erase_ignore(vma, &mm->mm_rb, ignore); - next = vma->vm_next; - prev = vma->vm_prev; - if (prev) - prev->vm_next = next; - else - mm->mmap = next; - if (next) - next->vm_prev = prev; - + __vma_unlink_list(mm, vma); /* Kill the cache */ vmacache_invalidate(mm); } diff --git a/mm/nommu.c b/mm/nommu.c index 12a66fbeb988..1a403f65b99e 100644 --- a/mm/nommu.c +++ b/mm/nommu.c @@ -673,13 +673,7 @@ static void delete_vma_from_mm(struct vm_area_struct *vma) /* remove from the MM's tree and list */ rb_erase(&vma->vm_rb, &mm->mm_rb); - if (vma->vm_prev) - vma->vm_prev->vm_next = vma->vm_next; - else - mm->mmap = vma->vm_next; - - if (vma->vm_next) - vma->vm_next->vm_prev = vma->vm_prev; + __vma_unlink_list(mm, vma); } /* diff --git a/mm/util.c b/mm/util.c index 80632db29247..5f113cd0acad 100644 --- a/mm/util.c +++ b/mm/util.c @@ -281,6 +281,20 @@ void __vma_link_list(struct mm_struct *mm, struct vm_area_struct *vma, next->vm_prev = vma; } +void __vma_unlink_list(struct mm_struct *mm, struct vm_area_struct *vma) +{ + struct vm_area_struct *prev, *next; + + next = vma->vm_next; + prev = vma->vm_prev; + if (prev) + prev->vm_next = next; + else + mm->mmap = next; + if (next) + next->vm_prev = prev; +} + /* Check if the vma is being used as a stack by this task */ int vma_is_stack_for_current(struct vm_area_struct *vma) { -- 2.17.1