hyperv/vmbus: Use default mtx for channel message queue

First of all sema_post() can't be called w/ spinlock, and the channel
message queue processing is not on hot code path, i.e. spinlock is not
necessary.

Submitted by:	Jun Su <junsu microsoft com>
Reviewed by:	sephe, Dexuan Cui <decui microsoft com>
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D5812
This commit is contained in:
Sepherosa Ziehau 2016-04-07 05:45:49 +00:00
parent d8258c4498
commit aec810d4c5
3 changed files with 27 additions and 27 deletions

View File

@ -270,12 +270,12 @@ hv_vmbus_channel_open(
if (user_data_len)
memcpy(open_msg->user_data, user_data, user_data_len);
mtx_lock_spin(&hv_vmbus_g_connection.channel_msg_lock);
mtx_lock(&hv_vmbus_g_connection.channel_msg_lock);
TAILQ_INSERT_TAIL(
&hv_vmbus_g_connection.channel_msg_anchor,
open_info,
msg_list_entry);
mtx_unlock_spin(&hv_vmbus_g_connection.channel_msg_lock);
mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock);
ret = hv_vmbus_post_message(
open_msg, sizeof(hv_vmbus_channel_open_channel));
@ -302,12 +302,12 @@ hv_vmbus_channel_open(
}
cleanup:
mtx_lock_spin(&hv_vmbus_g_connection.channel_msg_lock);
mtx_lock(&hv_vmbus_g_connection.channel_msg_lock);
TAILQ_REMOVE(
&hv_vmbus_g_connection.channel_msg_anchor,
open_info,
msg_list_entry);
mtx_unlock_spin(&hv_vmbus_g_connection.channel_msg_lock);
mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock);
sema_destroy(&open_info->wait_sema);
free(open_info, M_DEVBUF);
@ -496,13 +496,13 @@ hv_vmbus_channel_establish_gpadl(
gpadl_msg->child_rel_id = channel->offer_msg.child_rel_id;
gpadl_msg->gpadl = next_gpadl_handle;
mtx_lock_spin(&hv_vmbus_g_connection.channel_msg_lock);
mtx_lock(&hv_vmbus_g_connection.channel_msg_lock);
TAILQ_INSERT_TAIL(
&hv_vmbus_g_connection.channel_msg_anchor,
msg_info,
msg_list_entry);
mtx_unlock_spin(&hv_vmbus_g_connection.channel_msg_lock);
mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock);
ret = hv_vmbus_post_message(
gpadl_msg,
@ -541,10 +541,10 @@ hv_vmbus_channel_establish_gpadl(
cleanup:
mtx_lock_spin(&hv_vmbus_g_connection.channel_msg_lock);
mtx_lock(&hv_vmbus_g_connection.channel_msg_lock);
TAILQ_REMOVE(&hv_vmbus_g_connection.channel_msg_anchor,
msg_info, msg_list_entry);
mtx_unlock_spin(&hv_vmbus_g_connection.channel_msg_lock);
mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock);
sema_destroy(&msg_info->wait_sema);
free(msg_info, M_DEVBUF);
@ -583,10 +583,10 @@ hv_vmbus_channel_teardown_gpdal(
msg->child_rel_id = channel->offer_msg.child_rel_id;
msg->gpadl = gpadl_handle;
mtx_lock_spin(&hv_vmbus_g_connection.channel_msg_lock);
mtx_lock(&hv_vmbus_g_connection.channel_msg_lock);
TAILQ_INSERT_TAIL(&hv_vmbus_g_connection.channel_msg_anchor,
info, msg_list_entry);
mtx_unlock_spin(&hv_vmbus_g_connection.channel_msg_lock);
mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock);
ret = hv_vmbus_post_message(msg,
sizeof(hv_vmbus_channel_gpadl_teardown));
@ -599,10 +599,10 @@ cleanup:
/*
* Received a torndown response
*/
mtx_lock_spin(&hv_vmbus_g_connection.channel_msg_lock);
mtx_lock(&hv_vmbus_g_connection.channel_msg_lock);
TAILQ_REMOVE(&hv_vmbus_g_connection.channel_msg_anchor,
info, msg_list_entry);
mtx_unlock_spin(&hv_vmbus_g_connection.channel_msg_lock);
mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock);
sema_destroy(&info->wait_sema);
free(info, M_DEVBUF);

View File

@ -492,7 +492,7 @@ vmbus_channel_on_open_result(hv_vmbus_channel_msg_header* hdr)
/*
* Find the open msg, copy the result and signal/unblock the wait event
*/
mtx_lock_spin(&hv_vmbus_g_connection.channel_msg_lock);
mtx_lock(&hv_vmbus_g_connection.channel_msg_lock);
TAILQ_FOREACH(msg_info, &hv_vmbus_g_connection.channel_msg_anchor,
msg_list_entry) {
@ -510,7 +510,7 @@ vmbus_channel_on_open_result(hv_vmbus_channel_msg_header* hdr)
}
}
}
mtx_unlock_spin(&hv_vmbus_g_connection.channel_msg_lock);
mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock);
}
@ -534,7 +534,7 @@ vmbus_channel_on_gpadl_created(hv_vmbus_channel_msg_header* hdr)
/* Find the establish msg, copy the result and signal/unblock
* the wait event
*/
mtx_lock_spin(&hv_vmbus_g_connection.channel_msg_lock);
mtx_lock(&hv_vmbus_g_connection.channel_msg_lock);
TAILQ_FOREACH(msg_info, &hv_vmbus_g_connection.channel_msg_anchor,
msg_list_entry) {
request_header = (hv_vmbus_channel_msg_header*) msg_info->msg;
@ -553,7 +553,7 @@ vmbus_channel_on_gpadl_created(hv_vmbus_channel_msg_header* hdr)
}
}
}
mtx_unlock_spin(&hv_vmbus_g_connection.channel_msg_lock);
mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock);
}
/**
@ -578,7 +578,7 @@ vmbus_channel_on_gpadl_torndown(hv_vmbus_channel_msg_header* hdr)
* wait event.
*/
mtx_lock_spin(&hv_vmbus_g_connection.channel_msg_lock);
mtx_lock(&hv_vmbus_g_connection.channel_msg_lock);
TAILQ_FOREACH(msg_info, &hv_vmbus_g_connection.channel_msg_anchor,
msg_list_entry) {
@ -598,7 +598,7 @@ vmbus_channel_on_gpadl_torndown(hv_vmbus_channel_msg_header* hdr)
}
}
}
mtx_unlock_spin(&hv_vmbus_g_connection.channel_msg_lock);
mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock);
}
/**
@ -618,7 +618,7 @@ vmbus_channel_on_version_response(hv_vmbus_channel_msg_header* hdr)
versionResponse = (hv_vmbus_channel_version_response*)hdr;
mtx_lock_spin(&hv_vmbus_g_connection.channel_msg_lock);
mtx_lock(&hv_vmbus_g_connection.channel_msg_lock);
TAILQ_FOREACH(msg_info, &hv_vmbus_g_connection.channel_msg_anchor,
msg_list_entry) {
requestHeader = (hv_vmbus_channel_msg_header*) msg_info->msg;
@ -632,7 +632,7 @@ vmbus_channel_on_version_response(hv_vmbus_channel_msg_header* hdr)
sema_post(&msg_info->wait_sema);
}
}
mtx_unlock_spin(&hv_vmbus_g_connection.channel_msg_lock);
mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock);
}

View File

@ -96,26 +96,26 @@ hv_vmbus_negotiate_version(hv_vmbus_channel_msg_info *msg_info,
* Add to list before we send the request since we may receive the
* response before returning from this routine
*/
mtx_lock_spin(&hv_vmbus_g_connection.channel_msg_lock);
mtx_lock(&hv_vmbus_g_connection.channel_msg_lock);
TAILQ_INSERT_TAIL(
&hv_vmbus_g_connection.channel_msg_anchor,
msg_info,
msg_list_entry);
mtx_unlock_spin(&hv_vmbus_g_connection.channel_msg_lock);
mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock);
ret = hv_vmbus_post_message(
msg,
sizeof(hv_vmbus_channel_initiate_contact));
if (ret != 0) {
mtx_lock_spin(&hv_vmbus_g_connection.channel_msg_lock);
mtx_lock(&hv_vmbus_g_connection.channel_msg_lock);
TAILQ_REMOVE(
&hv_vmbus_g_connection.channel_msg_anchor,
msg_info,
msg_list_entry);
mtx_unlock_spin(&hv_vmbus_g_connection.channel_msg_lock);
mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock);
return (ret);
}
@ -124,12 +124,12 @@ hv_vmbus_negotiate_version(hv_vmbus_channel_msg_info *msg_info,
*/
ret = sema_timedwait(&msg_info->wait_sema, 5 * hz); /* KYS 5 seconds */
mtx_lock_spin(&hv_vmbus_g_connection.channel_msg_lock);
mtx_lock(&hv_vmbus_g_connection.channel_msg_lock);
TAILQ_REMOVE(
&hv_vmbus_g_connection.channel_msg_anchor,
msg_info,
msg_list_entry);
mtx_unlock_spin(&hv_vmbus_g_connection.channel_msg_lock);
mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock);
/**
* Check if successful
@ -166,7 +166,7 @@ hv_vmbus_connect(void) {
TAILQ_INIT(&hv_vmbus_g_connection.channel_msg_anchor);
mtx_init(&hv_vmbus_g_connection.channel_msg_lock, "vmbus channel msg",
NULL, MTX_SPIN);
NULL, MTX_DEF);
TAILQ_INIT(&hv_vmbus_g_connection.channel_anchor);
mtx_init(&hv_vmbus_g_connection.channel_lock, "vmbus channel",