From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1423080AbcFMUKK (ORCPT ); Mon, 13 Jun 2016 16:10:10 -0400 Received: from mga04.intel.com ([192.55.52.120]:41433 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161119AbcFMUKI (ORCPT ); Mon, 13 Jun 2016 16:10:08 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,467,1459839600"; d="scan'208";a="996831701" From: "Jiang, Dave" To: "Allen.Hubbe@emc.com" , "logang@deltatee.com" , "jdmason@kudzu.us" CC: "linux-kernel@vger.kernel.org" , "shuahkh@osg.samsung.com" , "sudipm.mukherjee@gmail.com" , "linux-kselftest@vger.kernel.org" , "arnd@arndb.de" , "linux-ntb@googlegroups.com" Subject: Re: [PATCH 3/8] ntb_perf: Return results by reading the run file Thread-Topic: [PATCH 3/8] ntb_perf: Return results by reading the run file Thread-Index: AQHRw2s0idK9PSsrXEedxN+f1fjGjJ/oTYeA Date: Mon, 13 Jun 2016 20:09:54 +0000 Message-ID: <1465848577.16234.250.camel@intel.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [143.182.137.38] Content-Type: text/plain; charset="utf-8" Content-ID: <723834952C9CA34CBB6CBBE9511BA0B7@intel.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id u5DKAGn6011705 On Fri, 2016-06-10 at 16:54 -0600, Logan Gunthorpe wrote: > 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 Acked-by: Dave Jiang > --- >  drivers/ntb/test/ntb_perf.c | 67 > +++++++++++++++++++++++++++++++++++++-------- >  1 file changed, 55 insertions(+), 12 deletions(-) > > diff --git a/drivers/ntb/test/ntb_perf.c > b/drivers/ntb/test/ntb_perf.c > index db4dc61..05a8705 100644 > --- a/drivers/ntb/test/ntb_perf.c > +++ b/drivers/ntb/test/ntb_perf.c > @@ -123,6 +123,9 @@ struct pthr_ctx { >   int src_idx; >   void *srcs[MAX_SRCS]; >   wait_queue_head_t       *wq; > + int status; > + u64 copied; > + u64 diff_us; >  }; >   >  struct perf_ctx { > @@ -305,7 +308,7 @@ static int perf_move_data(struct pthr_ctx *pctx, > char __iomem *dst, char *src, >   } >   >   if (use_dma) { > - pr_info("%s: All DMA descriptors submitted\n", > current->comm); > + pr_debug("%s: All DMA descriptors submitted\n", > current->comm); >   while (atomic_read(&pctx->dma_sync) != 0) { >   if (kthread_should_stop()) >   break; > @@ -317,13 +320,16 @@ static int perf_move_data(struct pthr_ctx > *pctx, char __iomem *dst, char *src, >   kdiff = ktime_sub(kstop, kstart); >   diff_us = ktime_to_us(kdiff); >   > - pr_info("%s: copied %llu bytes\n", current->comm, copied); > + pr_debug("%s: copied %llu bytes\n", current->comm, copied); >   > - pr_info("%s: lasted %llu usecs\n", current->comm, diff_us); > + pr_debug("%s: lasted %llu usecs\n", current->comm, diff_us); >   >   perf = div64_u64(copied, diff_us); >   > - pr_info("%s: MBytes/s: %llu\n", current->comm, perf); > + pr_debug("%s: MBytes/s: %llu\n", current->comm, perf); > + > + pctx->copied = copied; > + pctx->diff_us = diff_us; >   >   return 0; >  } > @@ -345,7 +351,7 @@ static int ntb_perf_thread(void *data) >   int rc, node, i; >   struct dma_chan *dma_chan = NULL; >   > - pr_info("kthread %s starting...\n", current->comm); > + pr_debug("kthread %s starting...\n", current->comm); >   >   node = dev_to_node(&pdev->dev); >   > @@ -575,19 +581,44 @@ static ssize_t debugfs_run_read(struct file > *filp, char __user *ubuf, >  { >   struct perf_ctx *perf = filp->private_data; >   char *buf; > - ssize_t ret, out_offset; > - int running; > + ssize_t ret, out_off = 0; > + struct pthr_ctx *pctx; > + int i; > + u64 rate; >   >   if (!perf) >   return 0; >   > - buf = kmalloc(64, GFP_KERNEL); > + buf = kmalloc(1024, GFP_KERNEL); >   if (!buf) >   return -ENOMEM; >   > - running = mutex_is_locked(&perf->run_mutex); > - out_offset = snprintf(buf, 64, "%d\n", running); > - ret = simple_read_from_buffer(ubuf, count, offp, buf, > out_offset); > + if (mutex_is_locked(&perf->run_mutex)) { > + out_off = snprintf(buf, 64, "running\n"); > + goto read_from_buf; > + } > + > + for (i = 0; i < MAX_THREADS; i++) { > + pctx = &perf->pthr_ctx[i]; > + > + if (pctx->status == -ENODATA) > + break; > + > + if (pctx->status) { > + out_off += snprintf(buf + out_off, 1024 - > out_off, > +     "%d: error %d\n", i, > +     pctx->status); > + continue; > + } > + > + rate = div64_u64(pctx->copied, pctx->diff_us); > + out_off += snprintf(buf + out_off, 1024 - out_off, > + "%d: copied %llu bytes in %llu usecs, %llu > MBytes/s\n", > + i, pctx->copied, pctx->diff_us, rate); > + } > + > +read_from_buf: > + ret = simple_read_from_buffer(ubuf, count, offp, buf, > out_off); >   kfree(buf); >   >   return ret; > @@ -601,12 +632,20 @@ static void threads_cleanup(struct perf_ctx > *perf) >   for (i = 0; i < MAX_THREADS; i++) { >   pctx = &perf->pthr_ctx[i]; >   if (pctx->thread) { > - kthread_stop(pctx->thread); > + pctx->status = kthread_stop(pctx->thread); >   pctx->thread = NULL; >   } >   } >  } >   > +static void perf_clear_thread_status(struct perf_ctx *perf) > +{ > + int i; > + > + for (i = 0; i < MAX_THREADS; i++) > + perf->pthr_ctx[i].status = -ENODATA; > +} > + >  static ssize_t debugfs_run_write(struct file *filp, const char > __user *ubuf, >    size_t count, loff_t *offp) >  { > @@ -623,6 +662,8 @@ static ssize_t debugfs_run_write(struct file > *filp, const char __user *ubuf, >   if (!mutex_trylock(&perf->run_mutex)) >   return -EBUSY; >   > + perf_clear_thread_status(perf); > + >   if (perf->perf_threads > MAX_THREADS) { >   perf->perf_threads = MAX_THREADS; >   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) >   if (rc) >   goto err_ctx; >   > + perf_clear_thread_status(perf); > + >   return 0; >   >  err_ctx: > --  > 2.1.4 >