From: Rasmus Andersen <rasmus@jaquet.dk>
To: torvalds@transmeta.com
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: [PATCH] guard mm->rss with page_table_lock (241p11)
Date: Mon, 29 Jan 2001 22:23:37 +0100 [thread overview]
Message-ID: <20010129222337.F603@jaquet.dk> (raw)
Hi.
This patch tries to fix the potential rss accounting race where we
fiddle with mm->rss without holding the page_table_lock.
In addition to the places this patch touches there are some places
in fs/ where mm->rss is touched. But I am not sure of the finer
points of this code, so perhaps somebody else could have a look?
The files are binfmt_aout.c, binfmt_elf.c, and exec.c.
It applies against ac12 and 241p11.
Please comment. Or else I will continue to sumbit it :)
diff -aur linux-2.4.1-pre11-clean/mm/memory.c linux/mm/memory.c
--- linux-2.4.1-pre11-clean/mm/memory.c Sun Jan 28 20:53:13 2001
+++ linux/mm/memory.c Sun Jan 28 22:43:04 2001
@@ -377,7 +377,6 @@
address = (address + PGDIR_SIZE) & PGDIR_MASK;
dir++;
} while (address && (address < end));
- spin_unlock(&mm->page_table_lock);
/*
* Update rss for the mm_struct (not necessarily current->mm)
* Notice that rss is an unsigned long.
@@ -386,6 +385,7 @@
mm->rss -= freed;
else
mm->rss = 0;
+ spin_unlock(&mm->page_table_lock);
}
@@ -1038,7 +1038,9 @@
flush_icache_page(vma, page);
}
+ spin_lock(&mm->page_table_lock);
mm->rss++;
+ spin_unlock(&mm->page_table_lock);
pte = mk_pte(page, vma->vm_page_prot);
@@ -1072,7 +1074,9 @@
return -1;
clear_user_highpage(page, addr);
entry = pte_mkwrite(pte_mkdirty(mk_pte(page, vma->vm_page_prot)));
+ spin_lock(&mm->page_table_lock);
mm->rss++;
+ spin_unlock(&mm->page_table_lock);
flush_page_to_ram(page);
}
set_pte(page_table, entry);
@@ -1111,7 +1115,9 @@
return 0;
if (new_page == NOPAGE_OOM)
return -1;
+ spin_lock(&mm->page_table_lock);
++mm->rss;
+ spin_unlock(&mm->page_table_lock);
/*
* This silly early PAGE_DIRTY setting removes a race
* due to the bad i386 page protection. But it's valid
diff -aur linux-2.4.1-pre11-clean/mm/mmap.c linux/mm/mmap.c
--- linux-2.4.1-pre11-clean/mm/mmap.c Sat Dec 30 18:35:19 2000
+++ linux/mm/mmap.c Sun Jan 28 22:43:04 2001
@@ -879,8 +879,8 @@
spin_lock(&mm->page_table_lock);
mpnt = mm->mmap;
mm->mmap = mm->mmap_avl = mm->mmap_cache = NULL;
- spin_unlock(&mm->page_table_lock);
mm->rss = 0;
+ spin_unlock(&mm->page_table_lock);
mm->total_vm = 0;
mm->locked_vm = 0;
while (mpnt) {
diff -aur linux-2.4.1-pre11-clean/mm/swapfile.c linux/mm/swapfile.c
--- linux-2.4.1-pre11-clean/mm/swapfile.c Fri Dec 29 23:07:24 2000
+++ linux/mm/swapfile.c Sun Jan 28 22:43:04 2001
@@ -231,7 +231,9 @@
set_pte(dir, pte_mkdirty(mk_pte(page, vma->vm_page_prot)));
swap_free(entry);
get_page(page);
+ spin_lock(&vma->vm_mm->page_table_lock);
++vma->vm_mm->rss;
+ spin_unlock(&vma->vm_mm->page_table_lock);
}
static inline void unuse_pmd(struct vm_area_struct * vma, pmd_t *dir,
diff -aur linux-2.4.1-pre11-clean/mm/vmscan.c linux/mm/vmscan.c
--- linux-2.4.1-pre11-clean/mm/vmscan.c Sun Jan 28 20:53:13 2001
+++ linux/mm/vmscan.c Mon Jan 29 22:09:18 2001
@@ -72,7 +72,9 @@
swap_duplicate(entry);
set_pte(page_table, swp_entry_to_pte(entry));
drop_pte:
+ spin_lock(&mm->page_table_lock);
mm->rss--;
+ spin_unlock(&mm->page_table_lock);
if (!page->age)
deactivate_page(page);
UnlockPage(page);
--
Regards,
Rasmus(rasmus@jaquet.dk)
I've never had major knee surgery on any other part of my body.
-Winston Bennett, University of Kentucky basketball forward
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/
WARNING: multiple messages have this Message-ID (diff)
From: Rasmus Andersen <rasmus@jaquet.dk>
To: torvalds@transmeta.com
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: [PATCH] guard mm->rss with page_table_lock (241p11)
Date: Mon, 29 Jan 2001 22:23:37 +0100 [thread overview]
Message-ID: <20010129222337.F603@jaquet.dk> (raw)
Hi.
This patch tries to fix the potential rss accounting race where we
fiddle with mm->rss without holding the page_table_lock.
In addition to the places this patch touches there are some places
in fs/ where mm->rss is touched. But I am not sure of the finer
points of this code, so perhaps somebody else could have a look?
The files are binfmt_aout.c, binfmt_elf.c, and exec.c.
It applies against ac12 and 241p11.
Please comment. Or else I will continue to sumbit it :)
diff -aur linux-2.4.1-pre11-clean/mm/memory.c linux/mm/memory.c
--- linux-2.4.1-pre11-clean/mm/memory.c Sun Jan 28 20:53:13 2001
+++ linux/mm/memory.c Sun Jan 28 22:43:04 2001
@@ -377,7 +377,6 @@
address = (address + PGDIR_SIZE) & PGDIR_MASK;
dir++;
} while (address && (address < end));
- spin_unlock(&mm->page_table_lock);
/*
* Update rss for the mm_struct (not necessarily current->mm)
* Notice that rss is an unsigned long.
@@ -386,6 +385,7 @@
mm->rss -= freed;
else
mm->rss = 0;
+ spin_unlock(&mm->page_table_lock);
}
@@ -1038,7 +1038,9 @@
flush_icache_page(vma, page);
}
+ spin_lock(&mm->page_table_lock);
mm->rss++;
+ spin_unlock(&mm->page_table_lock);
pte = mk_pte(page, vma->vm_page_prot);
@@ -1072,7 +1074,9 @@
return -1;
clear_user_highpage(page, addr);
entry = pte_mkwrite(pte_mkdirty(mk_pte(page, vma->vm_page_prot)));
+ spin_lock(&mm->page_table_lock);
mm->rss++;
+ spin_unlock(&mm->page_table_lock);
flush_page_to_ram(page);
}
set_pte(page_table, entry);
@@ -1111,7 +1115,9 @@
return 0;
if (new_page == NOPAGE_OOM)
return -1;
+ spin_lock(&mm->page_table_lock);
++mm->rss;
+ spin_unlock(&mm->page_table_lock);
/*
* This silly early PAGE_DIRTY setting removes a race
* due to the bad i386 page protection. But it's valid
diff -aur linux-2.4.1-pre11-clean/mm/mmap.c linux/mm/mmap.c
--- linux-2.4.1-pre11-clean/mm/mmap.c Sat Dec 30 18:35:19 2000
+++ linux/mm/mmap.c Sun Jan 28 22:43:04 2001
@@ -879,8 +879,8 @@
spin_lock(&mm->page_table_lock);
mpnt = mm->mmap;
mm->mmap = mm->mmap_avl = mm->mmap_cache = NULL;
- spin_unlock(&mm->page_table_lock);
mm->rss = 0;
+ spin_unlock(&mm->page_table_lock);
mm->total_vm = 0;
mm->locked_vm = 0;
while (mpnt) {
diff -aur linux-2.4.1-pre11-clean/mm/swapfile.c linux/mm/swapfile.c
--- linux-2.4.1-pre11-clean/mm/swapfile.c Fri Dec 29 23:07:24 2000
+++ linux/mm/swapfile.c Sun Jan 28 22:43:04 2001
@@ -231,7 +231,9 @@
set_pte(dir, pte_mkdirty(mk_pte(page, vma->vm_page_prot)));
swap_free(entry);
get_page(page);
+ spin_lock(&vma->vm_mm->page_table_lock);
++vma->vm_mm->rss;
+ spin_unlock(&vma->vm_mm->page_table_lock);
}
static inline void unuse_pmd(struct vm_area_struct * vma, pmd_t *dir,
diff -aur linux-2.4.1-pre11-clean/mm/vmscan.c linux/mm/vmscan.c
--- linux-2.4.1-pre11-clean/mm/vmscan.c Sun Jan 28 20:53:13 2001
+++ linux/mm/vmscan.c Mon Jan 29 22:09:18 2001
@@ -72,7 +72,9 @@
swap_duplicate(entry);
set_pte(page_table, swp_entry_to_pte(entry));
drop_pte:
+ spin_lock(&mm->page_table_lock);
mm->rss--;
+ spin_unlock(&mm->page_table_lock);
if (!page->age)
deactivate_page(page);
UnlockPage(page);
--
Regards,
Rasmus(rasmus@jaquet.dk)
I've never had major knee surgery on any other part of my body.
-Winston Bennett, University of Kentucky basketball forward
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/
next reply other threads:[~2001-01-29 21:24 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-01-29 21:23 Rasmus Andersen [this message]
2001-01-29 21:23 ` [PATCH] guard mm->rss with page_table_lock (241p11) Rasmus Andersen
2001-01-29 21:30 ` Rik van Riel
2001-01-29 21:30 ` Rik van Riel
2001-01-29 21:43 ` Rasmus Andersen
2001-01-29 21:43 ` Rasmus Andersen
2001-01-29 21:47 ` Rik van Riel
2001-01-29 21:47 ` Rik van Riel
2001-01-30 8:18 ` David Howells
2001-01-30 8:18 ` David Howells
2001-01-30 8:31 ` Rasmus Andersen
2001-01-30 8:31 ` Rasmus Andersen
2001-01-30 14:32 ` Mark Hahn
2001-01-30 15:30 ` Eric W. Biederman
2001-01-30 8:39 ` David S. Miller
2001-01-30 8:39 ` David S. Miller
2001-01-30 11:17 ` Chris Wedgwood
2001-01-30 11:17 ` Chris Wedgwood
2001-01-30 11:23 ` Rik van Riel
2001-01-30 11:23 ` Rik van Riel
2001-01-30 11:38 ` Rasmus Andersen
2001-01-30 11:38 ` Rasmus Andersen
2001-02-13 3:15 ` george anzinger
2001-02-13 3:15 ` george anzinger
2001-02-13 2:05 ` Marcelo Tosatti
2001-02-13 2:05 ` Marcelo Tosatti
2001-02-13 10:08 ` Stephen C. Tweedie
2001-02-13 10:08 ` Stephen C. Tweedie
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=20010129222337.F603@jaquet.dk \
--to=rasmus@jaquet.dk \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=torvalds@transmeta.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.