From patchwork Thu Aug 31 13:16:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Ostrovsky X-Patchwork-Id: 9932187 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 6DAFD6022E for ; Thu, 31 Aug 2017 13:16:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5FCD128867 for ; Thu, 31 Aug 2017 13:16:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 54BA928875; Thu, 31 Aug 2017 13:16:11 +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 B4FB428867 for ; Thu, 31 Aug 2017 13:16:10 +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 1dnPHp-000519-TV; Thu, 31 Aug 2017 13:13:33 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dnPHo-00050c-TO for xen-devel@lists.xen.org; Thu, 31 Aug 2017 13:13:33 +0000 Received: from [85.158.137.68] by server-12.bemta-3.messagelabs.com id 06/5C-01916-C7B08A95; Thu, 31 Aug 2017 13:13:32 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrLLMWRWlGSWpSXmKPExsXSO6nOVbeae0W kwbEeFYslHxezODB6HN39mymAMYo1My8pvyKBNeNt+0fGgoVSFTd7m9gbGI+IdjFycQgJTGSS ePtlGhOE85dR4vqftVDORkaJDc+aGSGcHkaJQ9fXAGU4OdgEjCTOHp3OCGKLCEhLXPt8GcxmF ljLJHG5IwHEFhYIl1g7rZ0NxGYRUJX4su41O4jNK+Apcf//ebA5EgIKElMevmcGsTkFvCTW3r 3MCmILAdUcWbsUqsZQ4vTDbYwTGPkWMDKsYtQoTi0qSy3SNTLXSyrKTM8oyU3MzNE1NDDWy00 tLk5MT81JTCrWS87P3cQIDJZ6BgbGHYwte/0OMUpyMCmJ8j68vTxSiC8pP6UyI7E4I76oNCe1 +BCjDAeHkgRvJ9eKSCHBotT01Iq0zBxg2MKkJTh4lER4C0HSvMUFibnFmekQqVOMilLivNkgC QGQREZpHlwbLFYuMcpKCfMyMjAwCPEUpBblZpagyr9iFOdgVBLmtQOZwpOZVwI3/RXQYiagxb FeS0EWlyQipKQaGHXWc81eUPtJf4NorO3UBGdXj+mrxf9fNsu6826u+QupS4XcT4UbZxxk0Fe 4b6zroOmREbg48ePjXJ+HGb93eSZLBcx8OjWMMbbkTrxqxTrrbboPVRvOzHZxyHK+OeO5nGRf /MLm8orDUft2Lw16vGCXnHjvi0cX70f5CHk/61T67SzKZut2WYmlOCPRUIu5qDgRAIOyhYaQA gAA X-Env-Sender: boris.ostrovsky@oracle.com X-Msg-Ref: server-15.tower-31.messagelabs.com!1504185210!108452889!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 6013 invoked from network); 31 Aug 2017 13:13:31 -0000 Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by server-15.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 31 Aug 2017 13:13:31 -0000 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v7VDDMlb017142 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 31 Aug 2017 13:13:22 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id v7VDDLHn023047 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 31 Aug 2017 13:13:21 GMT Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id v7VDDKHd003845; Thu, 31 Aug 2017 13:13:20 GMT Received: from ovs104.us.oracle.com (/10.149.76.204) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 31 Aug 2017 06:13:20 -0700 From: Boris Ostrovsky To: xen-devel@lists.xen.org Date: Thu, 31 Aug 2017 09:16:11 -0400 Message-Id: <1504185374-7581-2-git-send-email-boris.ostrovsky@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1504185374-7581-1-git-send-email-boris.ostrovsky@oracle.com> References: <1504185374-7581-1-git-send-email-boris.ostrovsky@oracle.com> X-Source-IP: userv0021.oracle.com [156.151.31.71] 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, Julien Grall , jbeulich@suse.com, Boris Ostrovsky Subject: [Xen-devel] [PATCH v2 1/4] mm: Initialize lowmem virq when boot-time scrubbing is disabled 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 scrub_heap_pages() does early return if boot-time scrubbing is disabled, neglecting to initialize lowmem VIRQ. Because setup_low_mem_virq() doesn't logically belong in scrub_heap_pages() we put them both into the newly added heap_init_late(). Signed-off-by: Boris Ostrovsky Reviewed-by: Wei Liu --- CC: Julien Grall --- Changes in v2: * Dropped unnecessary opt_bootscrub test in scrub_heap_pages() * Restored comment for setup_low_mem_virq(). xen/arch/arm/setup.c | 3 +-- xen/arch/x86/setup.c | 3 +-- xen/common/page_alloc.c | 18 +++++++++++------- xen/include/xen/mm.h | 2 +- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index 3b34855..92f173b 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -861,8 +861,7 @@ void __init start_xen(unsigned long boot_phys_offset, if ( construct_dom0(dom0) != 0) panic("Could not set up DOM0 guest OS"); - /* Scrub RAM that is still free and so may go to an unprivileged domain. */ - scrub_heap_pages(); + heap_init_late(); init_constructors(); diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index ec96287..bc466e8 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1662,8 +1662,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) cr4_pv32_mask |= X86_CR4_SMAP; } - /* Scrub RAM that is still free and so may go to an unprivileged domain. */ - scrub_heap_pages(); + heap_init_late(); init_trace_bufs(); diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 9fa62d2..43f5a38 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -1839,7 +1839,7 @@ static int __init find_non_smt(unsigned int node, cpumask_t *dest) * Scrub all unallocated pages in all heap zones. This function uses all * online cpu's to scrub the memory in parallel. */ -void __init scrub_heap_pages(void) +static void __init scrub_heap_pages(void) { cpumask_t node_cpus, all_worker_cpus; unsigned int i, j; @@ -1849,9 +1849,6 @@ void __init scrub_heap_pages(void) int last_distance, best_node; int cpus; - if ( !opt_bootscrub ) - return; - cpumask_clear(&all_worker_cpus); /* Scrub block size. */ chunk_size = opt_bootscrub_chunk >> PAGE_SHIFT; @@ -1970,12 +1967,19 @@ void __init scrub_heap_pages(void) #ifdef CONFIG_SCRUB_DEBUG boot_scrub_done = true; #endif +} - /* Now that the heap is initialized, run checks and set bounds - * for the low mem virq algorithm. */ +void __init heap_init_late(void) +{ + /* + * Now that the heap is initialized set bounds + * for the low mem virq algorithm. + */ setup_low_mem_virq(); -} + if ( opt_bootscrub ) + scrub_heap_pages(); +} /************************* diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h index ddc3fb3..c2f5a08 100644 --- a/xen/include/xen/mm.h +++ b/xen/include/xen/mm.h @@ -199,7 +199,7 @@ int offline_page(unsigned long mfn, int broken, uint32_t *status); int query_page_offline(unsigned long mfn, uint32_t *status); unsigned long total_free_pages(void); -void scrub_heap_pages(void); +void heap_init_late(void); int assign_pages( struct domain *d,