diff mbox

[RFC,2/3] list_lru: add a new LRU_SKIP_REST lru_status value and handling

Message ID 1386241253-5781-3-git-send-email-jlayton@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jeff Layton Dec. 5, 2013, 11 a.m. UTC
The current list_lru_walk_node implementation always walks the entire
list. In some cases, we can be sure that when an entry isn't freeable
that none of the rest of the entries on the list will be either.

Create a new LRU_SKIP_REST return value that not only indicates that
the current entry was skipped, but that caller should stop scanning
the current node.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
---
 include/linux/list_lru.h | 2 ++
 mm/list_lru.c            | 4 +++-
 2 files changed, 5 insertions(+), 1 deletion(-)

Comments

Christoph Hellwig Dec. 5, 2013, 1:30 p.m. UTC | #1
On Thu, Dec 05, 2013 at 06:00:52AM -0500, Jeff Layton wrote:
> The current list_lru_walk_node implementation always walks the entire
> list. In some cases, we can be sure that when an entry isn't freeable
> that none of the rest of the entries on the list will be either.
> 
> Create a new LRU_SKIP_REST return value that not only indicates that
> the current entry was skipped, but that caller should stop scanning
> the current node.
> 
> Signed-off-by: Jeff Layton <jlayton@redhat.com>

I'd call it LRU_DONE, but otherwise this looks fine to me.

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jeff Layton Dec. 5, 2013, 1:36 p.m. UTC | #2
On Thu, 5 Dec 2013 05:30:08 -0800
Christoph Hellwig <hch@infradead.org> wrote:

> On Thu, Dec 05, 2013 at 06:00:52AM -0500, Jeff Layton wrote:
> > The current list_lru_walk_node implementation always walks the entire
> > list. In some cases, we can be sure that when an entry isn't freeable
> > that none of the rest of the entries on the list will be either.
> > 
> > Create a new LRU_SKIP_REST return value that not only indicates that
> > the current entry was skipped, but that caller should stop scanning
> > the current node.
> > 
> > Signed-off-by: Jeff Layton <jlayton@redhat.com>
> 
> I'd call it LRU_DONE, but otherwise this looks fine to me.
> 

Ok, if we end up taking this in I'll change the name...

Thanks,
diff mbox

Patch

diff --git a/include/linux/list_lru.h b/include/linux/list_lru.h
index 3ce5417..6140c3a 100644
--- a/include/linux/list_lru.h
+++ b/include/linux/list_lru.h
@@ -15,6 +15,8 @@  enum lru_status {
 	LRU_REMOVED,		/* item removed from list */
 	LRU_ROTATE,		/* item referenced, give another pass */
 	LRU_SKIP,		/* item cannot be locked, skip */
+	LRU_SKIP_REST,		/* item isn't freeable, and none of the rest
+				   on the list will be either */
 	LRU_RETRY,		/* item not freeable. May drop the lock
 				   internally, but has to return locked. */
 };
diff --git a/mm/list_lru.c b/mm/list_lru.c
index 72f9dec..abec7fb 100644
--- a/mm/list_lru.c
+++ b/mm/list_lru.c
@@ -98,6 +98,8 @@  restart:
 			break;
 		case LRU_SKIP:
 			break;
+		case LRU_SKIP_REST:
+			goto done;
 		case LRU_RETRY:
 			/*
 			 * The lru lock has been dropped, our list traversal is
@@ -108,7 +110,7 @@  restart:
 			BUG();
 		}
 	}
-
+done:
 	spin_unlock(&nlru->lock);
 	return isolated;
 }