From patchwork Fri Mar 11 06:30:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nicholas A. Bellinger" X-Patchwork-Id: 8562351 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2A6689F6E4 for ; Fri, 11 Mar 2016 06:34:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 326AD2026D for ; Fri, 11 Mar 2016 06:34:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2B8CC2035E for ; Fri, 11 Mar 2016 06:34:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754227AbcCKGeo (ORCPT ); Fri, 11 Mar 2016 01:34:44 -0500 Received: from mail-oi0-f50.google.com ([209.85.218.50]:33883 "EHLO mail-oi0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932612AbcCKGem (ORCPT ); Fri, 11 Mar 2016 01:34:42 -0500 Received: by mail-oi0-f50.google.com with SMTP id m82so78982116oif.1 for ; Thu, 10 Mar 2016 22:34:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daterainc-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ej6DlkB/P9cBBJ9L9Kj0YhC7MHx6+hUi+HPdJhRe3Bk=; b=HsQ5ip+7iMvrFoG1m1vE8OGTg9TbSiDRft81HbHxrkt3j5SInMp8qysgr5FEN0rWWx zkTZHX2iD7WqHGAuROd4QCcSRVFOKeuKkwC8yvg/Xz+wRx5YGh6rxeXyQUX33VgpAawj YujcSPQBbHJAuobaU6fqKL1ChIEhQ+XqQy0QpyxJ3xTVubYHLKGSH/ImvBGPiJpMiWA1 Pj9Tri8v7QTBeoclplEIKro+lUp6v9EN4Re9fL0ADxSL4iorNTbphoL5flDAhCHEQAe1 Q5NtsQo3yU+I16s+5Bfe35k2CdI1clhYb8jwG+asVwvQQihv28OeH/wS72koKMMxcreG 0sRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ej6DlkB/P9cBBJ9L9Kj0YhC7MHx6+hUi+HPdJhRe3Bk=; b=eEYadR0WGosWc4bXwnnKjpOFbXueQrgo3WNhoywInOrjztqx3Xk5TjQSA1K86o00Ou sPodtNwvLMoaEnTvNgZKHu9gSZ6Zf5S3cCKP/50rIjHRQ/DaDRyD93Yivuj9q3bo4w0w tJqyDywyyyd10VNZMCoZQC8xvzhParCkK68jzXnMUwgi2l+zSpsIT1d3FflZWD/0Xk7b EoWT490pQOpwzOFEJjQ7wHz427fiZjhudw/yewffTffgGSsIxcB/e3TQSuSg3rzmZkUY IPFeh4aQk6Fp9LJcHcbvBftWa4pJIe33kAnu3No6psqJoe0dw4pfbk5ScV0mF1birLDX GFlg== X-Gm-Message-State: AD7BkJKZxzwiXAr0Equ455URZXNe+ui6MvJj3jKyJXLqWgzyfdGtmnJMHnAcqZ1kMxcyeQ== X-Received: by 10.202.49.12 with SMTP id x12mr4460276oix.106.1457678081756; Thu, 10 Mar 2016 22:34:41 -0800 (PST) Received: from localhost.localdomain (mail.linux-iscsi.org. [67.23.28.174]) by smtp.gmail.com with ESMTPSA id s81sm3540631oif.0.2016.03.10.22.34.41 (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 10 Mar 2016 22:34:41 -0800 (PST) From: "Nicholas A. Bellinger" To: target-devel Cc: linux-scsi , Christoph Hellwig , Hannes Reinecke , Mike Christie , Sagi Grimberg , Andy Grover , Sebastian Andrzej Siewior , Juergen Gross , Andrzej Pietrasiewicz , Chris Boot , Felipe Balbi , Nicholas Bellinger Subject: [PATCH-v4 07/14] sbp-target: Conversion to percpu_ida tag pre-allocation Date: Fri, 11 Mar 2016 06:30:03 +0000 Message-Id: <1457677810-2478-8-git-send-email-nab@daterainc.com> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1457677810-2478-1-git-send-email-nab@daterainc.com> References: <1457677810-2478-1-git-send-email-nab@daterainc.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Nicholas Bellinger This patch converts sbp-target to use struct sbp_target_request descriptor tag pre-allocation using percpu_ida. (Fix sbp_mgt_get_req() IS_ERR failure checking - Dan Carpenter) (Add missing sbp_target_request tag memset - Chris Boot) Acked-by: Chris Boot Tested-by: Chris Boot Cc: Christoph Hellwig Cc: Hannes Reinecke Signed-off-by: Nicholas Bellinger --- drivers/target/sbp/sbp_target.c | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/drivers/target/sbp/sbp_target.c b/drivers/target/sbp/sbp_target.c index ddd3398..627044f2 100644 --- a/drivers/target/sbp/sbp_target.c +++ b/drivers/target/sbp/sbp_target.c @@ -209,8 +209,10 @@ static struct sbp_session *sbp_session_create( INIT_DELAYED_WORK(&sess->maint_work, session_maintenance_work); sess->guid = guid; - sess->se_sess = target_alloc_session(&tpg->se_tpg, 0, 0, TARGET_PROT_NORMAL, - guid_str, sess, NULL); + sess->se_sess = target_alloc_session(&tpg->se_tpg, 128, + sizeof(struct sbp_target_request), + TARGET_PROT_NORMAL, guid_str, + sess, NULL); if (IS_ERR(sess->se_sess)) { pr_err("failed to init se_session\n"); ret = PTR_ERR(sess->se_sess); @@ -921,6 +923,25 @@ static inline bool tgt_agent_check_active(struct sbp_target_agent *agent) return active; } +static struct sbp_target_request *sbp_mgt_get_req(struct sbp_session *sess, + struct fw_card *card, u64 next_orb) +{ + struct se_session *se_sess = sess->se_sess; + struct sbp_target_request *req; + int tag; + + tag = percpu_ida_alloc(&se_sess->sess_tag_pool, GFP_ATOMIC); + if (tag < 0) + return ERR_PTR(-ENOMEM); + + req = &((struct sbp_target_request *)se_sess->sess_cmd_map)[tag]; + memset(req, 0, sizeof(*req)); + req->se_cmd.map_tag = tag; + req->se_cmd.tag = next_orb; + + return req; +} + static void tgt_agent_fetch_work(struct work_struct *work) { struct sbp_target_agent *agent = @@ -932,8 +953,8 @@ static void tgt_agent_fetch_work(struct work_struct *work) u64 next_orb = agent->orb_pointer; while (next_orb && tgt_agent_check_active(agent)) { - req = kzalloc(sizeof(*req), GFP_KERNEL); - if (!req) { + req = sbp_mgt_get_req(sess, sess->card, next_orb); + if (IS_ERR(req)) { spin_lock_bh(&agent->lock); agent->state = AGENT_STATE_DEAD; spin_unlock_bh(&agent->lock); @@ -1430,9 +1451,13 @@ static int sbp_send_sense(struct sbp_target_request *req) static void sbp_free_request(struct sbp_target_request *req) { + struct se_cmd *se_cmd = &req->se_cmd; + struct se_session *se_sess = se_cmd->se_sess; + kfree(req->pg_tbl); kfree(req->cmd_buf); - kfree(req); + + percpu_ida_free(&se_sess->sess_tag_pool, se_cmd->map_tag); } static void sbp_mgt_agent_process(struct work_struct *work) @@ -1592,7 +1617,6 @@ static void sbp_mgt_agent_rw(struct fw_card *card, rcode = RCODE_CONFLICT_ERROR; goto out; } - req = kzalloc(sizeof(*req), GFP_ATOMIC); if (!req) { rcode = RCODE_CONFLICT_ERROR;