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 Jun 18, 2024
1 parent cb85dfa commit 28a74e6
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 @@ -343,12 +343,12 @@ static int gnttab_init(void)
put_free_entry(gref);
}

for (i = 0; i < NR_GRANT_FRAMES; i++) {
for (i = 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(Z_TOPLEVEL_ROM_NAME(grant_tables).phys_addr) + i;
xatp.idx = i - 1;
xatp.gpfn = xen_virt_to_gfn(Z_TOPLEVEL_ROM_NAME(grant_tables).phys_addr) + (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 28a74e6

Please sign in to comment.