From patchwork Mon Aug 28 20:40:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Ostrovsky X-Patchwork-Id: 9926105 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 B05F960380 for ; Mon, 28 Aug 2017 20:39:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A39C1287A5 for ; Mon, 28 Aug 2017 20:39:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9865F287A6; Mon, 28 Aug 2017 20:39:56 +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 2670D287A5 for ; Mon, 28 Aug 2017 20:39:56 +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 1dmQn1-0003PN-Oa; Mon, 28 Aug 2017 20:37:43 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dmQn0-0003OG-7W for xen-devel@lists.xen.org; Mon, 28 Aug 2017 20:37:42 +0000 Received: from [193.109.254.147] by server-8.bemta-6.messagelabs.com id FE/35-09901-51F74A95; Mon, 28 Aug 2017 20:37:41 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrHLMWRWlGSWpSXmKPExsXSO6nOVVe0fkm kwax2ZoslHxezODB6HN39mymAMYo1My8pvyKBNaN37h3Ggk/cFZ2bNrE3ME7g7GLk4hASmMgk cXfZQkYI5zejxIPLG6CcjYwSHRNbmSGcHkaJ5e93snQxcnKwCRhJnD06nRHEFhGQlrj2+TJYB 7NAA5PE83MHwRLCApESr3qXsIPYLAKqEu1rJ4LZvAJeEs3fFjGD2BICChJTHr4HszkFvCV+PP 0LtkAIqObp1DNMEDWGEp83LmWewMi3gJFhFaNGcWpRWWqRrrGhXlJRZnpGSW5iZo6uoYGZXm5 qcXFiempOYlKxXnJ+7iZGYLgwAMEOxqZFgYcYJTmYlER5d1YsjhTiS8pPqcxILM6ILyrNSS0+ xCjDwaEkwfu3dkmkkGBRanpqRVpmDjBwYdISHDxKIrwrQdK8xQWJucWZ6RCpU4yKUuK81nVAC QGQREZpHlwbLFouMcpKCfMyAh0ixFOQWpSbWYIq/4pRnINRSZj3Gch4nsy8Erjpr4AWMwEtVh RcCLK4JBEhJdXAuHfjL3XuIpeqqJUGm2QXZxdK2Dd4rU/cWRzscfReheJ2ZrGmZCNWt29v2y3 r1B9udZDekxY/tcrl+KLrpv5VN94ubfu3bc2up9w7MnatOaxh8TiA/VSZK8OH1SvntAUd8FUx jK5KPXLofZav7RcjvbyV7DUNHJM0fIPtlstqry2YGPLNfxGfEktxRqKhFnNRcSIA7VeF2JECA AA= X-Env-Sender: boris.ostrovsky@oracle.com X-Msg-Ref: server-11.tower-27.messagelabs.com!1503952659!82029300!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 821 invoked from network); 28 Aug 2017 20:37:40 -0000 Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by server-11.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 28 Aug 2017 20:37:40 -0000 Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v7SKbZV5022026 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 28 Aug 2017 20:37:35 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id v7SKbZXs000992 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 28 Aug 2017 20:37:35 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id v7SKbYYK031679; Mon, 28 Aug 2017 20:37:34 GMT Received: from ovs104.us.oracle.com (/10.149.76.204) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 28 Aug 2017 13:37:34 -0700 From: Boris Ostrovsky To: xen-devel@lists.xen.org Date: Mon, 28 Aug 2017 16:40:29 -0400 Message-Id: <1503952829-11065-5-git-send-email-boris.ostrovsky@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1503952829-11065-1-git-send-email-boris.ostrovsky@oracle.com> References: <1503952829-11065-1-git-send-email-boris.ostrovsky@oracle.com> X-Source-IP: userv0022.oracle.com [156.151.31.74] 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 4/4] 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: Wei Liu Reviewed-by: Jan Beulich --- 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 b93dae9..1ec788e 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -858,6 +858,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))); @@ -943,6 +944,8 @@ static struct page_info *alloc_heap_pages( check_low_mem_virq(); + spin_unlock(&heap_lock); + if ( d != NULL ) d->last_alloc_node = node; @@ -955,7 +958,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; @@ -977,6 +980,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 )