From patchwork Mon Feb 8 18:13:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Gardner X-Patchwork-Id: 580453 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 9BF971402DE; Tue, 9 Feb 2016 05:13:28 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical-com.20150623.gappssmtp.com header.i=@canonical-com.20150623.gappssmtp.com header.b=f42Z4Z58; dkim-atps=neutral Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1aSqJM-0001LW-VE; Mon, 08 Feb 2016 18:13:20 +0000 Received: from mail-pf0-f180.google.com ([209.85.192.180]) by huckleberry.canonical.com with esmtps (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.76) (envelope-from ) id 1aSqJH-0001KR-US for kernel-team@lists.ubuntu.com; Mon, 08 Feb 2016 18:13:16 +0000 Received: by mail-pf0-f180.google.com with SMTP id e127so17860997pfe.3 for ; Mon, 08 Feb 2016 10:13:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id; bh=LcXONKmtUkd/HciXpJAZOLshdW6SeARjOVFe9A8V+Ek=; b=f42Z4Z58+7r7uXCqw1d1uyjX2mD85sCvQ5BPnyaUUqLpcFp/cehWirbnZp5KR4E8pL WPL8RT3d8/3QD8K7jD2Qfi73HNhQdS0uG/amY7u7yWxUrfBhGgEhQ6g/tyu24p49gJMV 86L0nQY5e5odBJR0aDx2yjHdbIo6MJ3LPEK3Wz+sRB1m4kMSdD6Hqkz6HF9FdLWkpiHl a4KkAv1HzNFKvouqpOQZSJde3eGFShuzJciOnXGYLjvsk4TUaTCJhHwG62ec/mJOD5CY xOciqinHu4HnIZoNjtBIdAMLpvuIgzbH4FMjRwHC0o19FBhOXD1GB8P3zCjFIcG31D/5 WNiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id; bh=LcXONKmtUkd/HciXpJAZOLshdW6SeARjOVFe9A8V+Ek=; b=U1SdstTcW9+0pVCHhQjD+FiOtAdHSH0Xv49+MnrmX02BktGnaHM84TYykARIW6Iu5m tLhuQrMo0Zw7vub8AaSa8uCfUI75XQIKiWoq8uVapROHtU6M+1y71dZGKXHjG6uWr+K4 QLk0Irsl2d//wYOL0RapA9LfnQz+lCvKnomRnz08WDFcL/nwg4tanFqVGG6zjFuoS/Wt 5a6Cxsn4e8w5LR+/PjWspVIQDdGEfow+e8HQ8+D4U3O0JD72lH9r26DdH1JUVsAy2Mch Y6GfB7bBCjz5ro7M3nJf0oyaFEuXEH4h3J6LbqJU3Nub320GMfZnacnbCviAjWg5/BcI Ge/g== X-Gm-Message-State: AG10YORiFMvMGYqK0dGt+A5H5uTZ4IL9KlgOo+m262OYjQVoP4tGlD4e1QtLZ+E/uAqy+yLo X-Received: by 10.98.76.80 with SMTP id z77mr44230652pfa.121.1454955194623; Mon, 08 Feb 2016 10:13:14 -0800 (PST) Received: from localhost.localdomain (host-174-45-44-32.hln-mt.client.bresnan.net. [174.45.44.32]) by smtp.gmail.com with ESMTPSA id 76sm44962718pft.44.2016.02.08.10.13.12 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 08 Feb 2016 10:13:13 -0800 (PST) From: tim.gardner@canonical.com To: kernel-team@lists.ubuntu.com Subject: [PATCH Vivid/Wily SRU] x86/xen/p2m: hint at the last populated P2M entry Date: Mon, 8 Feb 2016 11:13:09 -0700 Message-Id: <1454955189-2020-1-git-send-email-tim.gardner@canonical.com> X-Mailer: git-send-email 1.9.1 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: kernel-team-bounces@lists.ubuntu.com From: David Vrabel BugLink: http://bugs.launchpad.net/bugs/1542941 With commit 633d6f17cd91ad5bf2370265946f716e42d388c6 (x86/xen: prepare p2m list for memory hotplug) the P2M may be sized to accomdate a much larger amount of memory than the domain currently has. When saving a domain, the toolstack must scan all the P2M looking for populated pages. This results in a performance regression due to the unnecessary scanning. Instead of reporting (via shared_info) the maximum possible size of the P2M, hint at the last PFN which might be populated. This hint is increased as new leaves are added to the P2M (in the expectation that they will be used for populated entries). Signed-off-by: David Vrabel Cc: # 4.0+ (back ported from commit 98dd166ea3a3c3b57919e20d9b0d1237fcd0349d) Signed-off-by: Tim Gardner Conflicts: arch/x86/xen/p2m.c Acked-by: Andy Whitcroft --- arch/x86/xen/p2m.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/arch/x86/xen/p2m.c b/arch/x86/xen/p2m.c index 8b7f18e..912b123 100644 --- a/arch/x86/xen/p2m.c +++ b/arch/x86/xen/p2m.c @@ -108,6 +108,15 @@ static unsigned long *p2m_identity; static pte_t *p2m_missing_pte; static pte_t *p2m_identity_pte; +/* + * Hint at last populated PFN. + * + * Used to set HYPERVISOR_shared_info->arch.max_pfn so the toolstack + * can avoid scanning the whole P2M (which may be sized to account for + * hotplugged memory). + */ +static unsigned long xen_p2m_last_pfn; + static inline unsigned p2m_top_index(unsigned long pfn) { BUG_ON(pfn >= MAX_P2M_PFN); @@ -262,7 +271,7 @@ void xen_setup_mfn_list_list(void) HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list_list = virt_to_mfn(p2m_top_mfn); - HYPERVISOR_shared_info->arch.max_pfn = xen_max_p2m_pfn; + HYPERVISOR_shared_info->arch.max_pfn = xen_p2m_last_pfn; } /* Set up p2m_top to point to the domain-builder provided p2m pages */ @@ -394,6 +403,8 @@ void __init xen_vmalloc_p2m_tree(void) static struct vm_struct vm; unsigned long p2m_limit; + xen_p2m_last_pfn = xen_max_p2m_pfn; + p2m_limit = (phys_addr_t)P2M_LIMIT * 1024 * 1024 * 1024 / PAGE_SIZE; vm.flags = VM_ALLOC; vm.size = ALIGN(sizeof(unsigned long) * max(xen_max_p2m_pfn, p2m_limit), @@ -590,6 +601,12 @@ static bool alloc_p2m(unsigned long pfn) free_p2m_page(p2m); } + /* Expanded the p2m? */ + if (pfn > xen_p2m_last_pfn) { + xen_p2m_last_pfn = pfn; + HYPERVISOR_shared_info->arch.max_pfn = xen_p2m_last_pfn; + } + return true; }