From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751915AbcFIUKx (ORCPT ); Thu, 9 Jun 2016 16:10:53 -0400 Received: from mga03.intel.com ([134.134.136.65]:12559 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751090AbcFIUKw convert rfc822-to-8bit (ORCPT ); Thu, 9 Jun 2016 16:10:52 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,446,1459839600"; d="scan'208";a="998809981" From: "Chen, Tim C" To: "Hansen, Dave" , Ingo Molnar , Waiman Long CC: Linus Torvalds , Ingo Molnar , Davidlohr Bueso , "Peter Zijlstra (Intel)" , Jason Low , "Michel Lespinasse" , "Paul E. McKenney" , Waiman Long , Al Viro , LKML Subject: RE: performance delta after VFS i_mutex=>i_rwsem conversion Thread-Topic: performance delta after VFS i_mutex=>i_rwsem conversion Thread-Index: AQHRwC4gWmfBBoBkZUWS8fet0B/ugp/dXfWAgAAHnQCAAldNgIABqrYAgACDDAD//6eLsA== Date: Thu, 9 Jun 2016 20:10:49 +0000 Message-ID: <045D8A5597B93E4EBEDDCBF1FC15F50935A8B538@fmsmsx104.amr.corp.intel.com> References: <5755D671.9070908@intel.com> <5755E782.90800@hpe.com> <20160608085837.GA10792@gmail.com> <20160609102552.GA16968@gmail.com> <5759B21E.2030003@intel.com> In-Reply-To: <5759B21E.2030003@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNzIwN2RlZGQtOGQ5Ni00YWQ1LWJmMzItNjQzOWZiZmNhZTUyIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6ImczOFk1SzA0MUhcL0ltRVk3aW0weEFxZnNhTFJYYzZLTVNPakFhQmxnZEJRPSJ9 x-ctpclassification: CTP_IC x-originating-ip: [10.1.200.108] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org >> Ok, these enhancements are now in the locking tree and are queued up for >v4.8: >> >> git pull git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git >> locking/core >> >> Dave, you might want to check your numbers with these changes: is >> rwsem performance still significantly worse than mutex performance? > >It's substantially closer than it was, but there's probably a little work still to do. >The rwsem still looks to be sleeping a lot more than the mutex. Here's where >we started: > > https://www.sr71.net/~dave/intel/rwsem-vs-mutex.png > >The rwsem peaked lower and earlier than the mutex code. Now, if we compare >the old (4.7-rc1) rwsem code to the newly-patched rwsem code (from >tip/locking): > >> https://www.sr71.net/~dave/intel/bb.html?1=4.7.0-rc1&2=4.7.0-rc1-00127 >> -gd4c3be7 > >We can see the peak is a bit higher and more importantly, it's more of a plateau >than a sharp peak. We can also compare the new rwsem code to the 4.5 code >that had the mutex in place: > >> https://www.sr71.net/~dave/intel/bb.html?1=4.5.0-rc6&2=4.7.0-rc1-00127 >> -gd4c3be7 > >rwsems are still a _bit_ below the mutex code at the peak, and they also seem >to be substantially lower during the tail from 20 cpus on up. The rwsems are >sleeping less than they were before the tip/locking updates, but they are still >idling the CPUs 90% of the time while the mutexes end up idle 15-20% of the >time when all the cpus are contending on the lock. In Al Viro's conversion, he introduced inode_lock_shared which uses read lock in lookup_slow. The rwsem does bail out of optimistic spin when readers acquire the lock, thus causing us to see a lot less optimistic spinning attempts for the unlink test case. Whereas earlier for mutex, we will keep spinning. A simple test may be to see if we get similar performance when changing inode_lock_shared to the writer version. That said, hopefully we should have a lot more read locking than write locking (i.e. more path look up than changes to the path) so the switch to rwsem is still a win. I guess the lesson here is when there is an equal mix of writers and readers, rwsem could be a bit worse in performance than mutex as we don't spin as hard. Tim