linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Jiang, Dave" <dave.jiang@intel.com>
To: "Allen.Hubbe@emc.com" <Allen.Hubbe@emc.com>,
	"logang@deltatee.com" <logang@deltatee.com>,
	"jdmason@kudzu.us" <jdmason@kudzu.us>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"shuahkh@osg.samsung.com" <shuahkh@osg.samsung.com>,
	"sudipm.mukherjee@gmail.com" <sudipm.mukherjee@gmail.com>,
	"linux-kselftest@vger.kernel.org"
	<linux-kselftest@vger.kernel.org>,
	"arnd@arndb.de" <arnd@arndb.de>,
	"linux-ntb@googlegroups.com" <linux-ntb@googlegroups.com>
Subject: Re: [PATCH 3/8] ntb_perf: Return results by reading the run file
Date: Mon, 13 Jun 2016 20:09:54 +0000	[thread overview]
Message-ID: <1465848577.16234.250.camel@intel.com> (raw)
In-Reply-To: <c859fa29b84c39cb952611904ecbf0ca02077840.1465598632.git.logang@deltatee.com>

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 <logang@deltatee.com>
Acked-by: Dave Jiang <dave.jiang@intel.com>

> ---
>  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
> 

  parent reply	other threads:[~2016-06-13 20:10 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1465598632.git.logang@deltatee.com>
     [not found] ` <e447cedb6197b62f141e7688ed2329c259f33eb9.1465598632.git.logang@deltatee.com>
2016-06-11  2:27   ` [PATCH 6/8] ntb_tool: Add link status file to debugfs Allen Hubbe
2016-06-11 15:28     ` Logan Gunthorpe
2016-06-12  1:28       ` Allen Hubbe
2016-06-14 15:45         ` Allen Hubbe
2016-06-14 15:48           ` Logan Gunthorpe
2016-06-14 15:54             ` Allen Hubbe
     [not found] ` <d9488f2c946644c2b1258a78929d3543747283ec.1465598632.git.logang@deltatee.com>
2016-06-11  2:35   ` [PATCH 5/8] ntb_tool: BUG: Ensure the buffer size is large enough to return all spads Allen Hubbe
2016-06-11 15:29     ` Logan Gunthorpe
     [not found] ` <a326e5cfecc9c780e97d9ce1665d13474b7367c3.1465598632.git.logang@deltatee.com>
2016-06-11  2:46   ` [PATCH 7/8] ntb_pingpong: Add a debugfs file to get the ping count Allen Hubbe
2016-06-11 15:30     ` Logan Gunthorpe
     [not found] ` <03a622a20a667b17046fbd45bb952f8dbd235653.1465598632.git.logang@deltatee.com>
2016-06-13 18:05   ` [PATCH 1/8] ntb_perf: Schedule based on time not on performance Jiang, Dave
     [not found] ` <65833d43bfcc3e37cbd136fa2a033b8948982629.1465598632.git.logang@deltatee.com>
2016-06-13 18:16   ` [PATCH 2/8] ntb_perf: Improve thread handling to increase robustness Jiang, Dave
     [not found] ` <c859fa29b84c39cb952611904ecbf0ca02077840.1465598632.git.logang@deltatee.com>
2016-06-13 20:09   ` Jiang, Dave [this message]
     [not found] ` <71664260d670af5f24beb9c825791802659f3cd2.1465598632.git.logang@deltatee.com>
2016-06-13 20:14   ` [PATCH 4/8] ntb_perf: Wait for link before running test Jiang, Dave
     [not found] ` <773161e84a4447a0a91edb42fe18171819ef2319.1465598632.git.logang@deltatee.com>
2016-06-14 14:06   ` [PATCH 8/8] ntb_test: Add a selftest script for the NTB subsystem Jon Mason
2016-06-14 14:16     ` Shuah Khan
2016-06-14 15:45       ` Logan Gunthorpe
2016-06-14 15:47   ` Allen Hubbe
2016-06-14 15:49     ` Logan Gunthorpe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1465848577.16234.250.camel@intel.com \
    --to=dave.jiang@intel.com \
    --cc=Allen.Hubbe@emc.com \
    --cc=arnd@arndb.de \
    --cc=jdmason@kudzu.us \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-ntb@googlegroups.com \
    --cc=logang@deltatee.com \
    --cc=shuahkh@osg.samsung.com \
    --cc=sudipm.mukherjee@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).