From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.suse.de ([195.135.220.15]:56355 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932398AbdJ0ApU (ORCPT ); Thu, 26 Oct 2017 20:45:20 -0400 From: NeilBrown To: paulmck@linux.vnet.ibm.com Date: Fri, 27 Oct 2017 11:45:08 +1100 Cc: Alexander Viro , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Josh Triplett Subject: Re: [PATCH] VFS: use synchronize_rcu_expedited() in namespace_unlock() In-Reply-To: <20171026122743.GX3659@linux.vnet.ibm.com> References: <87y3nyd4pu.fsf@notabene.neil.brown.name> <20171026122743.GX3659@linux.vnet.ibm.com> Message-ID: <87po99ctbf.fsf@notabene.neil.brown.name> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Sender: linux-fsdevel-owner@vger.kernel.org List-ID: --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Thu, Oct 26 2017, Paul E. McKenney wrote: > On Thu, Oct 26, 2017 at 01:26:37PM +1100, NeilBrown wrote: >>=20 >> The synchronize_rcu() in namespace_unlock() is called every time >> a filesystem is unmounted. If a great many filesystems are mounted, >> this can cause a noticable slow-down in, for example, system shutdown. >>=20 >> The sequence: >> mkdir -p /tmp/Mtest/{0..5000} >> time for i in /tmp/Mtest/*; do mount -t tmpfs tmpfs $i ; done >> time umount /tmp/Mtest/* >>=20 >> on a 4-cpu VM can report 8 seconds to mount the tmpfs filesystems, and >> 100 seconds to unmount them. >>=20 >> Boot the same VM with 1 CPU and it takes 18 seconds to mount the >> tmpfs filesystems, but only 36 to unmount. >>=20 >> If we change the synchronize_rcu() to synchronize_rcu_expedited() >> the umount time on a 4-cpu VM is 8 seconds to mount and 0.6 to >> unmount. >>=20 >> I think this 200-fold speed up is worth the slightly higher system >> impact of use synchronize_rcu_expedited(). >>=20 >> Signed-off-by: NeilBrown >> --- >>=20 >> Cc: to Paul and Josh in case they'll correct me if using _expedited() >> is really bad here. > > I suspect that filesystem unmount is pretty rare in production real-time > workloads, which are the ones that might care. So I would guess that > this is OK. > > If the real-time guys ever do want to do filesystem unmounts while their > real-time applications are running, they might modify this so that it can > use synchronize_rcu() instead for real-time builds of the kernel. Thanks for the confirmation Paul. > > But just for completeness, one way to make this work across the board > might be to instead use call_rcu(), with the callback function kicking > off a workqueue handler to do the rest of the unmount. Of course, > in saying that, I am ignoring any mutexes that you might be holding > across this whole thing, and also ignoring any problems that might arise > when returning to userspace with some portion of the unmount operation > still pending. (For example, someone unmounting a filesystem and then > immediately remounting that same filesystem.) I had briefly considered that option, but it doesn't work. The purpose of this synchronize_rcu() is to wait for any filename lookup which might be locklessly touching the mountpoint to complete. It is only after that that the real meat of unmount happen - the filesystem is told that the last reference is gone, and it gets to flush any saved changes out to disk etc. That stuff really has to happen before the umount syscall returns. Thanks, NeilBrown --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEG8Yp69OQ2HB7X0l6Oeye3VZigbkFAlnygZYACgkQOeye3VZi gbnY+xAAwUXXqoJ7lUPmMOxpWXUUgzgga8mM7ZxP/OhWhoLVYppH5cm/dkjmxBYb QU2ahnjVUws70AY6mAlsNJp2pdVi5oQXYTBRCDsbsZnJ8wbcyFWbd+F4plr1Ux4M 1BDg2R4g7kQMSae/txICU2AJ51QEq5WYSNADm4xe2HZY9S+Hx41rmbEcqQe7jjpG 2yO6iZhcjOXrtwimN/lqMVVyNlq8ObTQERNp0ZMsbMCQ/1FTsDRaXUqpHCIsKTnt 6+6DgZgHNPMuHxsE7gL/7BGY0q0ClhWmeoXlvca9uJqKOGkKYQptZB14O+VivSov BJ8AhQXnyKSU2Y2wl2ag2j8M6tIDSLuqXnF059lxWITgpqW1tw28KsxEGBjIg2Rs 87KDPsl3dgbnf8Jb9uDZG2ZHj8NBPxZTF/8jRJmP9elnEdaCUFmHsPSWYadCsIDh 5QPnoPe4LjPAyEOhcjdCqCfWgkRr8fjwnauDqDoDsoFgkiVOb3Mr8Fam8+tlQFr6 8DLN9UlNl4iRcqtvY2WKjVeqj6M8ZyPUjFkWluVNrs37QFrAMpeNzYX1y7eHtuFm lXjYFWlzm1HQ+FgKzyTva9WBW5wMUShBmSqiBeOrKH52KaK0iM6sP6RxDXeM/XxO kugXjjHpjkFyWOQNJB1k1gq4IvMrA2X6MESSZuqLc7BGROS2tKQ= =BR7C -----END PGP SIGNATURE----- --=-=-=--