From owner-svn-src-head@freebsd.org Thu Jul 21 05:38:07 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 298EDB9FF4C; Thu, 21 Jul 2016 05:38:07 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E02591651; Thu, 21 Jul 2016 05:38:06 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6L5c603094225; Thu, 21 Jul 2016 05:38:06 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6L5c6WC094223; Thu, 21 Jul 2016 05:38:06 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201607210538.u6L5c6WC094223@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 21 Jul 2016 05:38:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r303128 - head/sys/dev/hyperv/vmbus X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jul 2016 05:38:07 -0000 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)