All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] xen/evtchn: rearrange fields
@ 2014-03-25 17:23 Daniel De Graaf
  2014-03-26 11:41 ` Jan Beulich
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel De Graaf @ 2014-03-25 17:23 UTC (permalink / raw)
  To: xen-devel; +Cc: dgdegra, Keir Fraser, David Vrabel, Jan Beulich

Event channel arrays are allocated in blocks with EVTCHNS_PER_BUCKET
elements, which must be a power of 2.  When XSM is disabled, struct
evtchn is 32 bytes including padding; however, when XSM is enabled, the
structure becomes larger and EVTCHNS_PER_BUCKET is halved.  Rearranging
some of the fields in struct evtchn allows a 4-byte XSM field to fit
within the 32-byte structure.

This rearrangement turns the xen_consumer field of struct evtchn into a
bitfield and adjusts the xen_consumers array to fit the number of
addressable elements from this value.  Since there are currently only
two users of this array, only 3 bits (7 values) are reserved.  This
field is also used rarely enough that the slight overhead from applying
a bitmask should not cause problems.

Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Cc: David Vrabel <david.vrabel@citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Keir Fraser <keir@xen.org>
---
 xen/common/event_channel.c | 2 +-
 xen/include/xen/sched.h    | 9 ++++++---
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/xen/common/event_channel.c b/xen/common/event_channel.c
index db952af..83bc7df 100644
--- a/xen/common/event_channel.c
+++ b/xen/common/event_channel.c
@@ -59,7 +59,7 @@
  * with a pointer, we stash them dynamically in a small lookup array which
  * can be indexed by a small integer.
  */
-static xen_event_channel_notification_t xen_consumers[8];
+static xen_event_channel_notification_t xen_consumers[NR_XEN_CONSUMERS];
 
 /* Default notification action: wake up from wait_on_xen_event_channel(). */
 static void default_xen_notification_fn(struct vcpu *v, unsigned int port)
diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index b9ba379..94c7db3 100644
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -68,6 +68,9 @@ extern struct domain *dom0;
 #define EVTCHNS_PER_GROUP  (BUCKETS_PER_GROUP * EVTCHNS_PER_BUCKET)
 #define NR_EVTCHN_GROUPS   DIV_ROUND_UP(MAX_NR_EVTCHNS, EVTCHNS_PER_GROUP)
 
+#define XEN_CONSUMER_BITS 3
+#define NR_XEN_CONSUMERS ((1 << XEN_CONSUMER_BITS) - 1)
+
 struct evtchn
 {
 #define ECS_FREE         0 /* Channel is available for use.                  */
@@ -78,7 +81,8 @@ struct evtchn
 #define ECS_VIRQ         5 /* Channel is bound to a virtual IRQ line.        */
 #define ECS_IPI          6 /* Channel is bound to a virtual IPI line.        */
     u8  state;             /* ECS_* */
-    u8  xen_consumer;      /* Consumer in Xen, if any? (0 = send to guest) */
+    u8  xen_consumer:XEN_CONSUMER_BITS; /* Consumer in Xen if nonzero */
+    u8  pending:1;
     u16 notify_vcpu_id;    /* VCPU for local delivery notification */
     u32 port;
     union {
@@ -97,9 +101,8 @@ struct evtchn
         u16 virq;      /* state == ECS_VIRQ */
     } u;
     u8 priority;
-    u8 pending:1;
-    u16 last_vcpu_id;
     u8 last_priority;
+    u16 last_vcpu_id;
 #ifdef XSM_ENABLE
     union {
 #ifdef XSM_NEED_GENERIC_EVTCHN_SSID
-- 
1.8.5.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-04-01 15:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-25 17:23 [PATCH v2] xen/evtchn: rearrange fields Daniel De Graaf
2014-03-26 11:41 ` Jan Beulich
2014-04-01 15:56   ` Keir Fraser

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.