From patchwork Tue Sep 10 04:03:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 11138707 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1F12576 for ; Tue, 10 Sep 2019 04:03:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E424021924 for ; Tue, 10 Sep 2019 04:03:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ntl4gn/d" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731683AbfIJEDx (ORCPT ); Tue, 10 Sep 2019 00:03:53 -0400 Received: from mail-io1-f47.google.com ([209.85.166.47]:41768 "EHLO mail-io1-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725283AbfIJEDx (ORCPT ); Tue, 10 Sep 2019 00:03:53 -0400 Received: by mail-io1-f47.google.com with SMTP id r26so34249881ioh.8 for ; Mon, 09 Sep 2019 21:03:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=Eci64ju3Fxd3NkK+D+JXIT+Wb2UNsBD52dsCzd+zNTc=; b=ntl4gn/dpWvIdD26Nkw7jU8Atl34yz1kme8eIHde6+3HXWtxrA+obcEvuHI3obDHUf 1COejYj+O8clndJobTeQg34p2G0zUkBTl9g1udBrawTFktB4OJQDcvTjMpXiDRLraAWM OF5+faHPqZ28uiVF+P55+swWNvD0SaOLsnSQvHSFalT4z6+xj3lTfkE17805hW1G92CG GbXP2PYjr313mLlDGkARFLuK9Q+betMdTyLn9w/ChTjiKGGyAWLkeS8kQuzFkdBeroVO cxA9BreLBvSAjJCSXnIrrvK7MHO4cMaX+J5eWEJhTEQK++zu2UJ7pP7ysXFpHR6KEsXZ U8fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=Eci64ju3Fxd3NkK+D+JXIT+Wb2UNsBD52dsCzd+zNTc=; b=fjrZv5ZIR8dO66HAbcq15RTIsZR6mZSX5fiEZ04dV72kY50MYd5v/gBWtWlzQxe4j9 +WVPK3o6exe+Sx5b6DSbc/FY6HoICXL5oEQWTVCDPGMGDEJMPeh8MDix0aos7cCjw0jx 9WD79Ae0r7oFyiqMnEaN37Nu9ZcGluAx/yutKLryvsPc7ch2Jnmv9hxtY/BD/CWPwEVx l3AWWcX9SU77hcxYOEZbRMvhPjzm9W530ct5KoQIEw+J4UO3/H2hoEx8JXukrFxd3lpC AlCTg8PlBsPL7fs8IUaWsXh0NeGuIzfcMMlQlu+9Cb8jOTd0FZ/xICfV2u48jawnWYiU cu5A== X-Gm-Message-State: APjAAAUCjkyeeAQyfdfl+a0QW5doaG+9fFuOCvPLu3OumW/jmKTmK8Ta W5GC3XxJZev1ASC0s9FIzUaBjl5ved88t74q76taSRb/ X-Google-Smtp-Source: APXvYqwJpgZUADxr0REjW0YxsNCq0T3Nay+uDSx/4oPBz0iQEG0Mhgc4UrcnCf3BB04J/Jcn4LOiPHGZcEN+aw/n4h0= X-Received: by 2002:a6b:2b07:: with SMTP id r7mr28642541ior.173.1568088231721; Mon, 09 Sep 2019 21:03:51 -0700 (PDT) MIME-Version: 1.0 From: Steve French Date: Mon, 9 Sep 2019 23:03:40 -0500 Message-ID: Subject: [PATCH] Display max credits used at any one time for in flight requests To: CIFS Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org From 0ab83f3152dc67da643844d91b70ef9eb98a723f Mon Sep 17 00:00:00 2001 From: Steve French Date: Mon, 9 Sep 2019 22:57:11 -0500 Subject: [PATCH] smb3: display max credits used at any one time Displayed in /proc/fs/cifs/Stats once for each socket we are connected to. This allows us to find out what the maximum load we put on a server was. Except for large writes which can use multiple credits this would normally equal the maximum number of requests that had been in flight (at any one time). Note that /proc/fs/cifs/Stats can be reset if you want to look at a maximum in flight credits over a small period of time. Sample output (immediately after mount): Resources in use CIFS Session: 1 Share (unique mount targets): 2 SMB Request/Response Buffer: 1 Pool size: 5 SMB Small Req/Resp Buffer: 1 Pool size: 30 Operations (MIDs): 0 0 session 0 share reconnects Total vfs operations: 5 maximum at one time: 2 Max credits in flight: 2 1) \\localhost\scratch SMBs: 18 Bytes read: 0 Bytes written: 0 ... Signed-off-by: Steve French --- fs/cifs/cifs_debug.c | 2 ++ fs/cifs/cifsglob.h | 1 + fs/cifs/connect.c | 1 + fs/cifs/smb2ops.c | 2 ++ fs/cifs/transport.c | 4 ++++ 5 files changed, 10 insertions(+) diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c index a38d796f5ffe..dc543ca801bf 100644 --- a/fs/cifs/cifs_debug.c +++ b/fs/cifs/cifs_debug.c @@ -452,6 +452,7 @@ static ssize_t cifs_stats_proc_write(struct file *file, list_for_each(tmp1, &cifs_tcp_ses_list) { server = list_entry(tmp1, struct TCP_Server_Info, tcp_ses_list); + server->max_in_flight = 0; #ifdef CONFIG_CIFS_STATS2 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) { atomic_set(&server->num_cmds[i], 0); @@ -526,6 +527,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v) list_for_each(tmp1, &cifs_tcp_ses_list) { server = list_entry(tmp1, struct TCP_Server_Info, tcp_ses_list); + seq_printf(m, "\nMax credits in flight: %d", server->max_in_flight); #ifdef CONFIG_CIFS_STATS2 seq_puts(m, "\nTotal time spent processing by command. Time "); seq_printf(m, "units are jiffies (%d per second)\n", HZ); diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index 6987fbc5a24a..ef2199913217 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h @@ -677,6 +677,7 @@ struct TCP_Server_Info { unsigned int credits; /* send no more requests at once */ unsigned int max_credits; /* can override large 32000 default at mnt */ unsigned int in_flight; /* number of requests on the wire to server */ + unsigned int max_in_flight; /* max number of requests that were on wire */ spinlock_t req_lock; /* protect the two values above */ struct mutex srv_mutex; struct task_struct *tsk; diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index e70112d67b0e..df1ccb581828 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -2728,6 +2728,7 @@ cifs_get_tcp_session(struct smb_vol *volume_info) tcp_ses->tcp_nodelay = volume_info->sockopt_tcp_nodelay; tcp_ses->rdma = volume_info->rdma; tcp_ses->in_flight = 0; + tcp_ses->max_in_flight = 0; tcp_ses->credits = 1; init_waitqueue_head(&tcp_ses->response_q); init_waitqueue_head(&tcp_ses->request_q); diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index f04cf62ff91d..8546e63bb9b9 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -203,6 +203,8 @@ smb2_wait_mtu_credits(struct TCP_Server_Info *server, unsigned int size, credits->instance = server->reconnect_instance; server->credits -= credits->value; server->in_flight++; + if (server->in_flight > server->max_in_flight) + server->max_in_flight = server->in_flight; break; } } diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c index 4fccb90492e9..308ad0f495e1 100644 --- a/fs/cifs/transport.c +++ b/fs/cifs/transport.c @@ -532,6 +532,8 @@ wait_for_free_credits(struct TCP_Server_Info *server, const int num_credits, if ((flags & CIFS_TIMEOUT_MASK) == CIFS_NON_BLOCKING) { /* oplock breaks must not be held up */ server->in_flight++; + if (server->in_flight > server->max_in_flight) + server->max_in_flight = server->in_flight; *credits -= 1; *instance = server->reconnect_instance; spin_unlock(&server->req_lock); @@ -608,6 +610,8 @@ wait_for_free_credits(struct TCP_Server_Info *server, const int num_credits, if ((flags & CIFS_TIMEOUT_MASK) != CIFS_BLOCKING_OP) { *credits -= num_credits; server->in_flight += num_credits; + if (server->in_flight > server->max_in_flight) + server->max_in_flight = server->in_flight; *instance = server->reconnect_instance; } spin_unlock(&server->req_lock); -- 2.20.1