From patchwork Fri Mar 31 10:24:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Punit Agrawal X-Patchwork-Id: 9655887 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 25D8A60350 for ; Fri, 31 Mar 2017 10:27:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 16DD126E39 for ; Fri, 31 Mar 2017 10:27:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0B94D2766D; Fri, 31 Mar 2017 10:27:19 +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 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 A417D26E39 for ; Fri, 31 Mar 2017 10:27:18 +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 1cttk6-0002DQ-Ry; Fri, 31 Mar 2017 10:25:18 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cttk6-0002Co-0t for xen-devel@lists.xen.org; Fri, 31 Mar 2017 10:25:18 +0000 Received: from [85.158.137.68] by server-17.bemta-3.messagelabs.com id 36/ED-04270-D8E2ED85; Fri, 31 Mar 2017 10:25:17 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrGLMWRWlGSWpSXmKPExsVysyfVTbdH716 Ewd0zhhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8bM6wUFbRIV3ccvMjUwtol0MXJyCAlsYpT4 c9Kvi5ELyN7OKLFl8jYmkASbgLbE1N8TmUFsEQFpiWufLzOCFDELNDBJNE3rZgRJCAvESMy6f Y0NxGYRUJU43HGfFcTmFbCSuH/5MtggCQF5iV1tF8HinALWEo+2NrNBbLaSeHjiMOsERu4FjA yrGDWKU4vKUot0Dc31kooy0zNKchMzc3QNDYz1clOLixPTU3MSk4r1kvNzNzEC/csABDsYX57 2PMQoycGkJMr7/fHdCCG+pPyUyozE4oz4otKc1OJDjDIcHEoSvO4a9yKEBItS01Mr0jJzgIEG k5bg4FES4Z2oCZTmLS5IzC3OTIdInWJUlBLnVdYCSgiAJDJK8+DaYMF9iVFWSpiXEegQIZ6C1 KLczBJU+VeM4hyMSsK83iBTeDLzSuCmvwJazAS02OLrXZDFJYkIKakGRu/nJTeyyw12PLkXe3 Nn2gYjx9ea/aZMM6acaNPK7HnvOyvTvfPPj6kXTTOiVojXTs6xdj74fo3Xwcg7E3j+SzdonXb T3qgiEt5qrVoaeGPXzeTPW37wJ+s+vnvgQrOBRlSpjU3e3n81StpmD12fHXlwNuZvzLMeqSOe nF1TtWeaHOWWzpy9UYmlOCPRUIu5qDgRAH4QhVppAgAA X-Env-Sender: punit.agrawal@arm.com X-Msg-Ref: server-8.tower-31.messagelabs.com!1490955916!93231307!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 49189 invoked from network); 31 Mar 2017 10:25:16 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-8.tower-31.messagelabs.com with SMTP; 31 Mar 2017 10:25:16 -0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0CF5CB16; Fri, 31 Mar 2017 03:25:16 -0700 (PDT) Received: from localhost (e105922-lin.cambridge.arm.com [10.1.195.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D00143F59A; Fri, 31 Mar 2017 03:25:15 -0700 (PDT) From: Punit Agrawal To: xen-devel@lists.xen.org Date: Fri, 31 Mar 2017 11:24:24 +0100 Message-Id: <20170331102424.11869-4-punit.agrawal@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170331102424.11869-1-punit.agrawal@arm.com> References: <20170331102424.11869-1-punit.agrawal@arm.com> Cc: sstabellini@kernel.org, wei.liu2@citrix.com, George.Dunlap@eu.citrix.com, andrew.cooper3@citrix.com, Punit Agrawal , tim@xen.org, julien.grall@arm.com, jbeulich@suse.com, ian.jackson@eu.citrix.com Subject: [Xen-devel] [For Xen-4.10 RFC PATCH 3/3] Prevent redundant icache flushes in populate_physmap() 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 populate_physmap() calls alloc_heap_pages() per requested extent. As alloc_heap_pages() performs icache maintenance operations affecting the entire instruction cache, this leads to redundant cache flushes when allocating multiple extents in populate_physmap(). To alleviate this problem, introduce a new flag "MEMF_no_icache_flush" which can be used prevent alloc_heap_pages() to perform unnecessary icache maintenance operations. Use the flag in populate_physmap() and perform the required icache maintenance function at the end of the operation. Signed-off-by: Punit Agrawal --- xen/common/memory.c | 6 ++++++ xen/common/page_alloc.c | 2 +- xen/include/asm-x86/page.h | 4 ++++ xen/include/xen/mm.h | 2 ++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/xen/common/memory.c b/xen/common/memory.c index ad0b33ceb6..507f363924 100644 --- a/xen/common/memory.c +++ b/xen/common/memory.c @@ -162,6 +162,8 @@ static void populate_physmap(struct memop_args *a) if ( unlikely(!d->creation_finished) ) a->memflags |= MEMF_no_tlbflush; + a->memflags |= MEMF_no_icache_flush; + for ( i = a->nr_done; i < a->nr_extents; i++ ) { if ( i != a->nr_done && hypercall_preempt_check() ) @@ -253,6 +255,10 @@ static void populate_physmap(struct memop_args *a) out: if ( need_tlbflush ) filtered_flush_tlb_mask(tlbflush_timestamp); + + if ( a->memflags & MEMF_no_icache_flush ) + invalidate_icache(); + a->nr_done = i; } diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 15450a3b6d..1a51bc6b15 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -838,7 +838,7 @@ static struct page_info *alloc_heap_pages( /* Ensure cache and RAM are consistent for platforms where the * guest can control its own visibility of/through the cache. */ - flush_page_to_ram(page_to_mfn(&pg[i]), true); + flush_page_to_ram(page_to_mfn(&pg[i]), !(memflags & MEMF_no_icache_flush)); } spin_unlock(&heap_lock); diff --git a/xen/include/asm-x86/page.h b/xen/include/asm-x86/page.h index bc5946b9d2..13dc9e2299 100644 --- a/xen/include/asm-x86/page.h +++ b/xen/include/asm-x86/page.h @@ -375,6 +375,10 @@ perms_strictly_increased(uint32_t old_flags, uint32_t new_flags) #define PAGE_ALIGN(x) (((x) + PAGE_SIZE - 1) & PAGE_MASK) +static inline void invalidate_icache(void) +{ +} + #endif /* __X86_PAGE_H__ */ /* diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h index 88de3c1fa6..ee50d4cd7b 100644 --- a/xen/include/xen/mm.h +++ b/xen/include/xen/mm.h @@ -224,6 +224,8 @@ struct npfec { #define MEMF_no_owner (1U<<_MEMF_no_owner) #define _MEMF_no_tlbflush 6 #define MEMF_no_tlbflush (1U<<_MEMF_no_tlbflush) +#define _MEMF_no_icache_flush 7 +#define MEMF_no_icache_flush (1U<<_MEMF_no_icache_flush) #define _MEMF_node 8 #define MEMF_node_mask ((1U << (8 * sizeof(nodeid_t))) - 1) #define MEMF_node(n) ((((n) + 1) & MEMF_node_mask) << _MEMF_node)