DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] app/compress-perf: prevent output buffer overflow
@ 2019-07-23  9:53 Adam Dybkowski
  2019-07-26 12:55 ` Trahe, Fiona
  0 siblings, 1 reply; 3+ messages in thread
From: Adam Dybkowski @ 2019-07-23  9:53 UTC (permalink / raw)
  To: dev, fiona.trahe, akhil.goyal; +Cc: Adam Dybkowski

This patch fixes the issue of memory overwrite after the end of
the output buffer by calculating its size as the number of all
segments multipled by the output segment size.
Additionally buffer overflow errors returned by PMD driver are
detected and shown, ending the test.

Also the output buffer size multiplier was increased from 105%
to 110% to allow running the tests on noncompressible files that
expand to over 107% of original size during the compression.

The changes were made in the verification part of the flow and
they don't affect the benchmark results.

Fixes: 424dd6c8c1 ("app/compress-perf: add weak functions for multicore test")

Signed-off-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 app/test-compress-perf/comp_perf_options.h    |  2 +-
 .../comp_perf_test_common.c                   |  7 +++---
 .../comp_perf_test_verify.c                   | 23 ++++++++++++++++---
 3 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/app/test-compress-perf/comp_perf_options.h b/app/test-compress-perf/comp_perf_options.h
index 5a32ed3a6..651cbea4e 100644
--- a/app/test-compress-perf/comp_perf_options.h
+++ b/app/test-compress-perf/comp_perf_options.h
@@ -7,7 +7,7 @@
 
 #define MAX_LIST		32
 #define MIN_COMPRESSED_BUF_SIZE 8
-#define EXPANSE_RATIO 1.05
+#define EXPANSE_RATIO 1.1
 #define MAX_MBUF_DATA_SIZE (UINT16_MAX - RTE_PKTMBUF_HEADROOM)
 #define MAX_SEG_SIZE ((int)(MAX_MBUF_DATA_SIZE / EXPANSE_RATIO))
 
diff --git a/app/test-compress-perf/comp_perf_test_common.c b/app/test-compress-perf/comp_perf_test_common.c
index 472c76686..c9bf6c5b1 100644
--- a/app/test-compress-perf/comp_perf_test_common.c
+++ b/app/test-compress-perf/comp_perf_test_common.c
@@ -135,8 +135,10 @@ comp_perf_allocate_memory(struct comp_test_data *test_data,
 	 * if data cannot be compressed
 	 */
 	mem->compressed_data = rte_zmalloc_socket(NULL,
-				test_data->input_data_sz * EXPANSE_RATIO
-						+ MIN_COMPRESSED_BUF_SIZE, 0,
+				RTE_MAX(
+				    (size_t) test_data->out_seg_sz * total_segs,
+				    (size_t) MIN_COMPRESSED_BUF_SIZE),
+				0,
 				rte_socket_id());
 	if (mem->compressed_data == NULL) {
 		RTE_LOG(ERR, USER1, "Memory to hold the data from the input "
@@ -267,7 +269,6 @@ prepare_bufs(struct comp_test_data *test_data, struct cperf_mem_resources *mem)
 
 			data_addr = (uint8_t *)rte_pktmbuf_append(next_seg,
 				test_data->out_seg_sz);
-
 			if (data_addr == NULL) {
 				RTE_LOG(ERR, USER1, "Could not append data\n");
 				return -1;
diff --git a/app/test-compress-perf/comp_perf_test_verify.c b/app/test-compress-perf/comp_perf_test_verify.c
index 37ac38da6..f66f95ff7 100644
--- a/app/test-compress-perf/comp_perf_test_verify.c
+++ b/app/test-compress-perf/comp_perf_test_verify.c
@@ -217,7 +217,16 @@ main_loop(struct cperf_verify_ctx *ctx, enum rte_comp_xform_type type)
 			for (i = 0; i < num_deq; i++) {
 				struct rte_comp_op *op = deq_ops[i];
 
-				if (op->status != RTE_COMP_OP_STATUS_SUCCESS) {
+				if (op->status ==
+				  RTE_COMP_OP_STATUS_OUT_OF_SPACE_TERMINATED ||
+				  op->status ==
+				  RTE_COMP_OP_STATUS_OUT_OF_SPACE_RECOVERABLE) {
+					RTE_LOG(ERR, USER1,
+"Out of space error occurred due to uncompressible input data expanding to larger than destination buffer. Increase the EXPANSE_RATIO constant to use this data.\n");
+					res = -1;
+					goto end;
+				} else if (op->status !=
+						RTE_COMP_OP_STATUS_SUCCESS) {
 					RTE_LOG(ERR, USER1,
 						"Some operations were not successful\n");
 					goto end;
@@ -293,12 +302,20 @@ main_loop(struct cperf_verify_ctx *ctx, enum rte_comp_xform_type type)
 			for (i = 0; i < num_deq; i++) {
 				struct rte_comp_op *op = deq_ops[i];
 
-				if (op->status != RTE_COMP_OP_STATUS_SUCCESS) {
+				if (op->status ==
+				  RTE_COMP_OP_STATUS_OUT_OF_SPACE_TERMINATED ||
+				  op->status ==
+				  RTE_COMP_OP_STATUS_OUT_OF_SPACE_RECOVERABLE) {
+					RTE_LOG(ERR, USER1,
+"Out of space error occurred due to uncompressible input data expanding to larger than destination buffer. Increase the EXPANSE_RATIO constant to use this data.\n");
+					res = -1;
+					goto end;
+				} else if (op->status !=
+						RTE_COMP_OP_STATUS_SUCCESS) {
 					RTE_LOG(ERR, USER1,
 						"Some operations were not successful\n");
 					goto end;
 				}
-
 				const void *read_data_addr =
 						rte_pktmbuf_read(op->m_dst,
 								 op->dst.offset,
-- 
2.17.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH] app/compress-perf: prevent output buffer overflow
  2019-07-23  9:53 [dpdk-dev] [PATCH] app/compress-perf: prevent output buffer overflow Adam Dybkowski
@ 2019-07-26 12:55 ` Trahe, Fiona
  2019-07-26 14:00   ` Akhil Goyal
  0 siblings, 1 reply; 3+ messages in thread
From: Trahe, Fiona @ 2019-07-26 12:55 UTC (permalink / raw)
  To: Dybkowski, AdamX, dev, akhil.goyal



> -----Original Message-----
> From: Dybkowski, AdamX
> Sent: Tuesday, July 23, 2019 10:53 AM
> To: dev@dpdk.org; Trahe, Fiona <fiona.trahe@intel.com>; akhil.goyal@nxp.com
> Cc: Dybkowski, AdamX <adamx.dybkowski@intel.com>
> Subject: [PATCH] app/compress-perf: prevent output buffer overflow
> 
> This patch fixes the issue of memory overwrite after the end of
> the output buffer by calculating its size as the number of all
> segments multipled by the output segment size.
> Additionally buffer overflow errors returned by PMD driver are
> detected and shown, ending the test.
> 
> Also the output buffer size multiplier was increased from 105%
> to 110% to allow running the tests on noncompressible files that
> expand to over 107% of original size during the compression.
> 
> The changes were made in the verification part of the flow and
> they don't affect the benchmark results.
> 
> Fixes: 424dd6c8c1 ("app/compress-perf: add weak functions for multicore test")
> 
> Signed-off-by: Adam Dybkowski <adamx.dybkowski@intel.com>
Acked-by: Fiona Trahe <fiona.trahe@intel.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH] app/compress-perf: prevent output buffer overflow
  2019-07-26 12:55 ` Trahe, Fiona
@ 2019-07-26 14:00   ` Akhil Goyal
  0 siblings, 0 replies; 3+ messages in thread
From: Akhil Goyal @ 2019-07-26 14:00 UTC (permalink / raw)
  To: Trahe, Fiona, Dybkowski, AdamX, dev


> >
> > This patch fixes the issue of memory overwrite after the end of
> > the output buffer by calculating its size as the number of all
> > segments multipled by the output segment size.
> > Additionally buffer overflow errors returned by PMD driver are
> > detected and shown, ending the test.
> >
> > Also the output buffer size multiplier was increased from 105%
> > to 110% to allow running the tests on noncompressible files that
> > expand to over 107% of original size during the compression.
> >
> > The changes were made in the verification part of the flow and
> > they don't affect the benchmark results.
> >
> > Fixes: 424dd6c8c1 ("app/compress-perf: add weak functions for multicore
> test")
> >
> > Signed-off-by: Adam Dybkowski <adamx.dybkowski@intel.com>
> Acked-by: Fiona Trahe <fiona.trahe@intel.com>

Applied to dpdk-next-crypto

Thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-07-26 14:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-23  9:53 [dpdk-dev] [PATCH] app/compress-perf: prevent output buffer overflow Adam Dybkowski
2019-07-26 12:55 ` Trahe, Fiona
2019-07-26 14:00   ` Akhil Goyal

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