From patchwork Wed Jun 21 10:11:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 9801393 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 96C5E60234 for ; Wed, 21 Jun 2017 10:13:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 861BC28581 for ; Wed, 21 Jun 2017 10:13:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7AB282858E; Wed, 21 Jun 2017 10:13:57 +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 DCD2128581 for ; Wed, 21 Jun 2017 10:13: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 1dNcc7-0004Vd-Uf; Wed, 21 Jun 2017 10:11:55 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dNcc6-0004VL-Qs for xen-devel@lists.xenproject.org; Wed, 21 Jun 2017 10:11:54 +0000 Received: from [85.158.143.35] by server-9.bemta-6.messagelabs.com id DA/3E-03557-A664A495; Wed, 21 Jun 2017 10:11:54 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrNIsWRWlGSWpSXmKPExsXS6fjDSzfNzSv S4PAqI4vvWyYzOTB6HP5whSWAMYo1My8pvyKBNePi2aUsBafMK679WcfSwHhTs4uRk0NIIE/i 2LQnbCA2r4CdxJdvbWC2hIChxOmFN1lAbBYBVYlXc78xg9hsAuoSbc+2s3YxcnCICBhInDuaB GIyC+hLbFsHVi0s4CrxbOEJRojpdhLv3x0Aq+YVEJT4u0MYJMwMFJ70/CXLBEbuWQiZWUgyEL aWxMNft6BsbYllC18zzwLbJS2x/B8HhOkmsfapAaoKEDtQ4un89WwLGDlWMWoUpxaVpRbpGlr oJRVlpmeU5CZm5ugaGpjp5aYWFyemp+YkJhXrJefnbmIEBiQDEOxgvLkx4BCjJAeTkijvBVmv SCG+pPyUyozE4oz4otKc1OJDjBocHAITzs6dziTFkpefl6okwdviClQnWJSanlqRlpkDjBmYU gkOHiUR3jUgad7igsTc4sx0iNQpRkUpcYg+AZBERmkeXBssTi8xykoJ8zICHSXEU5BalJtZgi r/ilGcg1FJmDfCBWgKT2ZeCdz0V0CLmYAWvzjiAbK4JBEhJdXAyKMmsOvz6X7Okljxhoyl6RV bD9/cKyZRIpkmP7HE/IlWyA1x1wlmRh7X3xTM8XVxu9W57JUwZyhHjuYvNnlrSa1Ynuhfz88c fKHx+5qTeOvnC2HZ868ur3KxCXOT3vvt8hf+/sTsddUz5/KerAuYUBRyaJH0KbcTJtfPd37eV K9ukDD7/rJZSizFGYmGWsxFxYkAiIl/Nc4CAAA= X-Env-Sender: JBeulich@suse.com X-Msg-Ref: server-13.tower-21.messagelabs.com!1498039909!69065665!1 X-Originating-IP: [137.65.248.74] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 61994 invoked from network); 21 Jun 2017 10:11:50 -0000 Received: from prv-mh.provo.novell.com (HELO prv-mh.provo.novell.com) (137.65.248.74) by server-13.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 21 Jun 2017 10:11:50 -0000 Received: from INET-PRV-MTA by prv-mh.provo.novell.com with Novell_GroupWise; Wed, 21 Jun 2017 04:11:48 -0600 Message-Id: <594A6283020000780016517F@prv-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 14.2.2 Date: Wed, 21 Jun 2017 04:11:47 -0600 From: "Jan Beulich" To: "xen-devel" References: <594A6283020000780016517F@prv-mh.provo.novell.com> Mime-Version: 1.0 Cc: Andrew Cooper Subject: [Xen-devel] [PATCH] x86/mm: consolidate setting of TLB flush time stamps 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: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Move code and comment into a helper function instead of repeating it in multiple places. Signed-off-by: Jan Beulich x86/mm: consolidate setting of TLB flush time stamps Move code and comment into a helper function instead of repeating it in multiple places. Signed-off-by: Jan Beulich --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -602,6 +602,20 @@ static inline void guest_get_eff_kern_l1 TOGGLE_MODE(); } +static inline void page_set_tlbflush_timestamp(struct page_info *page) +{ + /* + * Record TLB information for flush later. We do not stamp page tables + * when running in shadow mode: + * 1. Pointless, since it's the shadow pt's which must be tracked. + * 2. Shadow mode reuses this field for shadowed page tables to store + * flags info -- we don't want to conflict with that. + */ + if ( !(page->count_info & PGC_page_table) || + !shadow_mode_enabled(page_get_owner(page)) ) + page->tlbflush_timestamp = tlbflush_current_time(); +} + const char __section(".bss.page_aligned.const") __aligned(PAGE_SIZE) zero_page[PAGE_SIZE]; @@ -2417,16 +2431,7 @@ static int __put_final_page_type( /* No need for atomic update of type_info here: noone else updates it. */ if ( rc == 0 ) { - /* - * Record TLB information for flush later. We do not stamp page tables - * when running in shadow mode: - * 1. Pointless, since it's the shadow pt's which must be tracked. - * 2. Shadow mode reuses this field for shadowed page tables to - * store flags info -- we don't want to conflict with that. - */ - if ( !(shadow_mode_enabled(page_get_owner(page)) && - (page->count_info & PGC_page_table)) ) - page->tlbflush_timestamp = tlbflush_current_time(); + page_set_tlbflush_timestamp(page); wmb(); page->u.inuse.type_info--; } @@ -2434,9 +2439,7 @@ static int __put_final_page_type( { ASSERT((page->u.inuse.type_info & (PGT_count_mask|PGT_validated|PGT_partial)) == 1); - if ( !(shadow_mode_enabled(page_get_owner(page)) && - (page->count_info & PGC_page_table)) ) - page->tlbflush_timestamp = tlbflush_current_time(); + page_set_tlbflush_timestamp(page); wmb(); page->u.inuse.type_info |= PGT_validated; } @@ -2486,16 +2489,7 @@ static int __put_page_type(struct page_i break; } - /* - * Record TLB information for flush later. We do not stamp page - * tables when running in shadow mode: - * 1. Pointless, since it's the shadow pt's which must be tracked. - * 2. Shadow mode reuses this field for shadowed page tables to - * store flags info -- we don't want to conflict with that. - */ - if ( !(shadow_mode_enabled(page_get_owner(page)) && - (page->count_info & PGC_page_table)) ) - page->tlbflush_timestamp = tlbflush_current_time(); + page_set_tlbflush_timestamp(page); } if ( likely((y = cmpxchg(&page->u.inuse.type_info, x, nx)) == x) ) --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -602,6 +602,20 @@ static inline void guest_get_eff_kern_l1 TOGGLE_MODE(); } +static inline void page_set_tlbflush_timestamp(struct page_info *page) +{ + /* + * Record TLB information for flush later. We do not stamp page tables + * when running in shadow mode: + * 1. Pointless, since it's the shadow pt's which must be tracked. + * 2. Shadow mode reuses this field for shadowed page tables to store + * flags info -- we don't want to conflict with that. + */ + if ( !(page->count_info & PGC_page_table) || + !shadow_mode_enabled(page_get_owner(page)) ) + page->tlbflush_timestamp = tlbflush_current_time(); +} + const char __section(".bss.page_aligned.const") __aligned(PAGE_SIZE) zero_page[PAGE_SIZE]; @@ -2417,16 +2431,7 @@ static int __put_final_page_type( /* No need for atomic update of type_info here: noone else updates it. */ if ( rc == 0 ) { - /* - * Record TLB information for flush later. We do not stamp page tables - * when running in shadow mode: - * 1. Pointless, since it's the shadow pt's which must be tracked. - * 2. Shadow mode reuses this field for shadowed page tables to - * store flags info -- we don't want to conflict with that. - */ - if ( !(shadow_mode_enabled(page_get_owner(page)) && - (page->count_info & PGC_page_table)) ) - page->tlbflush_timestamp = tlbflush_current_time(); + page_set_tlbflush_timestamp(page); wmb(); page->u.inuse.type_info--; } @@ -2434,9 +2439,7 @@ static int __put_final_page_type( { ASSERT((page->u.inuse.type_info & (PGT_count_mask|PGT_validated|PGT_partial)) == 1); - if ( !(shadow_mode_enabled(page_get_owner(page)) && - (page->count_info & PGC_page_table)) ) - page->tlbflush_timestamp = tlbflush_current_time(); + page_set_tlbflush_timestamp(page); wmb(); page->u.inuse.type_info |= PGT_validated; } @@ -2486,16 +2489,7 @@ static int __put_page_type(struct page_i break; } - /* - * Record TLB information for flush later. We do not stamp page - * tables when running in shadow mode: - * 1. Pointless, since it's the shadow pt's which must be tracked. - * 2. Shadow mode reuses this field for shadowed page tables to - * store flags info -- we don't want to conflict with that. - */ - if ( !(shadow_mode_enabled(page_get_owner(page)) && - (page->count_info & PGC_page_table)) ) - page->tlbflush_timestamp = tlbflush_current_time(); + page_set_tlbflush_timestamp(page); } if ( likely((y = cmpxchg(&page->u.inuse.type_info, x, nx)) == x) )