summaryrefslogtreecommitdiffstats
path: root/drivers/hv
diff options
context:
space:
mode:
authorVitaly Kuznetsov <vkuznets@redhat.com>2015-05-06 17:47:46 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-05-24 12:19:00 -0700
commitce59fec836a9b4dc51cbcf9cb245b59e0ef53bea (patch)
tree2927aa4419cc9de7cc50b8f298b75e6dfbf7c40a /drivers/hv
parentf38e7dd72337d83cced910cfbf6016475ef85bf7 (diff)
downloadblackbird-op-linux-ce59fec836a9b4dc51cbcf9cb245b59e0ef53bea.tar.gz
blackbird-op-linux-ce59fec836a9b4dc51cbcf9cb245b59e0ef53bea.zip
Drivers: hv: vmbus: distribute subchannels among all vcpus
Primary channels are distributed evenly across all vcpus we have. When the host asks us to create subchannels it usually makes us num_cpus-1 offers and we are supposed to distribute the work evenly among the channel itself and all its subchannels. Make sure they are all assigned to different vcpus. Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/hv')
-rw-r--r--drivers/hv/channel_mgmt.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index 655c0a09c902..1f1417d19c7e 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -387,6 +387,8 @@ static void init_vp_index(struct vmbus_channel *channel, const uuid_le *type_gui
int i;
bool perf_chn = false;
u32 max_cpus = num_online_cpus();
+ struct vmbus_channel *primary = channel->primary_channel, *prev;
+ unsigned long flags;
for (i = IDE; i < MAX_PERF_CHN; i++) {
if (!memcmp(type_guid->b, hp_devs[i].guid,
@@ -407,7 +409,32 @@ static void init_vp_index(struct vmbus_channel *channel, const uuid_le *type_gui
channel->target_vp = 0;
return;
}
- cur_cpu = (++next_vp % max_cpus);
+
+ /*
+ * Primary channels are distributed evenly across all vcpus we have.
+ * When the host asks us to create subchannels it usually makes us
+ * num_cpus-1 offers and we are supposed to distribute the work evenly
+ * among the channel itself and all its subchannels. Make sure they are
+ * all assigned to different vcpus.
+ */
+ if (!primary)
+ cur_cpu = (++next_vp % max_cpus);
+ else {
+ /*
+ * Let's assign the first subchannel of a channel to the
+ * primary->target_cpu+1 and all the subsequent channels to
+ * the prev->target_cpu+1.
+ */
+ spin_lock_irqsave(&primary->lock, flags);
+ if (primary->num_sc == 1)
+ cur_cpu = (primary->target_cpu + 1) % max_cpus;
+ else {
+ prev = list_prev_entry(channel, sc_list);
+ cur_cpu = (prev->target_cpu + 1) % max_cpus;
+ }
+ spin_unlock_irqrestore(&primary->lock, flags);
+ }
+
channel->target_cpu = cur_cpu;
channel->target_vp = hv_context.vp_index[cur_cpu];
}
OpenPOWER on IntegriCloud