Received: by 10.213.65.68 with SMTP id h4csp290662imn; Fri, 23 Mar 2018 04:52:33 -0700 (PDT) X-Google-Smtp-Source: AG47ELtjj5LxnWTejfTUSRipT0xJVt2YNMxAstvpK7UiODV/xXC1gXDGrVvfyL6tUshfrH8zcPUa X-Received: by 10.99.167.78 with SMTP id w14mr10538036pgo.408.1521805953715; Fri, 23 Mar 2018 04:52:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521805953; cv=none; d=google.com; s=arc-20160816; b=APJvgU3zW+v0AiLPG0gR4WvvsVgQSn2OcIUuygqc2XAZebqqYG/yNGdDhtRmLpAo+S nx+wq/2GMH1bDKLhJiEPetTSqYAYmVDKdUJtSh8j35vTDirYof++ygDjmLhUacF7IauH tZMr8q70daGcM/IIMjDJRddijSYouK2cqD/XVeDA8nb2d+BmHlhfKF9a3MUZ5nOwx+Q3 GgxKKAdzUyLjTxoHpmma3PZZbCOWtHvJZzSuWzgQwhA8+gbH0xKXARIxKJWY5KhcFLoh AD1cMIcOjkidAuf54xAsLJF74g0CLGb4FjfQfx2eolfbQRIl8Z4El5kVaFj3HWu2PO+E Vq/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=YCUsZcLaUa3RegewBvqguB/UnBH2BWHPnsJ8o6z4uiI=; b=x2azyFOJmatLN/lz5MXY19U+Tw130x1OMbI0fx20vyjbnQQxCmJ9wbhNMpuu++bvts 5RzB6n+HBPUcWnTetEum3xyEiRmRd5Qwm0TakfmBcIFtN7vz/bfgaCE/8/BHEE0rzyDq unK42xA6QayvfUPJYJ7ddAsna/DeankFFibz2SOhVBme/0PO3u3kuao3NPpPWQn5WaRZ GeuU7umxyy4ITx00lX/Vy+1w9oKcKPdgtv1dtLPJfodjs0aXBnJqPRkxPFFxwe5R4vp1 6Sr4DukyduFo0TXbo8ezch3eN/knqYXVfq4HfS9yPF96PbAhBX9SxiIvJvcUnvcBwZe7 qjNQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y8si5936843pgq.230.2018.03.23.04.52.19; Fri, 23 Mar 2018 04:52:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754556AbeCWLuW (ORCPT + 99 others); Fri, 23 Mar 2018 07:50:22 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:38314 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754202AbeCWKC0 (ORCPT ); Fri, 23 Mar 2018 06:02:26 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 13B5C1071; Fri, 23 Mar 2018 10:02:25 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Potnuri Bharat Teja , Sagi Grimberg , Jason Gunthorpe , Sasha Levin Subject: [PATCH 4.14 38/77] iser-target: avoid reinitializing rdma contexts for isert commands Date: Fri, 23 Mar 2018 10:54:12 +0100 Message-Id: <20180323094144.810455882@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180323094142.260022880@linuxfoundation.org> References: <20180323094142.260022880@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Bharat Potnuri [ Upstream commit 66f53e6f5400578bae58db0c06d85a8820831f40 ] isert commands that failed during isert_rdma_rw_ctx_post() are queued to Queue-Full(QF) queue and are scheduled to be reposted during queue-full queue processing. During this reposting, the rdma contexts are initialised again in isert_rdma_rw_ctx_post(), which is leaking significant memory. unreferenced object 0xffff8830201d9640 (size 64): comm "kworker/0:2", pid 195, jiffies 4295374851 (age 4528.436s) hex dump (first 32 bytes): 00 60 8b cb 2e 00 00 00 00 10 00 00 00 00 00 00 .`.............. 00 90 e3 cb 2e 00 00 00 00 10 00 00 00 00 00 00 ................ backtrace: [] kmemleak_alloc+0x4e/0xb0 [] __kmalloc+0x125/0x2b0 [] rdma_rw_ctx_init+0x15f/0x6f0 [ib_core] [] isert_rdma_rw_ctx_post+0xc4/0x3c0 [ib_isert] [] isert_put_datain+0x112/0x1c0 [ib_isert] [] lio_queue_data_in+0x2e/0x30 [iscsi_target_mod] [] target_qf_do_work+0x2b2/0x4b0 [target_core_mod] [] process_one_work+0x1db/0x5d0 [] worker_thread+0x4d/0x3e0 [] kthread+0x117/0x150 [] ret_from_fork+0x27/0x40 [] 0xffffffffffffffff Here is patch to use the older rdma contexts while reposting the isert commands intead of reinitialising them. Signed-off-by: Potnuri Bharat Teja Reviewed-by: Sagi Grimberg Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/ulp/isert/ib_isert.c | 7 +++++++ drivers/infiniband/ulp/isert/ib_isert.h | 1 + 2 files changed, 8 insertions(+) --- a/drivers/infiniband/ulp/isert/ib_isert.c +++ b/drivers/infiniband/ulp/isert/ib_isert.c @@ -2124,6 +2124,9 @@ isert_rdma_rw_ctx_post(struct isert_cmd u32 rkey, offset; int ret; + if (cmd->ctx_init_done) + goto rdma_ctx_post; + if (dir == DMA_FROM_DEVICE) { addr = cmd->write_va; rkey = cmd->write_stag; @@ -2151,11 +2154,15 @@ isert_rdma_rw_ctx_post(struct isert_cmd se_cmd->t_data_sg, se_cmd->t_data_nents, offset, addr, rkey, dir); } + if (ret < 0) { isert_err("Cmd: %p failed to prepare RDMA res\n", cmd); return ret; } + cmd->ctx_init_done = true; + +rdma_ctx_post: ret = rdma_rw_ctx_post(&cmd->rw, conn->qp, port_num, cqe, chain_wr); if (ret < 0) isert_err("Cmd: %p failed to post RDMA res\n", cmd); --- a/drivers/infiniband/ulp/isert/ib_isert.h +++ b/drivers/infiniband/ulp/isert/ib_isert.h @@ -126,6 +126,7 @@ struct isert_cmd { struct rdma_rw_ctx rw; struct work_struct comp_work; struct scatterlist sg; + bool ctx_init_done; }; static inline struct isert_cmd *tx_desc_to_cmd(struct iser_tx_desc *desc)