[PATCH 0/2] target: Pre-allocation fixes for v3.12-rc

ยอดดู 10 ครั้ง
ข้ามไปที่ข้อความที่ยังไม่อ่านรายการแรก

Nicholas A. Bellinger

ยังไม่อ่าน,
23 ก.ย. 2556 15:10:2223/9/56
ถึง target-devel, Nicholas Bellinger
From: Nicholas Bellinger <n...@linux-iscsi.org>

Hi folks,

Here are two pre-allocation conversion related fixes that I'm queueing
up for v3.12-rc.

The first is a small vhost/scsi patch to fix a typo where GFP_KERNEL
instead of GFP_ATOMIC was used with percpu_ida_alloc() from interrupt
context in vhost_scsi_get_tag().

And the second is a patch for transport_alloc_session_tags() that
allows a high order kzalloc() failure of se_session->sess_cmd_map
memory to fallback to vzalloc, if necessary.

Thanks,

--nab

Nicholas Bellinger (2):
vhost/scsi: Use GFP_ATOMIC with percpu_ida_alloc for obtaining tag
target: Fall back to vzalloc for se_sess->sess_cmd_map if necessary

drivers/target/target_core_transport.c | 17 +++++++++++++----
drivers/vhost/scsi.c | 2 +-
2 files changed, 14 insertions(+), 5 deletions(-)

--
1.7.10.4

Nicholas A. Bellinger

ยังไม่อ่าน,
23 ก.ย. 2556 15:10:2323/9/56
ถึง target-devel, Nicholas Bellinger, Michael S. Tsirkin, Asias He
From: Nicholas Bellinger <n...@linux-iscsi.org>

Fix GFP_KERNEL -> GFP_ATOMIC usage of percpu_ida_alloc() within
vhost_scsi_get_tag(), as this code is expected to be called directly
from interrupt context.

Cc: Michael S. Tsirkin <m...@redhat.com>
Cc: Asias He <as...@redhat.com>
Signed-off-by: Nicholas Bellinger <n...@linux-iscsi.org>
---
drivers/vhost/scsi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
index 4b79a1f..532820c 100644
--- a/drivers/vhost/scsi.c
+++ b/drivers/vhost/scsi.c
@@ -728,7 +728,7 @@ vhost_scsi_get_tag(struct vhost_virtqueue *vq,
}
se_sess = tv_nexus->tvn_se_sess;

- tag = percpu_ida_alloc(&se_sess->sess_tag_pool, GFP_KERNEL);
+ tag = percpu_ida_alloc(&se_sess->sess_tag_pool, GFP_ATOMIC);
cmd = &((struct tcm_vhost_cmd *)se_sess->sess_cmd_map)[tag];
sg = cmd->tvc_sgl;
pages = cmd->tvc_upages;
--
1.7.10.4

Nicholas A. Bellinger

ยังไม่อ่าน,
23 ก.ย. 2556 15:10:2423/9/56
ถึง target-devel, Nicholas Bellinger, Michael S. Tsirkin, Asias He, Kent Overstreet
From: Nicholas Bellinger <n...@linux-iscsi.org>

This patch changes transport_alloc_session_tags() to fall back to
use vzalloc when kzalloc fails for big tag_num that end up generating
larger order allocations.

Also use is_vmalloc_addr() in transport_alloc_session_tags() failure
path, and normal transport_free_session() patch to determine when
vfree() needs to be called instead of kfree().

Cc: Michael S. Tsirkin <m...@redhat.com>
Cc: Asias He <as...@redhat.com>
Cc: Kent Overstreet <k...@dataerainc.com>
Signed-off-by: Nicholas Bellinger <n...@linux-iscsi.org>
---
drivers/target/target_core_transport.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index 4aace78..fd7a063 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -238,15 +238,21 @@ int transport_alloc_session_tags(struct se_session *se_sess,

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;
+ se_sess->sess_cmd_map = vzalloc(tag_num * tag_size);
+ 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);
+ if (is_vmalloc_addr(se_sess->sess_cmd_map))
+ vfree(se_sess->sess_cmd_map);
+ else
+ kfree(se_sess->sess_cmd_map);
se_sess->sess_cmd_map = NULL;
return -ENOMEM;
}
@@ -412,7 +418,10 @@ 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);
+ if (is_vmalloc_addr(se_sess->sess_cmd_map))
+ vfree(se_sess->sess_cmd_map);
+ else
+ kfree(se_sess->sess_cmd_map);
}
kmem_cache_free(se_sess_cache, se_sess);
}
--
1.7.10.4

ตอบทุกคน
ตอบกลับผู้สร้าง
ส่งต่อ
ข้อความใหม่ 0 รายการ