ntb: ntb perf tool
Dave Jiang
maintainerPATCH v4 1/1 ntb: ntb perf tool
Providing raw performance data via a tool that directly access data from NTB w/o any software overhead. This allows measurement of the hardware performance limit. In revision one we are only doing single direction CPU and DMA writes. Eventually we will provide bi-directional writes.
The measurement using DMA engine for NTB performance measure does not measure the raw performance of DMA engine over NTB due to software overhead. But it should provide the peak performance through the Linux DMA driver.
--- drivers/ntb/ntb_transport.c | 6 drivers/ntb/test/Kconfig | 8 drivers/ntb/test/Makefile | 1 drivers/ntb/test/ntb_perf.c | 752 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 767 insertions(+) create mode 100644 drivers/ntb/test/ntb_perf.c
drivers/ntb/ntb_transport.c +6 -0
@@ -177,6 +177,7 @@ struct ntb_transport_qp {u64 tx_err_no_buf;u64 tx_memcpy;u64 tx_async; +u64 tx_dma_debug; };struct ntb_transport_mw {
@@ -486,6 +487,8 @@ static ssize_t debugfs_read(struct file *filp, char __user *ubuf, size_t count, out_offset +=snprintf (buf + out_offset, out_count - out_offset,"tx_async - \t%llu\n" , qp->tx_async); out_offset +=snprintf (buf + out_offset, out_count - out_offset, +"tx_dma_debug - \t%llu\n" , qp->tx_dma_debug); + out_offset +=snprintf (buf + out_offset, out_count - out_offset,"tx_ring_full - \t%llu\n" , qp->tx_ring_full); out_offset +=snprintf (buf + out_offset, out_count - out_offset,"tx_err_no_buf - %llu\n" , qp->tx_err_no_buf);
@@ -726,6 +729,7 @@ static void ntb_qp_link_down_reset(struct ntb_transport_qp *qp) qp->tx_err_no_buf =0 ; qp->tx_memcpy =0 ; qp->tx_async =0 ; + qp->tx_dma_debug =0 ; }static void ntb_qp_link_cleanup (struct ntb_transport_qp *qp)
@@ -1499,6 +1503,8 @@ static void ntb_async_tx(struct ntb_transport_qp *qp,if (!txd) goto err_get_unmap; + qp->tx_dma_debug++; + txd->callback = ntb_tx_copy_callback; txd->callback_param = entry;dma_set_unmap (txd, unmap);
drivers/ntb/test/Kconfig +8 -0
@@ -17,3 +17,11 @@ config NTB_TOOL functioning at a basic level. If unsure, say N. + +config NTB_PERF + tristate "NTB RAW Perf Measuring Tool" + help + This is a tool to measure raw NTB performance by transferring data + to and from the window without additional software interaction. + + If unsure, say N.
drivers/ntb/test/Makefile +1 -0
@@ -1,2 +1,3 @@ obj-$(CONFIG_NTB_PINGPONG) += ntb_pingpong.o obj-$(CONFIG_NTB_TOOL) += ntb_tool.o +obj-$(CONFIG_NTB_PERF) += ntb_perf.o
drivers/ntb/test/ntb_perf.c new file +752 -0
752 lines not on this page · raw message
From: Dave Jiang
drivers/ntb/ntb_transport.c static void ntb_async_tx(struct ntb_transport_qp
Quoted 10 lines
Providing raw performance data via a tool that directly access data from
drivers/ntb/ntb_transport.c +0
-0@@ -177,6 +177,7 @@ struct ntb_transport_qp {@@ -486,6 +487,8 @@ static ssize_t debugfs_read(struct file *filp, char@@ -726,6 +729,7 @@ static void ntb_qp_link_down_reset(struct@@ -1499,6 +1503,8 @@ static void ntb_async_tx(struct ntb_transport_qp
Git am failed on some of these hunks.
Why are there are ntb_tranport changes in the ntb_perf patch?
Allen
Jiang, Dave
maintainerQuoted 18 lines · Allen
From: Dave Jiang
drivers/ntb/ntb_transport.c static void ntb_async_tx(struct ntb_transport_qp
Quoted 10 lines
Providing raw performance data via a tool that directly access data from
drivers/ntb/ntb_transport.c +0
-0@@ -177,6 +177,7 @@ struct ntb_transport_qp {@@ -486,6 +487,8 @@ static ssize_t debugfs_read(struct file *filp, char@@ -726,6 +729,7 @@ static void ntb_qp_link_down_reset(struct@@ -1499,6 +1503,8 @@ static void ntb_async_tx(struct ntb_transport_qpGit am failed on some of these hunks.
Quoted 1 line
Why are there are
ntb_tranportchanges in thentb_perfpatch?
There shouldn't be. Stack git must've messed up something.
Quoted 9 lines
Allen
Signature · 5 lines
You received this message because you are subscribed to the Google Groups "linux-ntb" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/linux-ntb/40F65EF2B5E2254199711F58E3ACB84D99F07704%40MX104CL02.corp.emc.com. For more options, visit https://groups.google.com/d/optout.
From: Jiang, Dave <[email protected]>
Quoted 17 lines
Quoted 3 lines · Allen
From: Dave Jiang
Quoted 1 line
Providing raw performance data via a tool that directly access data
from
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +0
-0
b/drivers/ntb/ntb_transport.cQuoted 5 lines
drivers/ntb/ntb_transport.c static ssize_t debugfs_read(struct file *filp,
Quoted 5 lines
index 60654d5..45583e6 100644
drivers/ntb/ntb_transport.c +0
-0@@ -177,6 +177,7 @@ struct ntb_transport_qp {@@ -486,6 +487,8 @@ static ssize_t debugfs_read(struct file *filp,char
Quoted 2 lines
drivers/ntb/ntb_transport.c static void ntb_async_tx(struct
Quoted 2 lines
drivers/ntb/ntb_transport.c +0
-0@@ -726,6 +729,7 @@ static void ntb_qp_link_down_reset(struct@@ -1499,6 +1503,8 @@ static void ntb_async_tx(struct
ntb_transport_qpQuoted 1 line
Quoted 5 lines
Quoted 3 lines
Git am failed on some of these hunks.
Why are there are
ntb_tranportchanges in thentb_perfpatch?There shouldn't be. Stack git must've messed up something.
I applied the patch without the ntb_transport changes. They are already provided by the patch, NTB: Address out of DMA descriptor issue with NTB.
With just the perf_tool changes, this v4 works for me, for cpu and dma.
It may still need some performance tuning. The numbers are much lower than I expected. Maybe I just need to run it with different parameters, or maybe there's some numa issue. It would be convenient to change the test parameters without reloading the modules.
There might also be a race in link-up. I got stuck with a lot of this, once, and no link related messages on the other side:
[60025.597128] ntb_perf: ntb_hw_intel 0000:00:03.0: Remote version = 0x0 [60025.607119] ntb_perf: ntb_hw_intel 0000:00:03.0: perf_link_work called [60025.607122] ntb_perf: ntb_hw_intel 0000:00:03.0: Remote version = 0x0 [60025.617122] ntb_perf: ntb_hw_intel 0000:00:03.0: perf_link_work called [60025.617127] ntb_perf: ntb_hw_intel 0000:00:03.0: Remote version = 0x0 [60025.627133] ntb_perf: ntb_hw_intel 0000:00:03.0: perf_link_work called [60025.627136] ntb_perf: ntb_hw_intel 0000:00:03.0: Remote version = 0x0 [60025.637118] ntb_perf: ntb_hw_intel 0000:00:03.0: perf_link_work called [60025.637121] ntb_perf: ntb_hw_intel 0000:00:03.0: Remote version = 0x0 [60025.647123] ntb_perf: ntb_hw_intel 0000:00:03.0: perf_link_work called [60025.647127] ntb_perf: ntb_hw_intel 0000:00:03.0: Remote version = 0x0 [60025.657115] ntb_perf: ntb_hw_intel 0000:00:03.0: perf_link_work called
On my dual-ntb system, I see both ntb are used by ntb_perf:
[60124.223795] ntb_perf: ntb_hw_intel 0000:00:03.0: perf_link_cleanup called [60124.226942] ntb_perf: ntb_hw_intel 0000:00:03.0: perf_link_work called [60124.226947] ntb_perf: ntb_hw_intel 0000:00:03.0: Remote MW size = 0x100000 [60124.246408] ntb_perf: ntb_hw_intel 0000:80:03.0: perf_link_cleanup called [60124.257389] ntb_perf: ntb_hw_intel 0000:80:03.0: perf_link_work called [60124.264699] ntb_perf: ntb_hw_intel 0000:80:03.0: Remote MW size = 0x100000
Only one of these ntb is in the debugfs dir, so the other one can't be tested:
root@HYR:/sys/kernel/debug/ntb_perf# ls 0000:00:03.0
Quoted 2 lines
(quoted diff) +2
-0+static int perf_probe(struct ntb_client *client, struct ntb_dev *ntb) +{
...
drivers/ntb/test/ntb_perf.c line 706
Quoted 9 lines
drivers/ntb/test/ntb_perf.c new file +9
-0+if (debugfs_initialized () && !perf_debugfs_dir) { + perf_debugfs_dir =debugfs_create_dir (KBUILD_MODNAME ,NULL ); +if (!perf_debugfs_dir) + goto err_ctx; + + rc =perf_debugfs_setup (perf); +if (rc) + goto err_ctx; + }
I think the problem is here. Should perf_debugfs_setup be outside of the if? It looks like the per-device setup is only done if the top level dir didn't already exist. If the top level dir already exists, per-device setup isn't called.
Allen
From: Allen Hubbe
Quoted 11 lines
From: Jiang, Dave <[email protected]>
Quoted 5 lines
On Jan 12, 2016, at 7:08 AM, Hubbe, Allen <[email protected]>
Quoted 2 lines
From: Dave Jiang
Quoted 1 line
Providing raw performance data via a tool that directly access data
from
Quoted 1 line
There might also be a race in link-up. I got stuck with a lot of this, once, and no link related messages on the other side:
[60025.597128] ntb_perf: ntb_hw_intel 0000:00:03.0: Remote version = 0x0 [60025.607119] ntb_perf: ntb_hw_intel 0000:00:03.0: perf_link_work
I think the race has is between clearing local spads in link cleanup, and the peer writing the same spads in link work.
Suppose B is already loaded, and then A is loaded.
B: link was down - link cleanup - clear spads on B.
A: modprobe ntb_perf.
A: ntb_link_enable - tells the ntb hw to enable, but link up is async.
A: ntb_link_event - trigger a link event, even if there was no link state change.
Race #1: is the link up fast enough on A?
A: perf_link_event - link state is down, schedule link cleanup.
A & B: perf_link_event - link state is now up, schedule link work.
Race #2: A clears good data written by B, AND B reads good data written by A?
B: link work - write good data to spads on A, continue below...
A: link cleanup - clear spads on A (oops!).
B: link work continued - read spads on B have good data, work is done!
Result:
A: link work - write good data to spads on B, read spads on A are zero, reschedule... forever.
This would be a very short window to race, so there might be something else, too. I don't recall seeing link work run on B at all, and I missed the opportunity to save that log. Now it's lost among all the others in dmesg, and I can't distinguish "no output" from "maybe these messages" that far back in the log. If a banner was printed each time the module is loaded, that would help.
In ntrdma, I avoid this race by /not/ clearing the local registers. To avoid reading bad data, the peer updates a counter as long as the data is valid. Observing a change in that counter value indicates good data. That avoids a race between A and B each writing the same registers.
Allen