All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: Christopher Clark <christopher.w.clark@gmail.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	George Dunlap <george.dunlap@citrix.com>,
	Julien Grall <julien@xen.org>,
	Stefano Stabellini <sstabellini@kernel.org>, Wei Liu <wl@xen.org>
Subject: [PATCH v2] Argo: don't obtain excess page references
Date: Wed, 14 Feb 2024 11:12:28 +0100	[thread overview]
Message-ID: <79ed633d-b0bd-4a7d-a0c6-37a034e1ee96@suse.com> (raw)

find_ring_mfn() already holds a page reference when trying to obtain a
writable type reference. We shouldn't make assumptions on the general
reference count limit being effectively "infinity". Obtain merely a type
ref, re-using the general ref by only dropping the previously acquired
one in the case of an error.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
I further question the log-dirty check there: The present P2M type of a
page doesn't really matter for writing to the page (plus it's stale by
the time it is looked at). Instead I think every write to such a page
needs to be accompanied by a call to paging_mark_dirty().
---
v2: Re-base.

--- a/xen/common/argo.c
+++ b/xen/common/argo.c
@@ -1426,7 +1426,7 @@ find_ring_mfn(struct domain *d, gfn_t gf
     switch ( p2mt )
     {
     case p2m_ram_rw:
-        if ( !get_page_and_type(page, d, PGT_writable_page) )
+        if ( !get_page_type(page, PGT_writable_page) )
             ret = -EINVAL;
         break;
 
@@ -1441,7 +1441,8 @@ find_ring_mfn(struct domain *d, gfn_t gf
         break;
     }
 
-    put_page(page);
+    if ( unlikely(ret) )
+        put_page(page);
 
     return ret;
 }


             reply	other threads:[~2024-02-14 10:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-14 10:12 Jan Beulich [this message]
2024-02-18 18:01 ` [PATCH v2] Argo: don't obtain excess page references Julien Grall
2024-02-28 14:52   ` Ping: " Jan Beulich
2024-03-06 22:10     ` Christopher Clark
2024-03-06 23:37   ` Christopher Clark
2024-03-07  9:54     ` George Dunlap

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=79ed633d-b0bd-4a7d-a0c6-37a034e1ee96@suse.com \
    --to=jbeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=christopher.w.clark@gmail.com \
    --cc=george.dunlap@citrix.com \
    --cc=julien@xen.org \
    --cc=sstabellini@kernel.org \
    --cc=wl@xen.org \
    --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.