Received: by 10.213.65.68 with SMTP id h4csp259025imn; Fri, 23 Mar 2018 04:07:45 -0700 (PDT) X-Google-Smtp-Source: AG47ELuOgoY/SVu/u+wXwwnVh13lixe8LGqnnoh3xInmKcpYteJIqX66J5FUJbFripwZpicrO3uk X-Received: by 10.98.7.68 with SMTP id b65mr23562063pfd.39.1521803265028; Fri, 23 Mar 2018 04:07:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521803264; cv=none; d=google.com; s=arc-20160816; b=XIt6VIhEXrabDv/6vPQCiQ/tsPKCJoKPYo9bjm4RHTHeilnQLVwugIg8dL5Lsiq8iF 83DNmiPtSxhdTbmtuzzrMMmtl3tkCEfNQSWRWK/CEhQBUTX7eyESTXjRSBSft4f5mqdU Bji4VALPGP6I14BaDRNWO8LgbXL9cztIaeTxojMQhEQRYPaum7pdaToNgMSvULpxWHR9 vh/3HaiReutrT6jnma6pt4JvhKcpmpaVDFlrZG8OtHZcl2N1KEflIuejEJzh67y3lOhR 5qIlES9NSRXEn64CZNHxcoK2ErQDXSXC739z/iKUeBg+6FTf4YzmlVBdqG8naeZL6sqM 58Vg== 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=2lmf6OZT0CpBfpRY6pHhk4dBVyW8x9rhX1yPd2LjtTg=; b=KRrfdtrcUZG9cH2GMLGMlkbY0fCu9m+aLZghGWZ1lw0/i8EKzJ1/7VaAra1n0h/w+k AW1wTFMXNOz+1pcYNfgcNpeeoJgsFuaPJyrmON0efBjYHQPlJTIuAtPpwAXvU2sTeiLP zhwUYo7KcxqrzNZoRqRDID5oUp7wSLhafqyq41HsRbRi2jrxDgaOa/nz8EQMjZDRIVUh yfZxQsKPN9DrS0kcmw475PUBkIzN6xOIa1bo81Xa1tMk6q4mgfwNtVrjkTviCh2c6d4D 8WG56K2OaaEfENuiXr7+WUlRGD8iQMcisZYs7TepLYvGww8SxkSeD2cW0+fSPRVCEvvK feyg== 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 x33-v6si5110467plb.512.2018.03.23.04.07.30; Fri, 23 Mar 2018 04:07:44 -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 S933141AbeCWKMK (ORCPT + 99 others); Fri, 23 Mar 2018 06:12:10 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:44138 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933106AbeCWKMC (ORCPT ); Fri, 23 Mar 2018 06:12:02 -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 217A41066; Fri, 23 Mar 2018 10:12:01 +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.9 155/177] iser-target: avoid reinitializing rdma contexts for isert commands Date: Fri, 23 Mar 2018 10:54:43 +0100 Message-Id: <20180323094212.018727602@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180323094205.090519271@linuxfoundation.org> References: <20180323094205.090519271@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.9-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 @@ -2098,6 +2098,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; @@ -2125,11 +2128,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 @@ -124,6 +124,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)