Skip to contentSkip to conversation

mm: Scrub pages returned back to heap if MEMF_no_scrub is set

PATCH In review Boris Ostrovsky 4 participants 5 messages Sep 15, 2017 – Sep 18, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm: Scrub pages returned back to heap if MEMF_no_scrub is set

Set free_heap_pages()'s need_scrub to true if alloc_domheap_pages() returns pages back to heap as result of assign_pages() error when those pages were requested with MEMF_no_scrub flag.

We need to do this because there is a possibility that alloc_heap_pages() might clear buddy's PGC_need_scrubs flag without actually clearing the page.

---
We are declaring a likely clean (or almost clean) chunk to be dirty. Since this only happend on assign_pages() error I figured it would be acceptable.

Alternatively, we could make alloc_heap_pages() return (via a parameter) an indication whether anything was dirty.

 xen/common/page_alloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/common/page_alloc.c +1 -1
index 86c0794..e88373d 100644
@@ -2227,7 +2227,7 @@ struct page_info *alloc_domheap_pages(
     if ( d && !(memflags & MEMF_no_owner) &&
          assign_pages(d, pg, order, memflags) )
     {
-        free_heap_pages(pg, order, false);
+        free_heap_pages(pg, order, !!(memflags & MEMF_no_scrub));
         return NULL;
     }
     
Signature · 7 lines
1.8.3.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 15.09.17 at 16:04, <[email protected]> wrote:

Set free_heap_pages()'s need_scrub to true if alloc_domheap_pages() returns pages back to heap as result of assign_pages() error when those pages were requested with MEMF_no_scrub flag.

Quoted 8 lines

We need to do this because there is a possibility that alloc_heap_pages() might clear buddy's PGC_need_scrubs flag without actually clearing the page.

---
We are declaring a likely clean (or almost clean) chunk to be dirty. Since this only happend on assign_pages() error I figured it would be acceptable.

I think that's fine, but let's wait a little to see whether others have differing opinions.

xen/common/page_alloc.c struct page_info *alloc_domheap_pages( · line 2230

Quoted 8 lines
xen/common/page_alloc.c +1 -1
@@ -2227,7 +2227,7 @@ struct page_info *alloc_domheap_pages(
     if ( d && !(memflags & MEMF_no_owner) &&
          assign_pages(d, pg, order, memflags) )
     {
-        free_heap_pages(pg, order, false);
+        free_heap_pages(pg, order, !!(memflags & MEMF_no_scrub));

No need for the !! (easily fixed while committing). With that

I take it this isn't related to the issue on ARM64 that Konrad has found?

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#2 lore raw
Quoted 16 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 15.09.17 at 16:04, <[email protected]> wrote:

Set free_heap_pages()'s need_scrub to true if alloc_domheap_pages() returns pages back to heap as result of assign_pages() error when those pages were requested with MEMF_no_scrub flag.

Quoted 8 lines

We need to do this because there is a possibility that alloc_heap_pages() might clear buddy's PGC_need_scrubs flag without actually clearing the page.

---
We are declaring a likely clean (or almost clean) chunk to be dirty. Since this only happend on assign_pages() error I figured it would be acceptable.

I think that's fine, but let's wait a little to see whether others have differing opinions.

Quoted 9 lines

xen/common/page_alloc.c struct page_info *alloc_domheap_pages( · line 2230

Quoted 8 lines
xen/common/page_alloc.c +1 -1
@@ -2227,7 +2227,7 @@ struct page_info *alloc_domheap_pages(
     if ( d && !(memflags & MEMF_no_owner) &&
          assign_pages(d, pg, order, memflags) )
     {
-        free_heap_pages(pg, order, false);
+        free_heap_pages(pg, order, !!(memflags & MEMF_no_scrub));

No need for the !! (easily fixed while committing).

Sure.

Quoted 5 lines

With that

I take it this isn't related to the issue on ARM64 that Konrad has found?

It's related in the sense that I noticed this while looking at Konrad's problem. Whether or not it also fixes his issue --- I don't know. If it does then I think it will indicate that something else is going on there since this would mean he is hitting assign_pages() error.

-boris

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#3 lore raw
Quoted 32 lines · Boris Ostrovsky
Quoted 16 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 15.09.17 at 16:04, <[email protected]> wrote:

Set free_heap_pages()'s need_scrub to true if alloc_domheap_pages() returns pages back to heap as result of assign_pages() error when those pages were requested with MEMF_no_scrub flag.

Quoted 8 lines

We need to do this because there is a possibility that alloc_heap_pages() might clear buddy's PGC_need_scrubs flag without actually clearing the page.

---
We are declaring a likely clean (or almost clean) chunk to be dirty. Since this only happend on assign_pages() error I figured it would be acceptable.

I think that's fine, but let's wait a little to see whether others have differing opinions.

Quoted 9 lines

xen/common/page_alloc.c struct page_info *alloc_domheap_pages( · line 2230

Quoted 8 lines
xen/common/page_alloc.c +1 -1
@@ -2227,7 +2227,7 @@ struct page_info *alloc_domheap_pages(
     if ( d && !(memflags & MEMF_no_owner) &&
          assign_pages(d, pg, order, memflags) )
     {
-        free_heap_pages(pg, order, false);
+        free_heap_pages(pg, order, !!(memflags & MEMF_no_scrub));

No need for the !! (easily fixed while committing).

Sure.

Quoted 3 lines

With that

Quoted 8 lines
Quoted 2 lines

I take it this isn't related to the issue on ARM64 that Konrad has found?

It's related in the sense that I noticed this while looking at Konrad's problem. Whether or not it also fixes his issue --- I don't know. If it does then I think it will indicate that something else is going on there since this would mean he is hitting assign_pages() error.

Sadly no. Let me update the other email.

Quoted 3 lines

-boris

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#4 lore raw
In reply to Jan Beulich
Quoted 9 lines · Jan Beulich
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 15.09.17 at 16:04, <[email protected]> wrote:

Set free_heap_pages()'s need_scrub to true if alloc_domheap_pages() returns pages back to heap as result of assign_pages() error when those pages were requested with MEMF_no_scrub flag.

We need to do this because there is a possibility that alloc_heap_pages() might clear buddy's PGC_need_scrubs flag without actually clearing the page.

Quoted 8 lines
Quoted 4 lines

---
We are declaring a likely clean (or almost clean) chunk to be dirty. Since this only happend on assign_pages() error I figured it would be acceptable.

I think that's fine, but let's wait a little to see whether others have differing opinions.

I think that's fine, too.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel