From patchwork Tue Aug 29 17:09:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Ostrovsky X-Patchwork-Id: 9927771 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8E23E603B5 for ; Tue, 29 Aug 2017 17:10:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC723289CE for ; Tue, 29 Aug 2017 17:10:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CB30B289D9; Tue, 29 Aug 2017 17:10:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DE0FF289D4 for ; Tue, 29 Aug 2017 17:10:13 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dmjyA-00053A-NF; Tue, 29 Aug 2017 17:06:30 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dmjy9-00052r-9C for xen-devel@lists.xen.org; Tue, 29 Aug 2017 17:06:29 +0000 Received: from [193.109.254.147] by server-9.bemta-6.messagelabs.com id FF/67-03422-41F95A95; Tue, 29 Aug 2017 17:06:28 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrLLMWRWlGSWpSXmKPExsXSO6nOVVdk/tJ Ig5Vf2CyWfFzM4sDocXT3b6YAxijWzLyk/IoE1ozPZ3MKjvBWzLnaz9TAuJmri5GLQ0hgMpNE 38fZTBDOX0aJw0cuQDkbGSV+PHzPDOH0MEpc3XeUsYuRk4NNwEji7NHpYLaIgLTEtc+XGUGKm AUamCSenzsIlhAWiJSYe+wimM0ioCpxYPVEdhCbV8BL4mDPQ2YQW0JAQWIK2AZODk4Bb4m7s+ 6D1QsB1cxZ3swGUWMs0Terj2UCI98CRoZVjBrFqUVlqUW6hsZ6SUWZ6RkluYmZObqGBmZ6uan FxYnpqTmJScV6yfm5mxiBwcIABDsYvywLOMQoycGkJMpbNXVppBBfUn5KZUZicUZ8UWlOavEh RhkODiUJ3mdzgHKCRanpqRVpmTnAsIVJS3DwKInwnp8FlOYtLkjMLc5Mh0idYlSUEuedORcoI QCSyCjNg2uDxcolRlkpYV5GoEOEeApSi3IzS1DlXzGKczAqCfNeAZnCk5lXAjf9FdBiJqDFsV 5gi0sSEVJSDYz62W0+1xRWn7wXYhSyx2Oa7XzLm0FWJjN2KQlzcXi4rw7ZdkdNcbWeRqVp2HT +VaZpU4tDQpRmhMjvZVz36PrVe7ea17f1JjV7SkZJvv592vdM+Nuc6z6cpprbJ1x5opjdeLhM wdpyydldV8tnnvjudGt3+LaycBM18dMZd0T8Xh7oTCj33KnEUpyRaKjFXFScCADruKdekAIAA A== X-Env-Sender: boris.ostrovsky@oracle.com X-Msg-Ref: server-14.tower-27.messagelabs.com!1504026386!101589669!1 X-Originating-IP: [141.146.126.69] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTQxLjE0Ni4xMjYuNjkgPT4gMjc3MjE4\n X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 13486 invoked from network); 29 Aug 2017 17:06:27 -0000 Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by server-14.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 29 Aug 2017 17:06:27 -0000 Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v7TH6Nk4026276 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 29 Aug 2017 17:06:23 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id v7TH6MPX028798 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 29 Aug 2017 17:06:22 GMT Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id v7TH6MrF003487; Tue, 29 Aug 2017 17:06:22 GMT Received: from ovs104.us.oracle.com (/10.149.76.204) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 29 Aug 2017 10:06:22 -0700 From: Boris Ostrovsky To: xen-devel@lists.xen.org Date: Tue, 29 Aug 2017 13:09:17 -0400 Message-Id: <1504026557-11365-6-git-send-email-boris.ostrovsky@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1504026557-11365-1-git-send-email-boris.ostrovsky@oracle.com> References: <1504026557-11365-1-git-send-email-boris.ostrovsky@oracle.com> X-Source-IP: aserv0021.oracle.com [141.146.126.233] Cc: sstabellini@kernel.org, wei.liu2@citrix.com, George.Dunlap@eu.citrix.com, andrew.cooper3@citrix.com, ian.jackson@eu.citrix.com, tim@xen.org, jbeulich@suse.com, Boris Ostrovsky Subject: [Xen-devel] [PATCH 5/5] mm: Don't hold heap lock in alloc_heap_pages() longer than necessary X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Once pages are removed from the heap we don't need to hold the heap lock. It is especially useful to drop it for an unscrubbed buddy since we will be scrubbing it. Signed-off-by: Boris Ostrovsky Reviewed-by: Jan Beulich Reviewed-by: Wei Liu --- Changes in v2: * Moved spin_unlock() after d->last_alloc_node assignment xen/common/page_alloc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 6c08983..8df92aa 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -860,6 +860,7 @@ static struct page_info *alloc_heap_pages( struct page_info *pg; bool need_tlbflush = false; uint32_t tlbflush_timestamp = 0; + unsigned int dirty_cnt = 0; /* Make sure there are enough bits in memflags for nodeID. */ BUILD_BUG_ON((_MEMF_bits - _MEMF_node) < (8 * sizeof(nodeid_t))); @@ -948,6 +949,8 @@ static struct page_info *alloc_heap_pages( if ( d != NULL ) d->last_alloc_node = node; + spin_unlock(&heap_lock); + for ( i = 0; i < (1 << order); i++ ) { /* Reference count must continuously be zero for free pages. */ @@ -957,7 +960,7 @@ static struct page_info *alloc_heap_pages( { if ( !(memflags & MEMF_no_scrub) ) scrub_one_page(&pg[i]); - node_need_scrub[node]--; + dirty_cnt++; } pg[i].count_info = PGC_state_inuse; @@ -979,6 +982,8 @@ static struct page_info *alloc_heap_pages( check_one_page(&pg[i]); } + spin_lock(&heap_lock); + node_need_scrub[node] -= dirty_cnt; spin_unlock(&heap_lock); if ( need_tlbflush )