From patchwork Mon Sep 12 08:16:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongli Zhang X-Patchwork-Id: 9325903 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 615BA607FD for ; Mon, 12 Sep 2016 08:19:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 568A728BD4 for ; Mon, 12 Sep 2016 08:19:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4B58A28BDE; Mon, 12 Sep 2016 08:19:42 +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 BCC0B28BD4 for ; Mon, 12 Sep 2016 08:19:41 +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 1bjMQj-0007gw-VR; Mon, 12 Sep 2016 08:17:29 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bjMQj-0007gp-3y for xen-devel@lists.xen.org; Mon, 12 Sep 2016 08:17:29 +0000 Received: from [85.158.143.35] by server-2.bemta-6.messagelabs.com id 8C/5E-13744-79466D75; Mon, 12 Sep 2016 08:17:27 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrCLMWRWlGSWpSXmKPExsXSO6nOVXdayrV wg/kTrS2WfFzM4sDocXT3b6YAxijWzLyk/IoE1ozGJxeZCi4KVmyfUNXAOJm3i5GLQ0igg0ni 86NtjBDON0aJh9N72CCcDYwSLz6cYYdwuhklzq/6BVTGycEmoCMx7cApFhBbREBa4trny2BxZ oE2Jol3211AbGGBcIn/a6aygdgsAqoS+69/ZwKxeQXcJF59eMMOYksIyEmcPDaZFcI2luib1c cygZFnASPDKkaN4tSistQiXSMDvaSizPSMktzEzBxdQwMzvdzU4uLE9NScxKRiveT83E2MQN8 zAMEOxl/LAg4xSnIwKYnyJgleCxfiS8pPqcxILM6ILyrNSS0+xCjDwaEkwZuaDJQTLEpNT61I y8wBBiFMWoKDR0mEtxMkzVtckJhbnJkOkTrFqCglzmsKkhAASWSU5sG1wQL/EqOslDAvI9AhQ jwFqUW5mSWo8q8YxTkYlYR5T4FM4cnMK4Gb/gpoMRPQ4qdbL4MsLklESEk1MAaWhPfazYmtSn lz6HjFvHscJW2pj95vCtyS1Txvp/FHxXl9J369EXb/39f9/+ipLztzPzpm1rsEJrdzO1z2fvN L/uFy/a12Rv31/P+OZ+898fHUkSLh4v4Dom5d7o7/7ebmzw/mfJCfvWJOwy9HK4/AHOPtkuEc 6v7br+Uv+rVuzVGZuYr/7iuxFGckGmoxFxUnAgDLUHJldwIAAA== X-Env-Sender: dongli.zhang@oracle.com X-Msg-Ref: server-4.tower-21.messagelabs.com!1473668245!26620281!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: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 14097 invoked from network); 12 Sep 2016 08:17:26 -0000 Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by server-4.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 12 Sep 2016 08:17:26 -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 u8C8HLvQ004301 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 12 Sep 2016 08:17:21 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0021.oracle.com (8.13.8/8.13.8) with ESMTP id u8C8HLrn020770 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 12 Sep 2016 08:17:21 GMT Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id u8C8HJkY021122; Mon, 12 Sep 2016 08:17:20 GMT Received: from linux.cn.oracle.com (/10.182.70.252) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 12 Sep 2016 01:17:19 -0700 From: Dongli Zhang To: xen-devel@lists.xen.org Date: Mon, 12 Sep 2016 16:16:14 +0800 Message-Id: <1473668175-3088-1-git-send-email-dongli.zhang@oracle.com> X-Mailer: git-send-email 1.9.1 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, dario.faggioli@citrix.com, ian.jackson@eu.citrix.com, tim@xen.org, david.vrabel@citrix.com, jbeulich@suse.com Subject: [Xen-devel] [PATCH v4 1/2] xen: replace complicated tlbflush check with an inline function 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 with an inline function. We should use this inline function to avoid the long and complicated to read tlbflush check when implementing TODOs left in commit a902c12ee45fc9389eb8fe54eeddaf267a555c58. Signed-off-by: Dongli Zhang --- Changed since v3: * Wrap the complicated tlbflush condition check as inline function (suggested by Dario). --- xen/common/page_alloc.c | 7 +++---- xen/include/xen/mm.h | 11 +++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 18ff6cf..5b93a01 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -827,10 +827,9 @@ 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 ( page_needs_tlbflush(&pg[i], need_tlbflush, + tlbflush_timestamp, + tlbflush_current_time()) ) { need_tlbflush = 1; tlbflush_timestamp = pg[i].tlbflush_timestamp; diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h index 58bc0b8..766559d 100644 --- a/xen/include/xen/mm.h +++ b/xen/include/xen/mm.h @@ -567,4 +567,15 @@ 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); +static inline int page_needs_tlbflush(struct page_info *page, + bool_t need_tlbflush, + uint32_t tlbflush_timestamp, + uint32_t tlbflush_current_time) +{ + return page->u.free.need_tlbflush && + page->tlbflush_timestamp <= tlbflush_current_time && + (!need_tlbflush || + page->tlbflush_timestamp > tlbflush_timestamp); +} + #endif /* __XEN_MM_H__ */