From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751440Ab2GGOmm (ORCPT ); Sat, 7 Jul 2012 10:42:42 -0400 Received: from mga11.intel.com ([192.55.52.93]:26007 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751288Ab2GGOmk (ORCPT ); Sat, 7 Jul 2012 10:42:40 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.71,315,1320652800"; d="scan'208";a="174496420" Date: Sat, 7 Jul 2012 22:42:28 +0800 From: Fengguang Wu To: Kamezawa Hiroyuki Cc: Sha Zhengju , linux-mm@kvack.org, cgroups@vger.kernel.org, gthelen@google.com, yinghan@google.com, akpm@linux-foundation.org, mhocko@suse.cz, linux-kernel@vger.kernel.org, torvalds@linux-foundation.org, viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, Sha Zhengju Subject: Re: [PATCH 3/7] Make TestSetPageDirty and dirty page accounting in one func Message-ID: <20120707144228.GA24329@localhost> References: <1340880885-5427-1-git-send-email-handai.szj@taobao.com> <1340881275-5651-1-git-send-email-handai.szj@taobao.com> <4FF1827A.7060806@jp.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4FF1827A.7060806@jp.fujitsu.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 02, 2012 at 08:14:02PM +0900, KAMEZAWA Hiroyuki wrote: > (2012/06/28 20:01), Sha Zhengju wrote: > > From: Sha Zhengju > > > > Commit a8e7d49a(Fix race in create_empty_buffers() vs __set_page_dirty_buffers()) > > extracts TestSetPageDirty from __set_page_dirty and is far away from > > account_page_dirtied.But it's better to make the two operations in one single > > function to keep modular.So in order to avoid the potential race mentioned in > > commit a8e7d49a, we can hold private_lock until __set_page_dirty completes. > > I guess there's no deadlock between ->private_lock and ->tree_lock by quick look. > > > > It's a prepare patch for following memcg dirty page accounting patches. > > > > Signed-off-by: Sha Zhengju > > I think there is no problem with the lock order. Me think so, too. > My small concern is the impact on the performance. IIUC, lock contention here can be > seen if multiple threads write to the same file in parallel. > Do you have any numbers before/after the patch ? That would be a worthwhile test. The patch moves ->tree_lock and ->i_lock into ->private_lock, these are often contented locks.. For example, in the below case of 12 hard disks, each running 1 dd write, the ->tree_lock and ->private_lock have the top #1 and #2 contentions. lkp-nex04/JBOD-12HDD-thresh=1000M/ext4-1dd-1-3.3.0/lock_stat ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- class name con-bounces contentions waittime-min waittime-max waittime-total acq-bounces acquisitions holdtime-min holdtime-max holdtime-total ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- &(&mapping->tree_lock)->rlock: 18629034 19138284 0.09 1029.32 24353812.07 49650988 482883410 0.11 186.88 260706119.09 ----------------------------- &(&mapping->tree_lock)->rlock 783 [] tag_pages_for_writeback+0x2b/0x9d &(&mapping->tree_lock)->rlock 3195817 [] add_to_page_cache_locked+0xa3/0x119 &(&mapping->tree_lock)->rlock 3863710 [] test_set_page_writeback+0x63/0x140 &(&mapping->tree_lock)->rlock 3311518 [] __set_page_dirty+0x25/0xa5 ----------------------------- &(&mapping->tree_lock)->rlock 3450725 [] add_to_page_cache_locked+0xa3/0x119 &(&mapping->tree_lock)->rlock 3225542 [] __set_page_dirty+0x25/0xa5 &(&mapping->tree_lock)->rlock 2241958 [] test_set_page_writeback+0x63/0x140 &(&mapping->tree_lock)->rlock 7339603 [] test_clear_page_writeback+0x64/0x155 ............................................................................................................................................................................................... &(&mapping->private_lock)->rlock: 1165199 1191201 0.11 2843.25 1621608.38 13341420 152761848 0.10 3727.92 33559035.07 -------------------------------- &(&mapping->private_lock)->rlock 1 [] __find_get_block_slow+0x5a/0x135 &(&mapping->private_lock)->rlock 385576 [] create_empty_buffers+0x48/0xbf &(&mapping->private_lock)->rlock 805624 [] try_to_free_buffers+0x57/0xaa -------------------------------- &(&mapping->private_lock)->rlock 1 [] __getblk+0x1b8/0x257 &(&mapping->private_lock)->rlock 952718 [] try_to_free_buffers+0x57/0xaa &(&mapping->private_lock)->rlock 238482 [] create_empty_buffers+0x48/0xbf Thanks, Fengguang From mboxrd@z Thu Jan 1 00:00:00 1970 From: Fengguang Wu Subject: Re: [PATCH 3/7] Make TestSetPageDirty and dirty page accounting in one func Date: Sat, 7 Jul 2012 22:42:28 +0800 Message-ID: <20120707144228.GA24329@localhost> References: <1340880885-5427-1-git-send-email-handai.szj@taobao.com> <1340881275-5651-1-git-send-email-handai.szj@taobao.com> <4FF1827A.7060806@jp.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Sha Zhengju , linux-mm@kvack.org, cgroups@vger.kernel.org, gthelen@google.com, yinghan@google.com, akpm@linux-foundation.org, mhocko@suse.cz, linux-kernel@vger.kernel.org, torvalds@linux-foundation.org, viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, Sha Zhengju To: Kamezawa Hiroyuki Return-path: Content-Disposition: inline In-Reply-To: <4FF1827A.7060806@jp.fujitsu.com> Sender: owner-linux-mm@kvack.org List-Id: linux-fsdevel.vger.kernel.org On Mon, Jul 02, 2012 at 08:14:02PM +0900, KAMEZAWA Hiroyuki wrote: > (2012/06/28 20:01), Sha Zhengju wrote: > > From: Sha Zhengju > > > > Commit a8e7d49a(Fix race in create_empty_buffers() vs __set_page_dirty_buffers()) > > extracts TestSetPageDirty from __set_page_dirty and is far away from > > account_page_dirtied.But it's better to make the two operations in one single > > function to keep modular.So in order to avoid the potential race mentioned in > > commit a8e7d49a, we can hold private_lock until __set_page_dirty completes. > > I guess there's no deadlock between ->private_lock and ->tree_lock by quick look. > > > > It's a prepare patch for following memcg dirty page accounting patches. > > > > Signed-off-by: Sha Zhengju > > I think there is no problem with the lock order. Me think so, too. > My small concern is the impact on the performance. IIUC, lock contention here can be > seen if multiple threads write to the same file in parallel. > Do you have any numbers before/after the patch ? That would be a worthwhile test. The patch moves ->tree_lock and ->i_lock into ->private_lock, these are often contented locks.. For example, in the below case of 12 hard disks, each running 1 dd write, the ->tree_lock and ->private_lock have the top #1 and #2 contentions. lkp-nex04/JBOD-12HDD-thresh=1000M/ext4-1dd-1-3.3.0/lock_stat ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- class name con-bounces contentions waittime-min waittime-max waittime-total acq-bounces acquisitions holdtime-min holdtime-max holdtime-total ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- &(&mapping->tree_lock)->rlock: 18629034 19138284 0.09 1029.32 24353812.07 49650988 482883410 0.11 186.88 260706119.09 ----------------------------- &(&mapping->tree_lock)->rlock 783 [] tag_pages_for_writeback+0x2b/0x9d &(&mapping->tree_lock)->rlock 3195817 [] add_to_page_cache_locked+0xa3/0x119 &(&mapping->tree_lock)->rlock 3863710 [] test_set_page_writeback+0x63/0x140 &(&mapping->tree_lock)->rlock 3311518 [] __set_page_dirty+0x25/0xa5 ----------------------------- &(&mapping->tree_lock)->rlock 3450725 [] add_to_page_cache_locked+0xa3/0x119 &(&mapping->tree_lock)->rlock 3225542 [] __set_page_dirty+0x25/0xa5 &(&mapping->tree_lock)->rlock 2241958 [] test_set_page_writeback+0x63/0x140 &(&mapping->tree_lock)->rlock 7339603 [] test_clear_page_writeback+0x64/0x155 ............................................................................................................................................................................................... &(&mapping->private_lock)->rlock: 1165199 1191201 0.11 2843.25 1621608.38 13341420 152761848 0.10 3727.92 33559035.07 -------------------------------- &(&mapping->private_lock)->rlock 1 [] __find_get_block_slow+0x5a/0x135 &(&mapping->private_lock)->rlock 385576 [] create_empty_buffers+0x48/0xbf &(&mapping->private_lock)->rlock 805624 [] try_to_free_buffers+0x57/0xaa -------------------------------- &(&mapping->private_lock)->rlock 1 [] __getblk+0x1b8/0x257 &(&mapping->private_lock)->rlock 952718 [] try_to_free_buffers+0x57/0xaa &(&mapping->private_lock)->rlock 238482 [] create_empty_buffers+0x48/0xbf Thanks, Fengguang -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org