From patchwork Thu May 4 13:20:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 9711939 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6FAE460235 for ; Thu, 4 May 2017 13:20:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 63C4828614 for ; Thu, 4 May 2017 13:20:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 584DD28693; Thu, 4 May 2017 13:20:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_TVD_MIME_EPI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B340D28614 for ; Thu, 4 May 2017 13:20:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751391AbdEDNU2 (ORCPT ); Thu, 4 May 2017 09:20:28 -0400 Received: from mail-pg0-f49.google.com ([74.125.83.49]:33986 "EHLO mail-pg0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753210AbdEDNUX (ORCPT ); Thu, 4 May 2017 09:20:23 -0400 Received: by mail-pg0-f49.google.com with SMTP id v1so8459654pgv.1 for ; Thu, 04 May 2017 06:20:23 -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=fvc7eH1KavmPFL3FAYbpN111H+XXI5MCRBpKAHfn4zc=; b=HHUNqOW7du091tt2WJwTEga6lUrcBPuRuG15x4WwNIQN90Ds3qDpopGyxlZ21OSSZ2 TstQ/6NZM8zDkyhTQYojpN58iKwcWQkOPDaQFiCbZXsZcEG1+2rsHYyyCYzz3QEKWCC4 WfjZrPWVWt5d3Wutf3EHUB6c1/to3L6cniCXaqdX7oKzwlMqOBvBlnlxpzD3EvoAs0Vr VKJQrQCSV3w+vFGN5xUafpzMSrfVS1pnEO5yykDE9SIG8MvrqV9KOM27EJbOAcj5Owt8 YYW/LcidKTUlaJS9nIsbDnCXZ32cUfiwOahZt7ucMTXyq3qX52NAO1oLlH7R+katNIZi PvrA== 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=fvc7eH1KavmPFL3FAYbpN111H+XXI5MCRBpKAHfn4zc=; b=qe7MVMDBjtVjLPhbr0qVg4zgdGzwbov8PWxz3kadDuKLx8zQE/pzeozhG2PGxC//8H SD7Mp0mwoyb4+SAJH5ojk5juuKiWQIDchlEA6zLYn+YaNM289L185kcY6IM6kco5AOv5 tVFsbBZtmK5A9LskEKH0cILxEwi/Pqq0ZBe1bT/aH0ShA9Oc+N5HM4c6Um4ELwzoXJxX LQnkIgqjnNYlSFyVN0yB/NRKYupGHsqzpUF7hJQwvbOSucRoToyj5DmlCPt05/tmPMA/ 7bcGheSxsoMrHGXGewjp/dUSPkFYbzNlGtTwJM1GHJNXa5571kQibOm32zyNzJvuC/Us JXSQ== X-Gm-Message-State: AN3rC/4GtRqNryfxPQ+MRcgHw6zIpaS4Nrvz0PxfFgOX0ckfJ2UW9CkA eMzFY6WKbgp74BE3k/mqk9PZoNs87d9p X-Received: by 10.84.193.129 with SMTP id f1mr57060846pld.97.1493904022508; Thu, 04 May 2017 06:20:22 -0700 (PDT) MIME-Version: 1.0 Received: by 10.100.186.194 with HTTP; Thu, 4 May 2017 06:20:01 -0700 (PDT) From: Steve French Date: Thu, 4 May 2017 08:20:01 -0500 Message-ID: Subject: To: Long Li , "linux-cifs@vger.kernel.org" , Pavel Shilovskiy Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Any thoughts on removing the dependency on srv_mutex in deleting completed requests (and freeing its memory) ? Otherwise it can cause problems with long running socket writes (on sending new requests) which don't get the benefit of finishing up response processing due to the blocking of DeleteMidQEntry on server->srv_mutex This should improve performance as well. (Long Li was noticing this looking at RDMA with cifs.ko) See attached patch From 429bb0e9da0db34bf75d5335fe6b4011db8765ad Mon Sep 17 00:00:00 2001 From: Steve French Date: Thu, 4 May 2017 07:54:04 -0500 Subject: [PATCH] [CIFS] Don't delay freeing mids when blocked on slow socket write of request When processing responses, and in particular freeing mids (DeleteMidQEntry), which is very important since it also frees the associated buffers (cifs_buf_release), we can block a long time if (writes to) socket is slow due to low memory or networking issues. We can block in send (smb request) waiting for memory, and be blocked in processing responess (which could free memory if we let it) - since they both grab the server->srv_mutex. In practice, in the DeleteMidQEntry case - there is no reason we need to grab the srv_mutex so remove these around DeleteMidQEntry, and it allows us to free memory faster. Signed-off-by: Steve French --- fs/cifs/cifssmb.c | 7 ------- fs/cifs/smb2pdu.c | 7 ------- fs/cifs/transport.c | 2 -- 3 files changed, 16 deletions(-) diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index 205fd94..5245723 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c @@ -697,9 +697,7 @@ static int validate_t2(struct smb_t2_rsp *pSMB) { struct TCP_Server_Info *server = mid->callback_data; - mutex_lock(&server->srv_mutex); DeleteMidQEntry(mid); - mutex_unlock(&server->srv_mutex); add_credits(server, 1, CIFS_ECHO_OP); } @@ -1599,9 +1597,7 @@ static __u16 convert_disposition(int disposition) } queue_work(cifsiod_wq, &rdata->work); - mutex_lock(&server->srv_mutex); DeleteMidQEntry(mid); - mutex_unlock(&server->srv_mutex); add_credits(server, 1, 0); } @@ -2058,7 +2054,6 @@ struct cifs_writedata * { struct cifs_writedata *wdata = mid->callback_data; struct cifs_tcon *tcon = tlink_tcon(wdata->cfile->tlink); - struct TCP_Server_Info *server = tcon->ses->server; unsigned int written; WRITE_RSP *smb = (WRITE_RSP *)mid->resp_buf; @@ -2095,9 +2090,7 @@ struct cifs_writedata * } queue_work(cifsiod_wq, &wdata->work); - mutex_lock(&server->srv_mutex); DeleteMidQEntry(mid); - mutex_unlock(&server->srv_mutex); add_credits(tcon->ses->server, 1, 0); } diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index 0fd63f0..e4007ee 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -2172,9 +2172,7 @@ static inline void init_copy_chunk_defaults(struct cifs_tcon *tcon) if (mid->mid_state == MID_RESPONSE_RECEIVED) credits_received = le16_to_cpu(rsp->hdr.sync_hdr.CreditRequest); - mutex_lock(&server->srv_mutex); DeleteMidQEntry(mid); - mutex_unlock(&server->srv_mutex); add_credits(server, credits_received, CIFS_ECHO_OP); } @@ -2432,9 +2430,7 @@ void smb2_reconnect_server(struct work_struct *work) cifs_stats_fail_inc(tcon, SMB2_READ_HE); queue_work(cifsiod_wq, &rdata->work); - mutex_lock(&server->srv_mutex); DeleteMidQEntry(mid); - mutex_unlock(&server->srv_mutex); add_credits(server, credits_received, 0); } @@ -2593,7 +2589,6 @@ void smb2_reconnect_server(struct work_struct *work) { struct cifs_writedata *wdata = mid->callback_data; struct cifs_tcon *tcon = tlink_tcon(wdata->cfile->tlink); - struct TCP_Server_Info *server = tcon->ses->server; unsigned int written; struct smb2_write_rsp *rsp = (struct smb2_write_rsp *)mid->resp_buf; unsigned int credits_received = 1; @@ -2633,9 +2628,7 @@ void smb2_reconnect_server(struct work_struct *work) cifs_stats_fail_inc(tcon, SMB2_WRITE_HE); queue_work(cifsiod_wq, &wdata->work); - mutex_lock(&server->srv_mutex); DeleteMidQEntry(mid); - mutex_unlock(&server->srv_mutex); add_credits(tcon->ses->server, credits_received, 0); } diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c index 4d64b5b..de589d0 100644 --- a/fs/cifs/transport.c +++ b/fs/cifs/transport.c @@ -613,9 +613,7 @@ struct mid_q_entry * } spin_unlock(&GlobalMid_Lock); - mutex_lock(&server->srv_mutex); DeleteMidQEntry(mid); - mutex_unlock(&server->srv_mutex); return rc; } -- 1.9.1