diff options
author | Dexuan Cui <decui@microsoft.com> | 2018-09-17 00:14:54 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-09-30 11:49:55 -0400 |
commit | 41e270f6898e7502be9fd6920ee0a108ca259d36 (patch) | |
tree | f74679a9255c3b509d8c6cf1e400f772e4ff5a48 | |
parent | 17b57b1883c1285f3d0dc2266e8f79286a7bef38 (diff) |
Drivers: hv: vmbus: Use get/put_cpu() in vmbus_connect()
With CONFIG_DEBUG_PREEMPT=y, I always see this warning:
BUG: using smp_processor_id() in preemptible [00000000]
Fix the false warning by using get/put_cpu().
Here vmbus_connect() sends a message to the host and waits for the
host's response. The host will deliver the response message and an
interrupt on CPU msg->target_vcpu, and later the interrupt handler
will wake up vmbus_connect(). vmbus_connect() doesn't really have
to run on the same cpu as CPU msg->target_vcpu, so it's safe to
call put_cpu() just here.
Signed-off-by: Dexuan Cui <decui@microsoft.com>
Cc: stable@vger.kernel.org
Cc: K. Y. Srinivasan <kys@microsoft.com>
Cc: Haiyang Zhang <haiyangz@microsoft.com>
Cc: Stephen Hemminger <sthemmin@microsoft.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/hv/connection.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c index ced041899456..f4d08c8ac7f8 100644 --- a/drivers/hv/connection.c +++ b/drivers/hv/connection.c | |||
@@ -76,6 +76,7 @@ static int vmbus_negotiate_version(struct vmbus_channel_msginfo *msginfo, | |||
76 | __u32 version) | 76 | __u32 version) |
77 | { | 77 | { |
78 | int ret = 0; | 78 | int ret = 0; |
79 | unsigned int cur_cpu; | ||
79 | struct vmbus_channel_initiate_contact *msg; | 80 | struct vmbus_channel_initiate_contact *msg; |
80 | unsigned long flags; | 81 | unsigned long flags; |
81 | 82 | ||
@@ -118,9 +119,10 @@ static int vmbus_negotiate_version(struct vmbus_channel_msginfo *msginfo, | |||
118 | * the CPU attempting to connect may not be CPU 0. | 119 | * the CPU attempting to connect may not be CPU 0. |
119 | */ | 120 | */ |
120 | if (version >= VERSION_WIN8_1) { | 121 | if (version >= VERSION_WIN8_1) { |
121 | msg->target_vcpu = | 122 | cur_cpu = get_cpu(); |
122 | hv_cpu_number_to_vp_number(smp_processor_id()); | 123 | msg->target_vcpu = hv_cpu_number_to_vp_number(cur_cpu); |
123 | vmbus_connection.connect_cpu = smp_processor_id(); | 124 | vmbus_connection.connect_cpu = cur_cpu; |
125 | put_cpu(); | ||
124 | } else { | 126 | } else { |
125 | msg->target_vcpu = 0; | 127 | msg->target_vcpu = 0; |
126 | vmbus_connection.connect_cpu = 0; | 128 | vmbus_connection.connect_cpu = 0; |