From: Andrea Arcangeli <andrea@qumranet.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Christoph Lameter <clameter@sgi.com>,
Jack Steiner <steiner@sgi.com>, Robin Holt <holt@sgi.com>,
Nick Piggin <npiggin@suse.de>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
kvm-devel@lists.sourceforge.net,
Kanoj Sarcar <kanojsarcar@yahoo.com>,
Roland Dreier <rdreier@cisco.com>,
Steve Wise <swise@opengridcomputing.com>,
linux-kernel@vger.kernel.org, Avi Kivity <avi@qumranet.com>,
linux-mm@kvack.org, general@lists.openfabrics.org,
Hugh Dickins <hugh@veritas.com>,
akpm@linux-foundation.org, Rusty Russell <rusty@rustcorp.com.au>,
Anthony Liguori <aliguori@us.ibm.com>,
Chris Wright <chrisw@redhat.com>,
Marcelo Tosatti <marcelo@kvack.org>,
Eric Dumazet <dada1@cosmosbay.com>,
"Paul E. McKenney" <paulmck@us.ibm.com>
Subject: [PATCH 05 of 11] unmap vmas tlb flushing
Date: Wed, 07 May 2008 16:35:55 +0200 [thread overview]
Message-ID: <20bc6a66a86ef6bd6091.1210170955@duo.random> (raw)
In-Reply-To: <patchbomb.1210170950@duo.random>
# HG changeset patch
# User Andrea Arcangeli <andrea@qumranet.com>
# Date 1210115131 -7200
# Node ID 20bc6a66a86ef6bd60919cc77ff51d4af741b057
# Parent 34f6a4bf67ce66714ba2d5c13a5fed241d34fb09
unmap vmas tlb flushing
Move the tlb flushing inside of unmap vmas. This saves us from passing
a pointer to the TLB structure around and simplifies the callers.
Signed-off-by: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Andrea Arcangeli <andrea@qumranet.com>
diff --git a/include/linux/mm.h b/include/linux/mm.h
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -744,8 +744,7 @@ struct page *vm_normal_page(struct vm_ar
unsigned long zap_page_range(struct vm_area_struct *vma, unsigned long address,
unsigned long size, struct zap_details *);
-unsigned long unmap_vmas(struct mmu_gather **tlb,
- struct vm_area_struct *start_vma, unsigned long start_addr,
+unsigned long unmap_vmas(struct vm_area_struct *start_vma, unsigned long start_addr,
unsigned long end_addr, unsigned long *nr_accounted,
struct zap_details *);
diff --git a/mm/memory.c b/mm/memory.c
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -849,7 +849,6 @@ static unsigned long unmap_page_range(st
/**
* unmap_vmas - unmap a range of memory covered by a list of vma's
- * @tlbp: address of the caller's struct mmu_gather
* @vma: the starting vma
* @start_addr: virtual address at which to start unmapping
* @end_addr: virtual address at which to end unmapping
@@ -861,20 +860,13 @@ static unsigned long unmap_page_range(st
* Unmap all pages in the vma list.
*
* We aim to not hold locks for too long (for scheduling latency reasons).
- * So zap pages in ZAP_BLOCK_SIZE bytecounts. This means we need to
- * return the ending mmu_gather to the caller.
+ * So zap pages in ZAP_BLOCK_SIZE bytecounts.
*
* Only addresses between `start' and `end' will be unmapped.
*
* The VMA list must be sorted in ascending virtual address order.
- *
- * unmap_vmas() assumes that the caller will flush the whole unmapped address
- * range after unmap_vmas() returns. So the only responsibility here is to
- * ensure that any thus-far unmapped pages are flushed before unmap_vmas()
- * drops the lock and schedules.
*/
-unsigned long unmap_vmas(struct mmu_gather **tlbp,
- struct vm_area_struct *vma, unsigned long start_addr,
+unsigned long unmap_vmas(struct vm_area_struct *vma, unsigned long start_addr,
unsigned long end_addr, unsigned long *nr_accounted,
struct zap_details *details)
{
@@ -883,9 +875,14 @@ unsigned long unmap_vmas(struct mmu_gath
int tlb_start_valid = 0;
unsigned long start = start_addr;
spinlock_t *i_mmap_lock = details? details->i_mmap_lock: NULL;
- int fullmm = (*tlbp)->fullmm;
+ int fullmm;
+ struct mmu_gather *tlb;
struct mm_struct *mm = vma->vm_mm;
+ lru_add_drain();
+ tlb = tlb_gather_mmu(mm, 0);
+ update_hiwater_rss(mm);
+ fullmm = tlb->fullmm;
mmu_notifier_invalidate_range_start(mm, start_addr, end_addr);
for ( ; vma && vma->vm_start < end_addr; vma = vma->vm_next) {
unsigned long end;
@@ -912,7 +909,7 @@ unsigned long unmap_vmas(struct mmu_gath
(HPAGE_SIZE / PAGE_SIZE);
start = end;
} else
- start = unmap_page_range(*tlbp, vma,
+ start = unmap_page_range(tlb, vma,
start, end, &zap_work, details);
if (zap_work > 0) {
@@ -920,22 +917,23 @@ unsigned long unmap_vmas(struct mmu_gath
break;
}
- tlb_finish_mmu(*tlbp, tlb_start, start);
+ tlb_finish_mmu(tlb, tlb_start, start);
if (need_resched() ||
(i_mmap_lock && spin_needbreak(i_mmap_lock))) {
if (i_mmap_lock) {
- *tlbp = NULL;
+ tlb = NULL;
goto out;
}
cond_resched();
}
- *tlbp = tlb_gather_mmu(vma->vm_mm, fullmm);
+ tlb = tlb_gather_mmu(vma->vm_mm, fullmm);
tlb_start_valid = 0;
zap_work = ZAP_BLOCK_SIZE;
}
}
+ tlb_finish_mmu(tlb, start_addr, end_addr);
out:
mmu_notifier_invalidate_range_end(mm, start_addr, end_addr);
return start; /* which is now the end (or restart) address */
@@ -951,18 +949,10 @@ unsigned long zap_page_range(struct vm_a
unsigned long zap_page_range(struct vm_area_struct *vma, unsigned long address,
unsigned long size, struct zap_details *details)
{
- struct mm_struct *mm = vma->vm_mm;
- struct mmu_gather *tlb;
unsigned long end = address + size;
unsigned long nr_accounted = 0;
- lru_add_drain();
- tlb = tlb_gather_mmu(mm, 0);
- update_hiwater_rss(mm);
- end = unmap_vmas(&tlb, vma, address, end, &nr_accounted, details);
- if (tlb)
- tlb_finish_mmu(tlb, address, end);
- return end;
+ return unmap_vmas(vma, address, end, &nr_accounted, details);
}
/*
diff --git a/mm/mmap.c b/mm/mmap.c
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1751,15 +1751,10 @@ static void unmap_region(struct mm_struc
unsigned long start, unsigned long end)
{
struct vm_area_struct *next = prev? prev->vm_next: mm->mmap;
- struct mmu_gather *tlb;
unsigned long nr_accounted = 0;
- lru_add_drain();
- tlb = tlb_gather_mmu(mm, 0);
- update_hiwater_rss(mm);
- unmap_vmas(&tlb, vma, start, end, &nr_accounted, NULL);
+ unmap_vmas(vma, start, end, &nr_accounted, NULL);
vm_unacct_memory(nr_accounted);
- tlb_finish_mmu(tlb, start, end);
free_pgtables(vma, prev? prev->vm_end: FIRST_USER_ADDRESS,
next? next->vm_start: 0);
}
@@ -2044,7 +2039,6 @@ EXPORT_SYMBOL(do_brk);
/* Release all mmaps. */
void exit_mmap(struct mm_struct *mm)
{
- struct mmu_gather *tlb;
struct vm_area_struct *vma = mm->mmap;
unsigned long nr_accounted = 0;
unsigned long end;
@@ -2055,12 +2049,11 @@ void exit_mmap(struct mm_struct *mm)
lru_add_drain();
flush_cache_mm(mm);
- tlb = tlb_gather_mmu(mm, 1);
+
/* Don't update_hiwater_rss(mm) here, do_exit already did */
/* Use -1 here to ensure all VMAs in the mm are unmapped */
- end = unmap_vmas(&tlb, vma, 0, -1, &nr_accounted, NULL);
+ end = unmap_vmas(vma, 0, -1, &nr_accounted, NULL);
vm_unacct_memory(nr_accounted);
- tlb_finish_mmu(tlb, 0, end);
free_pgtables(vma, FIRST_USER_ADDRESS, 0);
/*
next prev parent reply other threads:[~2008-05-07 14:40 UTC|newest]
Thread overview: 106+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-07 14:35 [PATCH 00 of 11] mmu notifier #v16 Andrea Arcangeli
2008-05-07 14:35 ` [PATCH 01 of 11] mmu-notifier-core Andrea Arcangeli
2008-05-07 17:35 ` Rik van Riel
2008-05-07 20:02 ` Andrew Morton
2008-05-07 20:05 ` Andrew Morton
2008-05-07 20:30 ` Linus Torvalds
2008-05-07 21:58 ` Andrea Arcangeli
2008-05-07 22:11 ` Linus Torvalds
2008-05-07 22:27 ` Andrea Arcangeli
2008-05-07 22:31 ` [ofa-general] " Roland Dreier
2008-05-07 22:39 ` Andrea Arcangeli
2008-05-07 23:03 ` Linus Torvalds
2008-05-07 22:37 ` Andrea Arcangeli
2008-05-07 23:38 ` Linus Torvalds
2008-05-07 23:00 ` Linus Torvalds
2008-05-07 14:35 ` [PATCH 02 of 11] get_task_mm Andrea Arcangeli
2008-05-07 15:59 ` Robin Holt
2008-05-07 16:20 ` Andrea Arcangeli
2008-05-07 14:35 ` [PATCH 03 of 11] invalidate_page outside PT lock Andrea Arcangeli
2008-05-07 17:39 ` Rik van Riel
2008-05-07 17:57 ` Andrea Arcangeli
2008-05-07 14:35 ` [PATCH 04 of 11] free-pgtables Andrea Arcangeli
2008-05-07 17:41 ` Rik van Riel
2008-05-07 14:35 ` Andrea Arcangeli [this message]
2008-05-07 17:46 ` [PATCH 05 of 11] unmap vmas tlb flushing Rik van Riel
2008-05-07 14:35 ` [PATCH 06 of 11] rwsem contended Andrea Arcangeli
2008-05-07 14:35 ` [PATCH 07 of 11] i_mmap_rwsem Andrea Arcangeli
2008-05-07 14:35 ` [PATCH 08 of 11] anon-vma-rwsem Andrea Arcangeli
2008-05-07 20:56 ` Linus Torvalds
2008-05-07 21:26 ` Andrea Arcangeli
2008-05-07 21:36 ` Linus Torvalds
2008-05-07 22:22 ` Andrea Arcangeli
2008-05-07 22:31 ` Andrew Morton
2008-05-07 22:44 ` Andrea Arcangeli
2008-05-07 22:59 ` Andrew Morton
2008-05-07 23:19 ` Linus Torvalds
2008-05-07 23:39 ` Christoph Lameter
2008-05-08 0:03 ` Linus Torvalds
2008-05-08 0:52 ` Robin Holt
2008-05-08 0:56 ` Christoph Lameter
2008-05-08 1:07 ` Linus Torvalds
2008-05-08 1:39 ` Linus Torvalds
2008-05-08 1:52 ` Andrea Arcangeli
2008-05-08 1:57 ` Linus Torvalds
2008-05-08 2:24 ` Andrea Arcangeli
2008-05-08 2:32 ` Linus Torvalds
2008-05-07 23:39 ` Andrea Arcangeli
2008-05-08 1:02 ` Linus Torvalds
2008-05-08 1:12 ` Christoph Lameter
2008-05-08 1:32 ` Linus Torvalds
2008-05-08 2:56 ` Andrea Arcangeli
2008-05-08 3:10 ` Christoph Lameter
2008-05-08 3:41 ` Andrea Arcangeli
2008-05-08 4:14 ` Linus Torvalds
2008-05-08 5:20 ` Andrea Arcangeli
2008-05-08 5:27 ` Pekka Enberg
2008-05-08 5:30 ` Pekka Enberg
2008-05-08 5:49 ` Andrea Arcangeli
2008-05-08 15:03 ` Linus Torvalds
2008-05-08 16:11 ` Linus Torvalds
2008-05-08 22:01 ` Andrea Arcangeli
2008-05-09 18:37 ` Peter Zijlstra
2008-05-09 18:55 ` Andrea Arcangeli
2008-05-09 19:04 ` Peter Zijlstra
2008-05-08 1:26 ` Andrea Arcangeli
2008-05-07 23:28 ` Benjamin Herrenschmidt
2008-05-07 23:45 ` Andrea Arcangeli
2008-05-08 1:34 ` Andrea Arcangeli
2008-05-13 12:14 ` Nick Piggin
2008-05-14 5:43 ` Benjamin Herrenschmidt
2008-05-14 6:06 ` Nick Piggin
2008-05-14 13:15 ` Jack Steiner
2008-05-07 22:44 ` Linus Torvalds
2008-05-07 22:58 ` Andrea Arcangeli
2008-05-07 23:02 ` Andrea Arcangeli
2008-05-07 23:09 ` Linus Torvalds
2008-05-08 0:38 ` Robin Holt
2008-05-08 0:55 ` Linus Torvalds
2008-05-13 12:06 ` Nick Piggin
2008-05-13 15:32 ` Robin Holt
2008-05-14 4:11 ` Nick Piggin
2008-05-14 11:26 ` Robin Holt
2008-05-14 15:18 ` Linus Torvalds
2008-05-14 16:22 ` Robin Holt
2008-05-14 16:56 ` Linus Torvalds
2008-05-14 17:57 ` Christoph Lameter
2008-05-14 18:27 ` Linus Torvalds
2008-05-17 1:38 ` mm notifier: Notifications when pages are unmapped Christoph Lameter
2008-05-15 7:57 ` [PATCH 08 of 11] anon-vma-rwsem Nick Piggin
2008-05-15 11:01 ` Robin Holt
2008-05-15 11:12 ` Avi Kivity
2008-05-15 17:33 ` Christoph Lameter
2008-05-15 23:52 ` Nick Piggin
2008-05-16 11:23 ` Robin Holt
2008-05-16 11:50 ` Robin Holt
2008-05-20 5:31 ` Nick Piggin
2008-05-20 10:01 ` Robin Holt
2008-05-20 10:50 ` Nick Piggin
2008-05-20 11:05 ` Robin Holt
2008-05-20 11:14 ` Nick Piggin
2008-05-20 11:26 ` Robin Holt
2008-05-07 22:42 ` Jack Steiner
2008-05-07 14:35 ` [PATCH 09 of 11] mm_lock-rwsem Andrea Arcangeli
2008-05-07 14:36 ` [PATCH 10 of 11] export zap_page_range for XPMEM Andrea Arcangeli
2008-05-07 14:36 ` [PATCH 11 of 11] mmap sems Andrea Arcangeli
-- strict thread matches above, loose matches on Subject: below --
2008-05-02 15:05 [PATCH 00 of 11] mmu notifier #v15 Andrea Arcangeli
2008-05-02 15:05 ` [PATCH 05 of 11] unmap vmas tlb flushing Andrea Arcangeli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20bc6a66a86ef6bd6091.1210170955@duo.random \
--to=andrea@qumranet.com \
--cc=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=aliguori@us.ibm.com \
--cc=avi@qumranet.com \
--cc=chrisw@redhat.com \
--cc=clameter@sgi.com \
--cc=dada1@cosmosbay.com \
--cc=general@lists.openfabrics.org \
--cc=holt@sgi.com \
--cc=hugh@veritas.com \
--cc=kanojsarcar@yahoo.com \
--cc=kvm-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=marcelo@kvack.org \
--cc=npiggin@suse.de \
--cc=paulmck@us.ibm.com \
--cc=rdreier@cisco.com \
--cc=rusty@rustcorp.com.au \
--cc=steiner@sgi.com \
--cc=swise@opengridcomputing.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).