From: Asias He <asias@redhat.com>
To: "Nicholas A. Bellinger" <nab@linux-iscsi.org>
Cc: target-devel <target-devel@vger.kernel.org>,
lkml <linux-kernel@vger.kernel.org>,
"Michael S. Tsirkin" <mst@redhat.com>,
Kent Overstreet <kmo@daterainc.com>,
Andrew Morton <akpm@linux-foundation.org>,
Jens Axboe <axboe@kernel.dk>, Tejun Heo <tj@kernel.org>,
Ingo Molnar <mingo@redhat.com>, Andi Kleen <andi@firstfloor.org>,
Christoph Lameter <cl@gentwo.org>
Subject: Re: [PATCH-v5 2/6] target: Add transport_init_session_tags using per-cpu ida
Date: Tue, 3 Sep 2013 16:16:08 +0800 [thread overview]
Message-ID: <20130903081608.GA7655@hj.localdomain> (raw)
In-Reply-To: <1377917556-11955-3-git-send-email-nab@linux-iscsi.org>
On Sat, Aug 31, 2013 at 02:52:32AM +0000, Nicholas A. Bellinger wrote:
> From: Nicholas Bellinger <nab@linux-iscsi.org>
>
> This patch adds lib/idr.c based transport_init_session_tags() logic
> that allows fabric drivers to setup a per-cpu se_sess->sess_tag_pool
> and associated se_sess->sess_cmd_map for basic tagged pre-allocation
> of fabric descriptor sized memory.
>
> v5 changes:
> - Convert to percpu_ida.h include
>
> v4 changes:
> - Add transport_alloc_session_tags() for fabrics that need early
> transport_init_session()
>
> v3 changes:
> - Update to percpu-ida usage
>
> Cc: Kent Overstreet <kmo@daterainc.com>
> Cc: Asias He <asias@redhat.com>
> Cc: Michael S. Tsirkin <mst@redhat.com>
> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Reviewed-by: Asias He <asias@redhat.com>
> ---
> drivers/target/target_core_transport.c | 48 ++++++++++++++++++++++++++++++++
> include/target/target_core_base.h | 5 +++
> include/target/target_core_fabric.h | 3 ++
> 3 files changed, 56 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
> index 7172d00..98ec711 100644
> --- a/drivers/target/target_core_transport.c
> +++ b/drivers/target/target_core_transport.c
> @@ -232,6 +232,50 @@ struct se_session *transport_init_session(void)
> }
> EXPORT_SYMBOL(transport_init_session);
>
> +int transport_alloc_session_tags(struct se_session *se_sess,
> + unsigned int tag_num, unsigned int tag_size)
> +{
> + int rc;
> +
> + se_sess->sess_cmd_map = kzalloc(tag_num * tag_size, GFP_KERNEL);
> + if (!se_sess->sess_cmd_map) {
> + pr_err("Unable to allocate se_sess->sess_cmd_map\n");
> + return -ENOMEM;
> + }
> +
> + rc = percpu_ida_init(&se_sess->sess_tag_pool, tag_num);
> + if (rc < 0) {
> + pr_err("Unable to init se_sess->sess_tag_pool,"
> + " tag_num: %u\n", tag_num);
> + kfree(se_sess->sess_cmd_map);
> + se_sess->sess_cmd_map = NULL;
> + return -ENOMEM;
> + }
> +
> + return 0;
> +}
> +EXPORT_SYMBOL(transport_alloc_session_tags);
> +
> +struct se_session *transport_init_session_tags(unsigned int tag_num,
> + unsigned int tag_size)
> +{
> + struct se_session *se_sess;
> + int rc;
> +
> + se_sess = transport_init_session();
> + if (IS_ERR(se_sess))
> + return se_sess;
> +
> + rc = transport_alloc_session_tags(se_sess, tag_num, tag_size);
> + if (rc < 0) {
> + transport_free_session(se_sess);
> + return ERR_PTR(-ENOMEM);
> + }
> +
> + return se_sess;
> +}
> +EXPORT_SYMBOL(transport_init_session_tags);
> +
> /*
> * Called with spin_lock_irqsave(&struct se_portal_group->session_lock called.
> */
> @@ -367,6 +411,10 @@ EXPORT_SYMBOL(transport_deregister_session_configfs);
>
> void transport_free_session(struct se_session *se_sess)
> {
> + if (se_sess->sess_cmd_map) {
> + percpu_ida_destroy(&se_sess->sess_tag_pool);
> + kfree(se_sess->sess_cmd_map);
> + }
> kmem_cache_free(se_sess_cache, se_sess);
> }
> EXPORT_SYMBOL(transport_free_session);
> diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
> index e34fc90..bd55acd 100644
> --- a/include/target/target_core_base.h
> +++ b/include/target/target_core_base.h
> @@ -5,6 +5,7 @@
> #include <linux/configfs.h>
> #include <linux/dma-mapping.h>
> #include <linux/blkdev.h>
> +#include <linux/percpu_ida.h>
> #include <scsi/scsi_cmnd.h>
> #include <net/sock.h>
> #include <net/tcp.h>
> @@ -415,6 +416,8 @@ struct se_cmd {
> enum dma_data_direction data_direction;
> /* For SAM Task Attribute */
> int sam_task_attr;
> + /* Used for se_sess->sess_tag_pool */
> + unsigned int map_tag;
> /* Transport protocol dependent state, see transport_state_table */
> enum transport_state_table t_state;
> unsigned cmd_wait_set:1;
> @@ -536,6 +539,8 @@ struct se_session {
> struct list_head sess_wait_list;
> spinlock_t sess_cmd_lock;
> struct kref sess_kref;
> + void *sess_cmd_map;
> + struct percpu_ida sess_tag_pool;
> };
>
> struct se_device;
> diff --git a/include/target/target_core_fabric.h b/include/target/target_core_fabric.h
> index 7a16178..d559c36 100644
> --- a/include/target/target_core_fabric.h
> +++ b/include/target/target_core_fabric.h
> @@ -84,6 +84,9 @@ struct target_core_fabric_ops {
> };
>
> struct se_session *transport_init_session(void);
> +int transport_alloc_session_tags(struct se_session *, unsigned int,
> + unsigned int);
> +struct se_session *transport_init_session_tags(unsigned int, unsigned int);
> void __transport_register_session(struct se_portal_group *,
> struct se_node_acl *, struct se_session *, void *);
> void transport_register_session(struct se_portal_group *,
> --
> 1.7.2.5
>
--
Asias
next prev parent reply other threads:[~2013-09-03 8:16 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-31 2:52 [PATCH-v5 0/6] target/vhost/iscsi: Add per-cpu ida tag pre-allocation for v3.12 Nicholas A. Bellinger
2013-08-31 2:52 ` [PATCH-v5 1/6] idr: Percpu ida Nicholas A. Bellinger
2013-09-03 16:06 ` Nicholas A. Bellinger
2013-09-04 1:27 ` Andrew Morton
2013-09-04 4:42 ` Nicholas A. Bellinger
2013-08-31 2:52 ` [PATCH-v5 2/6] target: Add transport_init_session_tags using per-cpu ida Nicholas A. Bellinger
2013-09-03 8:16 ` Asias He [this message]
2013-08-31 2:52 ` [PATCH-v5 3/6] vhost/scsi: Convert to per-cpu ida_alloc + ida_free command map Nicholas A. Bellinger
2013-08-31 2:52 ` [PATCH-v5 4/6] vhost/scsi: Add pre-allocation for tv_cmd SGL + upages memory Nicholas A. Bellinger
2013-09-03 8:13 ` Asias He
2013-08-31 2:52 ` [PATCH-v5 5/6] iscsi/iser-target: Convert to command priv_size usage Nicholas A. Bellinger
2013-08-31 2:52 ` [PATCH-v5 6/6] iscsi-target: Convert to per-cpu ida_alloc + ida_free command map Nicholas A. Bellinger
2013-09-03 16:04 ` [PATCH-v5 0/6] target/vhost/iscsi: Add per-cpu ida tag pre-allocation for v3.12 Michael S. Tsirkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130903081608.GA7655@hj.localdomain \
--to=asias@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=andi@firstfloor.org \
--cc=axboe@kernel.dk \
--cc=cl@gentwo.org \
--cc=kmo@daterainc.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=mst@redhat.com \
--cc=nab@linux-iscsi.org \
--cc=target-devel@vger.kernel.org \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®