cifs: deal with the channel loading lag while picking channels
commit 66d590b828b1fd9fa337047ae58fe1c4c6f43609 upstream.
Our current approach to select a channel for sending requests is this:
1. iterate all channels to find the min and max queue depth
2. if min and max are not the same, pick the channel with min depth
3. if min and max are same, round robin, as all channels are equally loaded
The problem with this approach is that there's a lag between selecting
a channel and sending the request (that increases the queue depth on the channel).
While these numbers will eventually catch up, there could be a skew in the
channel usage, depending on the application's I/O parallelism and the server's
speed of handling requests.
With sufficient parallelism, this lag can artificially increase the queue depth,
thereby impacting the performance negatively.
This change will change the step 1 above to start the iteration from the last
selected channel. This is to reduce the skew in channel usage even in the presence
of this lag.
Fixes: ea90708d3c
("cifs: use the least loaded channel for sending requests")
Cc: <stable@vger.kernel.org>
Signed-off-by: Shyam Prasad N <sprasad@microsoft.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
cd42ddddd7
commit
b530c44e1f
@@ -1025,14 +1025,16 @@ struct TCP_Server_Info *cifs_pick_channel(struct cifs_ses *ses)
|
|||||||
uint index = 0;
|
uint index = 0;
|
||||||
unsigned int min_in_flight = UINT_MAX, max_in_flight = 0;
|
unsigned int min_in_flight = UINT_MAX, max_in_flight = 0;
|
||||||
struct TCP_Server_Info *server = NULL;
|
struct TCP_Server_Info *server = NULL;
|
||||||
int i;
|
int i, start, cur;
|
||||||
|
|
||||||
if (!ses)
|
if (!ses)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
spin_lock(&ses->chan_lock);
|
spin_lock(&ses->chan_lock);
|
||||||
|
start = atomic_inc_return(&ses->chan_seq);
|
||||||
for (i = 0; i < ses->chan_count; i++) {
|
for (i = 0; i < ses->chan_count; i++) {
|
||||||
server = ses->chans[i].server;
|
cur = (start + i) % ses->chan_count;
|
||||||
|
server = ses->chans[cur].server;
|
||||||
if (!server || server->terminate)
|
if (!server || server->terminate)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -1049,17 +1051,15 @@ struct TCP_Server_Info *cifs_pick_channel(struct cifs_ses *ses)
|
|||||||
*/
|
*/
|
||||||
if (server->in_flight < min_in_flight) {
|
if (server->in_flight < min_in_flight) {
|
||||||
min_in_flight = server->in_flight;
|
min_in_flight = server->in_flight;
|
||||||
index = i;
|
index = cur;
|
||||||
}
|
}
|
||||||
if (server->in_flight > max_in_flight)
|
if (server->in_flight > max_in_flight)
|
||||||
max_in_flight = server->in_flight;
|
max_in_flight = server->in_flight;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if all channels are equally loaded, fall back to round-robin */
|
/* if all channels are equally loaded, fall back to round-robin */
|
||||||
if (min_in_flight == max_in_flight) {
|
if (min_in_flight == max_in_flight)
|
||||||
index = (uint)atomic_inc_return(&ses->chan_seq);
|
index = (uint)start % ses->chan_count;
|
||||||
index %= ses->chan_count;
|
|
||||||
}
|
|
||||||
|
|
||||||
server = ses->chans[index].server;
|
server = ses->chans[index].server;
|
||||||
spin_unlock(&ses->chan_lock);
|
spin_unlock(&ses->chan_lock);
|
||||||
|
Reference in New Issue
Block a user