From patchwork Tue Mar 10 17:49:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 11430009 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 8568C92A for ; Tue, 10 Mar 2020 17:51:32 +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 6729B20727 for ; Tue, 10 Mar 2020 17:51:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6729B20727 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org Authentication-Results: mail.kernel.org; spf=none 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 1jBj0W-0008QY-J6; Tue, 10 Mar 2020 17:49:32 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jBj0W-0008QT-6y for xen-devel@lists.xenproject.org; Tue, 10 Mar 2020 17:49:32 +0000 X-Inumbo-ID: 7eace40e-62f7-11ea-b34e-bc764e2007e4 Received: from smtp-fw-33001.amazon.com (unknown [207.171.190.10]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 7eace40e-62f7-11ea-b34e-bc764e2007e4; Tue, 10 Mar 2020 17:49:31 +0000 (UTC) IronPort-SDR: J6PH6fxGfN9alo+HwpnasG/6C3Du+EqBdglSczdBwpCYKj58eyHEvyxEdzSY9eb68/BuEV+fWS cG82Cy8JZQAg== X-IronPort-AV: E=Sophos;i="5.70,537,1574121600"; d="scan'208";a="31778865" Received: from sea32-co-svc-lb4-vlan3.sea.corp.amazon.com (HELO email-inbound-relay-1d-37fd6b3d.us-east-1.amazon.com) ([10.47.23.38]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 10 Mar 2020 17:49:30 +0000 Received: from EX13MTAUEB002.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1d-37fd6b3d.us-east-1.amazon.com (Postfix) with ESMTPS id 1CCFF28523C; Tue, 10 Mar 2020 17:49:26 +0000 (UTC) Received: from EX13D07UEB003.ant.amazon.com (10.43.60.7) by EX13MTAUEB002.ant.amazon.com (10.43.60.12) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Tue, 10 Mar 2020 17:49:25 +0000 Received: from EX13MTAUEB002.ant.amazon.com (10.43.60.12) by EX13D07UEB003.ant.amazon.com (10.43.60.7) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 10 Mar 2020 17:49:25 +0000 Received: from u2f063a87eabd5f.cbg10.amazon.com (10.125.106.135) by mail-relay.amazon.com (10.43.60.234) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Tue, 10 Mar 2020 17:49:24 +0000 From: To: Date: Tue, 10 Mar 2020 17:49:14 +0000 Message-ID: <20200310174917.1514-3-paul@xen.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200310174917.1514-1-paul@xen.org> References: <20200310174917.1514-1-paul@xen.org> MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v6 2/5] mm: keep PGC_extra pages on a separate list X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 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" From: Paul Durrant 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 --- Cc: Andrew Cooper Cc: George Dunlap Cc: Ian Jackson Cc: Jan Beulich Cc: Julien Grall Cc: Stefano Stabellini Cc: Wei Liu Cc: "Roger Pau Monné" v6: - New in v6 --- xen/arch/x86/domain.c | 7 +++++++ 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 | 12 ++++++++++++ 6 files changed, 25 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index bdcc0d972a..2dda2dbca1 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -257,6 +257,13 @@ void dump_pageframe_info(struct domain *d) _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 ba7a905258..4ef0d3b21e 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -406,6 +406,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..81beb359e1 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..0769e376d2 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 f41d0ad2a0..85433e0bb1 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -355,6 +355,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) */ /* @@ -538,6 +539,17 @@ 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; + else 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) {