Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754992Ab3HFInq (ORCPT ); Tue, 6 Aug 2013 04:43:46 -0400 Received: from lgeamrelo01.lge.com ([156.147.1.125]:56320 "EHLO LGEAMRELO01.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754539Ab3HFIno (ORCPT ); Tue, 6 Aug 2013 04:43:44 -0400 X-AuditID: 9c93017d-b7b45ae000000e34-4a-5200b73c09da From: Joonsoo Kim To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Joonsoo Kim , Minchan Kim , Johannes Weiner , Mel Gorman , Rik van Riel , Michel Lespinasse , Joonsoo Kim Subject: [PATCH 3/4] mm, rmap: minimize lock hold when unlink_anon_vmas Date: Tue, 6 Aug 2013 17:43:39 +0900 Message-Id: <1375778620-31593-3-git-send-email-iamjoonsoo.kim@lge.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1375778620-31593-1-git-send-email-iamjoonsoo.kim@lge.com> References: <1375778620-31593-1-git-send-email-iamjoonsoo.kim@lge.com> X-Brightmail-Tracker: AAAAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1502 Lines: 51 Currently, we free the avc objects with holding a lock. To minimize lock hold time, we just move the avc objects to another list with holding a lock. Then, iterate them and free objects without holding a lock. This makes lock hold time minimized. Signed-off-by: Joonsoo Kim diff --git a/mm/rmap.c b/mm/rmap.c index 1603f64..9cfb282 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -330,6 +330,7 @@ void unlink_anon_vmas(struct vm_area_struct *vma) { struct anon_vma_chain *avc, *next; struct anon_vma *root = NULL; + LIST_HEAD(avc_list); /* * Unlink each anon_vma chained to the VMA. This list is ordered @@ -348,10 +349,14 @@ void unlink_anon_vmas(struct vm_area_struct *vma) if (RB_EMPTY_ROOT(&anon_vma->rb_root)) continue; + list_move(&avc->same_vma, &avc_list); + } + unlock_anon_vma_root(root); + + list_for_each_entry_safe(avc, next, &avc_list, same_vma) { list_del(&avc->same_vma); anon_vma_chain_free(avc); } - unlock_anon_vma_root(root); /* * Iterate the list once more, it now only contains empty and unlinked @@ -363,7 +368,6 @@ void unlink_anon_vmas(struct vm_area_struct *vma) put_anon_vma(anon_vma); - list_del(&avc->same_vma); anon_vma_chain_free(avc); } } -- 1.7.9.5 -- 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/