svn commit: r301916 - stable/10/sys/dev/hyperv/vmbus
Sepherosa Ziehau
sephe at FreeBSD.org
Wed Jun 15 06:08:07 UTC 2016
Author: sephe
Date: Wed Jun 15 06:08:05 2016
New Revision: 301916
URL: https://svnweb.freebsd.org/changeset/base/301916
Log:
MFC 296291,301109
296291
hyperv/chan: Factor out the vcpu setting
And use it for cpu0 assignment; it does not sound right to assume that
cpu0 maps to vcpu0. And this factored out function will be exposed to
drivers, if driver specific CPU binding is needed, e.g. hn(4).
Move default cpu select after saving channel offer message. This makes
sure that all useful information of the channel has been setup.
MFC after: 1 week
Sponsored by: Microsoft OSTC
Differential Revision: https://reviews.freebsd.org/D5504
301109
hyperv/channel: Only cpu0 is supported as channel target cpu on WIN7
MFC after: 1 week
Sponsored by: Microsoft OSTC
Modified:
stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c
Directory Properties:
stable/10/ (props changed)
Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c
==============================================================================
--- stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Wed Jun 15 05:57:06 2016 (r301915)
+++ stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Wed Jun 15 06:08:05 2016 (r301916)
@@ -277,6 +277,27 @@ vmbus_channel_process_offer(hv_vmbus_cha
}
}
+static void
+vmbus_channel_cpu_set(struct hv_vmbus_channel *chan, int cpu)
+{
+ KASSERT(cpu >= 0 && cpu < mp_ncpus, ("invalid cpu %d", cpu));
+
+ if (hv_vmbus_protocal_version == HV_VMBUS_VERSION_WS2008 ||
+ hv_vmbus_protocal_version == HV_VMBUS_VERSION_WIN7) {
+ /* Only cpu0 is supported */
+ cpu = 0;
+ }
+
+ chan->target_cpu = cpu;
+ chan->target_vcpu = hv_vmbus_g_context.hv_vcpu_index[cpu];
+
+ if (bootverbose) {
+ printf("vmbus_chan%u: assigned to cpu%u [vcpu%u]\n",
+ chan->offer_msg.child_rel_id,
+ chan->target_cpu, chan->target_vcpu);
+ }
+}
+
/**
* Array of device guids that are performance critical. We try to distribute
* the interrupt load for these devices across all online cpus.
@@ -309,11 +330,12 @@ static uint32_t next_vcpu;
* distributed across all available CPUs.
*/
static void
-vmbus_channel_select_cpu(hv_vmbus_channel *channel, hv_guid *guid)
+vmbus_channel_select_defcpu(struct hv_vmbus_channel *channel)
{
uint32_t current_cpu;
int i;
boolean_t is_perf_channel = FALSE;
+ const hv_guid *guid = &channel->offer_msg.offer.interface_type;
for (i = PERF_CHN_NIC; i < MAX_PERF_CHN; i++) {
if (memcmp(guid->data, high_perf_devices[i].data,
@@ -323,24 +345,14 @@ vmbus_channel_select_cpu(hv_vmbus_channe
}
}
- if ((hv_vmbus_protocal_version == HV_VMBUS_VERSION_WS2008) ||
- (hv_vmbus_protocal_version == HV_VMBUS_VERSION_WIN7) ||
- (!is_perf_channel)) {
- /* Host's view of guest cpu */
- channel->target_vcpu = 0;
- /* Guest's own view of cpu */
- channel->target_cpu = 0;
+ if (!is_perf_channel) {
+ /* Stick to cpu0 */
+ vmbus_channel_cpu_set(channel, 0);
return;
}
/* mp_ncpus should have the number cpus currently online */
current_cpu = (++next_vcpu % mp_ncpus);
- channel->target_cpu = current_cpu;
- channel->target_vcpu =
- hv_vmbus_g_context.hv_vcpu_index[current_cpu];
- if (bootverbose)
- printf("VMBUS: Total online cpus %d, assign perf channel %d "
- "to vcpu %d, cpu %d\n", mp_ncpus, i, channel->target_vcpu,
- current_cpu);
+ vmbus_channel_cpu_set(channel, current_cpu);
}
/**
@@ -411,17 +423,14 @@ vmbus_channel_on_offer_internal(void* co
offer->connection_id;
}
- /*
- * Bind the channel to a chosen cpu.
- */
- vmbus_channel_select_cpu(new_channel,
- &offer->offer.interface_type);
-
memcpy(&new_channel->offer_msg, offer,
sizeof(hv_vmbus_channel_offer_channel));
new_channel->monitor_group = (uint8_t) offer->monitor_id / 32;
new_channel->monitor_bit = (uint8_t) offer->monitor_id % 32;
+ /* Select default cpu for this channel. */
+ vmbus_channel_select_defcpu(new_channel);
+
vmbus_channel_process_offer(new_channel);
free(offer, M_DEVBUF);
More information about the svn-src-stable-10
mailing list