From patchwork Mon Jan 25 08:11:01 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: 8104391 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0E1ACBEEE5 for ; Mon, 25 Jan 2016 08:14:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2609D20328 for ; Mon, 25 Jan 2016 08:14:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3121620306 for ; Mon, 25 Jan 2016 08:14:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755538AbcAYIOZ (ORCPT ); Mon, 25 Jan 2016 03:14:25 -0500 Received: from mail-oi0-f47.google.com ([209.85.218.47]:33455 "EHLO mail-oi0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753332AbcAYIOG (ORCPT ); Mon, 25 Jan 2016 03:14:06 -0500 Received: by mail-oi0-f47.google.com with SMTP id w75so82743056oie.0 for ; Mon, 25 Jan 2016 00:14:05 -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=DPp1fCtTV4QypOn+8W6FLtSwiqRr9D4bO8rel59Kfig=; b=ra0GcOl3fcCh097jvVS2lBVn57UND/rwEsV9NLEjKvsokT457zTI/QMeNA2ZJ9FYNI X7fUzDxSlQobKjCBRKPehOFZUgxMH0PTa+OSkXvujS+ntXc2kXWhKX8SDnqXhnIPoSAw KkigeZnPMf/a/gBzSI3YdoD2d7ZAqdHmKsoztA10sbQSLeZSlUYu1KC7IAPnnVnm0iEJ f5WvD2qx6tz8yuzcvGLwtIkUTSNtn3fTVreOGZDsGpat95uyT7ZfqdyekHsoDVs/4B6V hV5saITzCFLtPcmFO4wJGXDWZoSO0vhC+qAJo/PWdckGNECTiqpAhR2JT7D8BgXGAoUC HWYA== 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=DPp1fCtTV4QypOn+8W6FLtSwiqRr9D4bO8rel59Kfig=; b=RljxjjOCKkK+3XVLlqlPPb7cDbxyATVFdJWEXb7cgS9rKotuO3H3jf9ta+IzBe04p+ Edp1AODVPg0eVNeoXEa2UKyyCSNUlA5YkXNEDEBahmgcbskxdXRoPUX1VBNZDuerjFcY TSelfiBFQaDNFN4XO9JirWvKA9MkTDQPLM0w7uEdE5A/x+0sfIFnS69lxUzYBBpEi5mD BBDZN6u0nEaUc/aHYhDPwrRvlQ2EdoIucrAPsnlp5P4Rc/SkP7+kSFGopj2fDgbpC4ww hKRls59eEpr6w+tbfvCqMuYU3C1umUnq4lvwOkF1GvVDXkzo/JbnvGmyrgol7Xtzmn8n DM1g== X-Gm-Message-State: AG10YOSaKLp7r4OzTdRwp0B+GSjHjwoL+39bwsgOY+4mSJwG3bQN7L1aGx3FwWUusOc5og== X-Received: by 10.202.83.139 with SMTP id h133mr11718696oib.127.1453709644854; Mon, 25 Jan 2016 00:14:04 -0800 (PST) Received: from localhost.localdomain (mail.linux-iscsi.org. [67.23.28.174]) by smtp.gmail.com with ESMTPSA id v142sm9939087oie.28.2016.01.25.00.14.04 (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 25 Jan 2016 00:14:04 -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 , Nicholas Bellinger Subject: [PATCH-v2 07/12] sbp-target: Conversion to percpu_ida tag pre-allocation Date: Mon, 25 Jan 2016 08:11:01 +0000 Message-Id: <1453709466-6308-8-git-send-email-nab@daterainc.com> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1453709466-6308-1-git-send-email-nab@daterainc.com> References: <1453709466-6308-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 Cc: Chris Boot Cc: Christoph Hellwig Cc: Hannes Reinecke Signed-off-by: Nicholas Bellinger --- drivers/target/sbp/sbp_target.c | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/drivers/target/sbp/sbp_target.c b/drivers/target/sbp/sbp_target.c index ddd3398..756e87f 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,24 @@ 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]; + 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,7 +952,7 @@ 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); + req = sbp_mgt_get_req(sess, sess->card, next_orb); if (!req) { spin_lock_bh(&agent->lock); agent->state = AGENT_STATE_DEAD; @@ -1430,9 +1450,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,8 +1616,12 @@ static void sbp_mgt_agent_rw(struct fw_card *card, rcode = RCODE_CONFLICT_ERROR; goto out; } - + // XXX: +#if 0 + req = sbp_mgt_get_req(agent->login->sess, card); +#else req = kzalloc(sizeof(*req), GFP_ATOMIC); +#endif if (!req) { rcode = RCODE_CONFLICT_ERROR; goto out;