提交 9db9da33 编写于 作者: R roland@purestorage.com 提交者: Nicholas Bellinger

target: Don't zero pages used for data buffers

Doing alloc_page(GFP_KERNEL | __GFP_ZERO) to get pages used for data
buffers wastes a lot of CPU clearing pages that will be quickly be
overwritten by the actual data.  However, for emulated control
commands such as INQUIRY and so on, the code does assume that the
buffer is zeroed.

To avoid this CPU overhead, skip the __GFP_ZERO for commands that are
actually moving data, ie cmds that have SCF_SCSI_DATA_SG_IO_CDB set.
Signed-off-by: NRoland Dreier <roland@purestorage.com>
Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
上级 6816966a
...@@ -3516,6 +3516,7 @@ transport_generic_get_mem(struct se_cmd *cmd) ...@@ -3516,6 +3516,7 @@ transport_generic_get_mem(struct se_cmd *cmd)
u32 length = cmd->data_length; u32 length = cmd->data_length;
unsigned int nents; unsigned int nents;
struct page *page; struct page *page;
gfp_t zero_flag;
int i = 0; int i = 0;
nents = DIV_ROUND_UP(length, PAGE_SIZE); nents = DIV_ROUND_UP(length, PAGE_SIZE);
...@@ -3526,9 +3527,11 @@ transport_generic_get_mem(struct se_cmd *cmd) ...@@ -3526,9 +3527,11 @@ transport_generic_get_mem(struct se_cmd *cmd)
cmd->t_data_nents = nents; cmd->t_data_nents = nents;
sg_init_table(cmd->t_data_sg, nents); sg_init_table(cmd->t_data_sg, nents);
zero_flag = cmd->se_cmd_flags & SCF_SCSI_DATA_SG_IO_CDB ? 0 : __GFP_ZERO;
while (length) { while (length) {
u32 page_len = min_t(u32, length, PAGE_SIZE); u32 page_len = min_t(u32, length, PAGE_SIZE);
page = alloc_page(GFP_KERNEL | __GFP_ZERO); page = alloc_page(GFP_KERNEL | zero_flag);
if (!page) if (!page)
goto out; goto out;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册