Skip to content

Commit

Permalink
drivers: xen: gnttab: process gnttabs in reverse order
Browse files Browse the repository at this point in the history
The Xen extends domain grant tables every time domain requests gnttab
basing on gnttab idx. If idx > xen_current_max_gnttab_idx the Xen extends
grant table so that idx <= xen_current_max_gnttab_idx. The growing grant
tables on every hypercall is a bit costly operation and it also results in
the bunch of log messages:

(XEN) xen-source/xen/common/grant_table.c:1909:d0v0 Expanding d0 \
  grant table from 1 to 2 frames

This patch changes gnttab processing from gnttab max_idx to low_idx, so the
first hypercall has the largest index, ensuring that the grant table will
grow only once. It also reduces number of log messages.

Signed-off-by: Grygorii Strashko <[email protected]>
Acked-by: Volodymyr Babchuk <[email protected]>
Reviewed-by: Dmytro Firsov <[email protected]>
  • Loading branch information
Grygorii Strashko committed Jul 2, 2024
1 parent c792735 commit 216f45c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/xen/gnttab.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,12 +372,12 @@ static int gnttab_init(void)
gnttab.gref_list[0] = gref;
}

for (i = 0; i < CONFIG_NR_GRANT_FRAMES; i++) {
for (i = CONFIG_NR_GRANT_FRAMES; i; i--) {
xatp.domid = DOMID_SELF;
xatp.size = 0;
xatp.space = XENMAPSPACE_grant_table;
xatp.idx = i;
xatp.gpfn = xen_virt_to_gfn(gnttab_base) + i;
xatp.idx = i - 1;
xatp.gpfn = xen_virt_to_gfn(gnttab_base) + (i - 1);
rc = HYPERVISOR_memory_op(XENMEM_add_to_physmap, &xatp);
__ASSERT(!rc, "add_to_physmap failed; status = %d\n", rc);
}
Expand Down

0 comments on commit 216f45c

Please sign in to comment.