Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

SMB3: Track total time spent on roundtrips for each SMB3 command

Also track minimum and maximum time by command in /proc/fs/cifs/Stats

Signed-off-by: Steve French <stfrench@microsoft.com>

+44 -6
+17 -2
fs/cifs/cifs_debug.c
··· 462 462 server = list_entry(tmp1, struct TCP_Server_Info, 463 463 tcp_ses_list); 464 464 #ifdef CONFIG_CIFS_STATS2 465 - for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) 465 + for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) { 466 + atomic_set(&server->num_cmds[i], 0); 466 467 atomic_set(&server->smb2slowcmd[i], 0); 468 + server->time_per_cmd[i] = 0; 469 + server->slowest_cmd[i] = 0; 470 + server->fastest_cmd[0] = 0; 471 + } 467 472 #endif /* CONFIG_CIFS_STATS2 */ 468 473 list_for_each(tmp2, &server->smb_ses_list) { 469 474 ses = list_entry(tmp2, struct cifs_ses, ··· 536 531 server = list_entry(tmp1, struct TCP_Server_Info, 537 532 tcp_ses_list); 538 533 #ifdef CONFIG_CIFS_STATS2 534 + seq_puts(m, "\nTotal time spent processing by command. Time "); 535 + seq_printf(m, "units are jiffies (%d per second)\n", HZ); 536 + seq_puts(m, " SMB3 CMD\tNumber\tTotal Time\tFastest\tSlowest\n"); 537 + seq_puts(m, " --------\t------\t----------\t-------\t-------\n"); 538 + for (j = 0; j < NUMBER_OF_SMB2_COMMANDS; j++) 539 + seq_printf(m, " %d\t\t%d\t%llu\t\t%u\t%u\n", j, 540 + atomic_read(&server->num_cmds[j]), 541 + server->time_per_cmd[j], 542 + server->fastest_cmd[j], 543 + server->slowest_cmd[j]); 539 544 for (j = 0; j < NUMBER_OF_SMB2_COMMANDS; j++) 540 545 if (atomic_read(&server->smb2slowcmd[j])) 541 - seq_printf(m, "%d slow responses from %s for command %d\n", 546 + seq_printf(m, " %d slow responses from %s for command %d\n", 542 547 atomic_read(&server->smb2slowcmd[j]), 543 548 server->hostname, j); 544 549 #endif /* STATS2 */
+4
fs/cifs/cifsglob.h
··· 714 714 #ifdef CONFIG_CIFS_STATS2 715 715 atomic_t in_send; /* requests trying to send */ 716 716 atomic_t num_waiters; /* blocked waiting to get in sendrecv */ 717 + atomic_t num_cmds[NUMBER_OF_SMB2_COMMANDS]; /* total requests by cmd */ 717 718 atomic_t smb2slowcmd[NUMBER_OF_SMB2_COMMANDS]; /* count resps > 1 sec */ 719 + __u64 time_per_cmd[NUMBER_OF_SMB2_COMMANDS]; /* total time per cmd */ 720 + __u32 slowest_cmd[NUMBER_OF_SMB2_COMMANDS]; 721 + __u32 fastest_cmd[NUMBER_OF_SMB2_COMMANDS]; 718 722 #endif /* STATS2 */ 719 723 unsigned int max_read; 720 724 unsigned int max_write;
+23 -4
fs/cifs/transport.c
··· 104 104 { 105 105 #ifdef CONFIG_CIFS_STATS2 106 106 __le16 command = midEntry->server->vals->lock_cmd; 107 + __u16 smb_cmd = le16_to_cpu(midEntry->command); 107 108 unsigned long now; 109 + unsigned long roundtrip_time; 110 + struct TCP_Server_Info *server = midEntry->server; 108 111 #endif 109 112 midEntry->mid_state = MID_FREE; 110 113 atomic_dec(&midCount); ··· 117 114 cifs_small_buf_release(midEntry->resp_buf); 118 115 #ifdef CONFIG_CIFS_STATS2 119 116 now = jiffies; 117 + if (now < midEntry->when_alloc) 118 + cifs_dbg(VFS, "invalid mid allocation time\n"); 119 + roundtrip_time = now - midEntry->when_alloc; 120 + 121 + if (smb_cmd < NUMBER_OF_SMB2_COMMANDS) { 122 + if (atomic_read(&server->num_cmds[smb_cmd]) == 0) { 123 + server->slowest_cmd[smb_cmd] = roundtrip_time; 124 + server->fastest_cmd[smb_cmd] = roundtrip_time; 125 + } else { 126 + if (server->slowest_cmd[smb_cmd] < roundtrip_time) 127 + server->slowest_cmd[smb_cmd] = roundtrip_time; 128 + else if (server->fastest_cmd[smb_cmd] > roundtrip_time) 129 + server->fastest_cmd[smb_cmd] = roundtrip_time; 130 + } 131 + cifs_stats_inc(&server->num_cmds[smb_cmd]); 132 + server->time_per_cmd[smb_cmd] += roundtrip_time; 133 + } 120 134 /* 121 135 * commands taking longer than one second (default) can be indications 122 136 * that something is wrong, unless it is quite a slow link or a very ··· 151 131 * smb2slowcmd[NUMBER_OF_SMB2_COMMANDS] counts by command 152 132 * NB: le16_to_cpu returns unsigned so can not be negative below 153 133 */ 154 - if (le16_to_cpu(midEntry->command) < NUMBER_OF_SMB2_COMMANDS) 155 - cifs_stats_inc(&midEntry->server->smb2slowcmd[le16_to_cpu(midEntry->command)]); 134 + if (smb_cmd < NUMBER_OF_SMB2_COMMANDS) 135 + cifs_stats_inc(&server->smb2slowcmd[smb_cmd]); 156 136 157 - trace_smb3_slow_rsp(le16_to_cpu(midEntry->command), 158 - midEntry->mid, midEntry->pid, 137 + trace_smb3_slow_rsp(smb_cmd, midEntry->mid, midEntry->pid, 159 138 midEntry->when_sent, midEntry->when_received); 160 139 if (cifsFYI & CIFS_TIMER) { 161 140 pr_debug(" CIFS slow rsp: cmd %d mid %llu",