[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] x86: reduce code duplication in guest_remove_page()
commit 88f90693c74d5877f6b343076c31739e8754fb00 Author: Jan Beulich <jbeulich@xxxxxxxx> AuthorDate: Thu Dec 6 12:18:03 2018 +0100 Commit: Jan Beulich <jbeulich@xxxxxxxx> CommitDate: Thu Dec 6 12:18:03 2018 +0100 x86: reduce code duplication in guest_remove_page() Quite a bit of duplicate code has accumulated on the "paging" types special case path. Re-use what can be re-used from the common path. Since it needs touching anyway, slightly re-format and extend the gdprintk() on the common path as well. Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> --- xen/common/memory.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/xen/common/memory.c b/xen/common/memory.c index 175bd62c11..5f7d081c61 100644 --- a/xen/common/memory.c +++ b/xen/common/memory.c @@ -320,30 +320,15 @@ int guest_remove_page(struct domain *d, unsigned long gmfn) if ( p2mt == p2m_ram_paging_out ) { ASSERT(mfn_valid(mfn)); - page = mfn_to_page(mfn); - rc = -ENXIO; - if ( !get_page(page, d) ) - goto out_put_gfn; + goto obtain_page; } - else - page = NULL; rc = guest_physmap_remove_page(d, _gfn(gmfn), mfn, 0); if ( rc ) - { - if ( page ) - put_page(page); goto out_put_gfn; - } put_gfn(d, gmfn); - if ( page ) - { - if ( test_and_clear_bit(_PGC_allocated, &page->count_info) ) - put_page(page); - put_page(page); - } p2m_mem_paging_drop_page(d, gmfn, p2mt); return 0; @@ -387,13 +372,16 @@ int guest_remove_page(struct domain *d, unsigned long gmfn) } #endif /* CONFIG_X86 */ + obtain_page: __maybe_unused; page = mfn_to_page(mfn); if ( unlikely(!get_page(page, d)) ) { #ifdef CONFIG_X86 put_gfn(d, gmfn); + if ( !p2m_is_paging(p2mt) ) #endif - gdprintk(XENLOG_INFO, "Bad page free for domain %u\n", d->domain_id); + gdprintk(XENLOG_INFO, "Bad page free for Dom%u GFN %lx\n", + d->domain_id, gmfn); return -ENXIO; } -- generated by git-patchbot for /home/xen/git/xen.git#master _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |