From patchwork Wed Mar 18 17:32:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 11445793 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CB7971392 for ; Wed, 18 Mar 2020 17:36:00 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A7BDB20724 for ; Wed, 18 Mar 2020 17:36:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=xen.org header.i=@xen.org header.b="Ffb1syo9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A7BDB20724 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jEcYq-0006Rt-S9; Wed, 18 Mar 2020 17:32:56 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jEcYp-0006Rn-AJ for xen-devel@lists.xenproject.org; Wed, 18 Mar 2020 17:32:55 +0000 X-Inumbo-ID: 7d5027c2-693e-11ea-a6c1-bc764e2007e4 Received: from mail.xenproject.org (unknown [104.130.215.37]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 7d5027c2-693e-11ea-a6c1-bc764e2007e4; Wed, 18 Mar 2020 17:32:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:Content-Type:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=YLLsGkjP4tF/WD6q6mbIXn9yrxko9P1svCXUoA5+hZE=; b=Ffb1syo9zGhD03DXMHBiR9c6gb cZKF2fDaRkW8JXmgycd9b4Xw2cEAabUcYmtay+tDaPv4vbh0A+Twujn6gVRWHssuMk7eK+mELB+ba 2mb9pxfwDVsefLTREHfTIFDx3XWWnpJIcH/S7XTbjAzc5LYW0j/gpb58iv1kZg+NT9K8=; Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jEcYj-0005U5-9o; Wed, 18 Mar 2020 17:32:49 +0000 Received: from 54-240-197-232.amazon.com ([54.240.197.232] helo=u2f063a87eabd5f.cbg10.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1jEcYj-0007B3-0F; Wed, 18 Mar 2020 17:32:49 +0000 From: Paul Durrant To: xen-devel@lists.xenproject.org Date: Wed, 18 Mar 2020 17:32:41 +0000 Message-Id: <20200318173243.29183-2-paul@xen.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200318173243.29183-1-paul@xen.org> References: <20200318173243.29183-1-paul@xen.org> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v4 1/3] mm: keep PGC_extra pages on a separate list X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Julien Grall , Wei Liu , Paul Durrant , Andrew Cooper , Ian Jackson , George Dunlap , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" This patch adds a new page_list_head into struct domain to hold PGC_extra pages. This avoids them getting confused with 'normal' domheap pages where the domain's page_list is walked. A new dump loop is also added to dump_pageframe_info() to unconditionally dump the 'extra page list'. Signed-off-by: Paul Durrant Reviewed-by: Jan Beulich Acked-by: Julien Grall --- Cc: Andrew Cooper Cc: George Dunlap Cc: Ian Jackson Cc: Julien Grall Cc: Stefano Stabellini Cc: Wei Liu Cc: "Roger Pau Monné" v7: - Cosmetic changes v6: - New in v6 --- xen/arch/x86/domain.c | 9 +++++++++ xen/common/domain.c | 1 + xen/common/page_alloc.c | 2 +- xen/include/asm-x86/mm.h | 6 ++---- xen/include/xen/mm.h | 5 ++--- xen/include/xen/sched.h | 13 +++++++++++++ 6 files changed, 28 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index caf2ecad7e..683bc619aa 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -251,12 +251,21 @@ void dump_pageframe_info(struct domain *d) p2m_pod_dump_data(d); spin_lock(&d->page_alloc_lock); + page_list_for_each ( page, &d->xenpage_list ) { printk(" XenPage %p: caf=%08lx, taf=%" PRtype_info "\n", _p(mfn_x(page_to_mfn(page))), page->count_info, page->u.inuse.type_info); } + + page_list_for_each ( page, &d->extra_page_list ) + { + printk(" ExtraPage %p: caf=%08lx, taf=%" PRtype_info "\n", + _p(mfn_x(page_to_mfn(page))), + page->count_info, page->u.inuse.type_info); + } + spin_unlock(&d->page_alloc_lock); } diff --git a/xen/common/domain.c b/xen/common/domain.c index b4eb476a9c..3dcd73f67c 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -403,6 +403,7 @@ struct domain *domain_create(domid_t domid, spin_lock_init_prof(d, page_alloc_lock); spin_lock_init(&d->hypercall_deadlock_mutex); INIT_PAGE_LIST_HEAD(&d->page_list); + INIT_PAGE_LIST_HEAD(&d->extra_page_list); INIT_PAGE_LIST_HEAD(&d->xenpage_list); spin_lock_init(&d->node_affinity_lock); diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 76d37226df..10b7aeca48 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -2314,7 +2314,7 @@ int assign_pages( smp_wmb(); /* Domain pointer must be visible before updating refcnt. */ pg[i].count_info = (pg[i].count_info & PGC_extra) | PGC_allocated | 1; - page_list_add_tail(&pg[i], &d->page_list); + page_list_add_tail(&pg[i], page_to_list(d, &pg[i])); } out: diff --git a/xen/include/asm-x86/mm.h b/xen/include/asm-x86/mm.h index a06b2fb81f..1fa334b306 100644 --- a/xen/include/asm-x86/mm.h +++ b/xen/include/asm-x86/mm.h @@ -629,10 +629,8 @@ typedef struct mm_rwlock { const char *locker_function; /* func that took it */ } mm_rwlock_t; -#define arch_free_heap_page(d, pg) \ - page_list_del2(pg, is_xen_heap_page(pg) ? \ - &(d)->xenpage_list : &(d)->page_list, \ - &(d)->arch.relmem_list) +#define arch_free_heap_page(d, pg) \ + page_list_del2(pg, page_to_list(d, pg), &(d)->arch.relmem_list) extern const char zero_page[]; diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h index d0d095d9c7..a163c201e2 100644 --- a/xen/include/xen/mm.h +++ b/xen/include/xen/mm.h @@ -583,9 +583,8 @@ static inline unsigned int get_order_from_pages(unsigned long nr_pages) void scrub_one_page(struct page_info *); #ifndef arch_free_heap_page -#define arch_free_heap_page(d, pg) \ - page_list_del(pg, is_xen_heap_page(pg) ? \ - &(d)->xenpage_list : &(d)->page_list) +#define arch_free_heap_page(d, pg) \ + page_list_del(pg, page_to_list(d, pg)) #endif int xenmem_add_to_physmap_one(struct domain *d, unsigned int space, diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index e6813288ab..4b78291d51 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -329,6 +329,7 @@ struct domain spinlock_t page_alloc_lock; /* protects all the following fields */ struct page_list_head page_list; /* linked list */ + struct page_list_head extra_page_list; /* linked list (size extra_pages) */ struct page_list_head xenpage_list; /* linked list (size xenheap_pages) */ /* @@ -512,6 +513,18 @@ struct domain #endif }; +static inline struct page_list_head *page_to_list( + struct domain *d, const struct page_info *pg) +{ + if ( is_xen_heap_page(pg) ) + return &d->xenpage_list; + + if ( pg->count_info & PGC_extra ) + return &d->extra_page_list; + + return &d->page_list; +} + /* Return number of pages currently posessed by the domain */ static inline unsigned int domain_tot_pages(const struct domain *d) {