svn commit: r303128 - head/sys/dev/hyperv/vmbus
Sepherosa Ziehau
sephe at FreeBSD.org
Thu Jul 21 05:38:07 UTC 2016
Author: sephe
Date: Thu Jul 21 05:38:05 2016
New Revision: 303128
URL: https://svnweb.freebsd.org/changeset/base/303128
Log:
hyperv/vmbus: Reorder channel fields.
MFC after: 1 week
Sponsored by: Microsoft OSTC
Differential Revision: https://reviews.freebsd.org/D7258
Modified:
head/sys/dev/hyperv/vmbus/vmbus_chan.c
head/sys/dev/hyperv/vmbus/vmbus_chanvar.h
Modified: head/sys/dev/hyperv/vmbus/vmbus_chan.c
==============================================================================
--- head/sys/dev/hyperv/vmbus/vmbus_chan.c Thu Jul 21 05:30:31 2016 (r303127)
+++ head/sys/dev/hyperv/vmbus/vmbus_chan.c Thu Jul 21 05:38:05 2016 (r303128)
@@ -83,7 +83,7 @@ static __inline void
vmbus_chan_signal_tx(const struct hv_vmbus_channel *chan)
{
atomic_set_long(chan->ch_evtflag, chan->ch_evtflag_mask);
- if (chan->ch_flags & VMBUS_CHAN_FLAG_HASMNF)
+ if (chan->ch_txflags & VMBUS_CHAN_TXF_HASMNF)
atomic_set_int(chan->ch_montrig, chan->ch_montrig_mask);
else
hypercall_signal_event(chan->ch_monprm_dma.hv_paddr);
@@ -95,7 +95,7 @@ vmbus_chan_sysctl_mnf(SYSCTL_HANDLER_ARG
struct hv_vmbus_channel *chan = arg1;
int mnf = 0;
- if (chan->ch_flags & VMBUS_CHAN_FLAG_HASMNF)
+ if (chan->ch_txflags & VMBUS_CHAN_TXF_HASMNF)
mnf = 1;
return sysctl_handle_int(oidp, &mnf, 0, req);
}
@@ -1102,7 +1102,7 @@ vmbus_chan_msgproc_choffer(struct vmbus_
/*
* Setup MNF stuffs.
*/
- chan->ch_flags |= VMBUS_CHAN_FLAG_HASMNF;
+ chan->ch_txflags |= VMBUS_CHAN_TXF_HASMNF;
trig_idx = offer->chm_montrig / VMBUS_MONTRIG_LEN;
if (trig_idx >= VMBUS_MONTRIGS_MAX)
Modified: head/sys/dev/hyperv/vmbus/vmbus_chanvar.h
==============================================================================
--- head/sys/dev/hyperv/vmbus/vmbus_chanvar.h Thu Jul 21 05:30:31 2016 (r303127)
+++ head/sys/dev/hyperv/vmbus/vmbus_chanvar.h Thu Jul 21 05:38:05 2016 (r303128)
@@ -71,42 +71,63 @@ typedef struct {
} hv_vmbus_ring_buffer_info;
typedef struct hv_vmbus_channel {
- device_t ch_dev;
- struct vmbus_softc *ch_vmbus;
+ /*
+ * NOTE:
+ * Fields before ch_txbr are only accessed on this channel's
+ * target CPU.
+ */
uint32_t ch_flags; /* VMBUS_CHAN_FLAG_ */
- uint32_t ch_id; /* channel id */
+
+ /*
+ * RX bufring; immediately following ch_txbr.
+ */
+ hv_vmbus_ring_buffer_info ch_rxbr;
+
+ struct taskqueue *ch_tq;
+ struct task ch_task;
+ vmbus_chan_callback_t ch_cb;
+ void *ch_cbarg;
+
+ /*
+ * TX bufring; at the beginning of ch_bufring.
+ *
+ * NOTE:
+ * Put TX bufring and the following MNF/evtflag to a new
+ * cacheline, since they will be accessed on all CPUs by
+ * locking ch_txbr first.
+ *
+ * XXX
+ * TX bufring and following MNF/evtflags do _not_ fit in
+ * one 64B cacheline.
+ */
+ hv_vmbus_ring_buffer_info ch_txbr __aligned(CACHE_LINE_SIZE);
+ uint32_t ch_txflags; /* VMBUS_CHAN_TXF_ */
/*
* These are based on the vmbus_chanmsg_choffer.chm_montrig.
* Save it here for easy access.
*/
- volatile uint32_t *ch_montrig; /* MNF trigger loc. */
uint32_t ch_montrig_mask;/* MNF trig mask */
+ volatile uint32_t *ch_montrig; /* MNF trigger loc. */
/*
* These are based on the vmbus_chanmsg_choffer.chm_chanid.
* Save it here for easy access.
*/
- volatile u_long *ch_evtflag; /* event flag loc. */
u_long ch_evtflag_mask;/* event flag */
+ volatile u_long *ch_evtflag; /* event flag loc. */
/*
- * TX bufring; at the beginning of ch_bufring.
- */
- hv_vmbus_ring_buffer_info ch_txbr;
- /*
- * RX bufring; immediately following ch_txbr.
+ * Rarely used fields.
*/
- hv_vmbus_ring_buffer_info ch_rxbr;
-
- struct taskqueue *ch_tq;
- struct task ch_task;
- vmbus_chan_callback_t ch_cb;
- void *ch_cbarg;
struct hyperv_mon_param *ch_monprm;
struct hyperv_dma ch_monprm_dma;
+ uint32_t ch_id; /* channel id */
+ device_t ch_dev;
+ struct vmbus_softc *ch_vmbus;
+
int ch_cpuid; /* owner cpu */
/*
* Virtual cpuid for ch_cpuid; it is used to communicate cpuid
@@ -141,11 +162,10 @@ typedef struct hv_vmbus_channel {
struct hyperv_guid ch_guid_inst;
struct sysctl_ctx_list ch_sysctl_ctx;
-} hv_vmbus_channel;
+} hv_vmbus_channel __aligned(CACHE_LINE_SIZE);
#define VMBUS_CHAN_ISPRIMARY(chan) ((chan)->ch_subidx == 0)
-#define VMBUS_CHAN_FLAG_HASMNF 0x0001
/*
* If this flag is set, this channel's interrupt will be masked in ISR,
* and the RX bufring will be drained before this channel's interrupt is
@@ -156,6 +176,8 @@ typedef struct hv_vmbus_channel {
*/
#define VMBUS_CHAN_FLAG_BATCHREAD 0x0002
+#define VMBUS_CHAN_TXF_HASMNF 0x0001
+
#define VMBUS_CHAN_ST_OPENED_SHIFT 0
#define VMBUS_CHAN_ST_OPENED (1 << VMBUS_CHAN_ST_OPENED_SHIFT)
More information about the svn-src-all
mailing list