From: Rajesh Venkatasubramanian <vrajesh@umich.edu>
To: Andrea Arcangeli <andrea@suse.de>
Cc: akpm@osdl.org, hugh@veritas.com, mbligh@aracnet.com,
linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [RFC][PATCH 1/3] radix priority search tree - objrmap complexity fix
Date: Sun, 4 Apr 2004 23:14:25 -0400 (EDT) [thread overview]
Message-ID: <Pine.LNX.4.58.0404042311380.19523@red.engin.umich.edu> (raw)
In-Reply-To: <Pine.GSO.4.58.0403252258170.4298@azure.engin.umich.edu>
This patch fixes a couple of mask overflow bugs in the prio_tree
search code. These bugs trigger in some very rare corner cases.
The patch also removes a couple of BUG_ONs from the fast paths.
Now the code is well-tested. I have tested all __vma_prio_tree_*
functions in the user-space with as many as 10 million vmas and
all prio_tree functions work fine.
This patch is against 2.6.5-aa2. It will apply on top of Hugh's
patches also.
If you like to test the prio_tree code further in the user-space,
the programs in the following link may help you.
http://www-personal.engin.umich.edu/~vrajesh/linux/prio_tree/user_space/
mm/prio_tree.c | 46 ++++++++++++++++++++++++++++++----------------
1 files changed, 30 insertions(+), 16 deletions(-)
diff -puN mm/prio_tree.c~080_prio_tree mm/prio_tree.c
--- mmlinux-2.6/mm/prio_tree.c~080_prio_tree 2004-04-04 22:25:29.000000000 -0400
+++ mmlinux-2.6-jaya/mm/prio_tree.c 2004-04-04 22:25:30.000000000 -0400
@@ -124,10 +124,8 @@ static inline struct prio_tree_node *pri
node->parent = old->parent;
if (old->parent->left == old)
old->parent->left = node;
- else {
- BUG_ON(old->parent->right != old);
+ else
old->parent->right = node;
- }
}
if (!prio_tree_left_empty(old)) {
@@ -271,10 +269,8 @@ void prio_tree_remove(struct prio_tree_r
if (cur->parent->right == cur)
cur->parent->right = cur->parent;
- else {
- BUG_ON(cur->parent->left != cur);
+ else
cur->parent->left = cur->parent;
- }
while (cur != node)
cur = prio_tree_replace(root, cur->parent, cur);
@@ -308,8 +304,16 @@ static inline struct prio_tree_node *__p
iter->size_level++;
}
else {
- iter->size_level = 1;
- iter->mask = 1UL << (root->index_bits - 1);
+ if (iter->size_level) {
+ BUG_ON(!prio_tree_left_empty(iter->cur));
+ BUG_ON(!prio_tree_right_empty(iter->cur));
+ iter->size_level++;
+ iter->mask = ULONG_MAX;
+ }
+ else {
+ iter->size_level = 1;
+ iter->mask = 1UL << (root->index_bits - 1);
+ }
}
return iter->cur;
}
@@ -347,8 +351,16 @@ static inline struct prio_tree_node *__p
iter->size_level++;
}
else {
- iter->size_level = 1;
- iter->mask = 1UL << (root->index_bits - 1);
+ if (iter->size_level) {
+ BUG_ON(!prio_tree_left_empty(iter->cur));
+ BUG_ON(!prio_tree_right_empty(iter->cur));
+ iter->size_level++;
+ iter->mask = ULONG_MAX;
+ }
+ else {
+ iter->size_level = 1;
+ iter->mask = 1UL << (root->index_bits - 1);
+ }
}
return iter->cur;
}
@@ -360,13 +372,15 @@ static inline struct prio_tree_node *__p
struct prio_tree_iter *iter)
{
iter->cur = iter->cur->parent;
- iter->mask <<= 1;
- if (iter->size_level) {
- if (iter->size_level == 1)
- iter->mask = 1UL;
+ if (iter->mask == ULONG_MAX)
+ iter->mask = 1UL;
+ else if (iter->size_level == 1)
+ iter->mask = 1UL;
+ else
+ iter->mask <<= 1;
+ if (iter->size_level)
iter->size_level--;
- }
- else if (iter->value & iter->mask)
+ if (!iter->size_level && (iter->value & iter->mask))
iter->value ^= iter->mask;
return iter->cur;
}
_
--
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-mm.org/ .
Don't email: <a href=mailto:"aart@kvack.org"> aart@kvack.org </a>
next prev parent reply other threads:[~2004-04-05 3:14 UTC|newest]
Thread overview: 92+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <Pine.LNX.4.44.0403150527400.28579-100000@localhost.localdomain>
2004-03-21 22:10 ` Rajesh Venkatasubramanian
2004-03-21 22:12 ` [RFC][PATCH 2/3] Dave & Hugh's objrmap patch Rajesh Venkatasubramanian
2004-03-21 22:13 ` [RFC][PATCH 3/3] Covert objrmap to use prio_tree Rajesh Venkatasubramanian
2004-03-21 22:26 ` URL typo Rajesh Venkatasubramanian
2004-03-22 0:46 ` [RFC][PATCH 1/3] radix priority search tree - objrmap complexity fix Andrea Arcangeli
2004-03-22 2:32 ` Rik van Riel
2004-03-22 3:49 ` Rajesh Venkatasubramanian
2004-03-22 4:02 ` Rik van Riel
2004-03-25 22:59 ` Andrea Arcangeli
2004-03-26 4:06 ` Rajesh Venkatasubramanian
2004-03-26 7:53 ` Andrea Arcangeli
2004-03-26 15:43 ` Rajesh Venkatasubramanian
2004-03-26 17:58 ` Andrea Arcangeli
2004-03-27 19:51 ` Rajesh Venkatasubramanian
2004-03-29 17:22 ` Andrea Arcangeli
2004-03-29 17:50 ` Rajesh Venkatasubramanian
2004-03-29 18:01 ` Andrea Arcangeli
2004-03-29 20:40 ` Andrew Morton
2004-03-29 22:24 ` Hugh Dickins
2004-03-29 22:54 ` Andrea Arcangeli
2004-03-29 23:08 ` William Lee Irwin III
2004-03-29 22:39 ` Andrea Arcangeli
2004-03-29 22:42 ` Andrew Morton
2004-03-31 15:07 ` Andrea Arcangeli
2004-03-31 15:26 ` Andrea Arcangeli
2004-03-31 16:45 ` Hugh Dickins
2004-03-31 17:28 ` Andrea Arcangeli
2004-04-01 0:45 ` Andrea Arcangeli
2004-04-01 1:22 ` Andrew Morton
2004-04-01 1:26 ` Andrea Arcangeli
2004-04-01 1:51 ` Andrew Morton
2004-04-01 2:01 ` Andrea Arcangeli
2004-04-01 5:05 ` Hugh Dickins
2004-04-01 13:35 ` Andrea Arcangeli
2004-04-01 15:09 ` Andrea Arcangeli
2004-04-01 15:15 ` Andrea Arcangeli
2004-04-02 0:15 ` Andrea Arcangeli
2004-04-02 0:52 ` Andrew Morton
2004-04-02 1:06 ` Andrea Arcangeli
2004-04-02 1:03 ` Hugh Dickins
2004-04-02 1:16 ` Andrea Arcangeli
2004-04-02 1:36 ` Andrew Morton
2004-04-02 2:00 ` Andrea Arcangeli
2004-04-02 2:08 ` Andrew Morton
2004-04-02 2:22 ` Andrea Arcangeli
2004-04-02 6:05 ` Christoph Hellwig
2004-04-02 7:07 ` Paul Mackerras
2004-04-02 7:11 ` Christoph Hellwig
2004-04-02 15:28 ` Andrea Arcangeli
2004-04-02 15:22 ` Andrea Arcangeli
2004-04-02 15:27 ` Christoph Hellwig
2004-04-02 15:38 ` Andrea Arcangeli
2004-04-02 15:45 ` Andrea Arcangeli
2004-04-02 9:43 ` Christoph Hellwig
2004-04-02 10:21 ` Marc-Christian Petersen
2004-04-02 10:55 ` Hugh Dickins
2004-04-02 16:46 ` Andrea Arcangeli
2004-04-02 18:59 ` Christoph Hellwig
2004-04-02 19:29 ` Andrea Arcangeli
2004-04-02 19:54 ` Christoph Hellwig
2004-04-02 20:35 ` Andrea Arcangeli
2004-04-03 8:40 ` Christoph Hellwig
2004-04-03 15:20 ` Andrea Arcangeli
2004-04-03 15:59 ` Andrea Arcangeli
2004-04-03 17:02 ` Andrea Arcangeli
2004-04-05 9:59 ` Christoph Hellwig
2004-04-05 12:11 ` Christoph Hellwig
2004-04-05 16:08 ` Andrea Arcangeli
2004-04-06 4:22 ` Andrea Arcangeli
2004-04-06 4:43 ` Andrew Morton
2004-04-06 5:14 ` Christoph Hellwig
2004-04-06 21:54 ` Andrea Arcangeli
2004-04-07 1:39 ` Nathan Scott
2004-04-06 5:16 ` Christoph Hellwig
2004-04-06 16:01 ` Andrea Arcangeli
2004-04-07 1:33 ` Nathan Scott
2004-04-03 17:40 ` Andrea Arcangeli
2004-04-03 20:02 ` Andrew Morton
2004-04-03 23:27 ` Andrea Arcangeli
2004-04-03 23:46 ` Andrew Morton
2004-04-04 0:40 ` Andrea Arcangeli
2004-04-02 20:13 ` Pavel Machek
2004-04-02 21:42 ` Andrea Arcangeli
2004-04-02 21:45 ` Pavel Machek
2004-04-02 21:49 ` Andrea Arcangeli
2004-03-29 18:12 ` Hugh Dickins
2004-03-29 18:20 ` Andrea Arcangeli
2004-03-29 18:38 ` Christoph Hellwig
2004-04-05 3:14 ` Rajesh Venkatasubramanian [this message]
2004-04-05 4:42 ` Andrea Arcangeli
2004-03-26 12:26 ` William Lee Irwin III
2004-03-26 19:18 ` 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=Pine.LNX.4.58.0404042311380.19523@red.engin.umich.edu \
--to=vrajesh@umich.edu \
--cc=akpm@osdl.org \
--cc=andrea@suse.de \
--cc=hugh@veritas.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mbligh@aracnet.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