[DTrace-devel] [PATCH] options, test: correct bufsize calculations and tests
Kris Van Hees
kris.van.hees at oracle.com
Thu Sep 19 12:54:46 UTC 2024
Reported-by: Eugene Loh <eugene.loh at oracle.com>
Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
---
libdtrace/dt_work.c | 9 +++------
test/unittest/options/tst.b.d | 19 ++++++++++---------
test/unittest/options/tst.bufsize.d | 19 ++++++++++---------
3 files changed, 23 insertions(+), 24 deletions(-)
diff --git a/libdtrace/dt_work.c b/libdtrace/dt_work.c
index c98bbfb9..11335345 100644
--- a/libdtrace/dt_work.c
+++ b/libdtrace/dt_work.c
@@ -268,15 +268,12 @@ dtrace_go(dtrace_hdl_t *dtp, uint_t cflags)
return dt_set_errno(dtp, errno);
/*
- * We need enough space for the pref_event_header, a 32-bit size, a
- * 4-byte gap, and the largest trace data record we may be writing to
- * the buffer. In other words, the buffer needs to be large enough to
- * hold at least one perf-encapsulated trace data record.
+ * The buffer needs to be large enough to hold at least one
+ * perf-encapsulated trace data record.
*/
dtrace_getopt(dtp, "bufsize", &size);
if (size == 0 ||
- size < sizeof(struct perf_event_header) + sizeof(uint32_t) +
- dtp->dt_maxreclen)
+ size < sizeof(struct perf_event_header) + dtp->dt_maxreclen)
return dt_set_errno(dtp, EDT_BUFTOOSMALL);
if (dt_pebs_init(dtp, size) == -1)
return dt_set_errno(dtp, EDT_NOMEM);
diff --git a/test/unittest/options/tst.b.d b/test/unittest/options/tst.b.d
index 57fa030d..af7d090a 100644
--- a/test/unittest/options/tst.b.d
+++ b/test/unittest/options/tst.b.d
@@ -1,6 +1,6 @@
/*
* Oracle Linux DTrace.
- * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
* Licensed under the Universal Permissive License v 1.0 as shown at
* http://oss.oracle.com/licenses/upl.
*/
@@ -12,16 +12,17 @@
*/
/*
- * We use a buffer size of 60 because that should be the exact size necessary
- * to hold the trace records generated in this script:
- * - perf_event_header (40 bytes)
+ * We use a buffer size that is just large enough to store the data recorded by
+ * this script:
+ * - perf_event_header (8 bytes)
* - size (4 bytes)
- * - gap (4 bytes)
- * - EPID (4 bytes)
- * - tag (4 bytes)
- * - exit value (4 bytes)
+ * - specid (4 bytes)
+ * - PRID (4 bytes)
+ * - STID (4 bytes)
+ * - arg1 through arg5 (5 x 8 bytes)
+ * So, 64 bytes.
*/
-/* @@runtest-opts: -b60 */
+/* @@runtest-opts: -b64 */
BEGIN
{
diff --git a/test/unittest/options/tst.bufsize.d b/test/unittest/options/tst.bufsize.d
index 96b0f1b8..7884c0bc 100644
--- a/test/unittest/options/tst.bufsize.d
+++ b/test/unittest/options/tst.bufsize.d
@@ -1,6 +1,6 @@
/*
* Oracle Linux DTrace.
- * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
* Licensed under the Universal Permissive License v 1.0 as shown at
* http://oss.oracle.com/licenses/upl.
*/
@@ -12,16 +12,17 @@
*/
/*
- * We use a buffer size of 60 because that should be the exact size necessary
- * to hold the trace records generated in this script:
- * - perf_event_header (40 bytes)
+ * We use a buffer size that is just large enough to store the data recorded by
+ * this script:
+ * - perf_event_header (8 bytes)
* - size (4 bytes)
- * - gap (4 bytes)
- * - EPID (4 bytes)
- * - tag (4 bytes)
- * - exit value (4 bytes)
+ * - specid (4 bytes)
+ * - PRID (4 bytes)
+ * - STID (4 bytes)
+ * - arg1 through arg5 (5 x 8 bytes)
+ * So, 64 bytes.
*/
-/* @@runtest-opts: -xbufsize=60 */
+/* @@runtest-opts: -xbufsize=64 */
BEGIN
{
--
2.45.2
More information about the DTrace-devel
mailing list