Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754055AbbGBMkZ (ORCPT ); Thu, 2 Jul 2015 08:40:25 -0400 Received: from col004-omc1s17.hotmail.com ([65.55.34.27]:59379 "EHLO COL004-OMC1S17.hotmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753967AbbGBMkS (ORCPT ); Thu, 2 Jul 2015 08:40:18 -0400 X-TMN: [xwzZtVjiPVVJWmr0OF52vdKHHJhhmRXy] X-Originating-Email: [yuchaochina@hotmail.com] Message-ID: From: Chao Yu To: "'Jaegeuk Kim'" CC: , Subject: [PATCH] f2fs: reduce lock overhead of extent node releasing Date: Thu, 2 Jul 2015 20:40:12 +0800 MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 15.0 Thread-index: AdC0wxR7mNTDPhwCQgCe20kOqnlYZg== Content-Language: zh-cn X-OriginalArrivalTime: 02 Jul 2015 12:40:15.0724 (UTC) FILETIME=[3EFF1AC0:01D0B4C4] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2066 Lines: 67 >From e5c6600d01c4462c4e1ee0c70ec1d9319862077d Mon Sep 17 00:00:00 2001 From: Chao Yu Date: Thu, 2 Jul 2015 18:52:46 +0800 Subject: [PATCH] f2fs: reduce lock overhead of extent node releasing Open and close critical section for each extent node when traversing rb-tree results in high overhead of cpu, slows thing down. This patch alternates to batch mode for removing extent nodes under spin lock. Signed-off-by: Chao Yu --- fs/f2fs/data.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 6a706dd..7fb56a0 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -441,19 +441,31 @@ static unsigned int __free_extent_tree(struct f2fs_sb_info *sbi, struct extent_node *en; unsigned int count = et->count; - node = rb_first(&et->root); - while (node) { - next = rb_next(node); - en = rb_entry(node, struct extent_node, rb_node); + if (!et->count) + return 0; + + /* 1. remove all extent nodes in global lru list */ + if (free_all) { + spin_lock(&sbi->extent_lock); + node = rb_first(&et->root); + while (node) { + next = rb_next(node); + en = rb_entry(node, struct extent_node, rb_node); - if (free_all) { - spin_lock(&sbi->extent_lock); if (!list_empty(&en->list)) list_del_init(&en->list); - spin_unlock(&sbi->extent_lock); + node = next; } + spin_unlock(&sbi->extent_lock); + } + + /* 2. release all extent nodes which are not in global lru list */ + node = rb_first(&et->root); + while (node) { + next = rb_next(node); + en = rb_entry(node, struct extent_node, rb_node); - if (free_all || list_empty(&en->list)) { + if (list_empty(&en->list)) { __detach_extent_node(sbi, et, en); kmem_cache_free(extent_node_slab, en); } -- 2.4.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/