From patchwork Mon Sep 19 02:50:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongli Zhang X-Patchwork-Id: 9338459 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 2A5096089F for ; Mon, 19 Sep 2016 02:54:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 193D028EFE for ; Mon, 19 Sep 2016 02:54:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0D92328F23; Mon, 19 Sep 2016 02:54:07 +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 9B52C28F11 for ; Mon, 19 Sep 2016 02:54:06 +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 1blogF-0008E4-WF; Mon, 19 Sep 2016 02:51:39 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1blogE-0008Dy-Ua for xen-devel@lists.xen.org; Mon, 19 Sep 2016 02:51:39 +0000 Received: from [85.158.139.211] by server-2.bemta-5.messagelabs.com id 30/58-03032-AB25FD75; Mon, 19 Sep 2016 02:51:38 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrGLMWRWlGSWpSXmKPExsUyZ7p8oO7OoPv hBiuuKFss+biYxYHR4+ju30wBjFGsmXlJ+RUJrBkvdu1gKXghV7F5cidzA+MaiS5GLg4hgTYm ict9t9ghnG+MEnt3wzgbGSXuX33ABOF0M0qcfj6duYuRk4NNQEdi2oFTLCC2iIC0xLXPlxlBi pgFupgkXtzbwgSSEBYIl3jy+TqYzSKgKnH63GxGEJtXwFXiaMMVMFtCQE7i5LHJrBC2ocTph9 sYJzDyLGBkWMWoUZxaVJZapGtkqpdUlJmeUZKbmJmja2hgqpebWlycmJ6ak5hUrJecn7uJEej /egYGxh2Mu9r9DjFKcjApifLuKLkXLsSXlJ9SmZFYnBFfVJqTWnyIUYaDQ0mCNyfwfriQYFFq empFWmYOMBBh0hIcPEoivM9B0rzFBYm5xZnpEKlTjIpS4rw7QBICIImM0jy4NljwX2KUlRLmZ WRgYBDiKUgtys0sQZV/xSjOwagkzPseZApPZl4J3PRXQIuZgBavnnUbZHFJIkJKqoGx9M2hqv fXy7SyRI1l/jCwhEg7LuDRKv1/O+td6rpe8alfrobpZ+pnPJ7369aLnV/1Pl1ecOsGZ6uQhJO 29PUVET9eca4QfrXN79ehR8s2r/91PFZc2t7q3T8Brswz++zeJc6r/hl5f8fcEObGvyov5iT+ 3CNmdr2t0afubNsuS7fmFwzfQz30lViKMxINtZiLihMB8Vcnf3kCAAA= X-Env-Sender: dongli.zhang@oracle.com X-Msg-Ref: server-16.tower-206.messagelabs.com!1474253495!44281061!1 X-Originating-IP: [156.151.31.81] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTU2LjE1MS4zMS44MSA9PiAyODgzMzk=\n X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 25314 invoked from network); 19 Sep 2016 02:51:37 -0000 Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by server-16.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 19 Sep 2016 02:51:37 -0000 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u8J2pSrk001503 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 19 Sep 2016 02:51:28 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0021.oracle.com (8.13.8/8.13.8) with ESMTP id u8J2pRt9019862 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 19 Sep 2016 02:51:27 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id u8J2pP8F015143; Mon, 19 Sep 2016 02:51:26 GMT Received: from linux.cn.oracle.com (/10.182.70.252) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 18 Sep 2016 19:51:25 -0700 From: Dongli Zhang To: xen-devel@lists.xen.org Date: Mon, 19 Sep 2016 10:50:17 +0800 Message-Id: <1474253418-772-1-git-send-email-dongli.zhang@oracle.com> X-Mailer: git-send-email 1.9.1 X-Source-IP: userv0021.oracle.com [156.151.31.71] Cc: sstabellini@kernel.org, wei.liu2@citrix.com, George.Dunlap@eu.citrix.com, jinsong.liu@alibaba-inc.com, dario.faggioli@citrix.com, ian.jackson@eu.citrix.com, tim@xen.org, jbeulich@suse.com, andrew.cooper3@citrix.com Subject: [Xen-devel] [PATCH v5 1/2] xen: replace tlbflush check and operation with inline functions 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 This patch cleaned up the code by replacing complicated tlbflush check and operation with inline functions. We should use those inline functions to avoid the complicated tlbflush check and tlbflush operations when implementing TODOs left in commit a902c12ee45fc9389eb8fe54eeddaf267a555c58 (More efficient TLB-flush filtering in alloc_heap_pages()). "#include " is removed from xen/arch/x86/acpi/suspend.c to avoid the compiling error after we include "" to xen/include/xen/mm.h. Signed-off-by: Dongli Zhang --- Changed since v4: * Wrap the filtered tlbflush mask operation as inline function (suggested by Jan). * Remove asm/flushtlb.h from suspend.c to avoid compiling error. Changed since v3: * Wrap the complicated tlbflush condition check as inline function (suggested by Dario). --- xen/arch/x86/acpi/suspend.c | 1 - xen/common/page_alloc.c | 16 +++------------- xen/include/xen/mm.h | 25 +++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/xen/arch/x86/acpi/suspend.c b/xen/arch/x86/acpi/suspend.c index 1d8344c..d5c67ee 100644 --- a/xen/arch/x86/acpi/suspend.c +++ b/xen/arch/x86/acpi/suspend.c @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 18ff6cf..173c10d 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -827,10 +827,8 @@ static struct page_info *alloc_heap_pages( BUG_ON(pg[i].count_info != PGC_state_free); pg[i].count_info = PGC_state_inuse; - if ( pg[i].u.free.need_tlbflush && - (pg[i].tlbflush_timestamp <= tlbflush_current_time()) && - (!need_tlbflush || - (pg[i].tlbflush_timestamp > tlbflush_timestamp)) ) + if ( accumulate_tlbflush(need_tlbflush, &pg[i], + tlbflush_timestamp) ) { need_tlbflush = 1; tlbflush_timestamp = pg[i].tlbflush_timestamp; @@ -849,15 +847,7 @@ static struct page_info *alloc_heap_pages( spin_unlock(&heap_lock); if ( need_tlbflush ) - { - cpumask_t mask = cpu_online_map; - tlbflush_filter(mask, tlbflush_timestamp); - if ( !cpumask_empty(&mask) ) - { - perfc_incr(need_flush_tlb_flush); - flush_tlb_mask(&mask); - } - } + filtered_flush_tlb_mask(tlbflush_timestamp); return pg; } diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h index f470e49..85848e3 100644 --- a/xen/include/xen/mm.h +++ b/xen/include/xen/mm.h @@ -51,6 +51,7 @@ #include #include #include +#include #include TYPE_SAFE(unsigned long, mfn); @@ -567,4 +568,28 @@ int prepare_ring_for_helper(struct domain *d, unsigned long gmfn, struct page_info **_page, void **_va); void destroy_ring_for_helper(void **_va, struct page_info *page); +#include + +static inline bool accumulate_tlbflush(bool need_tlbflush, + const struct page_info *page, + uint32_t tlbflush_timestamp) +{ + return page->u.free.need_tlbflush && + page->tlbflush_timestamp <= tlbflush_current_time() && + (!need_tlbflush || + page->tlbflush_timestamp > tlbflush_timestamp); +} + +static inline void filtered_flush_tlb_mask(uint32_t tlbflush_timestamp) +{ + cpumask_t mask = cpu_online_map; + + tlbflush_filter(mask, tlbflush_timestamp); + if ( !cpumask_empty(&mask) ) + { + perfc_incr(need_flush_tlb_flush); + flush_tlb_mask(&mask); + } +} + #endif /* __XEN_MM_H__ */