mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: mc@linux.vnet.ibm.com
To: Jan Kara <jack@suse.cz>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] VFS: Go through the LRU list of inode from head
Date: Tue, 26 Jun 2012 03:35:46 -0400	[thread overview]
Message-ID: <20120626033546.Horde.D-JZIpir309P6WZSsiFCifA@imap.linux.ibm.com> (raw)
In-Reply-To: <20120621095223.GA11645@quack.suse.cz>


Quoting Jan Kara <jack@suse.cz>:

> On Thu 21-06-12 17:00:27, Cong Meng wrote:
>> Go through the LRU list of inode from head.
>>
>> (I'm not sure whether there is any trick here I doesn't get.  If yes,
>> any one could explain it)
>   Look at inode_lru_list_add(). It adds at the head of the list. So you
> should take from the tail to get the least recently used element...

I still have a quetion about the subsequent code and comment:

inode = list_entry(sb->s_inode_lru.prev, struct inode, i_lru);
/*
  * we are inverting the sb->s_inode_lru_lock/inode->i_lock here,
  * so use a trylock. If we fail to get the lock, just move the
  * inode to the back of the list so we don't spin on it.
  */
if (!spin_trylock(&inode->i_lock)) {
         list_move_tail(&inode->i_lru, &sb->s_inode_lru);
         continue;
}

Shouldn't the inode be moved to the head to avoid spin on it?
I note that list_move was replaced by list_move_tail purposely in a commit.


and below piece of code (at the bottom of prune_icache_sb()):

if (inode != list_entry(sb->s_inode_lru.next,
                         struct inode, i_lru))
         continue;       /* wrong inode or list_empty */

Should the inode be compared against to the tail of the list other  
than the head
after re-get the lru lock?

thanks.
cong.
>
> 								Honza
>
>>
>> Signed-off-by: Cong Meng <mc@linux.vnet.ibm.com>
>> ---
>>  fs/inode.c |    2 +-
>>  1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/fs/inode.c b/fs/inode.c
>> index 775cbab..aac8449 100644
>> --- a/fs/inode.c
>> +++ b/fs/inode.c
>> @@ -704,7 +704,7 @@ void prune_icache_sb(struct super_block *sb,  
>> int nr_to_scan)
>>  		if (list_empty(&sb->s_inode_lru))
>>  			break;
>>
>> -		inode = list_entry(sb->s_inode_lru.prev, struct inode, i_lru);
>> +		inode = list_entry(sb->s_inode_lru.next, struct inode, i_lru);
>>
>>  		/*
>>  		 * we are inverting the sb->s_inode_lru_lock/inode->i_lock here,
>> --
>> 1.7.5.4
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> --
> Jan Kara <jack@suse.cz>
> SUSE Labs, CR




  reply	other threads:[~2012-06-26  7:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-21  9:00 Cong Meng
2012-06-21  9:47 ` Wanpeng Li
2012-06-21  9:52 ` Jan Kara
2012-06-26  7:35   ` mc [this message]
2012-06-27 16:08     ` Jan Kara

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=20120626033546.Horde.D-JZIpir309P6WZSsiFCifA@imap.linux.ibm.com \
    --to=mc@linux.vnet.ibm.com \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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

all inboxes | Powered by JetHome®