Skip to contentSkip to conversation

Argo: don't obtain excess page references

PATCH In review Jan Beulich 4 participants 6 messages Feb 14, 2024 – Mar 7, 2024

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Argo: don't obtain excess page references

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.

---
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.

xen/common/argo.c +3 -2
@@ -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;
 }
Reviewed-by on v2 1/1
#1 lore raw

Hi Jan,

Quoted 7 lines · Jan Beulich

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.

Quoted 5 lines

---
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().

I agree with that.

Cheers,

Signature · 1 line
Julien Grall
#2 lore raw

Ping: [PATCH v2] Argo: don't obtain excess page references

Quoted 10 lines · Julien Grall
Quoted 7 lines · Jan Beulich

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.

I'll give it till the end of the week for an ack to arrive (or a substantial objection), and commit some time next week in the absence of any response.

Jan

#3 lore raw

Re: Ping: [PATCH v2] Argo: don't obtain excess page references

Quoted 9 lines · Jan Beulich
Quoted 7 lines · Julien Grall
Quoted 6 lines · Jan Beulich

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.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

I'll give it till the end of the week for an ack to arrive (or a substantial objection), and commit some time next week in the absence of any response.

I haven't gotten to this as quickly as I'd hoped for, sorry, but I've given reference to this thread to some of the downstream argo users / developers to see if there can be attention available and I'll be attending the Community Call.

Christopher

Quoted 3 lines

Jan

#4 lore raw
In reply to Julien Grall
Quoted 14 lines · Julien Grall

Hi Jan,

Quoted 7 lines · Jan Beulich

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.

Quoted 7 lines
Quoted 5 lines

---
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().

I agree with that.

Adding OpenXT mailing list as I have found that I have not had the time available that I had hoped for to spend on reviewing this Argo change, and to provide opportunity for downstream feedback.

Link to the posted patch (start of this thread):
https://lists.xenproject.org/archives/html/xen-devel/2024-02/msg00858.html

Christopher

Quoted 5 lines

Cheers,

--
Julien Grall

#5 lore raw
Quoted 22 lines · Christopher Clark
Quoted 20 lines · Julien Grall

Hi Jan,

Quoted 7 lines · Jan Beulich

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.

Quoted 5 lines

---
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().

Quoted 8 lines
Quoted 1 line

I agree with that.

Adding OpenXT mailing list as I have found that I have not had the time available that I had hoped for to spend on reviewing this Argo change, and to provide opportunity for downstream feedback.

Link to the posted patch (start of this thread):
https://lists.xenproject.org/archives/html/xen-devel/2024-02/msg00858.html

Could we add some more designated reviewers / maintainers to the Argo code to help spread the load a bit?

-George