public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
From: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
To: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org,
	Theodore Ts'o <tytso@mit.edu>,
	linux-kernel@vger.kernel.org,
	Alexander Viro <viro@zeniv.linux.org.uk>
Cc: David Howells <dhowells@redhat.com>,
	Andreas Dilger <adilger@dilger.ca>,
	Dmitry Monakhov <dmtrmonakhov@yandex-team.ru>
Subject: [PATCH v2 2/2] ext4: avoid spinlock congestion in lazytime optimization
Date: Thu, 30 Jan 2020 20:40:34 +0300	[thread overview]
Message-ID: <158040603451.1879.7954684107752709143.stgit@buzz> (raw)
In-Reply-To: <158040603214.1879.6549790415691475804.stgit@buzz>

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.

Let's use here non-blocking variant of function find_inode_nowait() and
skip opportunistic inode updates if spinlock is congested.


Synthetic testcase by Dmitry Monakhov:

modprobe brd rd_size=10240000 rd_nr=1
mkfs.ext4 -F -I 256 -b 4096 -q /dev/ram0
mkdir -p m
mount /dev/ram0 m -o lazytime,noload,barrier=0
mkdir m/{0..31}
fio --ioengine=ftruncate --direct=1 --bs=4k --filesize=16m --time_based=1 \
--runtime=10 --numjobs=32 --group_reporting --norandommap --name=write-32 \
--rw=randwrite --directory=m --filename_format='$jobnum/t'
umount m
rmdir m
rmmod brd

Before patch:	50k op/s
After patch:	3000k op/s

Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Cc: Dmitry Monakhov <dmtrmonakhov@yandex-team.ru>
Link: https://lore.kernel.org/lkml/158031264567.6836.126132376018905207.stgit@buzz/T/#u (v1)
---
 fs/ext4/inode.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 9512eb771820..3dea7327e7ab 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -4853,6 +4853,7 @@ static void ext4_update_other_inodes_time(struct super_block *sb,
 	unsigned long ino;
 	int i, inodes_per_block = EXT4_SB(sb)->s_inodes_per_block;
 	int inode_size = EXT4_INODE_SIZE(sb);
+	struct inode *res;
 
 	oi.orig_ino = orig_ino;
 	/*
@@ -4865,7 +4866,10 @@ static void ext4_update_other_inodes_time(struct super_block *sb,
 		if (ino == orig_ino)
 			continue;
 		oi.raw_inode = (struct ext4_inode *) buf;
-		(void)find_inode_nowait(sb, ino, other_inode_match, &oi, false);
+		/* Try to find inode, stop if inode_hash_lock is congested. */
+		res = find_inode_nowait(sb, ino, other_inode_match, &oi, true);
+		if (res == ERR_PTR(-EAGAIN))
+			break;
 	}
 }
 


  reply	other threads:[~2020-01-30 17:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-30 17:40 [PATCH v2 1/2] vfs: add non-blocking mode for function find_inode_nowait() Konstantin Khlebnikov
2020-01-30 17:40 ` Konstantin Khlebnikov [this message]
2020-03-09 16:12 ` David Howells

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=158040603451.1879.7954684107752709143.stgit@buzz \
    --to=khlebnikov@yandex-team.ru \
    --cc=adilger@dilger.ca \
    --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