aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLogan Gunthorpe <logang@deltatee.com>2016-06-20 15:15:06 -0400
committerJon Mason <jdmason@kudzu.us>2016-08-05 10:21:07 -0400
commit58fd0f3b1539a5bad451a823c9d039ea23387b23 (patch)
tree3c410c2c8cf6e66b06735167f0323dd3e4450a33
parentda573eaa3a13f60efafcbe25e4f4465cf1a1b40b (diff)
ntb_perf: Return results by reading the run file
Instead of having to watch logs, allow the results to be retrieved by reading back the run file. This file will return "running" when the test is running and nothing if no tests have been run yet. It returns 1 line per thread, and will display an error message if the corresponding thread returns an error. With the above change, the pr_info calls that returned the results are then changed to pr_debug calls. Signed-off-by: Logan Gunthorpe <logang@deltatee.com> Acked-by: Dave Jiang <dave.jiang@intel.com> Signed-off-by: Jon Mason <jdmason@kudzu.us>
-rw-r--r--drivers/ntb/test/ntb_perf.c67
1 files changed, 55 insertions, 12 deletions
diff --git a/drivers/ntb/test/ntb_perf.c b/drivers/ntb/test/ntb_perf.c
index db4dc61164ca..05a870524a67 100644
--- a/drivers/ntb/test/ntb_perf.c
+++ b/drivers/ntb/test/ntb_perf.c
@@ -123,6 +123,9 @@ struct pthr_ctx {
123 int src_idx; 123 int src_idx;
124 void *srcs[MAX_SRCS]; 124 void *srcs[MAX_SRCS];
125 wait_queue_head_t *wq; 125 wait_queue_head_t *wq;
126 int status;
127 u64 copied;
128 u64 diff_us;
126}; 129};
127 130
128struct perf_ctx { 131struct perf_ctx {
@@ -305,7 +308,7 @@ static int perf_move_data(struct pthr_ctx *pctx, char __iomem *dst, char *src,
305 } 308 }
306 309
307 if (use_dma) { 310 if (use_dma) {
308 pr_info("%s: All DMA descriptors submitted\n", current->comm); 311 pr_debug("%s: All DMA descriptors submitted\n", current->comm);
309 while (atomic_read(&pctx->dma_sync) != 0) { 312 while (atomic_read(&pctx->dma_sync) != 0) {
310 if (kthread_should_stop()) 313 if (kthread_should_stop())
311 break; 314 break;
@@ -317,13 +320,16 @@ static int perf_move_data(struct pthr_ctx *pctx, char __iomem *dst, char *src,
317 kdiff = ktime_sub(kstop, kstart); 320 kdiff = ktime_sub(kstop, kstart);
318 diff_us = ktime_to_us(kdiff); 321 diff_us = ktime_to_us(kdiff);
319 322
320 pr_info("%s: copied %llu bytes\n", current->comm, copied); 323 pr_debug("%s: copied %llu bytes\n", current->comm, copied);
321 324
322 pr_info("%s: lasted %llu usecs\n", current->comm, diff_us); 325 pr_debug("%s: lasted %llu usecs\n", current->comm, diff_us);
323 326
324 perf = div64_u64(copied, diff_us); 327 perf = div64_u64(copied, diff_us);
325 328
326 pr_info("%s: MBytes/s: %llu\n", current->comm, perf); 329 pr_debug("%s: MBytes/s: %llu\n", current->comm, perf);
330
331 pctx->copied = copied;
332 pctx->diff_us = diff_us;
327 333
328 return 0; 334 return 0;
329} 335}
@@ -345,7 +351,7 @@ static int ntb_perf_thread(void *data)
345 int rc, node, i; 351 int rc, node, i;
346 struct dma_chan *dma_chan = NULL; 352 struct dma_chan *dma_chan = NULL;
347 353
348 pr_info("kthread %s starting...\n", current->comm); 354 pr_debug("kthread %s starting...\n", current->comm);
349 355
350 node = dev_to_node(&pdev->dev); 356 node = dev_to_node(&pdev->dev);
351 357
@@ -575,19 +581,44 @@ static ssize_t debugfs_run_read(struct file *filp, char __user *ubuf,
575{ 581{
576 struct perf_ctx *perf = filp->private_data; 582 struct perf_ctx *perf = filp->private_data;
577 char *buf; 583 char *buf;
578 ssize_t ret, out_offset; 584 ssize_t ret, out_off = 0;
579 int running; 585 struct pthr_ctx *pctx;
586 int i;
587 u64 rate;
580 588
581 if (!perf) 589 if (!perf)
582 return 0; 590 return 0;
583 591
584 buf = kmalloc(64, GFP_KERNEL); 592 buf = kmalloc(1024, GFP_KERNEL);
585 if (!buf) 593 if (!buf)
586 return -ENOMEM; 594 return -ENOMEM;
587 595
588 running = mutex_is_locked(&perf->run_mutex); 596 if (mutex_is_locked(&perf->run_mutex)) {
589 out_offset = snprintf(buf, 64, "%d\n", running); 597 out_off = snprintf(buf, 64, "running\n");
590 ret = simple_read_from_buffer(ubuf, count, offp, buf, out_offset); 598 goto read_from_buf;
599 }
600
601 for (i = 0; i < MAX_THREADS; i++) {
602 pctx = &perf->pthr_ctx[i];
603
604 if (pctx->status == -ENODATA)
605 break;
606
607 if (pctx->status) {
608 out_off += snprintf(buf + out_off, 1024 - out_off,
609 "%d: error %d\n", i,
610 pctx->status);
611 continue;
612 }
613
614 rate = div64_u64(pctx->copied, pctx->diff_us);
615 out_off += snprintf(buf + out_off, 1024 - out_off,
616 "%d: copied %llu bytes in %llu usecs, %llu MBytes/s\n",
617 i, pctx->copied, pctx->diff_us, rate);
618 }
619
620read_from_buf:
621 ret = simple_read_from_buffer(ubuf, count, offp, buf, out_off);
591 kfree(buf); 622 kfree(buf);
592 623
593 return ret; 624 return ret;
@@ -601,12 +632,20 @@ static void threads_cleanup(struct perf_ctx *perf)
601 for (i = 0; i < MAX_THREADS; i++) { 632 for (i = 0; i < MAX_THREADS; i++) {
602 pctx = &perf->pthr_ctx[i]; 633 pctx = &perf->pthr_ctx[i];
603 if (pctx->thread) { 634 if (pctx->thread) {
604 kthread_stop(pctx->thread); 635 pctx->status = kthread_stop(pctx->thread);
605 pctx->thread = NULL; 636 pctx->thread = NULL;
606 } 637 }
607 } 638 }
608} 639}
609 640
641static void perf_clear_thread_status(struct perf_ctx *perf)
642{
643 int i;
644
645 for (i = 0; i < MAX_THREADS; i++)
646 perf->pthr_ctx[i].status = -ENODATA;
647}
648
610static ssize_t debugfs_run_write(struct file *filp, const char __user *ubuf, 649static ssize_t debugfs_run_write(struct file *filp, const char __user *ubuf,
611 size_t count, loff_t *offp) 650 size_t count, loff_t *offp)
612{ 651{
@@ -623,6 +662,8 @@ static ssize_t debugfs_run_write(struct file *filp, const char __user *ubuf,
623 if (!mutex_trylock(&perf->run_mutex)) 662 if (!mutex_trylock(&perf->run_mutex))
624 return -EBUSY; 663 return -EBUSY;
625 664
665 perf_clear_thread_status(perf);
666
626 if (perf->perf_threads > MAX_THREADS) { 667 if (perf->perf_threads > MAX_THREADS) {
627 perf->perf_threads = MAX_THREADS; 668 perf->perf_threads = MAX_THREADS;
628 pr_info("Reset total threads to: %u\n", MAX_THREADS); 669 pr_info("Reset total threads to: %u\n", MAX_THREADS);
@@ -757,6 +798,8 @@ static int perf_probe(struct ntb_client *client, struct ntb_dev *ntb)
757 if (rc) 798 if (rc)
758 goto err_ctx; 799 goto err_ctx;
759 800
801 perf_clear_thread_status(perf);
802
760 return 0; 803 return 0;
761 804
762err_ctx: 805err_ctx: