mirror of
https://github.com/SCST-project/scst.git
synced 2026-05-23 21:51:27 +00:00
Another micro-optimization: cache align all fast path structures
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@4785 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
@@ -850,7 +850,7 @@ static int iscsi_conn_alloc(struct iscsi_session *session,
|
||||
struct iscsi_conn *conn;
|
||||
int res = 0;
|
||||
|
||||
conn = kzalloc(sizeof(*conn), GFP_KERNEL);
|
||||
conn = kzalloc(L1_CACHE_ALIGN(sizeof(*conn)), GFP_KERNEL);
|
||||
if (!conn) {
|
||||
res = -ENOMEM;
|
||||
goto out_err;
|
||||
|
||||
@@ -3918,7 +3918,7 @@ int iscsi_threads_pool_get(const cpumask_t *cpu_mask,
|
||||
|
||||
TRACE_DBG("%s", "Creating new iSCSI thread pool");
|
||||
|
||||
p = kzalloc(sizeof(*p), GFP_KERNEL);
|
||||
p = kzalloc(L1_CACHE_ALIGN(sizeof(*p)), GFP_KERNEL);
|
||||
if (p == NULL) {
|
||||
PRINT_ERROR("Unable to allocate iSCSI thread pool (size %zd)",
|
||||
sizeof(*p));
|
||||
|
||||
@@ -77,7 +77,8 @@ struct iscsi_thread_pool {
|
||||
struct list_head rd_list;
|
||||
wait_queue_head_t rd_waitQ;
|
||||
|
||||
spinlock_t wr_lock;
|
||||
/* It's used by another thread, hence aligned */
|
||||
spinlock_t wr_lock ____cacheline_aligned_in_smp;
|
||||
struct list_head wr_list;
|
||||
wait_queue_head_t wr_waitQ;
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ static int iscsi_session_alloc(struct iscsi_target *target,
|
||||
struct iscsi_session *session;
|
||||
char *name = NULL;
|
||||
|
||||
session = kzalloc(sizeof(*session), GFP_KERNEL);
|
||||
session = kzalloc(L1_CACHE_ALIGN(sizeof(*session)), GFP_KERNEL);
|
||||
if (!session)
|
||||
return -ENOMEM;
|
||||
|
||||
|
||||
@@ -1155,7 +1155,7 @@ static struct q2t_sess *q2t_create_sess(scsi_qla_host_t *ha, fc_port_t *fcport,
|
||||
|
||||
/* We are under tgt_mutex, so a new sess can't be added behind us */
|
||||
|
||||
sess = kzalloc(sizeof(*sess), GFP_KERNEL);
|
||||
sess = kzalloc(L1_CACHE_ALIGN(sizeof(*sess)), GFP_KERNEL);
|
||||
if (sess == NULL) {
|
||||
PRINT_ERROR("qla2x00t(%ld): session allocation failed, "
|
||||
"all commands from port %02x:%02x:%02x:%02x:"
|
||||
@@ -5736,7 +5736,7 @@ static int q2t_add_target(scsi_qla_host_t *ha)
|
||||
|
||||
sBUG_ON((ha->q2t_tgt != NULL) || (ha->tgt != NULL));
|
||||
|
||||
tgt = kzalloc(sizeof(*tgt), GFP_KERNEL);
|
||||
tgt = kzalloc(L1_CACHE_ALIGN(sizeof(*tgt)), GFP_KERNEL);
|
||||
if (tgt == NULL) {
|
||||
PRINT_ERROR("qla2x00t: %s", "Allocation of tgt failed");
|
||||
res = -ENOMEM;
|
||||
|
||||
@@ -1196,9 +1196,8 @@ static int dev_user_map_buf(struct scst_user_cmd *ucmd, unsigned long ubuff,
|
||||
|
||||
ucmd->num_data_pages = num_pg;
|
||||
|
||||
ucmd->data_pages =
|
||||
kmalloc(sizeof(*ucmd->data_pages) * ucmd->num_data_pages,
|
||||
GFP_KERNEL);
|
||||
ucmd->data_pages = kmalloc(L1_CACHE_ALIGN(sizeof(*ucmd->data_pages) * ucmd->num_data_pages),
|
||||
GFP_KERNEL);
|
||||
if (ucmd->data_pages == NULL) {
|
||||
TRACE(TRACE_OUT_OF_MEM, "Unable to allocate data_pages array "
|
||||
"(num_data_pages=%d)", ucmd->num_data_pages);
|
||||
@@ -2931,7 +2930,7 @@ static int dev_user_register_dev(struct file *file,
|
||||
goto out;
|
||||
}
|
||||
|
||||
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
|
||||
dev = kzalloc(L1_CACHE_ALIGN(sizeof(*dev)), GFP_KERNEL);
|
||||
if (dev == NULL) {
|
||||
res = -ENOMEM;
|
||||
goto out_put;
|
||||
|
||||
@@ -1629,7 +1629,7 @@ static struct scatterlist *alloc_sg(size_t size, unsigned off, gfp_t gfp_mask,
|
||||
|
||||
sg_cnt = PAGE_ALIGN(size + off) >> PAGE_SHIFT;
|
||||
sg = sg_cnt <= small_sg_size ? small_sg :
|
||||
kmalloc(sg_cnt * sizeof(*sg), gfp_mask);
|
||||
kmalloc(L1_CACHE_ALIGN(sg_cnt * sizeof(*sg)), gfp_mask);
|
||||
if (!sg)
|
||||
goto out;
|
||||
|
||||
@@ -3387,7 +3387,7 @@ static struct iovec *vdisk_alloc_iv(struct scst_cmd *cmd,
|
||||
p->iv_count = 0;
|
||||
/* It can't be called in atomic context */
|
||||
p->iv = (iv_count <= ARRAY_SIZE(p->small_iv)) ? p->small_iv :
|
||||
kmalloc(sizeof(*p->iv) * iv_count, GFP_KERNEL);
|
||||
kmalloc(L1_CACHE_ALIGN(sizeof(*p->iv) * iv_count), GFP_KERNEL);
|
||||
if (p->iv == NULL) {
|
||||
PRINT_ERROR("Unable to allocate iv (%d)", iv_count);
|
||||
goto out;
|
||||
@@ -4307,7 +4307,7 @@ static int vdev_create(struct scst_dev_type *devt,
|
||||
if (vdev_find(name))
|
||||
goto out;
|
||||
|
||||
virt_dev = kzalloc(sizeof(*virt_dev), GFP_KERNEL);
|
||||
virt_dev = kzalloc(L1_CACHE_ALIGN(sizeof(*virt_dev)), GFP_KERNEL);
|
||||
if (virt_dev == NULL) {
|
||||
PRINT_ERROR("Allocation of virtual device %s failed",
|
||||
devt->name);
|
||||
|
||||
@@ -3373,7 +3373,7 @@ int scst_alloc_device(gfp_t gfp_mask, struct scst_device **out_dev)
|
||||
|
||||
TRACE_ENTRY();
|
||||
|
||||
dev = kzalloc(sizeof(*dev), gfp_mask);
|
||||
dev = kzalloc(L1_CACHE_ALIGN(sizeof(*dev)), gfp_mask);
|
||||
if (dev == NULL) {
|
||||
PRINT_ERROR("%s", "Allocation of scst_device failed");
|
||||
res = -ENOMEM;
|
||||
@@ -5249,9 +5249,10 @@ void scst_cmd_set_ext_cdb(struct scst_cmd *cmd,
|
||||
goto out;
|
||||
}
|
||||
|
||||
cmd->cdb = kmalloc(len, gfp_mask);
|
||||
cmd->cdb = kmalloc(L1_CACHE_ALIGN(len), gfp_mask);
|
||||
if (unlikely(cmd->cdb == NULL)) {
|
||||
PRINT_ERROR("Unable to alloc extended CDB (size %d)", len);
|
||||
PRINT_ERROR("Unable to alloc extended CDB (size %d)",
|
||||
L1_CACHE_ALIGN(len));
|
||||
goto out_err;
|
||||
}
|
||||
|
||||
@@ -5325,10 +5326,10 @@ int scst_pre_init_cmd(struct scst_cmd *cmd, const uint8_t *cdb,
|
||||
res = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
cmd->cdb = kmalloc(cdb_len, gfp_mask);
|
||||
cmd->cdb = kmalloc(L1_CACHE_ALIGN(cdb_len), gfp_mask);
|
||||
if (unlikely(cmd->cdb == NULL)) {
|
||||
PRINT_ERROR("Unable to alloc extended CDB (size %d)",
|
||||
cdb_len);
|
||||
L1_CACHE_ALIGN(cdb_len));
|
||||
res = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -660,7 +660,7 @@ static int sgv_alloc_arrays(struct sgv_pool_obj *obj,
|
||||
|
||||
sz = pages_to_alloc * sizeof(obj->sg_entries[0]);
|
||||
|
||||
obj->sg_entries = kmalloc(sz, gfp_mask);
|
||||
obj->sg_entries = kmalloc(L1_CACHE_ALIGN(sz), gfp_mask);
|
||||
if (unlikely(obj->sg_entries == NULL)) {
|
||||
TRACE(TRACE_OUT_OF_MEM, "Allocation of sgv_pool_obj "
|
||||
"SG vector failed (size %d)", sz);
|
||||
@@ -680,7 +680,7 @@ static int sgv_alloc_arrays(struct sgv_pool_obj *obj,
|
||||
*/
|
||||
} else {
|
||||
tsz = pages_to_alloc * sizeof(obj->trans_tbl[0]);
|
||||
obj->trans_tbl = kzalloc(tsz, gfp_mask);
|
||||
obj->trans_tbl = kzalloc(L1_CACHE_ALIGN(tsz), gfp_mask);
|
||||
if (unlikely(obj->trans_tbl == NULL)) {
|
||||
TRACE(TRACE_OUT_OF_MEM, "Allocation of "
|
||||
"trans_tbl failed (size %d)", tsz);
|
||||
@@ -1021,7 +1021,7 @@ struct scatterlist *sgv_pool_alloc(struct sgv_pool *pool, unsigned int size,
|
||||
|
||||
sz = sizeof(*obj) + pages * sizeof(obj->sg_entries[0]);
|
||||
|
||||
obj = kmalloc(sz, gfp_mask);
|
||||
obj = kmalloc(L1_CACHE_ALIGN(sz), gfp_mask);
|
||||
if (unlikely(obj == NULL)) {
|
||||
TRACE(TRACE_OUT_OF_MEM, "Allocation of "
|
||||
"sgv_pool_obj failed (size %d)", size);
|
||||
@@ -1374,7 +1374,7 @@ static void sgv_pool_init_cache(struct sgv_pool *pool, int cache_num)
|
||||
"%s-%uK", pool->name, (pages << PAGE_SHIFT) >> 10);
|
||||
pool->caches[cache_num] = kmem_cache_create(
|
||||
pool->cache_names[cache_num], size,
|
||||
__alignof__(struct sgv_pool_obj), SCST_SLAB_FLAGS, NULL
|
||||
0, SCST_SLAB_FLAGS|SLAB_HWCACHE_ALIGN, NULL
|
||||
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23))
|
||||
, NULL);
|
||||
#else
|
||||
@@ -1651,7 +1651,7 @@ struct sgv_pool *sgv_pool_create(const char *name,
|
||||
}
|
||||
}
|
||||
|
||||
pool = kzalloc(sizeof(*pool), GFP_KERNEL);
|
||||
pool = kzalloc(L1_CACHE_ALIGN(sizeof(*pool)), GFP_KERNEL);
|
||||
if (pool == NULL) {
|
||||
PRINT_ERROR("Allocation of sgv_pool failed (size %zd)",
|
||||
sizeof(*pool));
|
||||
|
||||
@@ -1623,7 +1623,7 @@ static int __scst_local_add_adapter(struct scst_local_tgt *tgt,
|
||||
|
||||
TRACE_ENTRY();
|
||||
|
||||
sess = kzalloc(sizeof(*sess), GFP_KERNEL);
|
||||
sess = kzalloc(L1_CACHE_ALIGN(sizeof(*sess)), GFP_KERNEL);
|
||||
if (NULL == sess) {
|
||||
PRINT_ERROR("Unable to alloc scst_lcl_host (size %zu)",
|
||||
sizeof(*sess));
|
||||
|
||||
Reference in New Issue
Block a user