HFI1: working but a bit slow

This commit is contained in:
Balazs Gerofi
2017-08-16 17:06:52 +09:00
parent 7f03c18d4d
commit 39deff4e10
4 changed files with 41 additions and 21 deletions

View File

@@ -13,7 +13,8 @@
//#define VERBOSE_DEBUG //#define VERBOSE_DEBUG
#define IF_VA_ARGS(...) , ##__VA_ARGS__ #define IF_VA_ARGS(...) , ##__VA_ARGS__
#define TP(msg, ...) kprintf("%s(%d):" msg "\n", __FUNCTION__, __LINE__ IF_VA_ARGS(__VA_ARGS__)) //#define TP(msg, ...) kprintf("%s(%d):" msg "\n", __FUNCTION__, __LINE__ IF_VA_ARGS(__VA_ARGS__))
#define TP(msg, ...) do {} while(0)
#ifdef VERBOSE_DEBUG #ifdef VERBOSE_DEBUG
#define SDMA_DBG(req, fmt, ...) kprintf("%s(%d): DBG:" fmt "\n", __FUNCTION__, __LINE__ IF_VA_ARGS(__VA_ARGS__)); #define SDMA_DBG(req, fmt, ...) kprintf("%s(%d): DBG:" fmt "\n", __FUNCTION__, __LINE__ IF_VA_ARGS(__VA_ARGS__));

View File

@@ -2535,7 +2535,7 @@ int sdma_send_txlist(struct sdma_engine *sde, struct iowait_work *wait,
u32 submit_count = 0, flush_count = 0, total_count; u32 submit_count = 0, flush_count = 0, total_count;
TP("+"); TP("+");
hfi1_cdbg(AIOWRITE, "+"); hfi1_cdbg(AIOWRITE, "+");
// spin_lock_irqsave(&sde->tail_lock, flags); spin_lock_irqsave(&sde->tail_lock, flags);
retry: retry:
list_for_each_entry_safe(tx, tx_next, tx_list, list) { list_for_each_entry_safe(tx, tx_next, tx_list, list) {
tx->wait = iowait_ioww_to_iow(wait); tx->wait = iowait_ioww_to_iow(wait);
@@ -2559,13 +2559,11 @@ retry:
update_tail: update_tail:
TP("+ update_tail:"); TP("+ update_tail:");
total_count = submit_count + flush_count; total_count = submit_count + flush_count;
#ifdef __HFI1_ORIG__
if (wait) if (wait)
iowait_sdma_add(iowait_ioww_to_iow(wait), total_count); iowait_sdma_add(iowait_ioww_to_iow(wait), total_count);
#endif /* __HFI1_ORIG__ */
if (tail != INVALID_TAIL) if (tail != INVALID_TAIL)
sdma_update_tail(sde, tail); sdma_update_tail(sde, tail);
// spin_unlock_irqrestore(&sde->tail_lock, flags); spin_unlock_irqrestore(&sde->tail_lock, flags);
*count_out = total_count; *count_out = total_count;
hfi1_cdbg(AIOWRITE, "-"); hfi1_cdbg(AIOWRITE, "-");
TP("-"); TP("-");

View File

@@ -3096,9 +3096,9 @@ SYSCALL_DECLARE(writev)
struct iovec *iovec = (struct iovec *)ihk_mc_syscall_arg1(ctx); struct iovec *iovec = (struct iovec *)ihk_mc_syscall_arg1(ctx);
int iovcnt = ihk_mc_syscall_arg2(ctx); int iovcnt = ihk_mc_syscall_arg2(ctx);
void *private_data = proc->fd_priv_table[fd]; void *private_data = proc->fd_priv_table[fd];
if (private_data) hfi1_aio_write(private_data, iovec, iovcnt); //if (private_data) hfi1_aio_write(private_data, iovec, iovcnt);
return 1; //return 1;
// return syscall_generic_forwarding(__NR_writev, ctx); return syscall_generic_forwarding(__NR_writev, ctx);
} }
SYSCALL_DECLARE(read) SYSCALL_DECLARE(read)

View File

@@ -567,6 +567,7 @@ int hfi1_user_sdma_process_request(void *private_data, struct iovec *iovec,
#ifndef __HFI1_ORIG__ #ifndef __HFI1_ORIG__
if (!hfi1_kregbase) { if (!hfi1_kregbase) {
struct process_vm *vm = cpu_local_var(current)->vm;
enum ihk_mc_pt_attribute attr = PTATTR_UNCACHABLE | PTATTR_WRITABLE; enum ihk_mc_pt_attribute attr = PTATTR_UNCACHABLE | PTATTR_WRITABLE;
void *virt; void *virt;
#if 1 #if 1
@@ -587,10 +588,23 @@ int hfi1_user_sdma_process_request(void *private_data, struct iovec *iovec,
*/ */
for (virt = hfi1_kregbase; virt < (hfi1_kregbase + TXE_PIO_SEND); for (virt = hfi1_kregbase; virt < (hfi1_kregbase + TXE_PIO_SEND);
virt += PAGE_SIZE, phys += PAGE_SIZE) { virt += PAGE_SIZE, phys += PAGE_SIZE) {
if (ihk_mc_pt_set_page(NULL, virt, phys, attr) < 0) { if (ihk_mc_pt_set_page(vm->address_space->page_table,
virt, phys, attr) < 0) {
kprintf("%s: ERROR: mapping kregbase: 0x%lx -> 0x%lx\n", kprintf("%s: ERROR: mapping kregbase: 0x%lx -> 0x%lx\n",
__FUNCTION__, virt, phys); __FUNCTION__, virt, phys);
} }
{
pte_t *ptep;
struct process_vm *vm = cpu_local_var(current)->vm;
ptep = ihk_mc_pt_lookup_pte(vm->address_space->page_table,
virt, 0, 0, 0, 0);
if (ptep && pte_is_present(ptep)) {
kprintf("%s: 0x%lx, PTE: 0x%lx\n",
__FUNCTION__, virt, *ptep);
}
}
} }
kprintf("%s: hfi1_kregbase: 0x%lx - 0x%lx -> 0x%lx:%lu\n", kprintf("%s: hfi1_kregbase: 0x%lx - 0x%lx -> 0x%lx:%lu\n",
@@ -603,7 +617,8 @@ int hfi1_user_sdma_process_request(void *private_data, struct iovec *iovec,
attr = PTATTR_WRITE_COMBINED | PTATTR_WRITABLE; attr = PTATTR_WRITE_COMBINED | PTATTR_WRITABLE;
for (virt = hfi1_piobase; virt < (hfi1_piobase + TXE_PIO_SIZE); for (virt = hfi1_piobase; virt < (hfi1_piobase + TXE_PIO_SIZE);
virt += PAGE_SIZE, phys += PAGE_SIZE) { virt += PAGE_SIZE, phys += PAGE_SIZE) {
if (ihk_mc_pt_set_page(NULL, virt, phys, attr) < 0) { if (ihk_mc_pt_set_page(vm->address_space->page_table,
virt, phys, attr) < 0) {
kprintf("%s: ERROR: mapping piobase: 0x%lx -> 0x%lx\n", kprintf("%s: ERROR: mapping piobase: 0x%lx -> 0x%lx\n",
__FUNCTION__, virt, phys); __FUNCTION__, virt, phys);
} }
@@ -620,7 +635,8 @@ int hfi1_user_sdma_process_request(void *private_data, struct iovec *iovec,
for (virt = hfi1_rcvarray_wc; for (virt = hfi1_rcvarray_wc;
virt < (hfi1_rcvarray_wc + dd->chip_rcv_array_count * 8); virt < (hfi1_rcvarray_wc + dd->chip_rcv_array_count * 8);
virt += PAGE_SIZE, phys += PAGE_SIZE) { virt += PAGE_SIZE, phys += PAGE_SIZE) {
if (ihk_mc_pt_set_page(NULL, virt, phys, attr) < 0) { if (ihk_mc_pt_set_page(vm->address_space->page_table,
virt, phys, attr) < 0) {
kprintf("%s: ERROR: mapping rcvarray_wc: 0x%lx -> 0x%lx\n", kprintf("%s: ERROR: mapping rcvarray_wc: 0x%lx -> 0x%lx\n",
__FUNCTION__, virt, phys); __FUNCTION__, virt, phys);
} }
@@ -687,6 +703,8 @@ int hfi1_user_sdma_process_request(void *private_data, struct iovec *iovec,
} }
#endif // __HFI1_ORIG__ #endif // __HFI1_ORIG__
TP("- kregbase and cq->comps"); TP("- kregbase and cq->comps");
hfi1_cdbg(AIOWRITE, "+"); hfi1_cdbg(AIOWRITE, "+");
if (iovec[idx].iov_len < sizeof(info) + sizeof(req->hdr)) { if (iovec[idx].iov_len < sizeof(info) + sizeof(req->hdr)) {
@@ -1002,7 +1020,6 @@ int hfi1_user_sdma_process_request(void *private_data, struct iovec *iovec,
return 0; return 0;
free_req: free_req:
TP("free_req"); TP("free_req");
return 0;
user_sdma_free_request(req, true); user_sdma_free_request(req, true);
if (req_queued) if (req_queued)
pq_update(pq); pq_update(pq);
@@ -1283,7 +1300,8 @@ static int user_sdma_send_pkts(struct user_sdma_request *req, unsigned maxpkts)
const void *virt = (unsigned long)iovec->iov.iov_base + iovec->offset; const void *virt = (unsigned long)iovec->iov.iov_base + iovec->offset;
WARN_ON(iovec->iov.iov_len < iovec->offset); WARN_ON(iovec->iov.iov_len < iovec->offset);
unsigned len = (unsigned)iovec->iov.iov_len - iovec->offset; unsigned len = (unsigned)iovec->iov.iov_len - iovec->offset;
len = min(PAGE_SIZE, len); len = min(((unsigned long)virt & PAGE_MASK)
+ PAGE_SIZE - (unsigned long)virt, PAGE_SIZE);
len = min(req->info.fragsize, len); len = min(req->info.fragsize, len);
len = min(txreq->tlen, len); len = min(txreq->tlen, len);
len = min((datalen - queued), len); len = min((datalen - queued), len);
@@ -1299,8 +1317,9 @@ static int user_sdma_send_pkts(struct user_sdma_request *req, unsigned maxpkts)
if (ret) { if (ret) {
kprintf("%s: ERROR _sdma_txadd_daddr()", __FUNCTION__); kprintf("%s: ERROR _sdma_txadd_daddr()", __FUNCTION__);
return 0; return 0;
} else { }
kprintf("%s: txadd: base = 0x%lx, len = %d\n", __FUNCTION__, base, len); else {
//kprintf("%s: txadd: base = 0x%lx, len = %d\n", __FUNCTION__, base, len);
} }
} }
TP("- custom sdma_txadd_page"); TP("- custom sdma_txadd_page");
@@ -1370,15 +1389,12 @@ dosend:
} }
hfi1_cdbg(AIOWRITE, "-"); hfi1_cdbg(AIOWRITE, "-");
TP("-"); TP("-");
return 0;
return ret; return ret;
free_txreq: free_txreq:
TP("free_txreq"); TP("free_txreq");
return 0;
sdma_txclean(pq->dd, &tx->txreq); sdma_txclean(pq->dd, &tx->txreq);
free_tx: free_tx:
TP("free_tx"); TP("free_tx");
return 0;
#ifdef __HFI1_ORIG__ #ifdef __HFI1_ORIG__
kmem_cache_free(pq->txreq_cache, tx); kmem_cache_free(pq->txreq_cache, tx);
hfi1_cdbg(AIOWRITE, "-"); hfi1_cdbg(AIOWRITE, "-");
@@ -1804,8 +1820,11 @@ static void user_sdma_txreq_cb(struct sdma_txreq *txreq, int status)
} }
req->seqcomp = tx->seqnum; req->seqcomp = tx->seqnum;
//TODO: kmem_cache_free #ifdef __HFI1_ORIG__
//kmem_cache_free(pq->txreq_cache, tx); kmem_cache_free(pq->txreq_cache, tx);
#else
kfree(tx);
#endif /* __HFI1_ORIG__ */
tx = NULL; tx = NULL;
idx = req->info.comp_idx; idx = req->info.comp_idx;
@@ -1851,6 +1870,8 @@ static void user_sdma_free_request(struct user_sdma_request *req, bool unpin)
sdma_txclean(req->pq->dd, t); sdma_txclean(req->pq->dd, t);
#ifdef __HFI1_ORIG__ #ifdef __HFI1_ORIG__
kmem_cache_free(req->pq->txreq_cache, tx); kmem_cache_free(req->pq->txreq_cache, tx);
#else
kfree(tx);
#endif /* __HFI1_ORIG__ */ #endif /* __HFI1_ORIG__ */
} }
} }