linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@poochiereds.net>
To: bfields@fieldses.org
Cc: linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org
Subject: [PATCH v4 02/16] list_lru: add list_lru_rotate
Date: Fri, 11 Sep 2015 06:54:28 -0400	[thread overview]
Message-ID: <1441968882-7851-3-git-send-email-jeff.layton@primarydata.com> (raw)
In-Reply-To: <1441968882-7851-1-git-send-email-jeff.layton@primarydata.com>

Add a function that can move an entry to the MRU end of the list.

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org
Reviewed-by: Vladimir Davydov <vdavydov@parallels.com>
Signed-off-by: Jeff Layton <jeff.layton@primarydata.com>
---
 include/linux/list_lru.h | 13 +++++++++++++
 mm/list_lru.c            | 15 +++++++++++++++
 2 files changed, 28 insertions(+)

diff --git a/include/linux/list_lru.h b/include/linux/list_lru.h
index 2a6b9947aaa3..4534b1b34d2d 100644
--- a/include/linux/list_lru.h
+++ b/include/linux/list_lru.h
@@ -96,6 +96,19 @@ bool list_lru_add(struct list_lru *lru, struct list_head *item);
 bool list_lru_del(struct list_lru *lru, struct list_head *item);
 
 /**
+ * list_lru_rotate: rotate an element to the end of an lru list
+ * @list_lru: the lru pointer
+ * @item: the item to be rotated
+ *
+ * This function moves an entry to the end of an LRU list. Should be used when
+ * an entry that is on the LRU is used, and should be moved to the MRU end of
+ * the list. If the item is not on a list, then this function has no effect.
+ * The comments about an element already pertaining to a list are also valid
+ * for list_lru_rotate.
+ */
+void list_lru_rotate(struct list_lru *lru, struct list_head *item);
+
+/**
  * list_lru_count_one: return the number of objects currently held by @lru
  * @lru: the lru pointer.
  * @nid: the node id to count from.
diff --git a/mm/list_lru.c b/mm/list_lru.c
index e1da19fac1b3..66718c2a9a7b 100644
--- a/mm/list_lru.c
+++ b/mm/list_lru.c
@@ -130,6 +130,21 @@ bool list_lru_del(struct list_lru *lru, struct list_head *item)
 }
 EXPORT_SYMBOL_GPL(list_lru_del);
 
+void list_lru_rotate(struct list_lru *lru, struct list_head *item)
+{
+	int nid = page_to_nid(virt_to_page(item));
+	struct list_lru_node *nlru = &lru->node[nid];
+	struct list_lru_one *l;
+
+	spin_lock(&nlru->lock);
+	if (!list_empty(item)) {
+		l = list_lru_from_kmem(nlru, item);
+		list_move_tail(item, &l->list);
+	}
+	spin_unlock(&nlru->lock);
+}
+EXPORT_SYMBOL_GPL(list_lru_rotate);
+
 void list_lru_isolate(struct list_lru_one *list, struct list_head *item)
 {
 	list_del_init(item);
-- 
2.4.3

--
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:"dont@kvack.org"> email@kvack.org </a>

  parent reply	other threads:[~2015-09-11 10:54 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-11 10:54 [PATCH v4 00/16] nfsd: open file caching Jeff Layton
2015-09-11 10:54 ` [PATCH v4 01/16] locks: change tracepoint for generic_add_lease Jeff Layton
2015-09-11 10:54 ` Jeff Layton [this message]
2015-09-11 10:54 ` [PATCH v4 03/16] fs: allow __fput_sync to be used by non-kthreads and in modules Jeff Layton
     [not found]   ` <1441968882-7851-4-git-send-email-jeff.layton-7I+n7zu2hftEKMMhf/gKZA@public.gmane.org>
2015-09-11 14:00     ` Al Viro
     [not found]       ` <20150911140049.GN22011-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@public.gmane.org>
2015-09-11 14:38         ` Jeff Layton
2015-09-11 10:54 ` [PATCH v4 04/16] fsnotify: export several symbols Jeff Layton
     [not found] ` <1441968882-7851-1-git-send-email-jeff.layton-7I+n7zu2hftEKMMhf/gKZA@public.gmane.org>
2015-09-11 10:54   ` [PATCH v4 05/16] locks: create a new notifier chain for lease attempts Jeff Layton
2015-09-11 10:54   ` [PATCH v4 08/16] nfsd: add a new struct file caching facility to nfsd Jeff Layton
2015-09-11 10:54   ` [PATCH v4 09/16] nfsd: hook up nfsd_write to the new nfsd_file cache Jeff Layton
2015-09-11 10:54   ` [PATCH v4 10/16] nfsd: hook up nfsd_read to the " Jeff Layton
2015-09-11 10:54   ` [PATCH v4 11/16] nfsd: hook nfsd_commit up " Jeff Layton
2015-09-11 10:54   ` [PATCH v4 13/16] nfsd: have nfsd_test_lock use " Jeff Layton
2015-09-11 10:54   ` [PATCH v4 15/16] nfsd: hook up nfs4_preprocess_stateid_op to " Jeff Layton
2015-09-11 10:54 ` [PATCH v4 06/16] nfsd: move include of state.h from trace.c to trace.h Jeff Layton
2015-09-11 10:54 ` [PATCH v4 07/16] sunrpc: add a new cache_detail operation for when a cache is flushed Jeff Layton
2015-09-11 10:54 ` [PATCH v4 12/16] nfsd: convert nfs4_file->fi_fds array to use nfsd_files Jeff Layton
2015-09-11 10:54 ` [PATCH v4 14/16] nfsd: convert fi_deleg_file and ls_file fields to nfsd_file Jeff Layton
2015-09-11 10:54 ` [PATCH v4 16/16] nfsd: rip out the raparms cache Jeff Layton

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=1441968882-7851-3-git-send-email-jeff.layton@primarydata.com \
    --to=jlayton@poochiereds.net \
    --cc=akpm@linux-foundation.org \
    --cc=bfields@fieldses.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-nfs@vger.kernel.org \
    /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).