Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752977AbbGXMPW (ORCPT ); Fri, 24 Jul 2015 08:15:22 -0400 Received: from smtp02.citrix.com ([66.165.176.63]:59832 "EHLO SMTP02.CITRIX.COM" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752381AbbGXMPT (ORCPT ); Fri, 24 Jul 2015 08:15:19 -0400 X-IronPort-AV: E=Sophos;i="5.15,538,1432598400"; d="scan'208";a="287238112" From: David Vrabel To: CC: David Vrabel , Konrad Rzeszutek Wilk , Boris Ostrovsky , , , Daniel Kiper Subject: [PATCHv2 10/10] xen/balloon: pre-allocate p2m entries for ballooned pages Date: Fri, 24 Jul 2015 12:47:48 +0100 Message-ID: <1437738468-24110-11-git-send-email-david.vrabel@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1437738468-24110-1-git-send-email-david.vrabel@citrix.com> References: <1437738468-24110-1-git-send-email-david.vrabel@citrix.com> MIME-Version: 1.0 Content-Type: text/plain X-DLP: MIA1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1717 Lines: 56 Pages returned by alloc_xenballooned_pages() will be used for grant mapping which will call set_phys_to_machine() (in PV guests). Ballooned pages are set as INVALID_P2M_ENTRY in the p2m and thus may be using the (shared) missing tables and a subsequent set_phys_to_machine() will need to allocate new tables. Since the grant mapping may be done from a context that cannot sleep, the p2m entries must already be allocated. Signed-off-by: David Vrabel --- drivers/xen/balloon.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c index fd6970f3..8932d10 100644 --- a/drivers/xen/balloon.c +++ b/drivers/xen/balloon.c @@ -541,6 +541,7 @@ int alloc_xenballooned_pages(int nr_pages, struct page **pages) { int pgno = 0; struct page *page; + int ret = -ENOMEM; mutex_lock(&balloon_mutex); @@ -550,6 +551,11 @@ int alloc_xenballooned_pages(int nr_pages, struct page **pages) page = balloon_retrieve(true); if (page) { pages[pgno++] = page; +#ifdef CONFIG_XEN_HAVE_PVMMU + ret = xen_alloc_p2m_entry(page_to_pfn(page)); + if (ret < 0) + goto out_undo; +#endif } else { enum bp_state st; @@ -576,7 +582,7 @@ int alloc_xenballooned_pages(int nr_pages, struct page **pages) out_undo: mutex_unlock(&balloon_mutex); free_xenballooned_pages(pgno, pages); - return -ENOMEM; + return ret; } EXPORT_SYMBOL(alloc_xenballooned_pages); -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/