Skip to contentSkip to conversation

gnttab: don't allocate status frame tracking array when "gnttab=max_ver:1"

PATCH In review Jan Beulich 2 participants 4 messages Nov 5, 2020 – Dec 4, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gnttab: don't allocate status frame tracking array when "gnttab=max_ver:1"

This array can be large when many grant frames are permitted; avoid allocating it when it's not going to be used anyway. Do so indirectly though, by making grant_to_status_frames() return zero in this case.

xen/common/grant_table.c +3 -0
@@ -446,11 +446,14 @@ static inline void active_entry_release(
 
 static inline unsigned int grant_to_status_frames(unsigned int grant_frames)
 {
+    if ( opt_gnttab_max_version < 2 )
+        return 0;
     return DIV_ROUND_UP(grant_frames * GRANT_PER_PAGE, GRANT_STATUS_PER_PAGE);
 }
 
 static inline unsigned int status_to_grant_frames(unsigned int status_frames)
 {
+    ASSERT(opt_gnttab_max_version >= 2);
     return DIV_ROUND_UP(status_frames * GRANT_STATUS_PER_PAGE, GRANT_PER_PAGE);
 }
 
#1 lore raw

Ping: [PATCH] gnttab: don't allocate status frame tracking array when "gnttab=max_ver:1"

Quoted 5 lines · Jan Beulich

This array can be large when many grant frames are permitted; avoid allocating it when it's not going to be used anyway. Do so indirectly though, by making grant_to_status_frames() return zero in this case.

Ping?

Quoted 18 lines
xen/common/grant_table.c +3 -0
@@ -446,11 +446,14 @@ static inline void active_entry_release(
 
 static inline unsigned int grant_to_status_frames(unsigned int grant_frames)
 {
+    if ( opt_gnttab_max_version < 2 )
+        return 0;
     return DIV_ROUND_UP(grant_frames * GRANT_PER_PAGE, GRANT_STATUS_PER_PAGE);
 }
 
 static inline unsigned int status_to_grant_frames(unsigned int status_frames)
 {
+    ASSERT(opt_gnttab_max_version >= 2);
     return DIV_ROUND_UP(status_frames * GRANT_STATUS_PER_PAGE, GRANT_PER_PAGE);
 }
 
#2 lore raw
In reply to Jan Beulich

Hi Jan,

Quoted 2 lines · Jan Beulich

This array can be large when many grant frames are permitted; avoid allocating it when it's not going to be used anyway.

Given there are not many users of grant-table v2, would it make sense to avoid allocating the array until the guest start using grant-table v2?

Cheers,

Signature · 1 line
Julien Grall
#3 lore raw
Quoted 6 lines · Julien Grall
Quoted 2 lines · Jan Beulich

This array can be large when many grant frames are permitted; avoid allocating it when it's not going to be used anyway.

Given there are not many users of grant-table v2, would it make sense to avoid allocating the array until the guest start using grant-table v2?

Hmm, yes, seems possible. Let me give this a try.

Jan