All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@suse.com>
To: xen-devel <xen-devel@lists.xenproject.org>
Cc: Stefano Stabellini <sstabellini@kernel.org>,
	Wei Liu <wei.liu2@citrix.com>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	George Dunlap <George.Dunlap@eu.citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Ian Jackson <Ian.Jackson@eu.citrix.com>, Tim Deegan <tim@xen.org>,
	Julien Grall <julien.grall@arm.com>
Subject: [PATCH v2 1/2] x86: reduce code duplication in guest_remove_page()
Date: Wed, 05 Dec 2018 09:17:02 -0700	[thread overview]
Message-ID: <5C07F9FE020000780020336A@prv1-mh.provo.novell.com> (raw)
In-Reply-To: <5C07F95A0200007800203354@prv1-mh.provo.novell.com>

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@suse.com>
---
v2: Re-base.

--- a/xen/common/memory.c
+++ b/xen/common/memory.c
@@ -320,30 +320,15 @@ int guest_remove_page(struct domain *d,
         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,
     }
 #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;
     }





_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2018-12-05 16:17 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-20 16:12 [PATCH 0/4] XSA-276 follow-up Jan Beulich
2018-11-20 16:17 ` [PATCH 1/4] mm: disallow MEMF_no_refcount to be passed for domain-owned allocations Jan Beulich
2018-11-20 16:35   ` Andrew Cooper
2018-11-23  9:45   ` [PATCH v2] " Jan Beulich
2018-11-23 10:28     ` Andrew Cooper
2018-11-23 10:49       ` Jan Beulich
2018-11-23 10:50         ` Andrew Cooper
2018-11-20 16:18 ` [PATCH 2/4] x86: correct instances of PGC_allocated clearing Jan Beulich
2018-11-20 16:59   ` Andrew Cooper
2018-11-20 17:12     ` Jan Beulich
2018-11-21  2:47       ` Tamas K Lengyel
2018-11-20 16:19 ` [PATCH 3/4] x86: reduce code duplication in guest_remove_page() Jan Beulich
2018-11-20 17:06   ` Andrew Cooper
2018-11-21  9:28     ` Jan Beulich
2018-11-20 16:19 ` [PATCH 4/4] make domain_adjust_tot_pages() __must_check Jan Beulich
2018-12-05 16:14 ` [PATCH v2 0/2] remaining XSA-276 follow-up Jan Beulich
2018-12-05 16:17   ` Jan Beulich [this message]
2018-12-05 20:03     ` [PATCH v2 1/2] x86: reduce code duplication in guest_remove_page() Andrew Cooper
2018-12-05 16:17   ` [PATCH v2 2/2] make domain_adjust_tot_pages() __must_check Jan Beulich
2018-12-05 20:08     ` Andrew Cooper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5C07F9FE020000780020336A@prv1-mh.provo.novell.com \
    --to=jbeulich@suse.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=julien.grall@arm.com \
    --cc=konrad.wilk@oracle.com \
    --cc=sstabellini@kernel.org \
    --cc=tim@xen.org \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.