public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Werner Almesberger <werner@almesberger.net>
To: linux-kernel@vger.kernel.org
Cc: Rajesh Venkatasubramanian <vrajesh@umich.edu>,
	Andrew Morton <akpm@osdl.org>
Subject: [PATCH 1/3] prio_tree: roll call to prio_tree_first into prio_tree_next
Date: Fri, 17 Dec 2004 15:37:57 -0300	[thread overview]
Message-ID: <20041217153757.A21393@almesberger.net> (raw)
In-Reply-To: <20041217153602.D31842@almesberger.net>; from werner@almesberger.net on Fri, Dec 17, 2004 at 03:36:02PM -0300

Allow prio_tree_next to be used as the only function for tree
traversal, similar to how vma_prio_tree_next works.

This patch isn't needed for the generalization, but since it
affects the API, it's better to include it first.

- Werner

---------------------------------- cut here -----------------------------------

Signed-off-by: Werner Almesberger <werner@almesberger.net>

--- linux-2.6.10-rc3-bk10/include/linux/prio_tree.h.orig	Fri Dec 17 01:05:14 2004
+++ linux-2.6.10-rc3-bk10/include/linux/prio_tree.h	Fri Dec 17 00:38:47 2004
@@ -29,6 +29,7 @@ static inline void prio_tree_iter_init(s
 	iter->root = root;
 	iter->r_index = r_index;
 	iter->h_index = h_index;
+	iter->cur = NULL;
 }
 
 #define INIT_PRIO_TREE_ROOT(ptr)	\
--- linux-2.6.10-rc3-bk10/mm/prio_tree.c.orig	Fri Dec 17 01:05:29 2004
+++ linux-2.6.10-rc3-bk10/mm/prio_tree.c	Fri Dec 17 00:39:02 2004
@@ -457,6 +457,9 @@ static struct prio_tree_node *prio_tree_
 {
 	unsigned long r_index, h_index;
 
+	if (iter->cur == NULL)
+		return prio_tree_first(iter);
+
 repeat:
 	while (prio_tree_left(iter, &r_index, &h_index))
 		if (overlap(iter, r_index, h_index))
@@ -620,7 +623,7 @@ struct vm_area_struct *vma_prio_tree_nex
 		/*
 		 * First call is with NULL vma
 		 */
-		ptr = prio_tree_first(iter);
+		ptr = prio_tree_next(iter);
 		if (ptr) {
 			next = prio_tree_entry(ptr, struct vm_area_struct,
 						shared.prio_tree_node);

-- 
  _________________________________________________________________________
 / Werner Almesberger, Buenos Aires, Argentina     werner@almesberger.net /
/_http://www.almesberger.net/____________________________________________/

  reply	other threads:[~2004-12-17 18:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-17 18:36 [PATCH 0/3] prio_tree generalization Werner Almesberger
2004-12-17 18:37 ` Werner Almesberger [this message]
2004-12-17 18:39 ` [PATCH 2/3] prio_tree: generalization Werner Almesberger
2004-12-17 18:40 ` [PATCH 3/3] prio_tree: move general code from mm/ to lib/ Werner Almesberger
2004-12-17 23:10   ` David Howells
2004-12-17 23:16     ` Werner Almesberger
2004-12-17 19:52 ` [PATCH 0/3] prio_tree generalization Andrew Morton

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=20041217153757.A21393@almesberger.net \
    --to=werner@almesberger.net \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vrajesh@umich.edu \
    /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