HFI1: move txreq kmalloc cache header into CPU local variable

This commit is contained in:
Balazs Gerofi
2017-08-24 17:39:51 +09:00
parent a65faeaed4
commit 5b5191ef64
2 changed files with 10 additions and 8 deletions

View File

@ -106,6 +106,7 @@ struct cpu_local_var {
struct list_head smp_func_req_list; struct list_head smp_func_req_list;
struct process_vm *on_fork_vm; struct process_vm *on_fork_vm;
struct kmalloc_cache_header txreq_cache;
} __attribute__((aligned(64))); } __attribute__((aligned(64)));

View File

@ -1215,12 +1215,10 @@ static inline u32 get_lrh_len(struct hfi1_pkt_header hdr, u32 len)
return ((sizeof(hdr) - sizeof(hdr.pbc)) + 4 + len); return ((sizeof(hdr) - sizeof(hdr.pbc)) + 4 + len);
} }
struct kmalloc_cache_header txreq_cache = {NULL};
void hfi1_txreq_prealloc(void) void hfi1_txreq_prealloc(void)
{ {
kmalloc_cache_prealloc(&txreq_cache, sizeof(struct user_sdma_txreq)); kmalloc_cache_prealloc(&cpu_local_var(txreq_cache),
sizeof(struct user_sdma_txreq));
} }
static int user_sdma_send_pkts(struct user_sdma_request *req, unsigned maxpkts) static int user_sdma_send_pkts(struct user_sdma_request *req, unsigned maxpkts)
@ -1230,9 +1228,12 @@ static int user_sdma_send_pkts(struct user_sdma_request *req, unsigned maxpkts)
struct user_sdma_txreq *tx = NULL; struct user_sdma_txreq *tx = NULL;
struct hfi1_user_sdma_pkt_q *pq = NULL; struct hfi1_user_sdma_pkt_q *pq = NULL;
struct user_sdma_iovec *iovec = NULL; struct user_sdma_iovec *iovec = NULL;
#ifndef __HFI1_ORIG__
unsigned long base_phys = 0; unsigned long base_phys = 0;
unsigned long base_pgsize = 0; unsigned long base_pgsize = 0;
void *base_virt = NULL; void *base_virt = NULL;
struct kmalloc_cache_header *txreq_cache = &cpu_local_var(txreq_cache);
#endif
TP("+"); TP("+");
hfi1_cdbg(AIOWRITE, "+"); hfi1_cdbg(AIOWRITE, "+");
@ -1282,7 +1283,7 @@ static int user_sdma_send_pkts(struct user_sdma_request *req, unsigned maxpkts)
} }
tx = kmem_cache_alloc(pq->txreq_cache, GFP_KERNEL); tx = kmem_cache_alloc(pq->txreq_cache, GFP_KERNEL);
#else #else
tx = kmalloc_cache_alloc(&txreq_cache, sizeof(*tx)); tx = kmalloc_cache_alloc(txreq_cache, sizeof(*tx));
#endif /* __HFI1_ORIG__ */ #endif /* __HFI1_ORIG__ */
if (!tx) if (!tx)
return -ENOMEM; return -ENOMEM;
@ -1572,7 +1573,7 @@ free_tx:
kmem_cache_free(pq->txreq_cache, tx); kmem_cache_free(pq->txreq_cache, tx);
hfi1_cdbg(AIOWRITE, "-"); hfi1_cdbg(AIOWRITE, "-");
#else #else
kmalloc_cache_free(&txreq_cache, tx); kmalloc_cache_free(tx);
#endif /* __HFI1_ORIG__ */ #endif /* __HFI1_ORIG__ */
return ret; return ret;
} }
@ -1996,7 +1997,7 @@ static void user_sdma_txreq_cb(struct sdma_txreq *txreq, int status)
#ifdef __HFI1_ORIG__ #ifdef __HFI1_ORIG__
kmem_cache_free(pq->txreq_cache, tx); kmem_cache_free(pq->txreq_cache, tx);
#else #else
kmalloc_cache_free(&txreq_cache, tx); kmalloc_cache_free(tx);
#endif /* __HFI1_ORIG__ */ #endif /* __HFI1_ORIG__ */
tx = NULL; tx = NULL;
@ -2044,7 +2045,7 @@ static void user_sdma_free_request(struct user_sdma_request *req, bool unpin)
#ifdef __HFI1_ORIG__ #ifdef __HFI1_ORIG__
kmem_cache_free(req->pq->txreq_cache, tx); kmem_cache_free(req->pq->txreq_cache, tx);
#else #else
kmalloc_cache_free(&txreq_cache, tx); kmalloc_cache_free(tx);
#endif /* __HFI1_ORIG__ */ #endif /* __HFI1_ORIG__ */
} }
} }