From owner-svn-src-stable-10@freebsd.org Wed Jun 15 06:08:07 2016 Return-Path: Delivered-To: svn-src-stable-10@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 25A08B7286E; Wed, 15 Jun 2016 06:08: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 00848217A; Wed, 15 Jun 2016 06:08: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 u5F6864x014183; Wed, 15 Jun 2016 06:08:06 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5F686ZG014182; Wed, 15 Jun 2016 06:08:06 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201606150608.u5F686ZG014182@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 15 Jun 2016 06:08:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301916 - stable/10/sys/dev/hyperv/vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Jun 2016 06:08:07 -0000 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);