From: Juergen Gross <jgross@suse.com>
To: xen-devel@lists.xenproject.org
Cc: Juergen Gross <jgross@suse.com>,
Andrew Cooper <andrew.cooper3@citrix.com>,
George Dunlap <george.dunlap@citrix.com>,
Jan Beulich <jbeulich@suse.com>, Julien Grall <julien@xen.org>,
Stefano Stabellini <sstabellini@kernel.org>, Wei Liu <wl@xen.org>
Subject: [PATCH 2/2] xen/gnttab: reduce size of struct active_grant_entry
Date: Mon, 12 Sep 2022 07:53:56 +0200 [thread overview]
Message-ID: <20220912055356.24064-3-jgross@suse.com> (raw)
In-Reply-To: <20220912055356.24064-1-jgross@suse.com>
The size of struct active_grant_entry for 64-bit builds is 40 or 48
bytes today (with or without NDEBUG).
It can easily be reduced by 8 bytes by replacing the trans_domain
pointer with the domid of the related domain. trans_domain is only ever
used for transitive grants, which last known user has been the old
Xenolinux branch of the Linux kernel.
This reduction will result in less memory usage and (for production
builds) in faster code, as indexing into the active_grant_entry array
will be much easier with an entry having a power-of-2 size.
The performance loss when using transitive grants shouldn't really
matter, given the probability that those aren't in use at all today.
Signed-off-by: Juergen Gross <jgross@suse.com>
---
xen/common/grant_table.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c
index fba329dcc2..8e4bbe3824 100644
--- a/xen/common/grant_table.c
+++ b/xen/common/grant_table.c
@@ -381,13 +381,13 @@ struct active_grant_entry {
})
domid_t domid; /* Domain being granted access. */
+ domid_t trans_domid; /* Domain granting access. */
unsigned int start:15; /* For sub-page grants, the start offset
in the page. */
bool is_sub_page:1; /* True if this is a sub-page grant. */
unsigned int length:16; /* For sub-page grants, the length of the
grant. */
grant_ref_t trans_gref;
- struct domain *trans_domain;
mfn_t mfn; /* Machine frame being granted. */
#ifndef NDEBUG
gfn_t gfn; /* Guest's idea of the frame being granted. */
@@ -1095,7 +1095,7 @@ map_grant_ref(
act->start = 0;
act->length = PAGE_SIZE;
act->is_sub_page = false;
- act->trans_domain = rd;
+ act->trans_domid = rd->domain_id;
act->trans_gref = ref;
}
}
@@ -2494,7 +2494,8 @@ release_grant_for_copy(
else
{
status = &status_entry(rgt, gref);
- td = act->trans_domain;
+ td = (act->trans_domid == rd->domain_id)
+ ? rd : domid_to_domain(act->trans_domid);
trans_gref = act->trans_gref;
}
@@ -2657,7 +2658,7 @@ acquire_grant_for_copy(
!mfn_eq(act->mfn, grant_mfn) ||
act->start != trans_page_off ||
act->length != trans_length ||
- act->trans_domain != td ||
+ act->trans_domid != td->domain_id ||
act->trans_gref != trans_gref ||
!act->is_sub_page)) )
{
@@ -2676,7 +2677,7 @@ acquire_grant_for_copy(
act->domid = ldom;
act->start = trans_page_off;
act->length = trans_length;
- act->trans_domain = td;
+ act->trans_domid = td->domain_id;
act->trans_gref = trans_gref;
act->mfn = grant_mfn;
act_set_gfn(act, INVALID_GFN);
@@ -2738,7 +2739,7 @@ acquire_grant_for_copy(
act->is_sub_page = is_sub_page;
act->start = trans_page_off;
act->length = trans_length;
- act->trans_domain = td;
+ act->trans_domid = td->domain_id;
act->trans_gref = trans_gref;
act->mfn = grant_mfn;
}
--
2.35.3
next prev parent reply other threads:[~2022-09-12 5:54 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-12 5:53 [RFC PATCH 0/2] xen/gnttab: reduce size of struct active_grant_entry Juergen Gross
2022-09-12 5:53 ` [PATCH 1/2] xen: add domid_to_domain() helper Juergen Gross
2022-09-12 8:19 ` Jan Beulich
2022-09-12 8:23 ` Juergen Gross
2022-09-12 8:31 ` Jan Beulich
2022-09-12 8:33 ` Juergen Gross
2022-09-12 8:34 ` Jan Beulich
2022-09-12 8:36 ` Julien Grall
2022-09-12 8:42 ` Jan Beulich
2022-09-12 8:44 ` Julien Grall
2022-09-12 8:47 ` Juergen Gross
2022-09-12 5:53 ` Juergen Gross [this message]
2022-09-12 8:11 ` [PATCH 2/2] xen/gnttab: reduce size of struct active_grant_entry Jan Beulich
2022-09-12 8:21 ` Juergen Gross
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220912055356.24064-3-jgross@suse.com \
--to=jgross@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=george.dunlap@citrix.com \
--cc=jbeulich@suse.com \
--cc=julien@xen.org \
--cc=sstabellini@kernel.org \
--cc=wl@xen.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.