linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
To: Theodore Ts'o <tytso@mit.edu>,
	linux-kernel@vger.kernel.org, David Howells <dhowells@redhat.com>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org,
	Dmitry Monakhov <dmtrmonakhov@yandex-team.ru>
Subject: [PATCH RFC] ext4: skip concurrent inode updates in lazytime optimization
Date: Wed, 29 Jan 2020 18:44:05 +0300	[thread overview]
Message-ID: <158031264567.6836.126132376018905207.stgit@buzz> (raw)

Function ext4_update_other_inodes_time() implements optimization which
opportunistically updates times for inodes within same inode table block.

For now	concurrent inode lookup by number does not scale well because
inode hash table is protected with single spinlock. It could become very
hot at concurrent writes to fast nvme when inode cache has enough inodes.

Probably someday inode hash will become searchable under RCU.
(see linked patchset by David Howells)

Let's skip concurrent updates instead of wasting cpu time at spinlock.

Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Link: https://lore.kernel.org/lkml/155620449631.4720.8762546550728087460.stgit@warthog.procyon.org.uk/
---
 fs/ext4/inode.c |    7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 629a25d999f0..dc3e1b38e3ed 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -4849,11 +4849,16 @@ static int other_inode_match(struct inode * inode, unsigned long ino,
 static void ext4_update_other_inodes_time(struct super_block *sb,
 					  unsigned long orig_ino, char *buf)
 {
+	static DEFINE_SPINLOCK(lock);
 	struct other_inode oi;
 	unsigned long ino;
 	int i, inodes_per_block = EXT4_SB(sb)->s_inodes_per_block;
 	int inode_size = EXT4_INODE_SIZE(sb);
 
+	/* Don't bother inode_hash_lock with concurrent updates. */
+	if (!spin_trylock(&lock))
+		return;
+
 	oi.orig_ino = orig_ino;
 	/*
 	 * Calculate the first inode in the inode table block.  Inode
@@ -4867,6 +4872,8 @@ static void ext4_update_other_inodes_time(struct super_block *sb,
 		oi.raw_inode = (struct ext4_inode *) buf;
 		(void) find_inode_nowait(sb, ino, other_inode_match, &oi);
 	}
+
+	spin_unlock(&lock);
 }
 
 /*


             reply	other threads:[~2020-01-29 15:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-29 15:44 Konstantin Khlebnikov [this message]
2020-01-29 19:53 ` [PATCH RFC] ext4: skip concurrent inode updates in lazytime optimization Andreas Dilger
2020-01-29 22:15 ` Theodore Y. Ts'o

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=158031264567.6836.126132376018905207.stgit@buzz \
    --to=khlebnikov@yandex-team.ru \
    --cc=dhowells@redhat.com \
    --cc=dmtrmonakhov@yandex-team.ru \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tytso@mit.edu \
    --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;
as well as URLs for NNTP newsgroup(s).