Add a hook for a provider-specific "update" function
PATCH 20/38 Add a hook for a provider-specific "update" function
From: Eugene Loh <[email protected]>
For up-coming USDT-probe support, we need to update a BPF map -- at least when the dtrace session starts but possibly also later to support systemwide USDT tracing for processes that may start up later.
One way to do this is with a USDT-specific update function.
For now, let's add a hook for providers to have provider-specific update functions. User space can either call
for (i = 0; i < ARRAY_SIZE(dt_providers); i++) {
if (dt_providers[i]->update)
dt_providers[i]->update(...);
}any time it likes. Or it can call dt_usdt.update(...).
This is for WIP. A different approach can be adopted later instead.
--- libdtrace/dt_provider.h | 2 ++ 1 file changed, 2 insertions(+)
libdtrace/dt_provider.h +2 -0
@@ -71,6 +71,8 @@ typedef struct dt_provimpl { void *datap);void (*destroy)(dtrace_hdl_t *dtp,/* free provider data */ void *datap); +void (*update)(dtrace_hdl_t *dtp,/* update provider-specific info */ +void *datap); } dt_provimpl_t;/* list dt_dtrace first */
Signature · 1 line
2.18.4
PATCH 21/38 Add some comments
From: Eugene Loh <[email protected]>
--- libdtrace/dt_prov_uprobe.c | 2 ++ 1 file changed, 2 insertions(+)
libdtrace/dt_prov_uprobe.c +2 -0
@@ -295,6 +295,7 @@ static int provide_probe(dtrace_hdl_t *dtp, const pid_probespec_t *psp,/* Mark the provider as a PID-based provider. */ pvp->pv_flags |=DT_PROVIDER_PID ; +/* Look up or create the underlying probe. */ uprp =create_underlying (dtp, psp);if (uprp ==NULL )return -1 ;
@@ -302,6 +303,7 @@ static int provide_probe(dtrace_hdl_t *dtp, const pid_probespec_t *psp, upp = uprp->prv_data; upp->flags |= flags; +/* Look up the overlying probe. */ prp =dt_probe_lookup (dtp, &pd);if (prp !=NULL ) {/*
Signature · 1 line
2.18.4
Re: [PATCH 21/38] Add some comments
Quoted 3 lines · On Thu, Jun 27, 2024 at 01:38:47AM -0400, [email protected] wrote:
From: Eugene Loh <[email protected]>
Signed-off-by Eugene Loh <[email protected]>
... with tiny suggestion below
libdtrace/dt_prov_uprobe.c static int provide_probe(dtrace_hdl_t *dtp, const pid_probespec_t *psp, · line 298
Quoted 13 lines
--- libdtrace/dt_prov_uprobe.c | 2 ++ 1 file changed, 2 insertions(+)libdtrace/dt_prov_uprobe.c +1
-0@@ -295,6 +295,7 @@ static int provide_probe(dtrace_hdl_t *dtp, const pid_probespec_t *psp,/* Mark the provider as a PID-based provider. */ pvp->pv_flags |=DT_PROVIDER_PID ; +/* Look up or create the underlying probe. */
This seems to contradict the function name. Perhaps rephrase this to say:
"Create and/or lookup the underlying probe."
Quoted 14 lines
libdtrace/dt_prov_uprobe.c +1
-0uprp =create_underlying (dtp, psp);if (uprp ==NULL )return -1 ;@@ -302,6 +303,7 @@ static int provide_probe(dtrace_hdl_t *dtp, const pid_probespec_t *psp, upp = uprp->prv_data; upp->flags |= flags; +/* Look up the overlying probe. */ prp =dt_probe_lookup (dtp, &pd);if (prp !=NULL ) {/* Signature · 1 line
2.18.4
PATCH 22/38 Fix aggs comment in dt_cg_tramp_prologue_act()
In reply to [email protected]From: Eugene Loh <[email protected]>
--- libdtrace/dt_cg.c | 11 ----------- 1 file changed, 11 deletions(-)
libdtrace/dt_cg.c +0 -11
@@ -372,17 +372,6 @@ dt_cg_tramp_prologue_act(dt_pcb_t *pcb, dt_activity_t act)* if (rc == 0) // jeq %r0, 0, lbl_exit * goto exit; * -* key = 0; // stdw [%r9 + DCTX_AGG], 0 -* rc = bpf_map_lookup_elem(rc, &key); -* // mov %r1, %r0 -* // mov %r2, %r9 -* // add %r2, DCTX_AGG -* // call bpf_map_lookup_elem -* // (%r1 ... %r5 clobbered) -* // (%r0 = aggs[cpuid] BPF map value) -* if (rc == 0) // jeq %r0, 0, lbl_exit -* goto exit; -* * dctx.aggs = rc; // stdw [%r9 + DCTX_AGG], %r0 */ if (dtp->dt_maxaggdsize >0 ) {
Signature · 1 line
2.18.4
Re: [PATCH 22/38] Fix aggs comment in dt_cg_tramp_prologue_act()
Quoted 3 lines · On Thu, Jun 27, 2024 at 01:38:48AM -0400, [email protected] wrote:
From: Eugene Loh <[email protected]>
Signed-off-by Eugene Loh <[email protected]>
... provided you mention in the commit msg what you are fixing. Because looking at the patch you are removing a big part of a comment block but without any indication why, and the patch does not provide context to be able to assess that.
Quoted 29 lines
--- libdtrace/dt_cg.c | 11 ----------- 1 file changed, 11 deletions(-)libdtrace/dt_cg.c +0
-11@@ -372,17 +372,6 @@ dt_cg_tramp_prologue_act(dt_pcb_t *pcb, dt_activity_t act)* if (rc == 0) // jeq %r0, 0, lbl_exit * goto exit; * -* key = 0; // stdw [%r9 + DCTX_AGG], 0 -* rc = bpf_map_lookup_elem(rc, &key); -* // mov %r1, %r0 -* // mov %r2, %r9 -* // add %r2, DCTX_AGG -* // call bpf_map_lookup_elem -* // (%r1 ... %r5 clobbered) -* // (%r0 = aggs[cpuid] BPF map value) -* if (rc == 0) // jeq %r0, 0, lbl_exit -* goto exit; -* * dctx.aggs = rc; // stdw [%r9 + DCTX_AGG], %r0 */ if (dtp->dt_maxaggdsize >0 ) {Signature · 1 line
2.18.4
Re: [PATCH 22/38] Fix aggs comment in dt_cg_tramp_prologue_act()
Quoted 10 lines · Kris Van Hees
Quoted 3 lines · On Thu, Jun 27, 2024 at 01:38:48AM -0400, [email protected] wrote:
From: Eugene Loh <[email protected]>
Signed-off-by Eugene Loh <[email protected]>Reviewed-by Kris Van Hees <[email protected]>... provided you mention in the commit msg what you are fixing. Because looking at the patch you are removing a big part of a comment block but without any indication why, and the patch does not provide context to be able to assess that.
Fair enough. I suppose I never really knew why, other than that the comment didn't match the code. Okay, I did my homework and added Since 2dd92c02 ("Add support for aggregation keys") removed a bunch
of code, the corresponding comments should also have been removed.
to the commit msg, along with your R_b.
Quoted 19 lines
Quoted 19 lines
libdtrace/dt_cg.c +0
-11@@ -372,17 +372,6 @@ dt_cg_tramp_prologue_act(dt_pcb_t *pcb, dt_activity_t act)* if (rc == 0) // jeq %r0, 0, lbl_exit * goto exit; * -* key = 0; // stdw [%r9 + DCTX_AGG], 0 -* rc = bpf_map_lookup_elem(rc, &key); -* // mov %r1, %r0 -* // mov %r2, %r9 -* // add %r2, DCTX_AGG -* // call bpf_map_lookup_elem -* // (%r1 ... %r5 clobbered) -* // (%r0 = aggs[cpuid] BPF map value) -* if (rc == 0) // jeq %r0, 0, lbl_exit -* goto exit; -* * dctx.aggs = rc; // stdw [%r9 + DCTX_AGG], %r0 */ if (dtp->dt_maxaggdsize >0 ) {
PATCH 23/38 test: Clean up the specsize tests
In reply to [email protected]From: Eugene Loh <[email protected]>
The tests had actions like
printf("%lld: Lots of data\n", x);
printf("%lld: Has to be crammed into this buffer\n", x);
printf("%lld: Until it overflows\n", x);
printf("%lld: And causes flops\n", x);suggesting that these strings were crowding the buffer, but these strings are not passed from producer to consumer at all.
The tests also only tested one clause per speculation. It would be nice also to test multiple clauses per speculation.
There is much replicated code from one of the tests to the other, a shortcoming that is amplified if we want to test more specsize values, which is the case when we test multiple clauses per speculation.
Therefore, replace the multiple tests with a single test that checks multiple clauses per speculation and more values of specsize.
--- .../speculation/tst.SpecSizeVariations.r | 68 +++++++++++++++++ .../speculation/tst.SpecSizeVariations.sh | 74 +++++++++++++++++++ .../speculation/tst.SpecSizeVariations4.d | 66 ----------------- .../speculation/tst.SpecSizeVariations4.r | 5 -- .../speculation/tst.SpecSizeVariations5.d | 61 --------------- .../speculation/tst.SpecSizeVariations5.r | 7 -- 6 files changed, 142 insertions(+), 139 deletions(-) create mode 100644 test/unittest/speculation/tst.SpecSizeVariations.r create mode 100755 test/unittest/speculation/tst.SpecSizeVariations.sh delete mode 100644 test/unittest/speculation/tst.SpecSizeVariations4.d delete mode 100644 test/unittest/speculation/tst.SpecSizeVariations4.r delete mode 100644 test/unittest/speculation/tst.SpecSizeVariations5.d delete mode 100644 test/unittest/speculation/tst.SpecSizeVariations5.r
test/unittest/speculation/tst.SpecSizeVariations.r new file +68 -0
@@ -0,0 +1,68 @@ +Speculative buffer ID: 1 +counts: 0 1 + +Speculative buffer ID: 1 +123456700 +123456701 +123456702 +123456703 +123456704 +123456705 +123456706 +counts: 1 1 + +Speculative buffer ID: 1 +123456700 +123456701 +123456702 +123456703 +123456704 +123456705 +123456706 +counts: 1 1 + +Speculative buffer ID: 1 +123456700 +123456701 +123456702 +123456703 +123456704 +123456705 +123456706 +counts: 2 1 + +Speculative buffer ID: 1 +123456700 +123456701 +123456702 +123456703 +123456704 +123456705 +123456706 +counts: 2 1 + +Speculative buffer ID: 1 +123456700 +123456701 +123456702 +123456703 +123456704 +123456705 +123456706 +123456800 +123456801 +123456802 +123456803 +123456804 +123456805 +123456806 +123456807 +123456808 +counts: 2 1 + +-- @@stderr -- +dtrace: 2 speculative drops +dtrace: 1 speculative drop +dtrace: 1 speculative drop +dtrace: 1 speculative drop +dtrace: 1 speculative drop
test/unittest/speculation/tst.SpecSizeVariations.sh new file +74 -0
74 lines not on this page · raw message
test/unittest/speculation/tst.SpecSizeVariations4.d deleted +0 -66
66 lines not on this page · raw message
test/unittest/speculation/tst.SpecSizeVariations4.r deleted +0 -5
@@ -1,5 +0,0 @@ -Speculative buffer ID: 1 -Statement wasn't executed - --- @@stderr -- -dtrace: 1 speculative drop
test/unittest/speculation/tst.SpecSizeVariations5.d deleted +0 -61
61 lines not on this page · raw message
test/unittest/speculation/tst.SpecSizeVariations5.r deleted +0 -7
@@ -1,7 +0,0 @@ -Speculative buffer ID: 1 -123456789: Lots of data -123456789: Has to be crammed into this buffer -123456789: Until it overflows -123456789: And causes flops -Statement was executed -
Signature · 1 line
2.18.4
PATCH 24/38 test: Make test independent of specific PC
In reply to [email protected]From: Eugene Loh <[email protected]>
--- test/unittest/error/tst.DTRACEFLT_UNKNOWN.d | 6 +++--- test/unittest/error/tst.DTRACEFLT_UNKNOWN.r | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
test/unittest/error/tst.DTRACEFLT_UNKNOWN.d +3 -3
@@ -1,6 +1,6 @@ /* * Oracle Linux DTrace. - * Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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. */
@@ -19,8 +19,8 @@ ERROR { - printf("The arguments are %u %u %u %u %u\n", - arg1, arg2, arg3, arg4, arg5); + printf("The arguments are %u %u PC %u %u\n", + arg1, arg2, arg4, arg5); printf("The value of arg4 = %u\n", DTRACEFLT_UNKNOWN); exit(0); }
test/unittest/error/tst.DTRACEFLT_UNKNOWN.r +1 -1
@@ -1,4 +1,4 @@ -The arguments are 2 2 4 1 64 +The arguments are 2 2 PC 1 64 The value of arg4 = 0 -- @@stderr --
Signature · 1 line
2.18.4
Re: [PATCH 24/38] test: Make test independent of specific PC
Quoted 1 line · On Thu, Jun 27, 2024 at 01:38:50AM -0400, [email protected] wrote:
From: Eugene Loh <[email protected]>
I agree in principle that this test should not depend on a specific PC value, but that leaves the issue that with this patch, I do not think there is any real test to verify that the PC value is sane. So, that probably should be added.
Quoted 42 lines
Signed-off-by Eugene Loh <[email protected]>--- test/unittest/error/tst.DTRACEFLT_UNKNOWN.d | 6 +++--- test/unittest/error/tst.DTRACEFLT_UNKNOWN.r | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)test/unittest/error/tst.DTRACEFLT_UNKNOWN.d +3
-3@@ -1,6 +1,6 @@ /* * Oracle Linux DTrace. - * Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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. */@@ -19,8 +19,8 @@ ERROR { - printf("The arguments are %u %u %u %u %u\n", - arg1, arg2, arg3, arg4, arg5); + printf("The arguments are %u %u PC %u %u\n", + arg1, arg2, arg4, arg5); printf("The value of arg4 = %u\n", DTRACEFLT_UNKNOWN); exit(0); }test/unittest/error/tst.DTRACEFLT_UNKNOWN.r +1
-1@@ -1,4 +1,4 @@ -The arguments are 2 2 4 1 64 +The arguments are 2 2 PC 1 64 The value of arg4 = 0 -- @@stderr --Signature · 1 line
2.18.4
Re: [PATCH 24/38] test: Make test independent of specific PC
Quoted 6 lines · Kris Van Hees
Quoted 1 line · On Thu, Jun 27, 2024 at 01:38:50AM -0400, [email protected] wrote:
From: Eugene Loh <[email protected]>
I agree in principle that this test should not depend on a specific PC value, but that leaves the issue that with this patch, I do not think there is any real test to verify that the PC value is sane. So, that probably should be added.
Hmm, yeah, I guess so. Okay, I posted v2 (with a tweaked title "test: Handle dtrace:::ERROR arg3 specially"). Also, I posted a v2 of patch 25/38. You already R-b'ed it, but it gets modified (in a very minor way) by the effects of this patch. I'll assume your R-b still stands, but take a look if you're curious.
Quoted 42 lines
Quoted 42 lines
Signed-off-by Eugene Loh <[email protected]>--- test/unittest/error/tst.DTRACEFLT_UNKNOWN.d | 6 +++--- test/unittest/error/tst.DTRACEFLT_UNKNOWN.r | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)test/unittest/error/tst.DTRACEFLT_UNKNOWN.d +3
-3@@ -1,6 +1,6 @@ /* * Oracle Linux DTrace. - * Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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. */@@ -19,8 +19,8 @@ ERROR { - printf("The arguments are %u %u %u %u %u\n", - arg1, arg2, arg3, arg4, arg5); + printf("The arguments are %u %u PC %u %u\n", + arg1, arg2, arg4, arg5); printf("The value of arg4 = %u\n", DTRACEFLT_UNKNOWN); exit(0); }test/unittest/error/tst.DTRACEFLT_UNKNOWN.r +1
-1@@ -1,4 +1,4 @@ -The arguments are 2 2 4 1 64 +The arguments are 2 2 PC 1 64 The value of arg4 = 0 -- @@stderr --Signature · 1 line
2.18.4
PATCH 25/38 test: Clean up tests still expecting obsolete "at DIF offset NN"
In reply to [email protected]From: Eugene Loh <[email protected]>
Also, the numbering of EPIDs has changed.
--- test/demo/dtrace/error.d | 1 - test/demo/dtrace/error.r | 2 +- test/unittest/assocs/tst.invalidref.r | 4 ++-- test/unittest/drops/drp.DTRACEDROP_DBLERROR.r | 2 +- test/unittest/error/tst.DTRACEFLT_UNKNOWN.d | 1 - test/unittest/error/tst.DTRACEFLT_UNKNOWN.r | 4 ++-- test/unittest/error/tst.DTRACEFLT_UNKNOWN.sparc64.r | 5 ----- test/unittest/pointers/err.BadAlign.d | 1 - test/unittest/pointers/err.BadAlign.r | 2 +- test/unittest/pointers/err.InvalidAddress2.d | 1 - test/unittest/pointers/err.InvalidAddress2.r | 2 +- test/unittest/pointers/err.InvalidAddress3.r | 2 +- test/unittest/pointers/err.InvalidAddress4.d | 1 - test/unittest/pointers/err.InvalidAddress4.r | 2 +- test/unittest/regression/tst.DTRACEFLT_BADADDR.d_path.d | 2 +- test/unittest/regression/tst.DTRACEFLT_BADADDR.d_path.r | 4 ++-- 16 files changed, 13 insertions(+), 23 deletions(-) delete mode 100644 test/unittest/error/tst.DTRACEFLT_UNKNOWN.sparc64.r
test/demo/dtrace/error.d +0 -1
@@ -5,7 +5,6 @@ * http://oss.oracle.com/licenses/upl. */ -/* @@xfail: dtv2 */ /* @@trigger: none */ BEGIN
test/demo/dtrace/error.r +1 -1
@@ -3,4 +3,4 @@ -- @@stderr -- dtrace: script 'test/demo/dtrace/error.d' matched 2 probes -dtrace: error on enabled probe ID 1 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at DIF offset 16 at BPF pc NNN +dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/assocs/tst.invalidref.r +2 -2
@@ -1,4 +1,4 @@ -- @@stderr -- -dtrace: error on enabled probe ID (ID: profile:::tick-1s): invalid address ({ptr}) in action #2 at DIF offset 64 at BPF pc NNN -dtrace: error on enabled probe ID (ID: profile:::tick-1s): invalid address ({ptr}) in action #2 at DIF offset 64 at BPF pc NNN +dtrace: error on enabled probe ID (ID: profile:::tick-1s): invalid address ({ptr}) in action #2 at BPF pc NNN +dtrace: error on enabled probe ID (ID: profile:::tick-1s): invalid address ({ptr}) in action #2 at BPF pc NNN
test/unittest/drops/drp.DTRACEDROP_DBLERROR.r +1 -1
@@ -4,4 +4,4 @@ -- @@stderr -- dtrace: script 'test/unittest/drops/drp.DTRACEDROP_DBLERROR.d' matched 3 probes dtrace: [DTRACEDROP_DBLERROR] 1 error in ERROR probe enabling -dtrace: error on enabled probe ID 1 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at DIF offset 16 at BPF pc NNN +dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/error/tst.DTRACEFLT_UNKNOWN.d +0 -1
@@ -4,7 +4,6 @@ * Licensed under the Universal Permissive License v 1.0 as shown at * http://oss.oracle.com/licenses/upl. */ -/* @@xfail: dtv2 */ /* * ASSERTION:
test/unittest/error/tst.DTRACEFLT_UNKNOWN.r +2 -2
@@ -1,5 +1,5 @@ -The arguments are 2 2 PC 1 64 +The arguments are 3 1 PC 1 64 The value of arg4 = 0 -- @@stderr -- -dtrace: error on enabled probe ID 2 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #2 at DIF offset 4 at BPF pc NNN +dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/error/tst.DTRACEFLT_UNKNOWN.sparc64.r deleted +0 -5
@@ -1,5 +0,0 @@ -The arguments are 2 2 4 1 0 -The value of arg4 = 0 - --- @@stderr -- -dtrace: error on enabled probe ID 2 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #2 at DIF offset 4
test/unittest/pointers/err.BadAlign.d +0 -1
@@ -4,7 +4,6 @@ * Licensed under the Universal Permissive License v 1.0 as shown at * http://oss.oracle.com/licenses/upl. */ -/* @@xfail: dtv2 */ /* * ASSERTION: This test reproduces the alignment error.
test/unittest/pointers/err.BadAlign.r +1 -1
@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 1 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #2 at DIF offset 4 +dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/pointers/err.InvalidAddress2.d +0 -1
@@ -4,7 +4,6 @@ * Licensed under the Universal Permissive License v 1.0 as shown at * http://oss.oracle.com/licenses/upl. */ -/* @@xfail: dtv2 */ /* * ASSERTION: D pointers do not allow invalid pointer accesses.
test/unittest/pointers/err.InvalidAddress2.r +1 -1
@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 1 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #4 at DIF offset 8 +dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/pointers/err.InvalidAddress3.r +1 -1
@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 1 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #2 at DIF offset 8 +dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/pointers/err.InvalidAddress4.d +0 -1
@@ -4,7 +4,6 @@ * Licensed under the Universal Permissive License v 1.0 as shown at * http://oss.oracle.com/licenses/upl. */ -/* @@xfail: dtv2 */ /* * ASSERTION: Demonstrating valid memory access.
test/unittest/pointers/err.InvalidAddress4.r +1 -1
@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 1 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #4 at DIF offset 8 +dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/regression/tst.DTRACEFLT_BADADDR.d_path.d +1 -1
@@ -4,7 +4,7 @@ * Licensed under the Universal Permissive License v 1.0 as shown at * http://oss.oracle.com/licenses/upl. */ -/* @@xfail: dtv2 */ +/* @@xfail: dtv2 d_path */ /* * ASSERTION:
test/unittest/regression/tst.DTRACEFLT_BADADDR.d_path.r +2 -2
@@ -1,6 +1,6 @@ -The arguments are 2 1 28 1 24 +The arguments are 3 1 28 1 24 The value of arg4 should be 1 The value of arg5 should be 24 -- @@stderr -- -dtrace: error on enabled probe ID 2 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at DIF offset 28 at BPF pc NNN +dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
Signature · 1 line
2.18.4
Re: [PATCH 25/38] test: Clean up tests still expecting obsolete "at DIF offset NN"
Quoted 3 lines · On Thu, Jun 27, 2024 at 01:38:51AM -0400, [email protected] wrote:
From: Eugene Loh <[email protected]>
Also, the numbering of EPIDs has changed.
Good catch on the DIF offset stuff that certainly should have been gone a long time ago.
Quoted 1 line
Signed-off-by Eugene Loh <[email protected]>
Quoted 199 lines
--- test/demo/dtrace/error.d | 1 - test/demo/dtrace/error.r | 2 +- test/unittest/assocs/tst.invalidref.r | 4 ++-- test/unittest/drops/drp.DTRACEDROP_DBLERROR.r | 2 +- test/unittest/error/tst.DTRACEFLT_UNKNOWN.d | 1 - test/unittest/error/tst.DTRACEFLT_UNKNOWN.r | 4 ++-- test/unittest/error/tst.DTRACEFLT_UNKNOWN.sparc64.r | 5 ----- test/unittest/pointers/err.BadAlign.d | 1 - test/unittest/pointers/err.BadAlign.r | 2 +- test/unittest/pointers/err.InvalidAddress2.d | 1 - test/unittest/pointers/err.InvalidAddress2.r | 2 +- test/unittest/pointers/err.InvalidAddress3.r | 2 +- test/unittest/pointers/err.InvalidAddress4.d | 1 - test/unittest/pointers/err.InvalidAddress4.r | 2 +- test/unittest/regression/tst.DTRACEFLT_BADADDR.d_path.d | 2 +- test/unittest/regression/tst.DTRACEFLT_BADADDR.d_path.r | 4 ++-- 16 files changed, 13 insertions(+), 23 deletions(-) delete mode 100644 test/unittest/error/tst.DTRACEFLT_UNKNOWN.sparc64.rtest/demo/dtrace/error.d +0
-1@@ -5,7 +5,6 @@ * http://oss.oracle.com/licenses/upl. */ -/* @@xfail: dtv2 */ /* @@trigger: none */ BEGINtest/demo/dtrace/error.r +1
-1@@ -3,4 +3,4 @@ -- @@stderr -- dtrace: script 'test/demo/dtrace/error.d' matched 2 probes -dtrace: error on enabled probe ID 1 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at DIF offset 16 at BPF pc NNN +dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNNtest/unittest/assocs/tst.invalidref.r +2
-2@@ -1,4 +1,4 @@ -- @@stderr -- -dtrace: error on enabled probe ID (ID: profile:::tick-1s): invalid address ({ptr}) in action #2 at DIF offset 64 at BPF pc NNN -dtrace: error on enabled probe ID (ID: profile:::tick-1s): invalid address ({ptr}) in action #2 at DIF offset 64 at BPF pc NNN +dtrace: error on enabled probe ID (ID: profile:::tick-1s): invalid address ({ptr}) in action #2 at BPF pc NNN +dtrace: error on enabled probe ID (ID: profile:::tick-1s): invalid address ({ptr}) in action #2 at BPF pc NNNtest/unittest/drops/drp.DTRACEDROP_DBLERROR.r +1
-1@@ -4,4 +4,4 @@ -- @@stderr -- dtrace: script 'test/unittest/drops/drp.DTRACEDROP_DBLERROR.d' matched 3 probes dtrace: [DTRACEDROP_DBLERROR] 1 error in ERROR probe enabling -dtrace: error on enabled probe ID 1 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at DIF offset 16 at BPF pc NNN +dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNNtest/unittest/error/tst.DTRACEFLT_UNKNOWN.d +0
-1@@ -4,7 +4,6 @@ * Licensed under the Universal Permissive License v 1.0 as shown at * http://oss.oracle.com/licenses/upl. */ -/* @@xfail: dtv2 */ /* * ASSERTION:test/unittest/error/tst.DTRACEFLT_UNKNOWN.r +2
-2@@ -1,5 +1,5 @@ -The arguments are 2 2 PC 1 64 +The arguments are 3 1 PC 1 64 The value of arg4 = 0 -- @@stderr -- -dtrace: error on enabled probe ID 2 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #2 at DIF offset 4 at BPF pc NNN +dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNNtest/unittest/error/tst.DTRACEFLT_UNKNOWN.sparc64.r deleted +0
-5@@ -1,5 +0,0 @@ -The arguments are 2 2 4 1 0 -The value of arg4 = 0 - --- @@stderr -- -dtrace: error on enabled probe ID 2 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #2 at DIF offset 4test/unittest/pointers/err.BadAlign.d +0
-1@@ -4,7 +4,6 @@ * Licensed under the Universal Permissive License v 1.0 as shown at * http://oss.oracle.com/licenses/upl. */ -/* @@xfail: dtv2 */ /* * ASSERTION: This test reproduces the alignment error.test/unittest/pointers/err.BadAlign.r +1
-1@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 1 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #2 at DIF offset 4 +dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNNtest/unittest/pointers/err.InvalidAddress2.d +0
-1@@ -4,7 +4,6 @@ * Licensed under the Universal Permissive License v 1.0 as shown at * http://oss.oracle.com/licenses/upl. */ -/* @@xfail: dtv2 */ /* * ASSERTION: D pointers do not allow invalid pointer accesses.test/unittest/pointers/err.InvalidAddress2.r +1
-1@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 1 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #4 at DIF offset 8 +dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNNtest/unittest/pointers/err.InvalidAddress3.r +1
-1@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 1 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #2 at DIF offset 8 +dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNNtest/unittest/pointers/err.InvalidAddress4.d +0
-1@@ -4,7 +4,6 @@ * Licensed under the Universal Permissive License v 1.0 as shown at * http://oss.oracle.com/licenses/upl. */ -/* @@xfail: dtv2 */ /* * ASSERTION: Demonstrating valid memory access.test/unittest/pointers/err.InvalidAddress4.r +1
-1@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 1 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #4 at DIF offset 8 +dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNNtest/unittest/regression/tst.DTRACEFLT_BADADDR.d_path.d +1
-1@@ -4,7 +4,7 @@ * Licensed under the Universal Permissive License v 1.0 as shown at * http://oss.oracle.com/licenses/upl. */ -/* @@xfail: dtv2 */ +/* @@xfail: dtv2 d_path */ /* * ASSERTION:test/unittest/regression/tst.DTRACEFLT_BADADDR.d_path.r +2
-2@@ -1,6 +1,6 @@ -The arguments are 2 1 28 1 24 +The arguments are 3 1 28 1 24 The value of arg4 should be 1 The value of arg5 should be 24 -- @@stderr -- -dtrace: error on enabled probe ID 2 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at DIF offset 28 at BPF pc NNN +dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNNSignature · 1 line
2.18.4
PATCH 26/38 test: Annotate xfail (chill not implemented yet)
In reply to [email protected]From: Eugene Loh <[email protected]>
--- test/unittest/speculation/tst.zerosize.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
test/unittest/speculation/tst.zerosize.d +1 -1
@@ -5,7 +5,7 @@ * http://oss.oracle.com/licenses/upl. */ -/* @@xfail: dtv2 */ +/* @@xfail: dtv2, chill not implemented yet */ #pragma D option destructive
Signature · 1 line
2.18.4
Re: [PATCH 26/38] test: Annotate xfail (chill not implemented yet)
Quoted 1 line · On Thu, Jun 27, 2024 at 01:38:52AM -0400, [email protected] wrote:
From: Eugene Loh <[email protected]>
Before I can really assess whether the annotation is valid, I'd like to know why chill) is even used here. I.e. I don't quite understand the test :)
Quoted 22 lines
Signed-off-by Eugene Loh <[email protected]>--- test/unittest/speculation/tst.zerosize.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)test/unittest/speculation/tst.zerosize.d +1
-1@@ -5,7 +5,7 @@ * http://oss.oracle.com/licenses/upl. */ -/* @@xfail: dtv2 */ +/* @@xfail: dtv2, chill not implemented yet */ #pragma D option destructiveSignature · 1 line
2.18.4
Re: [PATCH 26/38] test: Annotate xfail (chill not implemented yet)
Quoted 3 lines · Kris Van Hees
Quoted 1 line · On Thu, Jun 27, 2024 at 01:38:52AM -0400, [email protected] wrote:
From: Eugene Loh <[email protected]>
Before I can really assess whether the annotation is valid,
Well, I'm pretty sure the annotation is right.
Quoted 2 lines
I'd like to know
why chill) is even used here. I.e. I don't quite understand the test :)
Well, I'm all with you on that. I'm pretty sure the chill() is pretty irrelevant and that the test is "valid" and passes without it. I am of two minds:
1) Remove the chill() and @@xfail and move on.
2) Be grateful for idiosyncrasies in the test suite, since they often turn up bugs. Weird tests turn up weird bugs.
The patch was going with #2; that get my vote. I'm okay with #1, however. Feel free to decide.
Quoted 21 lines
Quoted 21 lines
Signed-off-by Eugene Loh <[email protected]>--- test/unittest/speculation/tst.zerosize.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)test/unittest/speculation/tst.zerosize.d +1
-1@@ -5,7 +5,7 @@ * http://oss.oracle.com/licenses/upl. */ -/* @@xfail: dtv2 */ +/* @@xfail: dtv2, chill not implemented yet */ #pragma D option destructiveSignature · 1 line
2.18.4
Re: [PATCH 26/38] test: Annotate xfail (chill not implemented yet)
If memory serves me well, I think the plan was to change this test to not use chill at all (and remove the xfail), and introduce a new test that exercises the use of chill in the context of a clause that is a zero-size speculation.
Quoted 41 lines · Eugene Loh
Quoted 3 lines · Kris Van Hees
Quoted 1 line · On Thu, Jun 27, 2024 at 01:38:52AM -0400, [email protected] wrote:
From: Eugene Loh <[email protected]>
Before I can really assess whether the annotation is valid,
Well, I'm pretty sure the annotation is right.
Quoted 2 lines
I'd like to know
why chill) is even used here. I.e. I don't quite understand the test :)Well, I'm all with you on that. I'm pretty sure the
chill()is pretty irrelevant and that the test is "valid" and passes without it. I am of two minds:1) Remove the
chill()and @@xfail and move on.2) Be grateful for idiosyncrasies in the test suite, since they often turn up bugs. Weird tests turn up weird bugs.
The patch was going with #2; that get my vote. I'm okay with #1, however. Feel free to decide.
Quoted 18 lines
Quoted 18 lines
Signed-off-by Eugene Loh <[email protected]>--- test/unittest/speculation/tst.zerosize.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)test/unittest/speculation/tst.zerosize.d +1
-1@@ -5,7 +5,7 @@ * http://oss.oracle.com/licenses/upl. */ -/* @@xfail: dtv2 */ +/* @@xfail: dtv2, chill not implemented yet */ #pragma D option destructiveSignature · 1 line
2.18.4
Re: [PATCH 26/38] test: Annotate xfail (chill not implemented yet)
Quoted 1 line · Kris Van Hees
If memory serves me well,
It does.
Quoted 3 lines
I think the plan was to change this test to not use
chill at all (and remove the xfail), and introduce a new test that exercises the use of chill in the context of a clause that is a zero-size speculation.
v2 will have the slightly different name
"test: Clean up zero-size speculation + chill()".
Quoted 40 lines · Eugene Loh
Quoted 39 lines · Kris Van Hees
Quoted 4 lines · On Thu, Jun 27, 2024 at 01:38:52AM -0400, [email protected] wrote:
Quoted 1 line
From: Eugene Loh <[email protected]>
Before I can really assess whether the annotation is valid,
Well, I'm pretty sure the annotation is right.
Quoted 2 lines
I'd like to know
why chill) is even used here. I.e. I don't quite understand the test :)Well, I'm all with you on that. I'm pretty sure the
chill()is pretty irrelevant and that the test is "valid" and passes without it. I am of two minds:1) Remove the
chill()and @@xfail and move on.2) Be grateful for idiosyncrasies in the test suite, since they often turn up bugs. Weird tests turn up weird bugs.
The patch was going with #2; that get my vote. I'm okay with #1, however. Feel free to decide.
Quoted 18 lines
Quoted 18 lines
Signed-off-by Eugene Loh <[email protected]>--- test/unittest/speculation/tst.zerosize.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)test/unittest/speculation/tst.zerosize.d +1
-1@@ -5,7 +5,7 @@ * http://oss.oracle.com/licenses/upl. */ -/* @@xfail: dtv2 */ +/* @@xfail: dtv2, chill not implemented yet */ #pragma D option destructiveSignature · 1 line
2.18.4
PATCH 27/38 test: Fix the speculative tests that checked bufsize
In reply to [email protected]From: Eugene Loh <[email protected]>
Ever since speculations were reimplemented, these tests simply were not testing what they claimed to test. Among other things:
1) There is a simple dependence on bufsize that is independent of speculations. So speculations have no special role in bufsize tests.
2) The messages in the print statements were not taxing bufsize. (A single default string would be enough to exhaust 60 bytes, but the producer wasn't passing the consumer these strings at all. The bufsize is being set by the implicit ERROR probe.)
3) The various size ranges described in the comments do not exist and were not being tested anyhow.
So remove these tests, and just rely on the other bufsize tests.
To be fair, there seemed to have been no other "negative bufsize" test, but add a more straightforward such test and add it to where the other bufsize tests are.
--- test/unittest/options/err.bufsize-negative.d | 24 +++++++ test/unittest/options/err.bufsize-negative.r | 2 + .../speculation/err.BufSizeVariations1.d | 67 ------------------- .../speculation/err.BufSizeVariations2.d | 67 ------------------- .../speculation/err.NegativeBufSize.d | 67 ------------------- .../speculation/err.NegativeBufSize.r | 2 - 6 files changed, 26 insertions(+), 203 deletions(-) create mode 100644 test/unittest/options/err.bufsize-negative.d create mode 100644 test/unittest/options/err.bufsize-negative.r delete mode 100644 test/unittest/speculation/err.BufSizeVariations1.d delete mode 100644 test/unittest/speculation/err.BufSizeVariations2.d delete mode 100644 test/unittest/speculation/err.NegativeBufSize.d delete mode 100644 test/unittest/speculation/err.NegativeBufSize.r
test/unittest/options/err.bufsize-negative.d new file +24 -0
@@ -0,0 +1,24 @@ +/* + * Oracle Linux DTrace. + * Copyright (c) 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. + */ + +/* + * ASSERTION: The -xbufsize option sets the trace buffer size. + * + * SECTION: Options and Tunables/Consumer Options + */ + +/* @@runtest-opts: -xbufsize=-1 */ + +BEGIN +{ + exit(0); +} + +ERROR +{ + exit(1); +}
test/unittest/options/err.bufsize-negative.r new file +2 -0
@@ -0,0 +1,2 @@ +-- @@stderr -- +dtrace: failed to set -x bufsize: Invalid value for specified option
test/unittest/speculation/err.BufSizeVariations1.d deleted +0 -67
67 lines not on this page · raw message
test/unittest/speculation/err.BufSizeVariations2.d deleted +0 -67
67 lines not on this page · raw message
test/unittest/speculation/err.NegativeBufSize.d deleted +0 -67
67 lines not on this page · raw message
test/unittest/speculation/err.NegativeBufSize.r deleted +0 -2
@@ -1,2 +0,0 @@ --- @@stderr -- -dtrace: failed to compile script test/unittest/speculation/err.NegativeBufSize.d: line 27: failed to set option 'bufsize' to '-72': Invalid value for specified option
Signature · 1 line
2.18.4
PATCH 28/38 Remove unused "next" arg from dt_flowindent()
In reply to [email protected]From: Eugene Loh <[email protected]>
--- libdtrace/dt_consume.c | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-)
libdtrace/dt_consume.c +3 -21
@@ -432,11 +432,9 @@ static dt_htab_ops_t dt_spec_buf_htab_ops = { };static int -dt_flowindent (dtrace_hdl_t *dtp,dtrace_probedata_t *data,dtrace_epid_t last, -dtrace_epid_t next) +dt_flowindent (dtrace_hdl_t *dtp,dtrace_probedata_t *data,dtrace_epid_t last) { -dtrace_probedesc_t *pd = data->dtpda_pdesc, *npd; -dtrace_datadesc_t *ndd; +dtrace_probedesc_t *pd = data->dtpda_pdesc;dtrace_flowkind_t flow =DTRACEFLOW_NONE ;const char *p = pd->prv;const char *n = pd->prb;
@@ -447,7 +445,6 @@ dt_flowindent(dtrace_hdl_t *dtp, dtrace_probedata_t *data, dtrace_epid_t last,static const char *ent ="entry" , *ret ="return" ;static int entlen =0 , retlen =0 ;dtrace_epid_t id = data->dtpda_epid; -int rval;if (entlen ==0 ) {assert (retlen ==0 );
@@ -485,21 +482,6 @@ dt_flowindent(dtrace_hdl_t *dtp, dtrace_probedata_t *data, dtrace_epid_t last, flow =DTRACEFLOW_NONE ; } -/* -* If we're going to unindent this, it's more difficult to see if -* we don't actually want to unindent it -- we need to look at the -* _next_ EPID. -*/ -if (flow ==DTRACEFLOW_RETURN && next !=DTRACE_EPIDNONE && - next != id) { - rval =dt_epid_lookup (dtp, next, &ndd, &npd); -if (rval !=0 ) -return rval; - -if (npd->id == pd->id) - flow =DTRACEFLOW_NONE ; - } -if (flow ==DTRACEFLOW_ENTRY || flow ==DTRACEFLOW_RETURN ) data->dtpda_prefix = str;else
@@ -2343,7 +2325,7 @@ dt_consume_one_probe(dtrace_hdl_t *dtp, FILE *fp, char *data, uint32_t size,if (data_recording) {if (flow) -dt_flowindent (dtp, pdat, *last,DTRACE_EPIDNONE ); +dt_flowindent (dtp, pdat, *last); rval = (*efunc)(pdat, arg);
Signature · 1 line
2.18.4
Re: [PATCH 28/38] Remove unused "next" arg from dt_flowindent()
Lookinga at this - it might be that 'next' is not needed (ever) but I need to look at this code again because I wrote it a very long time ago and I cannot recall whether I reworked it to never need it or whether this is essentially something that was left to be handled later (and forgotten).
Quoted 67 lines · On Thu, Jun 27, 2024 at 01:38:54AM -0400, [email protected] wrote:
From: Eugene Loh <[email protected]>
Signed-off-by Eugene Loh <[email protected]>--- libdtrace/dt_consume.c | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-)libdtrace/dt_consume.c +3
-21@@ -432,11 +432,9 @@ static dt_htab_ops_t dt_spec_buf_htab_ops = { };static int -dt_flowindent (dtrace_hdl_t *dtp,dtrace_probedata_t *data,dtrace_epid_t last, -dtrace_epid_t next) +dt_flowindent (dtrace_hdl_t *dtp,dtrace_probedata_t *data,dtrace_epid_t last) { -dtrace_probedesc_t *pd = data->dtpda_pdesc, *npd; -dtrace_datadesc_t *ndd; +dtrace_probedesc_t *pd = data->dtpda_pdesc;dtrace_flowkind_t flow =DTRACEFLOW_NONE ;const char *p = pd->prv;const char *n = pd->prb;@@ -447,7 +445,6 @@ dt_flowindent(dtrace_hdl_t *dtp, dtrace_probedata_t *data, dtrace_epid_t last,static const char *ent ="entry" , *ret ="return" ;static int entlen =0 , retlen =0 ;dtrace_epid_t id = data->dtpda_epid; -int rval;if (entlen ==0 ) {assert (retlen ==0 );@@ -485,21 +482,6 @@ dt_flowindent(dtrace_hdl_t *dtp, dtrace_probedata_t *data, dtrace_epid_t last, flow =DTRACEFLOW_NONE ; } -/* -* If we're going to unindent this, it's more difficult to see if -* we don't actually want to unindent it -- we need to look at the -* _next_ EPID. -*/ -if (flow ==DTRACEFLOW_RETURN && next !=DTRACE_EPIDNONE && - next != id) { - rval =dt_epid_lookup (dtp, next, &ndd, &npd); -if (rval !=0 ) -return rval; - -if (npd->id == pd->id) - flow =DTRACEFLOW_NONE ; - } -if (flow ==DTRACEFLOW_ENTRY || flow ==DTRACEFLOW_RETURN ) data->dtpda_prefix = str;else @@ -2343,7 +2325,7 @@ dt_consume_one_probe(dtrace_hdl_t *dtp, FILE *fp, char *data, uint32_t size,if (data_recording) {if (flow) -dt_flowindent (dtp, pdat, *last,DTRACE_EPIDNONE ); +dt_flowindent (dtp, pdat, *last); rval = (*efunc)(pdat, arg);Signature · 1 line
2.18.4
PATCH 29/38 Allow relocation of the ERROR PRID
In reply to [email protected]From: Eugene Loh <[email protected]>
--- libdtrace/dt_bpf.h | 1 + libdtrace/dt_cc.c | 3 +++ libdtrace/dt_dlibs.c | 1 + 3 files changed, 5 insertions(+)
libdtrace/dt_bpf.h +1 -0
@@ -56,6 +56,7 @@ extern "C" {#define DT_CONST_ZERO_OFF 22#define DT_CONST_STACK_OFF 23#define DT_CONST_STACK_SKIP 24 +#define DT_CONST_ERROR_PRID 25#define DT_BPF_LOG_SIZE_DEFAULT (UINT32_MAX >> 8)#define DT_BPF_LOG_SIZE_SMALL 4096
libdtrace/dt_cc.c +3 -0
@@ -1076,6 +1076,9 @@ dt_link_construct(dtrace_hdl_t *dtp, const dt_probe_t *prp, dtrace_difo_t *dp, nrp->dofr_data =sizeof (uint64_t ) * dtp->dt_options[DTRACEOPT_MAXFRAMES ];continue ; +case DT_CONST_ERROR_PRID : + nrp->dofr_data = dtp->dt_error->desc->id; +continue ;case DT_CONST_BOOTTM :if (boottime ==0 &&get_boottime ())return -1 ;
libdtrace/dt_dlibs.c +1 -0
@@ -80,6 +80,7 @@ static const dt_ident_t dt_bpf_symbols[] = {DT_BPF_SYMBOL_ID (STBSZ ,DT_IDENT_SCALAR ,DT_CONST_STBSZ ),DT_BPF_SYMBOL_ID (STRSZ ,DT_IDENT_SCALAR ,DT_CONST_STRSZ ),DT_BPF_SYMBOL_ID (STKSIZ ,DT_IDENT_SCALAR ,DT_CONST_STKSIZ ), +DT_BPF_SYMBOL_ID (ERROR_PRID ,DT_IDENT_SCALAR ,DT_CONST_ERROR_PRID ),DT_BPF_SYMBOL_ID (BOOTTM ,DT_IDENT_SCALAR ,DT_CONST_BOOTTM ),DT_BPF_SYMBOL_ID (NSPEC ,DT_IDENT_SCALAR ,DT_CONST_NSPEC ), DT_BPF_SYMBOL_ID(NCPUS, DT_IDENT_SCALAR, DT_CONST_NCPUS),
Signature · 1 line
2.18.4
Re: [DTrace-devel] [PATCH 29/38] Allow relocation of the ERROR PRID
Why is this patch needed? As far as I can see, BEGIN, END, and ERROR are always created as the first 3 probes (in that order), so they will have probe IDs 1, 2, and 3.
Quoted 55 lines · eugene.loh--- via DTrace-devel
From: Eugene Loh <[email protected]>
Signed-off-by Eugene Loh <[email protected]>--- libdtrace/dt_bpf.h | 1 + libdtrace/dt_cc.c | 3 +++ libdtrace/dt_dlibs.c | 1 + 3 files changed, 5 insertions(+)libdtrace/dt_bpf.h +1
-0@@ -56,6 +56,7 @@ extern "C" {#define DT_CONST_ZERO_OFF 22#define DT_CONST_STACK_OFF 23#define DT_CONST_STACK_SKIP 24 +#define DT_CONST_ERROR_PRID 25#define DT_BPF_LOG_SIZE_DEFAULT (UINT32_MAX >> 8)#define DT_BPF_LOG_SIZE_SMALL 4096libdtrace/dt_cc.c +3
-0@@ -1076,6 +1076,9 @@ dt_link_construct(dtrace_hdl_t *dtp, const dt_probe_t *prp, dtrace_difo_t *dp, nrp->dofr_data =sizeof (uint64_t ) * dtp->dt_options[DTRACEOPT_MAXFRAMES ];continue ; +case DT_CONST_ERROR_PRID : + nrp->dofr_data = dtp->dt_error->desc->id; +continue ;case DT_CONST_BOOTTM :if (boottime ==0 &&get_boottime ())return -1 ;libdtrace/dt_dlibs.c +1
-0@@ -80,6 +80,7 @@ static const dt_ident_t dt_bpf_symbols[] = {DT_BPF_SYMBOL_ID (STBSZ ,DT_IDENT_SCALAR ,DT_CONST_STBSZ ),DT_BPF_SYMBOL_ID (STRSZ ,DT_IDENT_SCALAR ,DT_CONST_STRSZ ),DT_BPF_SYMBOL_ID (STKSIZ ,DT_IDENT_SCALAR ,DT_CONST_STKSIZ ), +DT_BPF_SYMBOL_ID (ERROR_PRID ,DT_IDENT_SCALAR ,DT_CONST_ERROR_PRID ),DT_BPF_SYMBOL_ID (BOOTTM ,DT_IDENT_SCALAR ,DT_CONST_BOOTTM ),DT_BPF_SYMBOL_ID (NSPEC ,DT_IDENT_SCALAR ,DT_CONST_NSPEC ), DT_BPF_SYMBOL_ID(NCPUS, DT_IDENT_SCALAR, DT_CONST_NCPUS),Signature · 7 lines
2.18.4 _______________________________________________ DTrace-devel mailing list [email protected] https://oss.oracle.com/mailman/listinfo/dtrace-devel
Re: [DTrace-devel] [PATCH 29/38] Allow relocation of the ERROR PRID
Yeah. This patch was superseded by a v2 (Jun 27), which acknowledges your point. It's "simpler" to say "3". It is arguably more robust to set the value during relocation. I figured I'd do it the "more robust" way and am happy to be talked into the simpler patch.
I'll wait for your comments on the v2 patch. If there you say the extra effort is not worth it, I'll post a v3 with the simpler version.
Quoted 60 lines · Kris Van Hees
Why is this patch needed? As far as I can see, BEGIN, END, and ERROR are always created as the first 3 probes (in that order), so they will have probe IDs 1, 2, and 3.
Quoted 55 lines · eugene.loh--- via DTrace-devel
From: Eugene Loh <[email protected]>
Signed-off-by Eugene Loh <[email protected]>--- libdtrace/dt_bpf.h | 1 + libdtrace/dt_cc.c | 3 +++ libdtrace/dt_dlibs.c | 1 + 3 files changed, 5 insertions(+)libdtrace/dt_bpf.h +1
-0@@ -56,6 +56,7 @@ extern "C" {#define DT_CONST_ZERO_OFF 22#define DT_CONST_STACK_OFF 23#define DT_CONST_STACK_SKIP 24 +#define DT_CONST_ERROR_PRID 25#define DT_BPF_LOG_SIZE_DEFAULT (UINT32_MAX >> 8)#define DT_BPF_LOG_SIZE_SMALL 4096libdtrace/dt_cc.c +3
-0@@ -1076,6 +1076,9 @@ dt_link_construct(dtrace_hdl_t *dtp, const dt_probe_t *prp, dtrace_difo_t *dp, nrp->dofr_data =sizeof (uint64_t ) * dtp->dt_options[DTRACEOPT_MAXFRAMES ];continue ; +case DT_CONST_ERROR_PRID : + nrp->dofr_data = dtp->dt_error->desc->id; +continue ;case DT_CONST_BOOTTM :if (boottime ==0 &&get_boottime ())return -1 ;libdtrace/dt_dlibs.c +1
-0@@ -80,6 +80,7 @@ static const dt_ident_t dt_bpf_symbols[] = {DT_BPF_SYMBOL_ID (STBSZ ,DT_IDENT_SCALAR ,DT_CONST_STBSZ ),DT_BPF_SYMBOL_ID (STRSZ ,DT_IDENT_SCALAR ,DT_CONST_STRSZ ),DT_BPF_SYMBOL_ID (STKSIZ ,DT_IDENT_SCALAR ,DT_CONST_STKSIZ ), +DT_BPF_SYMBOL_ID (ERROR_PRID ,DT_IDENT_SCALAR ,DT_CONST_ERROR_PRID ),DT_BPF_SYMBOL_ID (BOOTTM ,DT_IDENT_SCALAR ,DT_CONST_BOOTTM ),DT_BPF_SYMBOL_ID (NSPEC ,DT_IDENT_SCALAR ,DT_CONST_NSPEC ), DT_BPF_SYMBOL_ID(NCPUS, DT_IDENT_SCALAR, DT_CONST_NCPUS),Signature · 7 lines
2.18.4 _______________________________________________ DTrace-devel mailing list [email protected] https://oss.oracle.com/mailman/listinfo/dtrace-devel
PATCH 30/38 Allow relocation on BPF_OR instructions
In reply to [email protected]From: Eugene Loh <[email protected]>
--- libdtrace/dt_as.c | 2 ++ 1 file changed, 2 insertions(+)
libdtrace/dt_as.c +2 -0
@@ -280,6 +280,7 @@ dt_as(dt_pcb_t *pcb)case BPF_ST |BPF_MEM |BPF_DW :/* stdw */ case BPF_ALU64 |BPF_MOV |BPF_K :/* mov */ case BPF_ALU64 |BPF_ADD |BPF_K :/* add */ +case BPF_ALU64 |BPF_OR |BPF_K :/* or */ if (idp->di_flags &DT_IDFLG_BPF ) brel++;else
@@ -492,6 +493,7 @@ fail:case BPF_ST |BPF_MEM |BPF_DW :/* stdw */ case BPF_ALU64 |BPF_MOV |BPF_K :/* mov */ case BPF_ALU64 |BPF_ADD |BPF_K :/* add */ +case BPF_ALU64 |BPF_OR |BPF_K :/* or */ rp->dofr_type =R_BPF_64_32 ;break ;case BPF_LD |BPF_IMM |BPF_DW :/* lddw */
Signature · 1 line
2.18.4
Re: [PATCH 30/38] Allow relocation on BPF_OR instructions
Quoted 3 lines · On Thu, Jun 27, 2024 at 01:38:56AM -0400, [email protected] wrote:
From: Eugene Loh <[email protected]>
Signed-off-by Eugene Loh <[email protected]>
Quoted 27 lines
--- libdtrace/dt_as.c | 2 ++ 1 file changed, 2 insertions(+)libdtrace/dt_as.c +2
-0@@ -280,6 +280,7 @@ dt_as(dt_pcb_t *pcb)case BPF_ST |BPF_MEM |BPF_DW :/* stdw */ case BPF_ALU64 |BPF_MOV |BPF_K :/* mov */ case BPF_ALU64 |BPF_ADD |BPF_K :/* add */ +case BPF_ALU64 |BPF_OR |BPF_K :/* or */ if (idp->di_flags &DT_IDFLG_BPF ) brel++;else @@ -492,6 +493,7 @@ fail:case BPF_ST |BPF_MEM |BPF_DW :/* stdw */ case BPF_ALU64 |BPF_MOV |BPF_K :/* mov */ case BPF_ALU64 |BPF_ADD |BPF_K :/* add */ +case BPF_ALU64 |BPF_OR |BPF_K :/* or */ rp->dofr_type =R_BPF_64_32 ;break ;case BPF_LD |BPF_IMM |BPF_DW :/* lddw */ Signature · 1 line
2.18.4
Re: [PATCH 30/38] Allow relocation on BPF_OR instructions
Quoted 6 lines · Kris Van Hees
Quoted 3 lines · On Thu, Jun 27, 2024 at 01:38:56AM -0400, [email protected] wrote:
From: Eugene Loh <[email protected]>
Signed-off-by Eugene Loh <[email protected]>Reviewed-by Kris Van Hees <[email protected]>
As far as I can see, there is nothing that uses this anymore. I suggest we ut it in cold storage until there is a need for it? Alternatively, we could turn this into a patch that adds support for all possible operations that could require relocations like this, and introduce that to the tree instead to support future uses.
Quoted 27 lines
Quoted 27 lines
--- libdtrace/dt_as.c | 2 ++ 1 file changed, 2 insertions(+)libdtrace/dt_as.c +2
-0@@ -280,6 +280,7 @@ dt_as(dt_pcb_t *pcb)case BPF_ST |BPF_MEM |BPF_DW :/* stdw */ case BPF_ALU64 |BPF_MOV |BPF_K :/* mov */ case BPF_ALU64 |BPF_ADD |BPF_K :/* add */ +case BPF_ALU64 |BPF_OR |BPF_K :/* or */ if (idp->di_flags &DT_IDFLG_BPF ) brel++;else @@ -492,6 +493,7 @@ fail:case BPF_ST |BPF_MEM |BPF_DW :/* stdw */ case BPF_ALU64 |BPF_MOV |BPF_K :/* mov */ case BPF_ALU64 |BPF_ADD |BPF_K :/* add */ +case BPF_ALU64 |BPF_OR |BPF_K :/* or */ rp->dofr_type =R_BPF_64_32 ;break ;case BPF_LD |BPF_IMM |BPF_DW :/* lddw */ Signature · 1 line
2.18.4
Re: [PATCH 30/38] Allow relocation on BPF_OR instructions
Quoted 7 lines · Kris Van Hees
Quoted 5 lines · Kris Van Hees
Quoted 3 lines · On Thu, Jun 27, 2024 at 01:38:56AM -0400, [email protected] wrote:
From: Eugene Loh <[email protected]>
Signed-off-by Eugene Loh <[email protected]>Reviewed-by Kris Van Hees <[email protected]>As far as I can see, there is nothing that uses this anymore.
Yes. As best as I can remember, that's right.
Quoted 2 lines
I suggest we
ut it in cold storage until there is a need for it?
Sounds great.
Quoted 4 lines
Alternatively, we could
turn this into a patch that adds support for all possible operations that could require relocations like this, and introduce that to the tree instead to support future uses.
Meh.
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
--- libdtrace/dt_as.c | 2 ++ 1 file changed, 2 insertions(+)libdtrace/dt_as.c +2
-0@@ -280,6 +280,7 @@ dt_as(dt_pcb_t *pcb)case BPF_ST |BPF_MEM |BPF_DW :/* stdw */ case BPF_ALU64 |BPF_MOV |BPF_K :/* mov */ case BPF_ALU64 |BPF_ADD |BPF_K :/* add */ +case BPF_ALU64 |BPF_OR |BPF_K :/* or */ if (idp->di_flags &DT_IDFLG_BPF ) brel++;else @@ -492,6 +493,7 @@ fail:case BPF_ST |BPF_MEM |BPF_DW :/* stdw */ case BPF_ALU64 |BPF_MOV |BPF_K :/* mov */ case BPF_ALU64 |BPF_ADD |BPF_K :/* add */ +case BPF_ALU64 |BPF_OR |BPF_K :/* or */ rp->dofr_type =R_BPF_64_32 ;break ;case BPF_LD |BPF_IMM |BPF_DW :/* lddw */ Signature · 1 line
2.18.4
PATCH 31/38 Fix dt_pebs_init() call
In reply to [email protected]From: Eugene Loh <[email protected]>
The function had a few issues, mainly with its comments, ranging from typos to incorrect descriptions of behavior.
The function has only one caller. The enforcement of a size minimum was problematic in a number of respects:
- it was missing 4 bytes
- it was enforcing the minimum before the size was increased by the caller
- it was checking dt_pebs_init()==-1,
missing errors with other negative return values
So change the function to accept a minimum and change its return values.
--- libdtrace/dt_peb.c | 27 ++++++++++----------- libdtrace/dt_peb.h | 2 +- libdtrace/dt_work.c | 15 +++++++----- test/unittest/options/err.b-too-low.d | 22 +++++++++-------- test/unittest/options/err.bufsize-too-low.d | 22 +++++++++-------- test/unittest/options/tst.b.d | 22 +++++++++-------- test/unittest/options/tst.bufsize.d | 22 +++++++++-------- 7 files changed, 71 insertions(+), 61 deletions(-)
libdtrace/dt_peb.c +13 -14
@@ -136,18 +136,14 @@ dt_pebs_exit(dtrace_hdl_t *dtp) }/* -* Initialize the perf event buffers (one per online CPU). Each buffer will -* the given number of pages (i.e. the total size of each buffer will be -* num_pages * getpagesize()). The allocated memory for each buffer is mmap'd -* so the kernel can write to it, and its representative file descriptor is -* recorded in the 'buffers' BPF map so that BPF code knows where to write -* trace data for a specific CPU. +* Initialize the perf event buffers, one per online CPU. Each buffer will +* have num_pages * getpagesize()). The dt_peb_open() call mmaps the allocated +* memory so the kernel can write to it. The file descriptor is recorded in +* the 'buffers' BPF map and added to the event polling file descriptor. * -* An event polling file descriptor is created as well, and it is configured to -* monitor all perf event buffers at once. This file descriptor is returned -* upon success.. Failure is indicated with a -1 return value. +* The return value indicates success (0) or failure (-1). */ -int dt_pebs_init (dtrace_hdl_t *dtp,size_t bufsize) +int dt_pebs_init (dtrace_hdl_t *dtp,size_t bufsize,size_t bufsizemin) {int i;int mapfd;
@@ -166,12 +162,15 @@ int dt_pebs_init(dtrace_hdl_t *dtp, size_t bufsize)fprintf (stderr,"bufsize increased to %lu\n" , num_pages *getpagesize ()); +if (num_pages *getpagesize () < bufsizemin) +return dt_set_errno (dtp,EDT_BUFTOOSMALL ); +/* * Determine the fd for the 'buffers' BPF map. */ idp =dt_dlib_get_map (dtp,"buffers" );if (idp ==NULL || idp->di_id ==DT_IDENT_UNDEF ) -return -ENOENT ; +return dt_set_errno (dtp,EDT_NOMEM );// FIXME we used to do something more akin to ENOENT mapfd = idp->di_id;
@@ -180,7 +179,7 @@ int dt_pebs_init(dtrace_hdl_t *dtp, size_t bufsize)*/ dtp->dt_pebset =dt_zalloc (dtp,sizeof (dt_pebset_t));if (dtp->dt_pebset ==NULL ) -return -ENOMEM ; +return dt_set_errno (dtp,EDT_NOMEM );/* * Allocate the per-CPU perf event buffers.
@@ -189,7 +188,7 @@ int dt_pebs_init(dtrace_hdl_t *dtp, size_t bufsize) sizeof(struct dt_peb));if (pebs ==NULL ) {dt_free (dtp, dtp->dt_pebset); -return -ENOMEM ; +return dt_set_errno (dtp,EDT_NOMEM ); } dtp->dt_pebset->pebs = pebs;
@@ -241,5 +240,5 @@ int dt_pebs_init(dtrace_hdl_t *dtp, size_t bufsize) fail:dt_pebs_exit (dtp); -return -1 ; +return dt_set_errno (dtp,EDT_NOMEM );// FIXME need something better }
libdtrace/dt_peb.h +1 -1
@@ -43,7 +43,7 @@ typedef struct dt_pebset { } dt_pebset_t;extern void dt_pebs_exit (dtrace_hdl_t *); -extern int dt_pebs_init (dtrace_hdl_t *,size_t ); +extern int dt_pebs_init (dtrace_hdl_t *,size_t ,size_t ); #ifdef __cplusplus }
libdtrace/dt_work.c +9 -6
@@ -267,18 +267,21 @@ 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 +* We need enough space for the perf_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. +* +* While dt_pebs_init() rounds the requested size up, size==0 is a +* special case. */ dtrace_getopt (dtp,"bufsize" , &size); -if (size ==0 || - size <sizeof (struct perf_event_header ) +sizeof (uint32_t ) + - dtp->dt_maxreclen) +if (size ==0 )return dt_set_errno (dtp,EDT_BUFTOOSMALL ); -if (dt_pebs_init (dtp, size) ==-1 ) -return dt_set_errno (dtp,EDT_NOMEM ); +if (dt_pebs_init (dtp, size, +sizeof (struct perf_event_header ) +sizeof (uint32_t ) + +4 + dtp->dt_maxreclen) ==-1 ) +return -1 ;/* * We must initialize the aggregation consumer handling before we
test/unittest/options/err.b-too-low.d +12 -10
@@ -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,19 +12,21 @@ */ /* - * We use a buffer size of 59 because that should be just too small to hold the - * trace records generated in this script: - * - perf_event_header (40 bytes) - * - size (4 bytes) - * - gap (4 bytes) - * - EPID (4 bytes) - * - tag (4 bytes) - * - exit value (4 bytes) + * We need over 4k bytes for the 4 string trace records generated in this script + * plus some meta data. + * A bufsize of 1 to 4096 bytes is rounded up to 4096 and is insufficient. + * A bufsize of 4097 to 8192 bytes is rounded up to 8192 and is sufficient. */ -/* @@runtest-opts: -b59 */ +/* @@runtest-opts: -b4096 */ + +#pragma D option strsize=1024 BEGIN { + trace("abc"); + trace("def"); + trace("ghi"); + trace("jkl"); exit(0); }
test/unittest/options/err.bufsize-too-low.d +12 -10
@@ -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,19 +12,21 @@ */ /* - * We use a buffer size of 59 because that should be just too small to hold the - * trace records generated in this script: - * - perf_event_header (40 bytes) - * - size (4 bytes) - * - gap (4 bytes) - * - EPID (4 bytes) - * - tag (4 bytes) - * - exit value (4 bytes) + * We need over 4k bytes for the 4 string trace records generated in this script + * plus some meta data. + * A bufsize of 1 to 4096 bytes is rounded up to 4096 and is insufficient. + * A bufsize of 4097 to 8192 bytes is rounded up to 8192 and is sufficient. */ -/* @@runtest-opts: -xbufsize=59 */ +/* @@runtest-opts: -xbufsize=4096 */ + +#pragma D option strsize=1024 BEGIN { + trace("abc"); + trace("def"); + trace("ghi"); + trace("jkl"); exit(0); }
test/unittest/options/tst.b.d +12 -10
@@ -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,19 +12,21 @@ */ /* - * 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) - * - size (4 bytes) - * - gap (4 bytes) - * - EPID (4 bytes) - * - tag (4 bytes) - * - exit value (4 bytes) + * We need over 4k bytes for the 4 string trace records generated in this script + * plus some meta data. + * A bufsize of 1 to 4096 bytes is rounded up to 4096 and is insufficient. + * A bufsize of 4097 to 8192 bytes is rounded up to 8192 and is sufficient. */ -/* @@runtest-opts: -b60 */ +/* @@runtest-opts: -b4097 */ + +#pragma D option strsize=1024 BEGIN { + trace("abc"); + trace("def"); + trace("ghi"); + trace("jkl"); exit(0); }
test/unittest/options/tst.bufsize.d +12 -10
@@ -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,19 +12,21 @@ */ /* - * 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) - * - size (4 bytes) - * - gap (4 bytes) - * - EPID (4 bytes) - * - tag (4 bytes) - * - exit value (4 bytes) + * We need over 4k bytes for the 4 string trace records generated in this script + * plus some meta data. + * A bufsize of 1 to 4096 bytes is rounded up to 4096 and is insufficient. + * A bufsize of 4097 to 8192 bytes is rounded up to 8192 and is sufficient. */ -/* @@runtest-opts: -xbufsize=60 */ +/* @@runtest-opts: -xbufsize=4097 */ + +#pragma D option strsize=1024 BEGIN { + trace("abc"); + trace("def"); + trace("ghi"); + trace("jkl"); exit(0); }
Signature · 1 line
2.18.4
Re: [PATCH 31/38] Fix dt_pebs_init() call
This patch goes against the intent of the code, as far as I can see. The point of performing the size check prior to increasing the buffer size was to enforce the limit on the size that was explicit set by the user. Then, if that size was sufficient, then DTrace is at liberty to increase that size to a whole multiple of the page size.
But if I were to insist that a buffer can only be 24 bytes, and 24 bytes are not enough to store a single trace record, DTrace should report an error rather than increasing my bufsize setting on its own.
Quoted 318 lines · On Thu, Jun 27, 2024 at 01:38:57AM -0400, [email protected] wrote:
From: Eugene Loh <[email protected]>
The function had a few issues, mainly with its comments, ranging from typos to incorrect descriptions of behavior.
The function has only one caller. The enforcement of a size minimum was problematic in a number of respects:
- it was missing 4 bytes
- it was enforcing the minimum before the size was increased by the caller
- it was checking dt_pebs_init()==-1,
missing errors with other negative return valuesSo change the function to accept a minimum and change its return values.
Signed-off-by Eugene Loh <[email protected]>--- libdtrace/dt_peb.c | 27 ++++++++++----------- libdtrace/dt_peb.h | 2 +- libdtrace/dt_work.c | 15 +++++++----- test/unittest/options/err.b-too-low.d | 22 +++++++++-------- test/unittest/options/err.bufsize-too-low.d | 22 +++++++++-------- test/unittest/options/tst.b.d | 22 +++++++++-------- test/unittest/options/tst.bufsize.d | 22 +++++++++-------- 7 files changed, 71 insertions(+), 61 deletions(-)libdtrace/dt_peb.c +13
-14@@ -136,18 +136,14 @@ dt_pebs_exit(dtrace_hdl_t *dtp) }/* -* Initialize the perf event buffers (one per online CPU). Each buffer will -* the given number of pages (i.e. the total size of each buffer will be -* num_pages * getpagesize()). The allocated memory for each buffer is mmap'd -* so the kernel can write to it, and its representative file descriptor is -* recorded in the 'buffers' BPF map so that BPF code knows where to write -* trace data for a specific CPU. +* Initialize the perf event buffers, one per online CPU. Each buffer will +* have num_pages * getpagesize()). The dt_peb_open() call mmaps the allocated +* memory so the kernel can write to it. The file descriptor is recorded in +* the 'buffers' BPF map and added to the event polling file descriptor. * -* An event polling file descriptor is created as well, and it is configured to -* monitor all perf event buffers at once. This file descriptor is returned -* upon success.. Failure is indicated with a -1 return value. +* The return value indicates success (0) or failure (-1). */ -int dt_pebs_init (dtrace_hdl_t *dtp,size_t bufsize) +int dt_pebs_init (dtrace_hdl_t *dtp,size_t bufsize,size_t bufsizemin) {int i;int mapfd;@@ -166,12 +162,15 @@ int dt_pebs_init(dtrace_hdl_t *dtp, size_t bufsize)fprintf (stderr,"bufsize increased to %lu\n" , num_pages *getpagesize ()); +if (num_pages *getpagesize () < bufsizemin) +return dt_set_errno (dtp,EDT_BUFTOOSMALL ); +/* * Determine the fd for the 'buffers' BPF map. */ idp =dt_dlib_get_map (dtp,"buffers" );if (idp ==NULL || idp->di_id ==DT_IDENT_UNDEF ) -return -ENOENT ; +return dt_set_errno (dtp,EDT_NOMEM );// FIXME we used to do something more akin to ENOENT mapfd = idp->di_id;@@ -180,7 +179,7 @@ int dt_pebs_init(dtrace_hdl_t *dtp, size_t bufsize)*/ dtp->dt_pebset =dt_zalloc (dtp,sizeof (dt_pebset_t));if (dtp->dt_pebset ==NULL ) -return -ENOMEM ; +return dt_set_errno (dtp,EDT_NOMEM );/* * Allocate the per-CPU perf event buffers. @@ -189,7 +188,7 @@ int dt_pebs_init(dtrace_hdl_t *dtp, size_t bufsize) sizeof(struct dt_peb));if (pebs ==NULL ) {dt_free (dtp, dtp->dt_pebset); -return -ENOMEM ; +return dt_set_errno (dtp,EDT_NOMEM ); } dtp->dt_pebset->pebs = pebs;@@ -241,5 +240,5 @@ int dt_pebs_init(dtrace_hdl_t *dtp, size_t bufsize) fail:dt_pebs_exit (dtp); -return -1 ; +return dt_set_errno (dtp,EDT_NOMEM );// FIXME need something better }libdtrace/dt_peb.h +1
-1@@ -43,7 +43,7 @@ typedef struct dt_pebset { } dt_pebset_t;extern void dt_pebs_exit (dtrace_hdl_t *); -extern int dt_pebs_init (dtrace_hdl_t *,size_t ); +extern int dt_pebs_init (dtrace_hdl_t *,size_t ,size_t ); #ifdef __cplusplus }libdtrace/dt_work.c +9
-6@@ -267,18 +267,21 @@ 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 +* We need enough space for the perf_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. +* +* While dt_pebs_init() rounds the requested size up, size==0 is a +* special case. */ dtrace_getopt (dtp,"bufsize" , &size); -if (size ==0 || - size <sizeof (struct perf_event_header ) +sizeof (uint32_t ) + - dtp->dt_maxreclen) +if (size ==0 )return dt_set_errno (dtp,EDT_BUFTOOSMALL ); -if (dt_pebs_init (dtp, size) ==-1 ) -return dt_set_errno (dtp,EDT_NOMEM ); +if (dt_pebs_init (dtp, size, +sizeof (struct perf_event_header ) +sizeof (uint32_t ) + +4 + dtp->dt_maxreclen) ==-1 ) +return -1 ;/* * We must initialize the aggregation consumer handling before we test/unittest/options/err.b-too-low.d +12
-10@@ -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,19 +12,21 @@ */ /* - * We use a buffer size of 59 because that should be just too small to hold the - * trace records generated in this script: - * - perf_event_header (40 bytes) - * - size (4 bytes) - * - gap (4 bytes) - * - EPID (4 bytes) - * - tag (4 bytes) - * - exit value (4 bytes) + * We need over 4k bytes for the 4 string trace records generated in this script + * plus some meta data. + * A bufsize of 1 to 4096 bytes is rounded up to 4096 and is insufficient. + * A bufsize of 4097 to 8192 bytes is rounded up to 8192 and is sufficient. */ -/* @@runtest-opts: -b59 */ +/* @@runtest-opts: -b4096 */ + +#pragma D option strsize=1024 BEGIN { + trace("abc"); + trace("def"); + trace("ghi"); + trace("jkl"); exit(0); }test/unittest/options/err.bufsize-too-low.d +12
-10@@ -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,19 +12,21 @@ */ /* - * We use a buffer size of 59 because that should be just too small to hold the - * trace records generated in this script: - * - perf_event_header (40 bytes) - * - size (4 bytes) - * - gap (4 bytes) - * - EPID (4 bytes) - * - tag (4 bytes) - * - exit value (4 bytes) + * We need over 4k bytes for the 4 string trace records generated in this script + * plus some meta data. + * A bufsize of 1 to 4096 bytes is rounded up to 4096 and is insufficient. + * A bufsize of 4097 to 8192 bytes is rounded up to 8192 and is sufficient. */ -/* @@runtest-opts: -xbufsize=59 */ +/* @@runtest-opts: -xbufsize=4096 */ + +#pragma D option strsize=1024 BEGIN { + trace("abc"); + trace("def"); + trace("ghi"); + trace("jkl"); exit(0); }test/unittest/options/tst.b.d +12
-10@@ -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,19 +12,21 @@ */ /* - * 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) - * - size (4 bytes) - * - gap (4 bytes) - * - EPID (4 bytes) - * - tag (4 bytes) - * - exit value (4 bytes) + * We need over 4k bytes for the 4 string trace records generated in this script + * plus some meta data. + * A bufsize of 1 to 4096 bytes is rounded up to 4096 and is insufficient. + * A bufsize of 4097 to 8192 bytes is rounded up to 8192 and is sufficient. */ -/* @@runtest-opts: -b60 */ +/* @@runtest-opts: -b4097 */ + +#pragma D option strsize=1024 BEGIN { + trace("abc"); + trace("def"); + trace("ghi"); + trace("jkl"); exit(0); }test/unittest/options/tst.bufsize.d +12
-10@@ -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,19 +12,21 @@ */ /* - * 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) - * - size (4 bytes) - * - gap (4 bytes) - * - EPID (4 bytes) - * - tag (4 bytes) - * - exit value (4 bytes) + * We need over 4k bytes for the 4 string trace records generated in this script + * plus some meta data. + * A bufsize of 1 to 4096 bytes is rounded up to 4096 and is insufficient. + * A bufsize of 4097 to 8192 bytes is rounded up to 8192 and is sufficient. */ -/* @@runtest-opts: -xbufsize=60 */ +/* @@runtest-opts: -xbufsize=4097 */ + +#pragma D option strsize=1024 BEGIN { + trace("abc"); + trace("def"); + trace("ghi"); + trace("jkl"); exit(0); }Signature · 1 line
2.18.4
Re: [PATCH 31/38] Fix dt_pebs_init() call
Quoted 9 lines · Kris Van Hees
This patch goes against the intent of the code, as far as I can see. The point of performing the size check prior to increasing the buffer size was to enforce the limit on the size that was explicit set by the user. Then, if that size was sufficient, then DTrace is at liberty to increase that size to a whole multiple of the page size.
But if I were to insist that a buffer can only be 24 bytes, and 24 bytes are not enough to store a single trace record, DTrace should report an error rather than increasing my bufsize setting on its own.
The point is that DTrace *does* increase my bufsize setting on its own. Why should DTrace complain about my setting when it's going to ignore my setting anyhow? What value does the pre-existing behavior offer to DTrace users? Are you saying that DTrace should not resize? That it should honor the user's bufsize? No more resizing (to page size or whatever it wants)?
Quoted 319 lines · On Thu, Jun 27, 2024 at 01:38:57AM -0400, [email protected] wrote:
Quoted 318 lines
From: Eugene Loh <[email protected]>
The function had a few issues, mainly with its comments, ranging from typos to incorrect descriptions of behavior.
The function has only one caller. The enforcement of a size minimum was problematic in a number of respects:
- it was missing 4 bytes
- it was enforcing the minimum before the size was increased by the caller
- it was checking dt_pebs_init()==-1,
missing errors with other negative return valuesSo change the function to accept a minimum and change its return values.
Signed-off-by Eugene Loh <[email protected]>--- libdtrace/dt_peb.c | 27 ++++++++++----------- libdtrace/dt_peb.h | 2 +- libdtrace/dt_work.c | 15 +++++++----- test/unittest/options/err.b-too-low.d | 22 +++++++++-------- test/unittest/options/err.bufsize-too-low.d | 22 +++++++++-------- test/unittest/options/tst.b.d | 22 +++++++++-------- test/unittest/options/tst.bufsize.d | 22 +++++++++-------- 7 files changed, 71 insertions(+), 61 deletions(-)libdtrace/dt_peb.c +13
-14@@ -136,18 +136,14 @@ dt_pebs_exit(dtrace_hdl_t *dtp) }/* -* Initialize the perf event buffers (one per online CPU). Each buffer will -* the given number of pages (i.e. the total size of each buffer will be -* num_pages * getpagesize()). The allocated memory for each buffer is mmap'd -* so the kernel can write to it, and its representative file descriptor is -* recorded in the 'buffers' BPF map so that BPF code knows where to write -* trace data for a specific CPU. +* Initialize the perf event buffers, one per online CPU. Each buffer will +* have num_pages * getpagesize()). The dt_peb_open() call mmaps the allocated +* memory so the kernel can write to it. The file descriptor is recorded in +* the 'buffers' BPF map and added to the event polling file descriptor. * -* An event polling file descriptor is created as well, and it is configured to -* monitor all perf event buffers at once. This file descriptor is returned -* upon success.. Failure is indicated with a -1 return value. +* The return value indicates success (0) or failure (-1). */ -int dt_pebs_init (dtrace_hdl_t *dtp,size_t bufsize) +int dt_pebs_init (dtrace_hdl_t *dtp,size_t bufsize,size_t bufsizemin) {int i;int mapfd;@@ -166,12 +162,15 @@ int dt_pebs_init(dtrace_hdl_t *dtp, size_t bufsize)fprintf (stderr,"bufsize increased to %lu\n" , num_pages *getpagesize ()); +if (num_pages *getpagesize () < bufsizemin) +return dt_set_errno (dtp,EDT_BUFTOOSMALL ); +/* * Determine the fd for the 'buffers' BPF map. */ idp =dt_dlib_get_map (dtp,"buffers" );if (idp ==NULL || idp->di_id ==DT_IDENT_UNDEF ) -return -ENOENT ; +return dt_set_errno (dtp,EDT_NOMEM );// FIXME we used to do something more akin to ENOENT mapfd = idp->di_id;@@ -180,7 +179,7 @@ int dt_pebs_init(dtrace_hdl_t *dtp, size_t bufsize)*/ dtp->dt_pebset =dt_zalloc (dtp,sizeof (dt_pebset_t));if (dtp->dt_pebset ==NULL ) -return -ENOMEM ; +return dt_set_errno (dtp,EDT_NOMEM );/* * Allocate the per-CPU perf event buffers. @@ -189,7 +188,7 @@ int dt_pebs_init(dtrace_hdl_t *dtp, size_t bufsize) sizeof(struct dt_peb));if (pebs ==NULL ) {dt_free (dtp, dtp->dt_pebset); -return -ENOMEM ; +return dt_set_errno (dtp,EDT_NOMEM ); } dtp->dt_pebset->pebs = pebs;@@ -241,5 +240,5 @@ int dt_pebs_init(dtrace_hdl_t *dtp, size_t bufsize) fail:dt_pebs_exit (dtp); -return -1 ; +return dt_set_errno (dtp,EDT_NOMEM );// FIXME need something better }libdtrace/dt_peb.h +1
-1@@ -43,7 +43,7 @@ typedef struct dt_pebset { } dt_pebset_t;extern void dt_pebs_exit (dtrace_hdl_t *); -extern int dt_pebs_init (dtrace_hdl_t *,size_t ); +extern int dt_pebs_init (dtrace_hdl_t *,size_t ,size_t ); #ifdef __cplusplus }libdtrace/dt_work.c +9
-6@@ -267,18 +267,21 @@ 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 +* We need enough space for the perf_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. +* +* While dt_pebs_init() rounds the requested size up, size==0 is a +* special case. */ dtrace_getopt (dtp,"bufsize" , &size); -if (size ==0 || - size <sizeof (struct perf_event_header ) +sizeof (uint32_t ) + - dtp->dt_maxreclen) +if (size ==0 )return dt_set_errno (dtp,EDT_BUFTOOSMALL ); -if (dt_pebs_init (dtp, size) ==-1 ) -return dt_set_errno (dtp,EDT_NOMEM ); +if (dt_pebs_init (dtp, size, +sizeof (struct perf_event_header ) +sizeof (uint32_t ) + +4 + dtp->dt_maxreclen) ==-1 ) +return -1 ;/* * We must initialize the aggregation consumer handling before we test/unittest/options/err.b-too-low.d +12
-10@@ -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,19 +12,21 @@ */ /* - * We use a buffer size of 59 because that should be just too small to hold the - * trace records generated in this script: - * - perf_event_header (40 bytes) - * - size (4 bytes) - * - gap (4 bytes) - * - EPID (4 bytes) - * - tag (4 bytes) - * - exit value (4 bytes) + * We need over 4k bytes for the 4 string trace records generated in this script + * plus some meta data. + * A bufsize of 1 to 4096 bytes is rounded up to 4096 and is insufficient. + * A bufsize of 4097 to 8192 bytes is rounded up to 8192 and is sufficient. */ -/* @@runtest-opts: -b59 */ +/* @@runtest-opts: -b4096 */ + +#pragma D option strsize=1024 BEGIN { + trace("abc"); + trace("def"); + trace("ghi"); + trace("jkl"); exit(0); }test/unittest/options/err.bufsize-too-low.d +12
-10@@ -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,19 +12,21 @@ */ /* - * We use a buffer size of 59 because that should be just too small to hold the - * trace records generated in this script: - * - perf_event_header (40 bytes) - * - size (4 bytes) - * - gap (4 bytes) - * - EPID (4 bytes) - * - tag (4 bytes) - * - exit value (4 bytes) + * We need over 4k bytes for the 4 string trace records generated in this script + * plus some meta data. + * A bufsize of 1 to 4096 bytes is rounded up to 4096 and is insufficient. + * A bufsize of 4097 to 8192 bytes is rounded up to 8192 and is sufficient. */ -/* @@runtest-opts: -xbufsize=59 */ +/* @@runtest-opts: -xbufsize=4096 */ + +#pragma D option strsize=1024 BEGIN { + trace("abc"); + trace("def"); + trace("ghi"); + trace("jkl"); exit(0); }test/unittest/options/tst.b.d +12
-10@@ -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,19 +12,21 @@ */ /* - * 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) - * - size (4 bytes) - * - gap (4 bytes) - * - EPID (4 bytes) - * - tag (4 bytes) - * - exit value (4 bytes) + * We need over 4k bytes for the 4 string trace records generated in this script + * plus some meta data. + * A bufsize of 1 to 4096 bytes is rounded up to 4096 and is insufficient. + * A bufsize of 4097 to 8192 bytes is rounded up to 8192 and is sufficient. */ -/* @@runtest-opts: -b60 */ +/* @@runtest-opts: -b4097 */ + +#pragma D option strsize=1024 BEGIN { + trace("abc"); + trace("def"); + trace("ghi"); + trace("jkl"); exit(0); }test/unittest/options/tst.bufsize.d +12
-10@@ -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,19 +12,21 @@ */ /* - * 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) - * - size (4 bytes) - * - gap (4 bytes) - * - EPID (4 bytes) - * - tag (4 bytes) - * - exit value (4 bytes) + * We need over 4k bytes for the 4 string trace records generated in this script + * plus some meta data. + * A bufsize of 1 to 4096 bytes is rounded up to 4096 and is insufficient. + * A bufsize of 4097 to 8192 bytes is rounded up to 8192 and is sufficient. */ -/* @@runtest-opts: -xbufsize=60 */ +/* @@runtest-opts: -xbufsize=4097 */ + +#pragma D option strsize=1024 BEGIN { + trace("abc"); + trace("def"); + trace("ghi"); + trace("jkl"); exit(0); }Signature · 1 line
2.18.4
Re: [PATCH 31/38] Fix dt_pebs_init() call
Quoted 13 lines · Eugene Loh
Quoted 9 lines · Kris Van Hees
This patch goes against the intent of the code, as far as I can see. The point of performing the size check prior to increasing the buffer size was to enforce the limit on the size that was explicit set by the user. Then, if that size was sufficient, then DTrace is at liberty to increase that size to a whole multiple of the page size.
But if I were to insist that a buffer can only be 24 bytes, and 24 bytes are not enough to store a single trace record, DTrace should report an error rather than increasing my bufsize setting on its own.
Quoted 5 lines
The point is that DTrace *does* increase my bufsize setting on its own. Why should DTrace complain about my setting when it's going to ignore my setting anyhow? What value does the pre-existing behavior offer to DTrace users? Are you saying that DTrace should not resize? That it should honor the user's bufsize? No more resizing (to page size or whatever it wants)?
The main point of this code was to retain the bevhaviour that DTrace provided, which is that if a user explicitly requests a bufsize that is less than the minimum required for the given trace programs, an error is reported. That is a mater of being consistent (even if it has no practical application that I can see). Tests from the existing version failed because this was not being done right.
As far as functionality, as long as the bufsize is large enough to hold the largest trace record, DTrace can (and needs to) ensure that the buffer size is a whole multiple of the page size because that is required by the perf ring buffer imlementation.
So, DTrace only increases the buffer size to the required multiple of page size if the user supplied bufsize is at least large enough to hold the largest trace record (or if no bufsize was explicitly specified).
We could opt to change the behaviour of the bufsize opton to always round up to a whole multiple of page size, but that is a deviation from the original implementation and thus is something that would need to be documented, etc...
Aside from the computation of the minimum required size needing updating when patches (e.g. the USDT changes) modify the layout and size of the trace records, I do not think that the existing code is wrong.
I am certainly open to a feature change to make bufsize always be rounded up as needed, but that is not a bug fix and I think that ought to be its own patch (along with documentation changes etc). And it might need some more discussion because it brings up the question why we wouldn't just simply always increase bufsize to be the smallest multiple of the page size to accomodate the largest trace record.
Quoted 296 lines
Quoted 296 lines · On Thu, Jun 27, 2024 at 01:38:57AM -0400, [email protected] wrote:
Quoted 295 lines
From: Eugene Loh <[email protected]>
The function had a few issues, mainly with its comments, ranging from typos to incorrect descriptions of behavior.
The function has only one caller. The enforcement of a size minimum was problematic in a number of respects:
- it was missing 4 bytes
- it was enforcing the minimum before the size was increased by the caller
- it was checking dt_pebs_init()==-1,
missing errors with other negative return valuesSo change the function to accept a minimum and change its return values.
Signed-off-by Eugene Loh <[email protected]>--- libdtrace/dt_peb.c | 27 ++++++++++----------- libdtrace/dt_peb.h | 2 +- libdtrace/dt_work.c | 15 +++++++----- test/unittest/options/err.b-too-low.d | 22 +++++++++-------- test/unittest/options/err.bufsize-too-low.d | 22 +++++++++-------- test/unittest/options/tst.b.d | 22 +++++++++-------- test/unittest/options/tst.bufsize.d | 22 +++++++++-------- 7 files changed, 71 insertions(+), 61 deletions(-)libdtrace/dt_peb.c +13
-14@@ -136,18 +136,14 @@ dt_pebs_exit(dtrace_hdl_t *dtp) }/* -* Initialize the perf event buffers (one per online CPU). Each buffer will -* the given number of pages (i.e. the total size of each buffer will be -* num_pages * getpagesize()). The allocated memory for each buffer is mmap'd -* so the kernel can write to it, and its representative file descriptor is -* recorded in the 'buffers' BPF map so that BPF code knows where to write -* trace data for a specific CPU. +* Initialize the perf event buffers, one per online CPU. Each buffer will +* have num_pages * getpagesize()). The dt_peb_open() call mmaps the allocated +* memory so the kernel can write to it. The file descriptor is recorded in +* the 'buffers' BPF map and added to the event polling file descriptor. * -* An event polling file descriptor is created as well, and it is configured to -* monitor all perf event buffers at once. This file descriptor is returned -* upon success.. Failure is indicated with a -1 return value. +* The return value indicates success (0) or failure (-1). */ -int dt_pebs_init (dtrace_hdl_t *dtp,size_t bufsize) +int dt_pebs_init (dtrace_hdl_t *dtp,size_t bufsize,size_t bufsizemin) {int i;int mapfd;@@ -166,12 +162,15 @@ int dt_pebs_init(dtrace_hdl_t *dtp, size_t bufsize)fprintf (stderr,"bufsize increased to %lu\n" , num_pages *getpagesize ()); +if (num_pages *getpagesize () < bufsizemin) +return dt_set_errno (dtp,EDT_BUFTOOSMALL ); +/* * Determine the fd for the 'buffers' BPF map. */ idp =dt_dlib_get_map (dtp,"buffers" );if (idp ==NULL || idp->di_id ==DT_IDENT_UNDEF ) -return -ENOENT ; +return dt_set_errno (dtp,EDT_NOMEM );// FIXME we used to do something more akin to ENOENT mapfd = idp->di_id;@@ -180,7 +179,7 @@ int dt_pebs_init(dtrace_hdl_t *dtp, size_t bufsize)*/ dtp->dt_pebset =dt_zalloc (dtp,sizeof (dt_pebset_t));if (dtp->dt_pebset ==NULL ) -return -ENOMEM ; +return dt_set_errno (dtp,EDT_NOMEM );/* * Allocate the per-CPU perf event buffers. @@ -189,7 +188,7 @@ int dt_pebs_init(dtrace_hdl_t *dtp, size_t bufsize) sizeof(struct dt_peb));if (pebs ==NULL ) {dt_free (dtp, dtp->dt_pebset); -return -ENOMEM ; +return dt_set_errno (dtp,EDT_NOMEM ); } dtp->dt_pebset->pebs = pebs;@@ -241,5 +240,5 @@ int dt_pebs_init(dtrace_hdl_t *dtp, size_t bufsize) fail:dt_pebs_exit (dtp); -return -1 ; +return dt_set_errno (dtp,EDT_NOMEM );// FIXME need something better }libdtrace/dt_peb.h +1
-1@@ -43,7 +43,7 @@ typedef struct dt_pebset { } dt_pebset_t;extern void dt_pebs_exit (dtrace_hdl_t *); -extern int dt_pebs_init (dtrace_hdl_t *,size_t ); +extern int dt_pebs_init (dtrace_hdl_t *,size_t ,size_t ); #ifdef __cplusplus }libdtrace/dt_work.c +9
-6@@ -267,18 +267,21 @@ 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 +* We need enough space for the perf_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. +* +* While dt_pebs_init() rounds the requested size up, size==0 is a +* special case. */ dtrace_getopt (dtp,"bufsize" , &size); -if (size ==0 || - size <sizeof (struct perf_event_header ) +sizeof (uint32_t ) + - dtp->dt_maxreclen) +if (size ==0 )return dt_set_errno (dtp,EDT_BUFTOOSMALL ); -if (dt_pebs_init (dtp, size) ==-1 ) -return dt_set_errno (dtp,EDT_NOMEM ); +if (dt_pebs_init (dtp, size, +sizeof (struct perf_event_header ) +sizeof (uint32_t ) + +4 + dtp->dt_maxreclen) ==-1 ) +return -1 ;/* * We must initialize the aggregation consumer handling before we test/unittest/options/err.b-too-low.d +12
-10@@ -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,19 +12,21 @@ */ /* - * We use a buffer size of 59 because that should be just too small to hold the - * trace records generated in this script: - * - perf_event_header (40 bytes) - * - size (4 bytes) - * - gap (4 bytes) - * - EPID (4 bytes) - * - tag (4 bytes) - * - exit value (4 bytes) + * We need over 4k bytes for the 4 string trace records generated in this script + * plus some meta data. + * A bufsize of 1 to 4096 bytes is rounded up to 4096 and is insufficient. + * A bufsize of 4097 to 8192 bytes is rounded up to 8192 and is sufficient. */ -/* @@runtest-opts: -b59 */ +/* @@runtest-opts: -b4096 */ + +#pragma D option strsize=1024 BEGIN { + trace("abc"); + trace("def"); + trace("ghi"); + trace("jkl"); exit(0); }test/unittest/options/err.bufsize-too-low.d +12
-10@@ -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,19 +12,21 @@ */ /* - * We use a buffer size of 59 because that should be just too small to hold the - * trace records generated in this script: - * - perf_event_header (40 bytes) - * - size (4 bytes) - * - gap (4 bytes) - * - EPID (4 bytes) - * - tag (4 bytes) - * - exit value (4 bytes) + * We need over 4k bytes for the 4 string trace records generated in this script + * plus some meta data. + * A bufsize of 1 to 4096 bytes is rounded up to 4096 and is insufficient. + * A bufsize of 4097 to 8192 bytes is rounded up to 8192 and is sufficient. */ -/* @@runtest-opts: -xbufsize=59 */ +/* @@runtest-opts: -xbufsize=4096 */ + +#pragma D option strsize=1024 BEGIN { + trace("abc"); + trace("def"); + trace("ghi"); + trace("jkl"); exit(0); }test/unittest/options/tst.b.d +12
-10@@ -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,19 +12,21 @@ */ /* - * 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) - * - size (4 bytes) - * - gap (4 bytes) - * - EPID (4 bytes) - * - tag (4 bytes) - * - exit value (4 bytes) + * We need over 4k bytes for the 4 string trace records generated in this script + * plus some meta data. + * A bufsize of 1 to 4096 bytes is rounded up to 4096 and is insufficient. + * A bufsize of 4097 to 8192 bytes is rounded up to 8192 and is sufficient. */ -/* @@runtest-opts: -b60 */ +/* @@runtest-opts: -b4097 */ + +#pragma D option strsize=1024 BEGIN { + trace("abc"); + trace("def"); + trace("ghi"); + trace("jkl"); exit(0); }test/unittest/options/tst.bufsize.d +12
-10@@ -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,19 +12,21 @@ */ /* - * 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) - * - size (4 bytes) - * - gap (4 bytes) - * - EPID (4 bytes) - * - tag (4 bytes) - * - exit value (4 bytes) + * We need over 4k bytes for the 4 string trace records generated in this script + * plus some meta data. + * A bufsize of 1 to 4096 bytes is rounded up to 4096 and is insufficient. + * A bufsize of 4097 to 8192 bytes is rounded up to 8192 and is sufficient. */ -/* @@runtest-opts: -xbufsize=60 */ +/* @@runtest-opts: -xbufsize=4097 */ + +#pragma D option strsize=1024 BEGIN { + trace("abc"); + trace("def"); + trace("ghi"); + trace("jkl"); exit(0); }Signature · 1 line
2.18.4
Re: [PATCH 31/38] Fix dt_pebs_init() call
Quoted 13 lines · Kris Van Hees
Quoted 12 lines · Eugene Loh
Quoted 9 lines · Kris Van Hees
This patch goes against the intent of the code, as far as I can see. The point of performing the size check prior to increasing the buffer size was to enforce the limit on the size that was explicit set by the user. Then, if that size was sufficient, then DTrace is at liberty to increase that size to a whole multiple of the page size.
But if I were to insist that a buffer can only be 24 bytes, and 24 bytes are not enough to store a single trace record, DTrace should report an error rather than increasing my bufsize setting on its own.
Quoted 6 lines
Quoted 5 lines
The point is that DTrace *does* increase my bufsize setting on its own. Why should DTrace complain about my setting when it's going to ignore my setting anyhow? What value does the pre-existing behavior offer to DTrace users? Are you saying that DTrace should not resize? That it should honor the user's bufsize? No more resizing (to page size or whatever it wants)?
The main point of this code was to retain the bevhaviour that DTrace provided,
As far as adhering to legacy behavior... quite simply, we do not. We do not set the "principal buffer size" to bufsize. Further, any legacy resizing behavior is, if I understand correctly, to go smaller than the user requested; we do the opposite. Looking to the legacy behavior for precedent is pointless. The situation is that we are unlike legacy behavior in fundamental respects, opposite in another respect (automatic resizing), but consistent in some impractical and useless respect. That consistency strikes me as small consolation.
There is no documentation to change; the documentation is already wrong. This patch was intended as a step to making the behavior something that was describable. Clearly, trying to hold on to a legacy buffering model has produced a byzantine situation in the current port, which treats buffering very differently.
Perhaps we simply disagree on those points, and this patch is DOA. But the patch points out other problems as well. E.g., the min computation wasn't even right and error checking was wrong.
Quoted 326 lines
which is that if a user explicitly requests a bufsize that is less than the minimum required for the given trace programs, an error is reported. That is a mater of being consistent (even if it has no practical application that I can see). Tests from the existing version failed because this was not being done right.
As far as functionality, as long as the bufsize is large enough to hold the largest trace record, DTrace can (and needs to) ensure that the buffer size is a whole multiple of the page size because that is required by the perf ring buffer imlementation.
So, DTrace only increases the buffer size to the required multiple of page size if the user supplied bufsize is at least large enough to hold the largest trace record (or if no bufsize was explicitly specified).
We could opt to change the behaviour of the bufsize opton to always round up to a whole multiple of page size, but that is a deviation from the original implementation and thus is something that would need to be documented, etc...
Aside from the computation of the minimum required size needing updating when patches (e.g. the USDT changes) modify the layout and size of the trace records, I do not think that the existing code is wrong.
I am certainly open to a feature change to make bufsize always be rounded up as needed, but that is not a bug fix and I think that ought to be its own patch (along with documentation changes etc). And it might need some more discussion because it brings up the question why we wouldn't just simply always increase bufsize to be the smallest multiple of the page size to accomodate the largest trace record.
Quoted 296 lines
Quoted 296 lines · On Thu, Jun 27, 2024 at 01:38:57AM -0400, [email protected] wrote:
Quoted 295 lines
From: Eugene Loh <[email protected]>
The function had a few issues, mainly with its comments, ranging from typos to incorrect descriptions of behavior.
The function has only one caller. The enforcement of a size minimum was problematic in a number of respects:
- it was missing 4 bytes
- it was enforcing the minimum before the size was increased by the caller
- it was checking dt_pebs_init()==-1,
missing errors with other negative return valuesSo change the function to accept a minimum and change its return values.
Signed-off-by Eugene Loh <[email protected]>--- libdtrace/dt_peb.c | 27 ++++++++++----------- libdtrace/dt_peb.h | 2 +- libdtrace/dt_work.c | 15 +++++++----- test/unittest/options/err.b-too-low.d | 22 +++++++++-------- test/unittest/options/err.bufsize-too-low.d | 22 +++++++++-------- test/unittest/options/tst.b.d | 22 +++++++++-------- test/unittest/options/tst.bufsize.d | 22 +++++++++-------- 7 files changed, 71 insertions(+), 61 deletions(-)libdtrace/dt_peb.c +13
-14@@ -136,18 +136,14 @@ dt_pebs_exit(dtrace_hdl_t *dtp) }/* -* Initialize the perf event buffers (one per online CPU). Each buffer will -* the given number of pages (i.e. the total size of each buffer will be -* num_pages * getpagesize()). The allocated memory for each buffer is mmap'd -* so the kernel can write to it, and its representative file descriptor is -* recorded in the 'buffers' BPF map so that BPF code knows where to write -* trace data for a specific CPU. +* Initialize the perf event buffers, one per online CPU. Each buffer will +* have num_pages * getpagesize()). The dt_peb_open() call mmaps the allocated +* memory so the kernel can write to it. The file descriptor is recorded in +* the 'buffers' BPF map and added to the event polling file descriptor. * -* An event polling file descriptor is created as well, and it is configured to -* monitor all perf event buffers at once. This file descriptor is returned -* upon success.. Failure is indicated with a -1 return value. +* The return value indicates success (0) or failure (-1). */ -int dt_pebs_init (dtrace_hdl_t *dtp,size_t bufsize) +int dt_pebs_init (dtrace_hdl_t *dtp,size_t bufsize,size_t bufsizemin) {int i;int mapfd;@@ -166,12 +162,15 @@ int dt_pebs_init(dtrace_hdl_t *dtp, size_t bufsize)fprintf (stderr,"bufsize increased to %lu\n" , num_pages *getpagesize ()); +if (num_pages *getpagesize () < bufsizemin) +return dt_set_errno (dtp,EDT_BUFTOOSMALL ); +/* * Determine the fd for the 'buffers' BPF map. */ idp =dt_dlib_get_map (dtp,"buffers" );if (idp ==NULL || idp->di_id ==DT_IDENT_UNDEF ) -return -ENOENT ; +return dt_set_errno (dtp,EDT_NOMEM );// FIXME we used to do something more akin to ENOENT mapfd = idp->di_id;@@ -180,7 +179,7 @@ int dt_pebs_init(dtrace_hdl_t *dtp, size_t bufsize)*/ dtp->dt_pebset =dt_zalloc (dtp,sizeof (dt_pebset_t));if (dtp->dt_pebset ==NULL ) -return -ENOMEM ; +return dt_set_errno (dtp,EDT_NOMEM );/* * Allocate the per-CPU perf event buffers. @@ -189,7 +188,7 @@ int dt_pebs_init(dtrace_hdl_t *dtp, size_t bufsize) sizeof(struct dt_peb));if (pebs ==NULL ) {dt_free (dtp, dtp->dt_pebset); -return -ENOMEM ; +return dt_set_errno (dtp,EDT_NOMEM ); } dtp->dt_pebset->pebs = pebs;@@ -241,5 +240,5 @@ int dt_pebs_init(dtrace_hdl_t *dtp, size_t bufsize) fail:dt_pebs_exit (dtp); -return -1 ; +return dt_set_errno (dtp,EDT_NOMEM );// FIXME need something better }libdtrace/dt_peb.h +1
-1@@ -43,7 +43,7 @@ typedef struct dt_pebset { } dt_pebset_t;extern void dt_pebs_exit (dtrace_hdl_t *); -extern int dt_pebs_init (dtrace_hdl_t *,size_t ); +extern int dt_pebs_init (dtrace_hdl_t *,size_t ,size_t ); #ifdef __cplusplus }libdtrace/dt_work.c +9
-6@@ -267,18 +267,21 @@ 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 +* We need enough space for the perf_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. +* +* While dt_pebs_init() rounds the requested size up, size==0 is a +* special case. */ dtrace_getopt (dtp,"bufsize" , &size); -if (size ==0 || - size <sizeof (struct perf_event_header ) +sizeof (uint32_t ) + - dtp->dt_maxreclen) +if (size ==0 )return dt_set_errno (dtp,EDT_BUFTOOSMALL ); -if (dt_pebs_init (dtp, size) ==-1 ) -return dt_set_errno (dtp,EDT_NOMEM ); +if (dt_pebs_init (dtp, size, +sizeof (struct perf_event_header ) +sizeof (uint32_t ) + +4 + dtp->dt_maxreclen) ==-1 ) +return -1 ;/* * We must initialize the aggregation consumer handling before we test/unittest/options/err.b-too-low.d +12
-10@@ -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,19 +12,21 @@ */ /* - * We use a buffer size of 59 because that should be just too small to hold the - * trace records generated in this script: - * - perf_event_header (40 bytes) - * - size (4 bytes) - * - gap (4 bytes) - * - EPID (4 bytes) - * - tag (4 bytes) - * - exit value (4 bytes) + * We need over 4k bytes for the 4 string trace records generated in this script + * plus some meta data. + * A bufsize of 1 to 4096 bytes is rounded up to 4096 and is insufficient. + * A bufsize of 4097 to 8192 bytes is rounded up to 8192 and is sufficient. */ -/* @@runtest-opts: -b59 */ +/* @@runtest-opts: -b4096 */ + +#pragma D option strsize=1024 BEGIN { + trace("abc"); + trace("def"); + trace("ghi"); + trace("jkl"); exit(0); }test/unittest/options/err.bufsize-too-low.d +12
-10@@ -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,19 +12,21 @@ */ /* - * We use a buffer size of 59 because that should be just too small to hold the - * trace records generated in this script: - * - perf_event_header (40 bytes) - * - size (4 bytes) - * - gap (4 bytes) - * - EPID (4 bytes) - * - tag (4 bytes) - * - exit value (4 bytes) + * We need over 4k bytes for the 4 string trace records generated in this script + * plus some meta data. + * A bufsize of 1 to 4096 bytes is rounded up to 4096 and is insufficient. + * A bufsize of 4097 to 8192 bytes is rounded up to 8192 and is sufficient. */ -/* @@runtest-opts: -xbufsize=59 */ +/* @@runtest-opts: -xbufsize=4096 */ + +#pragma D option strsize=1024 BEGIN { + trace("abc"); + trace("def"); + trace("ghi"); + trace("jkl"); exit(0); }test/unittest/options/tst.b.d +12
-10@@ -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,19 +12,21 @@ */ /* - * 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) - * - size (4 bytes) - * - gap (4 bytes) - * - EPID (4 bytes) - * - tag (4 bytes) - * - exit value (4 bytes) + * We need over 4k bytes for the 4 string trace records generated in this script + * plus some meta data. + * A bufsize of 1 to 4096 bytes is rounded up to 4096 and is insufficient. + * A bufsize of 4097 to 8192 bytes is rounded up to 8192 and is sufficient. */ -/* @@runtest-opts: -b60 */ +/* @@runtest-opts: -b4097 */ + +#pragma D option strsize=1024 BEGIN { + trace("abc"); + trace("def"); + trace("ghi"); + trace("jkl"); exit(0); }test/unittest/options/tst.bufsize.d +12
-10@@ -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,19 +12,21 @@ */ /* - * 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) - * - size (4 bytes) - * - gap (4 bytes) - * - EPID (4 bytes) - * - tag (4 bytes) - * - exit value (4 bytes) + * We need over 4k bytes for the 4 string trace records generated in this script + * plus some meta data. + * A bufsize of 1 to 4096 bytes is rounded up to 4096 and is insufficient. + * A bufsize of 4097 to 8192 bytes is rounded up to 8192 and is sufficient. */ -/* @@runtest-opts: -xbufsize=60 */ +/* @@runtest-opts: -xbufsize=4097 */ + +#pragma D option strsize=1024 BEGIN { + trace("abc"); + trace("def"); + trace("ghi"); + trace("jkl"); exit(0); }Signature · 1 line
2.18.4
Re: [PATCH 31/38] Fix dt_pebs_init() call
Quoted 22 lines · Eugene Loh
Quoted 13 lines · Kris Van Hees
Quoted 12 lines · Eugene Loh
Quoted 9 lines · Kris Van Hees
This patch goes against the intent of the code, as far as I can see. The point of performing the size check prior to increasing the buffer size was to enforce the limit on the size that was explicit set by the user. Then, if that size was sufficient, then DTrace is at liberty to increase that size to a whole multiple of the page size.
But if I were to insist that a buffer can only be 24 bytes, and 24 bytes are not enough to store a single trace record, DTrace should report an error rather than increasing my bufsize setting on its own.
Quoted 6 lines
Quoted 5 lines
The point is that DTrace *does* increase my bufsize setting on its own. Why should DTrace complain about my setting when it's going to ignore my setting anyhow? What value does the pre-existing behavior offer to DTrace users? Are you saying that DTrace should not resize? That it should honor the user's bufsize? No more resizing (to page size or whatever it wants)?
The main point of this code was to retain the bevhaviour that DTrace provided,
Quoted 8 lines
As far as adhering to legacy behavior... quite simply, we do not. We do not set the "principal buffer size" to bufsize. Further, any legacy resizing behavior is, if I understand correctly, to go smaller than the user requested; we do the opposite. Looking to the legacy behavior for precedent is pointless. The situation is that we are unlike legacy behavior in fundamental respects, opposite in another respect (automatic resizing), but consistent in some impractical and useless respect. That consistency strikes me as small consolation.
You can look at this from different angles, yes.
Quoted 5 lines
There is no documentation to change; the documentation is already wrong. This patch was intended as a step to making the behavior something that was describable. Clearly, trying to hold on to a legacy buffering model has produced a byzantine situation in the current port, which treats buffering very differently.
Yes, but if you want to go that route we ought to go all the way, and not some interim solution (see below).
Quoted 3 lines
Perhaps we simply disagree on those points, and this patch is DOA. But the patch points out other problems as well. E.g., the min computation wasn't even right and error checking was wrong.
Let's do this as two patches:
- one that ensures that the computation is updated to the current implementation changes and is correct
- one that provides for increasing the bufsize to be the smallest multiple of pagesize to fit the largest trace record needed for the tracing session
I don't think that checking the rounded up bufsize against the minimum size makes any sense if you are going to increase the specified bufsize anyway. Might as well increase it to fit the minimum size altogether.
Quoted 326 lines
Quoted 326 lines
which is that if a user explicitly requests a bufsize that is less than the minimum required for the given trace programs, an error is reported. That is a mater of being consistent (even if it has no practical application that I can see). Tests from the existing version failed because this was not being done right.
As far as functionality, as long as the bufsize is large enough to hold the largest trace record, DTrace can (and needs to) ensure that the buffer size is a whole multiple of the page size because that is required by the perf ring buffer imlementation.
So, DTrace only increases the buffer size to the required multiple of page size if the user supplied bufsize is at least large enough to hold the largest trace record (or if no bufsize was explicitly specified).
We could opt to change the behaviour of the bufsize opton to always round up to a whole multiple of page size, but that is a deviation from the original implementation and thus is something that would need to be documented, etc...
Aside from the computation of the minimum required size needing updating when patches (e.g. the USDT changes) modify the layout and size of the trace records, I do not think that the existing code is wrong.
I am certainly open to a feature change to make bufsize always be rounded up as needed, but that is not a bug fix and I think that ought to be its own patch (along with documentation changes etc). And it might need some more discussion because it brings up the question why we wouldn't just simply always increase bufsize to be the smallest multiple of the page size to accomodate the largest trace record.
Quoted 296 lines
Quoted 296 lines · On Thu, Jun 27, 2024 at 01:38:57AM -0400, [email protected] wrote:
Quoted 295 lines
From: Eugene Loh <[email protected]>
The function had a few issues, mainly with its comments, ranging from typos to incorrect descriptions of behavior.
The function has only one caller. The enforcement of a size minimum was problematic in a number of respects:
- it was missing 4 bytes
- it was enforcing the minimum before the size was increased by the caller
- it was checking dt_pebs_init()==-1,
missing errors with other negative return valuesSo change the function to accept a minimum and change its return values.
Signed-off-by Eugene Loh <[email protected]>--- libdtrace/dt_peb.c | 27 ++++++++++----------- libdtrace/dt_peb.h | 2 +- libdtrace/dt_work.c | 15 +++++++----- test/unittest/options/err.b-too-low.d | 22 +++++++++-------- test/unittest/options/err.bufsize-too-low.d | 22 +++++++++-------- test/unittest/options/tst.b.d | 22 +++++++++-------- test/unittest/options/tst.bufsize.d | 22 +++++++++-------- 7 files changed, 71 insertions(+), 61 deletions(-)libdtrace/dt_peb.c +13
-14@@ -136,18 +136,14 @@ dt_pebs_exit(dtrace_hdl_t *dtp) }/* -* Initialize the perf event buffers (one per online CPU). Each buffer will -* the given number of pages (i.e. the total size of each buffer will be -* num_pages * getpagesize()). The allocated memory for each buffer is mmap'd -* so the kernel can write to it, and its representative file descriptor is -* recorded in the 'buffers' BPF map so that BPF code knows where to write -* trace data for a specific CPU. +* Initialize the perf event buffers, one per online CPU. Each buffer will +* have num_pages * getpagesize()). The dt_peb_open() call mmaps the allocated +* memory so the kernel can write to it. The file descriptor is recorded in +* the 'buffers' BPF map and added to the event polling file descriptor. * -* An event polling file descriptor is created as well, and it is configured to -* monitor all perf event buffers at once. This file descriptor is returned -* upon success.. Failure is indicated with a -1 return value. +* The return value indicates success (0) or failure (-1). */ -int dt_pebs_init (dtrace_hdl_t *dtp,size_t bufsize) +int dt_pebs_init (dtrace_hdl_t *dtp,size_t bufsize,size_t bufsizemin) {int i;int mapfd;@@ -166,12 +162,15 @@ int dt_pebs_init(dtrace_hdl_t *dtp, size_t bufsize)fprintf (stderr,"bufsize increased to %lu\n" , num_pages *getpagesize ()); +if (num_pages *getpagesize () < bufsizemin) +return dt_set_errno (dtp,EDT_BUFTOOSMALL ); +/* * Determine the fd for the 'buffers' BPF map. */ idp =dt_dlib_get_map (dtp,"buffers" );if (idp ==NULL || idp->di_id ==DT_IDENT_UNDEF ) -return -ENOENT ; +return dt_set_errno (dtp,EDT_NOMEM );// FIXME we used to do something more akin to ENOENT mapfd = idp->di_id;@@ -180,7 +179,7 @@ int dt_pebs_init(dtrace_hdl_t *dtp, size_t bufsize)*/ dtp->dt_pebset =dt_zalloc (dtp,sizeof (dt_pebset_t));if (dtp->dt_pebset ==NULL ) -return -ENOMEM ; +return dt_set_errno (dtp,EDT_NOMEM );/* * Allocate the per-CPU perf event buffers. @@ -189,7 +188,7 @@ int dt_pebs_init(dtrace_hdl_t *dtp, size_t bufsize) sizeof(struct dt_peb));if (pebs ==NULL ) {dt_free (dtp, dtp->dt_pebset); -return -ENOMEM ; +return dt_set_errno (dtp,EDT_NOMEM ); } dtp->dt_pebset->pebs = pebs;@@ -241,5 +240,5 @@ int dt_pebs_init(dtrace_hdl_t *dtp, size_t bufsize) fail:dt_pebs_exit (dtp); -return -1 ; +return dt_set_errno (dtp,EDT_NOMEM );// FIXME need something better }libdtrace/dt_peb.h +1
-1@@ -43,7 +43,7 @@ typedef struct dt_pebset { } dt_pebset_t;extern void dt_pebs_exit (dtrace_hdl_t *); -extern int dt_pebs_init (dtrace_hdl_t *,size_t ); +extern int dt_pebs_init (dtrace_hdl_t *,size_t ,size_t ); #ifdef __cplusplus }libdtrace/dt_work.c +9
-6@@ -267,18 +267,21 @@ 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 +* We need enough space for the perf_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. +* +* While dt_pebs_init() rounds the requested size up, size==0 is a +* special case. */ dtrace_getopt (dtp,"bufsize" , &size); -if (size ==0 || - size <sizeof (struct perf_event_header ) +sizeof (uint32_t ) + - dtp->dt_maxreclen) +if (size ==0 )return dt_set_errno (dtp,EDT_BUFTOOSMALL ); -if (dt_pebs_init (dtp, size) ==-1 ) -return dt_set_errno (dtp,EDT_NOMEM ); +if (dt_pebs_init (dtp, size, +sizeof (struct perf_event_header ) +sizeof (uint32_t ) + +4 + dtp->dt_maxreclen) ==-1 ) +return -1 ;/* * We must initialize the aggregation consumer handling before we test/unittest/options/err.b-too-low.d +12
-10@@ -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,19 +12,21 @@ */ /* - * We use a buffer size of 59 because that should be just too small to hold the - * trace records generated in this script: - * - perf_event_header (40 bytes) - * - size (4 bytes) - * - gap (4 bytes) - * - EPID (4 bytes) - * - tag (4 bytes) - * - exit value (4 bytes) + * We need over 4k bytes for the 4 string trace records generated in this script + * plus some meta data. + * A bufsize of 1 to 4096 bytes is rounded up to 4096 and is insufficient. + * A bufsize of 4097 to 8192 bytes is rounded up to 8192 and is sufficient. */ -/* @@runtest-opts: -b59 */ +/* @@runtest-opts: -b4096 */ + +#pragma D option strsize=1024 BEGIN { + trace("abc"); + trace("def"); + trace("ghi"); + trace("jkl"); exit(0); }test/unittest/options/err.bufsize-too-low.d +12
-10@@ -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,19 +12,21 @@ */ /* - * We use a buffer size of 59 because that should be just too small to hold the - * trace records generated in this script: - * - perf_event_header (40 bytes) - * - size (4 bytes) - * - gap (4 bytes) - * - EPID (4 bytes) - * - tag (4 bytes) - * - exit value (4 bytes) + * We need over 4k bytes for the 4 string trace records generated in this script + * plus some meta data. + * A bufsize of 1 to 4096 bytes is rounded up to 4096 and is insufficient. + * A bufsize of 4097 to 8192 bytes is rounded up to 8192 and is sufficient. */ -/* @@runtest-opts: -xbufsize=59 */ +/* @@runtest-opts: -xbufsize=4096 */ + +#pragma D option strsize=1024 BEGIN { + trace("abc"); + trace("def"); + trace("ghi"); + trace("jkl"); exit(0); }test/unittest/options/tst.b.d +12
-10@@ -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,19 +12,21 @@ */ /* - * 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) - * - size (4 bytes) - * - gap (4 bytes) - * - EPID (4 bytes) - * - tag (4 bytes) - * - exit value (4 bytes) + * We need over 4k bytes for the 4 string trace records generated in this script + * plus some meta data. + * A bufsize of 1 to 4096 bytes is rounded up to 4096 and is insufficient. + * A bufsize of 4097 to 8192 bytes is rounded up to 8192 and is sufficient. */ -/* @@runtest-opts: -b60 */ +/* @@runtest-opts: -b4097 */ + +#pragma D option strsize=1024 BEGIN { + trace("abc"); + trace("def"); + trace("ghi"); + trace("jkl"); exit(0); }test/unittest/options/tst.bufsize.d +12
-10@@ -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,19 +12,21 @@ */ /* - * 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) - * - size (4 bytes) - * - gap (4 bytes) - * - EPID (4 bytes) - * - tag (4 bytes) - * - exit value (4 bytes) + * We need over 4k bytes for the 4 string trace records generated in this script + * plus some meta data. + * A bufsize of 1 to 4096 bytes is rounded up to 4096 and is insufficient. + * A bufsize of 4097 to 8192 bytes is rounded up to 8192 and is sufficient. */ -/* @@runtest-opts: -xbufsize=60 */ +/* @@runtest-opts: -xbufsize=4097 */ + +#pragma D option strsize=1024 BEGIN { + trace("abc"); + trace("def"); + trace("ghi"); + trace("jkl"); exit(0); }Signature · 1 line
2.18.4
Re: [PATCH 31/38] Fix dt_pebs_init() call
Quoted 46 lines · Kris Van Hees
Quoted 18 lines · Eugene Loh
Quoted 11 lines · Kris Van Hees
Quoted 10 lines · Eugene Loh
Quoted 9 lines · Kris Van Hees
This patch goes against the intent of the code, as far as I can see. The point of performing the size check prior to increasing the buffer size was to enforce the limit on the size that was explicit set by the user. Then, if that size was sufficient, then DTrace is at liberty to increase that size to a whole multiple of the page size.
But if I were to insist that a buffer can only be 24 bytes, and 24 bytes are not enough to store a single trace record, DTrace should report an error rather than increasing my bufsize setting on its own.
Quoted 6 lines
Quoted 5 lines
The point is that DTrace *does* increase my bufsize setting on its own. Why should DTrace complain about my setting when it's going to ignore my setting anyhow? What value does the pre-existing behavior offer to DTrace users? Are you saying that DTrace should not resize? That it should honor the user's bufsize? No more resizing (to page size or whatever it wants)?
The main point of this code was to retain the bevhaviour that DTrace provided,
Quoted 8 lines
As far as adhering to legacy behavior... quite simply, we do not. We do not set the "principal buffer size" to bufsize. Further, any legacy resizing behavior is, if I understand correctly, to go smaller than the user requested; we do the opposite. Looking to the legacy behavior for precedent is pointless. The situation is that we are unlike legacy behavior in fundamental respects, opposite in another respect (automatic resizing), but consistent in some impractical and useless respect. That consistency strikes me as small consolation.
You can look at this from different angles, yes.
Quoted 5 lines
There is no documentation to change; the documentation is already wrong. This patch was intended as a step to making the behavior something that was describable. Clearly, trying to hold on to a legacy buffering model has produced a byzantine situation in the current port, which treats buffering very differently.
Yes, but if you want to go that route we ought to go all the way, and not some interim solution (see below).
Quoted 3 lines
Perhaps we simply disagree on those points, and this patch is DOA. But the patch points out other problems as well. E.g., the min computation wasn't even right and error checking was wrong.
Let's do this as two patches:
- one that ensures that the computation is updated to the current implementation changes and is correct
- one that provides for increasing the bufsize to be the smallest multiple of pagesize to fit the largest trace record needed for the tracing session
Quoted 3 lines
I don't think that checking the rounded up bufsize against the minimum size makes any sense if you are going to increase the specified bufsize anyway. Might as well increase it to fit the minimum size altogether.
I'd like to understand this proposal. Are you saying:
*) Determine the min size (correctly).
*) Round that up per perf_event requirements (2^n + 1 pages).
*) Ignore the user's bufsize setting.
I'm fine with that (given that we do buffering so unlike the legacy implementation and will not be honoring the user's bufsize value anyhow), but I just wanted to be explicit about ignoring the user's bufsize.
Quoted 46 lines
Quoted 46 lines
Quoted 46 lines
which is that if a user explicitly requests a bufsize that is less than the minimum required for the given trace programs, an error is reported. That is a mater of being consistent (even if it has no practical application that I can see). Tests from the existing version failed because this was not being done right.
As far as functionality, as long as the bufsize is large enough to hold the largest trace record, DTrace can (and needs to) ensure that the buffer size is a whole multiple of the page size because that is required by the perf ring buffer imlementation.
So, DTrace only increases the buffer size to the required multiple of page size if the user supplied bufsize is at least large enough to hold the largest trace record (or if no bufsize was explicitly specified).
We could opt to change the behaviour of the bufsize opton to always round up to a whole multiple of page size, but that is a deviation from the original implementation and thus is something that would need to be documented, etc...
Aside from the computation of the minimum required size needing updating when patches (e.g. the USDT changes) modify the layout and size of the trace records, I do not think that the existing code is wrong.
I am certainly open to a feature change to make bufsize always be rounded up as needed, but that is not a bug fix and I think that ought to be its own patch (along with documentation changes etc). And it might need some more discussion because it brings up the question why we wouldn't just simply always increase bufsize to be the smallest multiple of the page size to accomodate the largest trace record.
Quoted 16 lines
Quoted 16 lines · On Thu, Jun 27, 2024 at 01:38:57AM -0400, [email protected] wrote:
Quoted 15 lines
From: Eugene Loh <[email protected]>
The function had a few issues, mainly with its comments, ranging from typos to incorrect descriptions of behavior.
The function has only one caller. The enforcement of a size minimum was problematic in a number of respects:
- it was missing 4 bytes
- it was enforcing the minimum before the size was increased by the caller
- it was checking dt_pebs_init()==-1,
missing errors with other negative return valuesSo change the function to accept a minimum and change its return values.
Re: [DTrace-devel] [PATCH 31/38] Fix dt_pebs_init() call
Quoted 48 lines · Eugene Loh via DTrace-devel
Quoted 46 lines · Kris Van Hees
Quoted 18 lines · Eugene Loh
Quoted 11 lines · Kris Van Hees
Quoted 10 lines · Eugene Loh
Quoted 9 lines · Kris Van Hees
This patch goes against the intent of the code, as far as I can see. The point of performing the size check prior to increasing the buffer size was to enforce the limit on the size that was explicit set by the user. Then, if that size was sufficient, then DTrace is at liberty to increase that size to a whole multiple of the page size.
But if I were to insist that a buffer can only be 24 bytes, and 24 bytes are not enough to store a single trace record, DTrace should report an error rather than increasing my bufsize setting on its own.
Quoted 6 lines
Quoted 5 lines
The point is that DTrace *does* increase my bufsize setting on its own. Why should DTrace complain about my setting when it's going to ignore my setting anyhow? What value does the pre-existing behavior offer to DTrace users? Are you saying that DTrace should not resize? That it should honor the user's bufsize? No more resizing (to page size or whatever it wants)?
The main point of this code was to retain the bevhaviour that DTrace provided,
Quoted 8 lines
As far as adhering to legacy behavior... quite simply, we do not. We do not set the "principal buffer size" to bufsize. Further, any legacy resizing behavior is, if I understand correctly, to go smaller than the user requested; we do the opposite. Looking to the legacy behavior for precedent is pointless. The situation is that we are unlike legacy behavior in fundamental respects, opposite in another respect (automatic resizing), but consistent in some impractical and useless respect. That consistency strikes me as small consolation.
You can look at this from different angles, yes.
Quoted 5 lines
There is no documentation to change; the documentation is already wrong. This patch was intended as a step to making the behavior something that was describable. Clearly, trying to hold on to a legacy buffering model has produced a byzantine situation in the current port, which treats buffering very differently.
Yes, but if you want to go that route we ought to go all the way, and not some interim solution (see below).
Quoted 3 lines
Perhaps we simply disagree on those points, and this patch is DOA. But the patch points out other problems as well. E.g., the min computation wasn't even right and error checking was wrong.
Let's do this as two patches:
- one that ensures that the computation is updated to the current implementation changes and is correct
- one that provides for increasing the bufsize to be the smallest multiple of pagesize to fit the largest trace record needed for the tracing session
Quoted 7 lines
Quoted 3 lines
I don't think that checking the rounded up bufsize against the minimum size makes any sense if you are going to increase the specified bufsize anyway. Might as well increase it to fit the minimum size altogether.
I'd like to understand this proposal. Are you saying:
*) Determine the min size (correctly).
Correct.
Quoted 1 line
*) Round that up per
perf_eventrequirements (2^n + 1 pages).
No, round up to nearest 2^n. The extra page is allocated automatically by dt_peb_open().
Quoted 1 line
*) Ignore the user's bufsize setting.
Well, no. The bufsize setting is not ignored. We just change the semantics a little (in view of the new implementation) to be a mechanism to allow the user to tune the buffer size, but within certain limitations.
Quoted 3 lines
I'm fine with that (given that we do buffering so unlike the legacy implementation and will not be honoring the user's bufsize value anyhow), but I just wanted to be explicit about ignoring the user's bufsize.
We do not ignore the bufsize as such. But the extent to which the bugsize can be tuned is limited by the implementation. The bufsizw setting cannot be less than the minimum requirement (and you prefer to not complain about that and instead just increase the buffer size). And its value must be a 2^n multiple of the page size, so it will be rounded up to the nearest acceptable value. But that is therefore still controlled by the user's bufsize setting.
Quoted 51 lines
Quoted 44 lines
Quoted 44 lines
Quoted 44 lines
which is that if a user explicitly requests a bufsize that is less than the minimum required for the given trace programs, an error is reported. That is a mater of being consistent (even if it has no practical application that I can see). Tests from the existing version failed because this was not being done right.
As far as functionality, as long as the bufsize is large enough to hold the largest trace record, DTrace can (and needs to) ensure that the buffer size is a whole multiple of the page size because that is required by the perf ring buffer imlementation.
So, DTrace only increases the buffer size to the required multiple of page size if the user supplied bufsize is at least large enough to hold the largest trace record (or if no bufsize was explicitly specified).
We could opt to change the behaviour of the bufsize opton to always round up to a whole multiple of page size, but that is a deviation from the original implementation and thus is something that would need to be documented, etc...
Aside from the computation of the minimum required size needing updating when patches (e.g. the USDT changes) modify the layout and size of the trace records, I do not think that the existing code is wrong.
I am certainly open to a feature change to make bufsize always be rounded up as needed, but that is not a bug fix and I think that ought to be its own patch (along with documentation changes etc). And it might need some more discussion because it brings up the question why we wouldn't just simply always increase bufsize to be the smallest multiple of the page size to accomodate the largest trace record.
Quoted 14 lines
Quoted 14 lines · On Thu, Jun 27, 2024 at 01:38:57AM -0400, [email protected] wrote:
Quoted 13 lines
From: Eugene Loh <[email protected]>
The function had a few issues, mainly with its comments, ranging from typos to incorrect descriptions of behavior.
The function has only one caller. The enforcement of a size minimum was problematic in a number of respects:
- it was missing 4 bytes
- it was enforcing the minimum before the size was increased by the caller
- it was checking dt_pebs_init()==-1,
missing errors with other negative return valuesQuoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
So change the function to accept a minimum and change its return values.
_______________________________________________
DTrace-devel mailing list
[email protected]
https://oss.oracle.com/mailman/listinfo/dtrace-devel
Re: [DTrace-devel] [PATCH 31/38] Fix dt_pebs_init() call
So do you have a proposal for what the new semantics for bufsize should be? (And, why not simply ignore bufsize?)
Quoted 125 lines · Kris Van Hees
Quoted 47 lines · Eugene Loh via DTrace-devel
Quoted 46 lines · Kris Van Hees
Quoted 18 lines · Eugene Loh
Quoted 11 lines · Kris Van Hees
Quoted 10 lines · Eugene Loh
Quoted 9 lines · Kris Van Hees
This patch goes against the intent of the code, as far as I can see. The point of performing the size check prior to increasing the buffer size was to enforce the limit on the size that was explicit set by the user. Then, if that size was sufficient, then DTrace is at liberty to increase that size to a whole multiple of the page size.
But if I were to insist that a buffer can only be 24 bytes, and 24 bytes are not enough to store a single trace record, DTrace should report an error rather than increasing my bufsize setting on its own.
Quoted 6 lines
Quoted 5 lines
The point is that DTrace *does* increase my bufsize setting on its own. Why should DTrace complain about my setting when it's going to ignore my setting anyhow? What value does the pre-existing behavior offer to DTrace users? Are you saying that DTrace should not resize? That it should honor the user's bufsize? No more resizing (to page size or whatever it wants)?
The main point of this code was to retain the bevhaviour that DTrace provided,
Quoted 8 lines
As far as adhering to legacy behavior... quite simply, we do not. We do not set the "principal buffer size" to bufsize. Further, any legacy resizing behavior is, if I understand correctly, to go smaller than the user requested; we do the opposite. Looking to the legacy behavior for precedent is pointless. The situation is that we are unlike legacy behavior in fundamental respects, opposite in another respect (automatic resizing), but consistent in some impractical and useless respect. That consistency strikes me as small consolation.
You can look at this from different angles, yes.
Quoted 5 lines
There is no documentation to change; the documentation is already wrong. This patch was intended as a step to making the behavior something that was describable. Clearly, trying to hold on to a legacy buffering model has produced a byzantine situation in the current port, which treats buffering very differently.
Yes, but if you want to go that route we ought to go all the way, and not some interim solution (see below).
Quoted 3 lines
Perhaps we simply disagree on those points, and this patch is DOA. But the patch points out other problems as well. E.g., the min computation wasn't even right and error checking was wrong.
Let's do this as two patches:
- one that ensures that the computation is updated to the current implementation changes and is correct
- one that provides for increasing the bufsize to be the smallest multiple of pagesize to fit the largest trace record needed for the tracing sessionQuoted 6 lines
Quoted 3 lines
I don't think that checking the rounded up bufsize against the minimum size makes any sense if you are going to increase the specified bufsize anyway. Might as well increase it to fit the minimum size altogether.
I'd like to understand this proposal. Are you saying:
*) Determine the min size (correctly).
Correct.
Quoted 1 line
*) Round that up per
perf_eventrequirements (2^n + 1 pages).No, round up to nearest 2^n. The extra page is allocated automatically by
dt_peb_open().Quoted 1 line
*) Ignore the user's bufsize setting.
Well, no. The bufsize setting is not ignored. We just change the semantics a little (in view of the new implementation) to be a mechanism to allow the user to tune the buffer size, but within certain limitations.
Quoted 3 lines
I'm fine with that (given that we do buffering so unlike the legacy implementation and will not be honoring the user's bufsize value anyhow), but I just wanted to be explicit about ignoring the user's bufsize.
We do not ignore the bufsize as such. But the extent to which the bugsize can be tuned is limited by the implementation. The bufsizw setting cannot be less than the minimum requirement (and you prefer to not complain about that and instead just increase the buffer size). And its value must be a 2^n multiple of the page size, so it will be rounded up to the nearest acceptable value. But that is therefore still controlled by the user's bufsize setting.
Quoted 50 lines
Quoted 44 lines
Quoted 44 lines
Quoted 44 lines
which is that if a user explicitly requests a bufsize that is less than the minimum required for the given trace programs, an error is reported. That is a mater of being consistent (even if it has no practical application that I can see). Tests from the existing version failed because this was not being done right.
As far as functionality, as long as the bufsize is large enough to hold the largest trace record, DTrace can (and needs to) ensure that the buffer size is a whole multiple of the page size because that is required by the perf ring buffer imlementation.
So, DTrace only increases the buffer size to the required multiple of page size if the user supplied bufsize is at least large enough to hold the largest trace record (or if no bufsize was explicitly specified).
We could opt to change the behaviour of the bufsize opton to always round up to a whole multiple of page size, but that is a deviation from the original implementation and thus is something that would need to be documented, etc...
Aside from the computation of the minimum required size needing updating when patches (e.g. the USDT changes) modify the layout and size of the trace records, I do not think that the existing code is wrong.
I am certainly open to a feature change to make bufsize always be rounded up as needed, but that is not a bug fix and I think that ought to be its own patch (along with documentation changes etc). And it might need some more discussion because it brings up the question why we wouldn't just simply always increase bufsize to be the smallest multiple of the page size to accomodate the largest trace record.
Quoted 14 lines
Quoted 14 lines · On Thu, Jun 27, 2024 at 01:38:57AM -0400, [email protected] wrote:
Quoted 13 lines
From: Eugene Loh <[email protected]>
The function had a few issues, mainly with its comments, ranging from typos to incorrect descriptions of behavior.
The function has only one caller. The enforcement of a size minimum was problematic in a number of respects:
- it was missing 4 bytes
- it was enforcing the minimum before the size was increased by the caller
- it was checking dt_pebs_init()==-1,
missing errors with other negative return valuesQuoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
So change the function to accept a minimum and change its return values.
_______________________________________________
DTrace-devel mailing list
[email protected]
https://oss.oracle.com/mailman/listinfo/dtrace-devel
Re: [DTrace-devel] [PATCH 31/38] Fix dt_pebs_init() call
Quoted 1 line · Eugene Loh
So do you have a proposal for what the new semantics for bufsize should be?
I believe the semantics of a user-specified bufsize should be as follows:
- If the bufsize specified by the user is less than the minimum buffer size required to store the largest trace record, an error should be reported.
- If the bufsize satisfies the minimum requirement, the implementation must ensure that it is round up (if needed) to satisfy the perf ring buffer size requirement (size needs to be 2^n * pagesize, for n = 0, 1, 2, ...)
Point 1 is clearly debatable but follows the principle that you cannot put something bigger into something that is too small to hold it.
Quoted 1 line
(And, why not simply ignore bufsize?)
Because we want users to be able to tune the size of the tracing buffer, which can affect performance in terms of how quickly trace data is generated versus how quiickly it is consumed. It interacts with things like switchrate.
Quoted 126 lines · Kris Van Hees
Quoted 125 lines · Eugene Loh via DTrace-devel
Quoted 47 lines · Kris Van Hees
Quoted 46 lines · Eugene Loh
Quoted 18 lines · Kris Van Hees
Quoted 11 lines · Eugene Loh
Quoted 10 lines · Kris Van Hees
Quoted 9 lines
This patch goes against the intent of the code, as far as I can see. The point of performing the size check prior to increasing the buffer size was to enforce the limit on the size that was explicit set by the user. Then, if that size was sufficient, then DTrace is at liberty to increase that size to a whole multiple of the page size.
But if I were to insist that a buffer can only be 24 bytes, and 24 bytes are not enough to store a single trace record, DTrace should report an error rather than increasing my bufsize setting on its own.
Quoted 6 lines
Quoted 5 lines
The point is that DTrace *does* increase my bufsize setting on its own. Why should DTrace complain about my setting when it's going to ignore my setting anyhow? What value does the pre-existing behavior offer to DTrace users? Are you saying that DTrace should not resize? That it should honor the user's bufsize? No more resizing (to page size or whatever it wants)?
The main point of this code was to retain the bevhaviour that DTrace provided,
Quoted 8 lines
As far as adhering to legacy behavior... quite simply, we do not. We do not set the "principal buffer size" to bufsize. Further, any legacy resizing behavior is, if I understand correctly, to go smaller than the user requested; we do the opposite. Looking to the legacy behavior for precedent is pointless. The situation is that we are unlike legacy behavior in fundamental respects, opposite in another respect (automatic resizing), but consistent in some impractical and useless respect. That consistency strikes me as small consolation.
You can look at this from different angles, yes.
Quoted 5 lines
There is no documentation to change; the documentation is already wrong. This patch was intended as a step to making the behavior something that was describable. Clearly, trying to hold on to a legacy buffering model has produced a byzantine situation in the current port, which treats buffering very differently.
Yes, but if you want to go that route we ought to go all the way, and not some interim solution (see below).
Quoted 3 lines
Perhaps we simply disagree on those points, and this patch is DOA. But the patch points out other problems as well. E.g., the min computation wasn't even right and error checking was wrong.
Let's do this as two patches:
- one that ensures that the computation is updated to the current implementation changes and is correct
- one that provides for increasing the bufsize to be the smallest multiple of pagesize to fit the largest trace record needed for the tracing sessionQuoted 6 lines
Quoted 3 lines
I don't think that checking the rounded up bufsize against the minimum size makes any sense if you are going to increase the specified bufsize anyway. Might as well increase it to fit the minimum size altogether.
I'd like to understand this proposal. Are you saying:
*) Determine the min size (correctly).
Correct.
Quoted 1 line
*) Round that up per
perf_eventrequirements (2^n + 1 pages).No, round up to nearest 2^n. The extra page is allocated automatically by
dt_peb_open().Quoted 1 line
*) Ignore the user's bufsize setting.
Well, no. The bufsize setting is not ignored. We just change the semantics a little (in view of the new implementation) to be a mechanism to allow the user to tune the buffer size, but within certain limitations.
Quoted 3 lines
I'm fine with that (given that we do buffering so unlike the legacy implementation and will not be honoring the user's bufsize value anyhow), but I just wanted to be explicit about ignoring the user's bufsize.
We do not ignore the bufsize as such. But the extent to which the bugsize can be tuned is limited by the implementation. The bufsizw setting cannot be less than the minimum requirement (and you prefer to not complain about that and instead just increase the buffer size). And its value must be a 2^n multiple of the page size, so it will be rounded up to the nearest acceptable value. But that is therefore still controlled by the user's bufsize setting.
Quoted 50 lines
Quoted 44 lines
Quoted 44 lines
Quoted 44 lines
which is that if a user explicitly requests a bufsize that is less than the minimum required for the given trace programs, an error is reported. That is a mater of being consistent (even if it has no practical application that I can see). Tests from the existing version failed because this was not being done right.
As far as functionality, as long as the bufsize is large enough to hold the largest trace record, DTrace can (and needs to) ensure that the buffer size is a whole multiple of the page size because that is required by the perf ring buffer imlementation.
So, DTrace only increases the buffer size to the required multiple of page size if the user supplied bufsize is at least large enough to hold the largest trace record (or if no bufsize was explicitly specified).
We could opt to change the behaviour of the bufsize opton to always round up to a whole multiple of page size, but that is a deviation from the original implementation and thus is something that would need to be documented, etc...
Aside from the computation of the minimum required size needing updating when patches (e.g. the USDT changes) modify the layout and size of the trace records, I do not think that the existing code is wrong.
I am certainly open to a feature change to make bufsize always be rounded up as needed, but that is not a bug fix and I think that ought to be its own patch (along with documentation changes etc). And it might need some more discussion because it brings up the question why we wouldn't just simply always increase bufsize to be the smallest multiple of the page size to accomodate the largest trace record.
Quoted 14 lines
Quoted 14 lines · On Thu, Jun 27, 2024 at 01:38:57AM -0400, [email protected] wrote:
Quoted 13 lines
From: Eugene Loh <[email protected]>
The function had a few issues, mainly with its comments, ranging from typos to incorrect descriptions of behavior.
The function has only one caller. The enforcement of a size minimum was problematic in a number of respects:
- it was missing 4 bytes
- it was enforcing the minimum before the size was increased by the caller
- it was checking dt_pebs_init()==-1,
missing errors with other negative return valuesQuoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
So change the function to accept a minimum and change its return values.
_______________________________________________
DTrace-devel mailing list
[email protected]
https://oss.oracle.com/mailman/listinfo/dtrace-devel
Re: [DTrace-devel] [PATCH 31/38] Fix dt_pebs_init() call
Quoted 4 lines · Kris Van Hees
Quoted 1 line · Eugene Loh
So do you have a proposal for what the new semantics for bufsize should be?
I believe the semantics of a user-specified bufsize should be as follows:
Quoted 8 lines
- If the bufsize specified by the user is less than the minimum buffer size required to store the largest trace record, an error should be reported.
- If the bufsize satisfies the minimum requirement, the implementation must ensure that it is round up (if needed) to satisfy the perf ring buffer size requirement (size needs to be 2^n * pagesize, for n = 0, 1, 2, ...)Point 1 is clearly debatable but follows the principle that you cannot put something bigger into something that is too small to hold it.
Thanks. It helps to see a specific proposal. It just strikes me as odd that we would say a user specified too low when we're not going to use that size anyhow -- we're going to increase it. Why should we complain about a request we're going to ignore?
What do you think about not automatically resizing? Resizing in legacy I think was by default and rounded down. You autosize up. How about we don't resize? If they ask for less than min, we complain and tell them what the min size. If they're not 2^n pages, we tell them so. The default right now is 4m. So if someone is playing with bufsize we might as well honor their request (and give them guidance if what they're trying to do doesn't work).
Quoted 131 lines
Quoted 1 line
(And, why not simply ignore bufsize?)
Because we want users to be able to tune the size of the tracing buffer, which can affect performance in terms of how quickly trace data is generated versus how quiickly it is consumed. It interacts with things like switchrate.
Quoted 126 lines · Kris Van Hees
Quoted 125 lines · Eugene Loh via DTrace-devel
Quoted 47 lines · Kris Van Hees
Quoted 46 lines · Eugene Loh
Quoted 18 lines · Kris Van Hees
Quoted 11 lines · Eugene Loh
Quoted 10 lines · Kris Van Hees
Quoted 9 lines
This patch goes against the intent of the code, as far as I can see. The point of performing the size check prior to increasing the buffer size was to enforce the limit on the size that was explicit set by the user. Then, if that size was sufficient, then DTrace is at liberty to increase that size to a whole multiple of the page size.
But if I were to insist that a buffer can only be 24 bytes, and 24 bytes are not enough to store a single trace record, DTrace should report an error rather than increasing my bufsize setting on its own.
Quoted 6 lines
Quoted 5 lines
The point is that DTrace *does* increase my bufsize setting on its own. Why should DTrace complain about my setting when it's going to ignore my setting anyhow? What value does the pre-existing behavior offer to DTrace users? Are you saying that DTrace should not resize? That it should honor the user's bufsize? No more resizing (to page size or whatever it wants)?
The main point of this code was to retain the bevhaviour that DTrace provided,
Quoted 8 lines
As far as adhering to legacy behavior... quite simply, we do not. We do not set the "principal buffer size" to bufsize. Further, any legacy resizing behavior is, if I understand correctly, to go smaller than the user requested; we do the opposite. Looking to the legacy behavior for precedent is pointless. The situation is that we are unlike legacy behavior in fundamental respects, opposite in another respect (automatic resizing), but consistent in some impractical and useless respect. That consistency strikes me as small consolation.
You can look at this from different angles, yes.
Quoted 5 lines
There is no documentation to change; the documentation is already wrong. This patch was intended as a step to making the behavior something that was describable. Clearly, trying to hold on to a legacy buffering model has produced a byzantine situation in the current port, which treats buffering very differently.
Yes, but if you want to go that route we ought to go all the way, and not some interim solution (see below).
Quoted 3 lines
Perhaps we simply disagree on those points, and this patch is DOA. But the patch points out other problems as well. E.g., the min computation wasn't even right and error checking was wrong.
Let's do this as two patches:
- one that ensures that the computation is updated to the current implementation changes and is correct
- one that provides for increasing the bufsize to be the smallest multiple of pagesize to fit the largest trace record needed for the tracing sessionQuoted 6 lines
Quoted 3 lines
I don't think that checking the rounded up bufsize against the minimum size makes any sense if you are going to increase the specified bufsize anyway. Might as well increase it to fit the minimum size altogether.
I'd like to understand this proposal. Are you saying:
*) Determine the min size (correctly).
Correct.
Quoted 1 line
*) Round that up per
perf_eventrequirements (2^n + 1 pages).No, round up to nearest 2^n. The extra page is allocated automatically by
dt_peb_open().Quoted 1 line
*) Ignore the user's bufsize setting.
Well, no. The bufsize setting is not ignored. We just change the semantics a little (in view of the new implementation) to be a mechanism to allow the user to tune the buffer size, but within certain limitations.
Quoted 3 lines
I'm fine with that (given that we do buffering so unlike the legacy implementation and will not be honoring the user's bufsize value anyhow), but I just wanted to be explicit about ignoring the user's bufsize.
We do not ignore the bufsize as such. But the extent to which the bugsize can be tuned is limited by the implementation. The bufsizw setting cannot be less than the minimum requirement (and you prefer to not complain about that and instead just increase the buffer size). And its value must be a 2^n multiple of the page size, so it will be rounded up to the nearest acceptable value. But that is therefore still controlled by the user's bufsize setting.
Quoted 50 lines
Quoted 44 lines
Quoted 44 lines
Quoted 44 lines
which is that if a user explicitly requests a bufsize that is less than the minimum required for the given trace programs, an error is reported. That is a mater of being consistent (even if it has no practical application that I can see). Tests from the existing version failed because this was not being done right.
As far as functionality, as long as the bufsize is large enough to hold the largest trace record, DTrace can (and needs to) ensure that the buffer size is a whole multiple of the page size because that is required by the perf ring buffer imlementation.
So, DTrace only increases the buffer size to the required multiple of page size if the user supplied bufsize is at least large enough to hold the largest trace record (or if no bufsize was explicitly specified).
We could opt to change the behaviour of the bufsize opton to always round up to a whole multiple of page size, but that is a deviation from the original implementation and thus is something that would need to be documented, etc...
Aside from the computation of the minimum required size needing updating when patches (e.g. the USDT changes) modify the layout and size of the trace records, I do not think that the existing code is wrong.
I am certainly open to a feature change to make bufsize always be rounded up as needed, but that is not a bug fix and I think that ought to be its own patch (along with documentation changes etc). And it might need some more discussion because it brings up the question why we wouldn't just simply always increase bufsize to be the smallest multiple of the page size to accomodate the largest trace record.
Quoted 14 lines
Quoted 14 lines · On Thu, Jun 27, 2024 at 01:38:57AM -0400, [email protected] wrote:
Quoted 13 lines
From: Eugene Loh <[email protected]>
The function had a few issues, mainly with its comments, ranging from typos to incorrect descriptions of behavior.
The function has only one caller. The enforcement of a size minimum was problematic in a number of respects:
- it was missing 4 bytes
- it was enforcing the minimum before the size was increased by the caller
- it was checking dt_pebs_init()==-1,
missing errors with other negative return valuesQuoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
So change the function to accept a minimum and change its return values.
_______________________________________________
DTrace-devel mailing list
[email protected]
https://oss.oracle.com/mailman/listinfo/dtrace-devel
Re: [DTrace-devel] [PATCH 31/38] Fix dt_pebs_init() call
Quoted 12 lines · Eugene Loh
Quoted 10 lines · Kris Van Hees
Quoted 1 line · Eugene Loh
So do you have a proposal for what the new semantics for bufsize should be?
I believe the semantics of a user-specified bufsize should be as follows:
- If the bufsize specified by the user is less than the minimum buffer size required to store the largest trace record, an error should be reported.
- If the bufsize satisfies the minimum requirement, the implementation must ensure that it is round up (if needed) to satisfy the perf ring buffer size requirement (size needs to be 2^n * pagesize, for n = 0, 1, 2, ...)
Quoted 7 lines
Quoted 2 lines
Point 1 is clearly debatable but follows the principle that you cannot put something bigger into something that is too small to hold it.
Thanks. It helps to see a specific proposal. It just strikes me as odd that we would say a user specified too low when we're not going to use that size anyhow -- we're going to increase it. Why should we complain about a request we're going to ignore?
We do not ignore it. If it is not big enough, we report and error and exit.
Quoted 7 lines
What do you think about not automatically resizing? Resizing in legacy I think was by default and rounded down. You autosize up. How about we don't resize? If they ask for less than min, we complain and tell them what the min size. If they're not 2^n pages, we tell them so. The default right now is 4m. So if someone is playing with bufsize we might as well honor their request (and give them guidance if what they're trying to do doesn't work).
Resizing in the original code was done if the allocation request could not be satisfied by the kernel code. The kernel code would then try a series of smaller sizes until it found one that resulted in successful allocation. We currently do not do that and instead simply fail if allocations fail, because we can - it is all done in userspace. We could do auto-reduction to try a size that works, but the user can do that themselves as easily.
The increasing of the size is done automatically because we do not want to bog down the user with needing to know what select sizes are acceptable. If they provide a size and we can satisfy it with that size or the nearest acceptable size, we can just do that.
Look at it in similarity to malloc()... we don't know whether our malloc request is satisfied by the exact size we supplied or by a larger block. And as a user, we do not really care.
Quoted 131 lines
Quoted 131 lines
Quoted 1 line
(And, why not simply ignore bufsize?)
Because we want users to be able to tune the size of the tracing buffer, which can affect performance in terms of how quickly trace data is generated versus how quiickly it is consumed. It interacts with things like switchrate.
Quoted 126 lines · Kris Van Hees
Quoted 125 lines · Eugene Loh via DTrace-devel
Quoted 47 lines · Kris Van Hees
Quoted 46 lines · Eugene Loh
Quoted 18 lines · Kris Van Hees
Quoted 11 lines · Eugene Loh
Quoted 10 lines · Kris Van Hees
Quoted 9 lines
This patch goes against the intent of the code, as far as I can see. The point of performing the size check prior to increasing the buffer size was to enforce the limit on the size that was explicit set by the user. Then, if that size was sufficient, then DTrace is at liberty to increase that size to a whole multiple of the page size.
But if I were to insist that a buffer can only be 24 bytes, and 24 bytes are not enough to store a single trace record, DTrace should report an error rather than increasing my bufsize setting on its own.
Quoted 6 lines
Quoted 5 lines
The point is that DTrace *does* increase my bufsize setting on its own. Why should DTrace complain about my setting when it's going to ignore my setting anyhow? What value does the pre-existing behavior offer to DTrace users? Are you saying that DTrace should not resize? That it should honor the user's bufsize? No more resizing (to page size or whatever it wants)?
The main point of this code was to retain the bevhaviour that DTrace provided,
Quoted 8 lines
As far as adhering to legacy behavior... quite simply, we do not. We do not set the "principal buffer size" to bufsize. Further, any legacy resizing behavior is, if I understand correctly, to go smaller than the user requested; we do the opposite. Looking to the legacy behavior for precedent is pointless. The situation is that we are unlike legacy behavior in fundamental respects, opposite in another respect (automatic resizing), but consistent in some impractical and useless respect. That consistency strikes me as small consolation.
You can look at this from different angles, yes.
Quoted 5 lines
There is no documentation to change; the documentation is already wrong. This patch was intended as a step to making the behavior something that was describable. Clearly, trying to hold on to a legacy buffering model has produced a byzantine situation in the current port, which treats buffering very differently.
Yes, but if you want to go that route we ought to go all the way, and not some interim solution (see below).
Quoted 3 lines
Perhaps we simply disagree on those points, and this patch is DOA. But the patch points out other problems as well. E.g., the min computation wasn't even right and error checking was wrong.
Let's do this as two patches:
- one that ensures that the computation is updated to the current implementation changes and is correct
- one that provides for increasing the bufsize to be the smallest multiple of pagesize to fit the largest trace record needed for the tracing sessionQuoted 6 lines
Quoted 3 lines
I don't think that checking the rounded up bufsize against the minimum size makes any sense if you are going to increase the specified bufsize anyway. Might as well increase it to fit the minimum size altogether.
I'd like to understand this proposal. Are you saying:
*) Determine the min size (correctly).
Correct.
Quoted 1 line
*) Round that up per
perf_eventrequirements (2^n + 1 pages).No, round up to nearest 2^n. The extra page is allocated automatically by
dt_peb_open().Quoted 1 line
*) Ignore the user's bufsize setting.
Well, no. The bufsize setting is not ignored. We just change the semantics a little (in view of the new implementation) to be a mechanism to allow the user to tune the buffer size, but within certain limitations.
Quoted 3 lines
I'm fine with that (given that we do buffering so unlike the legacy implementation and will not be honoring the user's bufsize value anyhow), but I just wanted to be explicit about ignoring the user's bufsize.
We do not ignore the bufsize as such. But the extent to which the bugsize can be tuned is limited by the implementation. The bufsizw setting cannot be less than the minimum requirement (and you prefer to not complain about that and instead just increase the buffer size). And its value must be a 2^n multiple of the page size, so it will be rounded up to the nearest acceptable value. But that is therefore still controlled by the user's bufsize setting.
Quoted 50 lines
Quoted 44 lines
Quoted 44 lines
Quoted 44 lines
which is that if a user explicitly requests a bufsize that is less than the minimum required for the given trace programs, an error is reported. That is a mater of being consistent (even if it has no practical application that I can see). Tests from the existing version failed because this was not being done right.
As far as functionality, as long as the bufsize is large enough to hold the largest trace record, DTrace can (and needs to) ensure that the buffer size is a whole multiple of the page size because that is required by the perf ring buffer imlementation.
So, DTrace only increases the buffer size to the required multiple of page size if the user supplied bufsize is at least large enough to hold the largest trace record (or if no bufsize was explicitly specified).
We could opt to change the behaviour of the bufsize opton to always round up to a whole multiple of page size, but that is a deviation from the original implementation and thus is something that would need to be documented, etc...
Aside from the computation of the minimum required size needing updating when patches (e.g. the USDT changes) modify the layout and size of the trace records, I do not think that the existing code is wrong.
I am certainly open to a feature change to make bufsize always be rounded up as needed, but that is not a bug fix and I think that ought to be its own patch (along with documentation changes etc). And it might need some more discussion because it brings up the question why we wouldn't just simply always increase bufsize to be the smallest multiple of the page size to accomodate the largest trace record.
Quoted 14 lines
Quoted 14 lines · On Thu, Jun 27, 2024 at 01:38:57AM -0400, [email protected] wrote:
Quoted 13 lines
From: Eugene Loh <[email protected]>
The function had a few issues, mainly with its comments, ranging from typos to incorrect descriptions of behavior.
The function has only one caller. The enforcement of a size minimum was problematic in a number of respects:
- it was missing 4 bytes
- it was enforcing the minimum before the size was increased by the caller
- it was checking dt_pebs_init()==-1,
missing errors with other negative return valuesQuoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
So change the function to accept a minimum and change its return values.
_______________________________________________
DTrace-devel mailing list
[email protected]
https://oss.oracle.com/mailman/listinfo/dtrace-devel
PATCH 32/38 Widen the EPID to include the PRID
In reply to [email protected]From: Eugene Loh <[email protected]>
Each output record has a EPID associated with it, allowing the consumer to get both a data description and a PRID (so it can report PRID and probe function and name). We want to support uprobes that trigger for multiple PRIDs, however, basically breaking this scheme.
So, expand the EPID to 64 bits, half for the old-style EPID (based on static information about the D programs) and half for the PRID (discovered at run time).
The EPID seen by compile-time files like dt_cc.c or dt_map.c are still the old-style EPIDs (even if now 64-bit) since they have no knowledge of the run-time PRIDs.
Further, we do not need to expand:
- the mstate (since it already had the PRID anyhow)
- the output buffer (since it already had an unused 4-byte pad)
The combination of EPID and PRID is for the built-in variable epid as well as what the consumer reads.
--- bpf/get_bvar.c | 6 ++- bpf/probe_error.c | 7 ++- include/dtrace/universal.h | 2 +- libdtrace/dt_bpf.c | 2 - libdtrace/dt_cg.c | 43 +++++++++++-------- libdtrace/dt_consume.c | 28 ++++++++---- libdtrace/dt_dctx.h | 12 ++++-- libdtrace/dt_handle.c | 9 ++-- libdtrace/dt_map.c | 3 ++ libdtrace/dt_open.c | 2 +- test/demo/dtrace/error.r | 2 +- test/stress/buffering/tst.resize3-manual.r | 2 +- test/stress/buffering/tst.resize3.r | 2 +- test/unittest/actions/setopt/tst.badopt.r | 14 +++--- .../arrays/tst.declared-bounds.runtime_out.r | 2 +- test/unittest/codegen/err.deref_0.r | 2 +- test/unittest/codegen/err.deref_1.r | 2 +- test/unittest/codegen/err.deref_i0.r | 2 +- test/unittest/codegen/err.deref_i1.r | 2 +- .../unittest/codegen/err.deref_string-assoc.r | 2 +- test/unittest/codegen/err.deref_string-gvar.r | 2 +- test/unittest/codegen/err.deref_string-lvar.r | 2 +- test/unittest/codegen/err.deref_string-tvar.r | 2 +- .../codegen/err.str_NULL_plus_offset-assoc.r | 2 +- .../codegen/err.str_NULL_plus_offset-lvar.r | 2 +- .../codegen/err.str_NULL_plus_offset-tvar.r | 2 +- .../codegen/err.str_NULL_plus_offset.r | 2 +- test/unittest/disasm/tst.vartab-bvar.r | 2 +- .../tst.DTRACEFLT_BADADDR.null_ptr_field.r | 2 +- test/unittest/error/tst.DTRACEFLT_BADADDR.r | 4 +- .../error/tst.DTRACEFLT_DIVZERO.div.r | 2 +- .../error/tst.DTRACEFLT_DIVZERO.mod.r | 2 +- test/unittest/error/tst.DTRACEFLT_UNKNOWN.r | 4 +- .../error/tst.clause_scope-begin-ended.r | 2 +- test/unittest/error/tst.clause_scope-begin.r | 2 +- .../error/tst.clause_scope-regular.r.p | 12 +++++- test/unittest/error/tst.error.r | 2 +- test/unittest/error/tst.errorend.r | 2 +- .../alloca/err.alloca-bcopy-before-beyond.r | 2 +- .../alloca/err.alloca-bcopy-before-bottom.r | 2 +- .../alloca/err.alloca-bcopy-beyond-top.r | 2 +- .../alloca/err.alloca-bcopy-crossing-bottom.r | 2 +- .../alloca/err.alloca-bcopy-crossing-top.r | 2 +- .../alloca/err.alloca-crossing-clauses.r | 2 +- .../alloca/err.alloca-load-before-bottom.r | 2 +- .../funcs/alloca/err.alloca-load-beyond-top.r | 2 +- .../alloca/err.alloca-load-crossing-bottom.r | 2 +- .../alloca/err.alloca-null-deref-lvalue.r | 2 +- .../funcs/alloca/err.alloca-null-deref.r | 2 +- .../err.alloca-scratch-exceeding-bcopy.r | 2 +- .../alloca/err.alloca-store-before-bottom.r | 2 +- .../alloca/err.alloca-store-beyond-top.r | 2 +- .../alloca/err.alloca-store-crossing-bottom.r | 2 +- test/unittest/funcs/bcopy/err.badbcopy1.r | 2 +- test/unittest/funcs/bcopy/err.badbcopy4.r | 2 +- test/unittest/funcs/bcopy/err.badbcopy5.r | 2 +- test/unittest/funcs/bcopy/err.badbcopy6.r | 2 +- test/unittest/funcs/bcopy/err.badbcopy7.r | 2 +- test/unittest/funcs/bcopy/err.badbcopy8.r | 2 +- test/unittest/funcs/copyin/err.badaddr.r | 2 +- test/unittest/funcs/copyin/err.null_arg1.r | 2 +- test/unittest/funcs/copyinstr/err.badaddr.r | 2 +- test/unittest/funcs/copyinstr/err.null_arg1.r | 2 +- test/unittest/funcs/copyinto/err.badaddr.r | 2 +- test/unittest/funcs/copyinto/err.badsize.r | 2 +- test/unittest/funcs/copyinto/err.null_arg1.r | 2 +- test/unittest/funcs/err.badalloca.r.p | 12 +++++- test/unittest/funcs/err.link_ntopbadaddr.r | 2 +- test/unittest/funcs/err.link_ntopbadarg.r | 2 +- .../inet_ntoa6/err.inet_ntoa6.arg1_null.r | 2 +- .../err.inet_ntoa6.arg1_null_const.r | 2 +- test/unittest/funcs/strlen/tst.null.r | 2 +- test/unittest/funcs/strtok/tst.strtok_null.r | 2 +- .../funcs/strtok/tst.strtok_nulldel.r | 2 +- .../funcs/strtok/tst.strtok_nullstr.r | 2 +- .../funcs/strtok/tst.strtok_nullstr2.r | 2 +- .../funcs/substr/err.substr_null_arg1.r | 2 +- test/unittest/pointers/err.AllocaOverrun.r | 2 +- test/unittest/pointers/err.BadAlign.r | 2 +- test/unittest/pointers/err.InvalidAddress2.r | 2 +- test/unittest/pointers/err.InvalidAddress4.r | 2 +- .../speculation/err.CommitWithInvalid.r | 2 +- .../speculation/err.DiscardWithInvalid.r | 2 +- .../speculation/tst.SpecSizeVariations.r | 22 ---------- .../speculation/tst.SpecSizeVariations.sh | 2 +- test/unittest/speculation/tst.negcommit.r | 2 +- 86 files changed, 174 insertions(+), 148 deletions(-)
bpf/get_bvar.c +4 -2
@@ -48,8 +48,10 @@ noinline uint64_t dt_get_bvar(const dt_dctx_t *dctx, uint32_t id, uint32_t idx) mst->tstamp =bpf_ktime_get_ns ();return mst->tstamp; -case DIF_VAR_EPID : -return mst->epid; +case DIF_VAR_EPID : { +uint64_t val = mst->prid; +return (val <<32 ) | mst->epid; + }case DIF_VAR_ID :return mst->prid;case DIF_VAR_ARG0 :case DIF_VAR_ARG1 :case DIF_VAR_ARG2 :
bpf/probe_error.c +6 -1
@@ -7,6 +7,8 @@#include <bpf/bpf_helpers.h> #include <dt_dctx.h> +extern uint64_t ERROR_PRID ; +#ifndef noinline# define noinline __attribute__((noinline))#endif
@@ -26,15 +28,18 @@ noinline void dt_probe_error(const dt_dctx_t *dctx, uint64_t pc, uint64_t fault, uint64_t illval) {dt_mstate_t *mst = dctx->mst; +int oldprid = mst->prid; mst->argv[0 ] =0 ; - mst->argv[1 ] = mst->epid; + mst->argv[1 ] = (((uint64_t )mst->prid) <<32 ) | mst->epid; mst->argv[2 ] = mst->clid; mst->argv[3 ] = pc; mst->argv[4 ] = fault; mst->argv[5 ] = illval; + mst->prid = ((uint64_t )&ERROR_PRID );dt_error (dctx); + mst->prid = oldprid; mst->fault = fault; }
include/dtrace/universal.h +1 -1
@@ -37,7 +37,7 @@ typedef uint16_t dtrace_actkind_t; /* action kind */typedef uint32_t dtrace_aggid_t ;/* aggregation identifier */ typedef uint32_t dtrace_cacheid_t ;/* predicate cache identifier */ -typedef uint32_t dtrace_epid_t ;/* enabled probe identifier */ +typedef uint64_t dtrace_epid_t ;/* enabled probe identifier */ typedef uint32_t dtrace_optid_t ;/* option identifier */ typedef uint32_t dtrace_specid_t ;/* speculation identifier */
libdtrace/dt_bpf.c +0 -2
@@ -778,7 +778,6 @@ gmap_create_cpuinfo(dtrace_hdl_t *dtp)* The size of the memory region is the sum of: * - size of the DTrace machine state, rounded up to the nearest * multiple of 8 -* - 8 bytes padding for trace buffer alignment purposes * - maximum trace buffer record size, rounded up to the nearest * multiple of 8 * - size of dctx->mem (see dt_dctx.h)
@@ -787,7 +786,6 @@ static int gmap_create_mem(dtrace_hdl_t *dtp) {size_t sz =roundup (sizeof (dt_mstate_t),8 ) + -8 +roundup (dtp->dt_maxreclen,8 ) +DMEM_SIZE (dtp);
libdtrace/dt_cg.c +26 -17
96 lines not on this page · raw message
libdtrace/dt_consume.c +19 -9
@@ -14,9 +14,11 @@#include <ctype.h> #include <alloca.h> #include <dt_impl.h> +#include <dt_dctx.h> #include <dt_module.h> #include <dt_pcap.h> #include <dt_peb.h> +#include <dt_probe.h> #include <dt_state.h> #include <dt_string.h> #include <libproc.h>
@@ -478,7 +480,7 @@ dt_flowindent(dtrace_hdl_t *dtp, dtrace_probedata_t *data, dtrace_epid_t last)*/ if (flow ==DTRACEFLOW_ENTRY ) {if (last !=DTRACE_EPIDNONE && id != last && - pd->id == dtp->dt_pdesc[last]->id) + pd->id == dtp->dt_probes[last >>32 ]->desc->id) flow =DTRACEFLOW_NONE ; }
@@ -2202,19 +2204,23 @@ dt_consume_one_probe(dtrace_hdl_t *dtp, FILE *fp, char *data, uint32_t size, int peekflags, dtrace_epid_t *last, int committing, void *arg) { + int specid;dtrace_epid_t epid; +uint32_t prid;dtrace_datadesc_t *epd;dt_spec_buf_t tmpl;dt_spec_buf_t *dtsb; -int specid;int i;int rval;dtrace_workstatus_t ret;int commit_discard_seen, only_commit_discards;int data_recording =1 ; - epid = ((uint32_t *)data)[0 ]; - specid = ((uint32_t *)data)[1 ]; + specid = *((uint32_t *)(data +DBUF_SPECID )); + epid = *((uint64_t *)(data +DBUF_EPID )); + prid = epid >>32 ; +if (prid > dtp->dt_probe_id) +return dt_set_errno (dtp,EDT_BADEPID );/* * Fill in the epid and address of the epid in the buffer. We need to
@@ -2227,6 +2233,7 @@ dt_consume_one_probe(dtrace_hdl_t *dtp, FILE *fp, char *data, uint32_t size, &pdat->dtpda_pdesc);if (rval !=0 )return dt_set_errno (dtp,EDT_BADEPID ); + pdat->dtpda_pdesc = (dtrace_probedesc_t *)dtp->dt_probes[prid]->desc; epd = pdat->dtpda_ddesc;if (epd->dtdd_uarg !=DT_ECB_DEFAULT ) {
@@ -2661,9 +2668,8 @@ dt_consume_one(dtrace_hdl_t *dtp, FILE *fp, char *buf,* struct { * struct perf_event_header header; * uint32_t size; -* uint32_t pad; -* uint32_t epid; * uint32_t specid; +* dtrace_epid_t epid; * uint64_t data[n]; * } * and 'data' points to the 'size' member at this point.
@@ -2673,13 +2679,17 @@ dt_consume_one(dtrace_hdl_t *dtp, FILE *fp, char *buf,return dt_set_errno (dtp,EDT_DSIZE ); size = *(uint32_t *)data; - data +=sizeof (size); ptr +=sizeof (size) + size;if (ptr != buf + hdr->size)return dt_set_errno (dtp,EDT_DSIZE ); - data +=sizeof (uint32_t );/* skip padding */ - size -=sizeof (uint32_t ); +/* +* The "size" measures from specid to the end. But our buffer +* offsets are relative to &size itself, to preserve 8-byte +* alignment. So, we leave data pointing at size, and we increase +* size by 4 bytes. +*/ + size +=4 ; return dt_consume_one_probe(dtp, fp, data, size, pdat, efunc, rfunc, flow, quiet, peekflags,
libdtrace/dt_dctx.h +8 -4
@@ -82,16 +82,20 @@ typedef struct dt_dctx {* The dctx->buf pointer references a block of memory that contains: * * +----------------+ -* 0 -> | EPID | +* 0 -> | pad | * +----------------+ -* 4 -> | Speculation ID | +* 4 -> | Speculation ID | * +----------------+ -* | Trace Data | +* 8 -> | EPID | +* +----------------+ +* 16 -> | Trace Data | * | ... | * +----------------+ */ -#define DBUF_EPID 0 +#define DBUF_PAD 0#define DBUF_SPECID 4 +#define DBUF_EPID 8 +#define DBUF_DATA 16/* * The dctx->mem pointer references a block of memory that contains:
libdtrace/dt_handle.c +5 -4
@@ -14,6 +14,7 @@#include <alloca.h> #include <dt_impl.h> +#include <dt_probe.h> #include <dt_program.h> static const char _dt_errprog[] =
@@ -147,11 +148,11 @@ dt_handle_err(dtrace_hdl_t *dtp, dtrace_probedata_t *data)* This is an error. We have the following items here: EPID, * faulting action, BPF pc, fault code and faulting address. */ - epid = (uint32_t )DT_REC (uint64_t,0 ); + epid =DT_REC (uint64_t,0 );if (dt_epid_lookup (dtp, epid, &errdd, &errpd) !=0 )return dt_set_errno (dtp,EDT_BADERROR ); - + errpd = (dtrace_probedesc_t *)dtp->dt_probes[epid>>32 ]->desc; err.dteda_ddesc = errdd; err.dteda_pdesc = errpd; err.dteda_cpu = data->dtpda_cpu;
@@ -195,7 +196,7 @@ no_addr: details[0 ] =0 ; } - snprintf(str, len, "error on enabled probe ID %u (ID %u: %s:%s:%s:%s): " + snprintf(str, len, "error on enabled probe ID %lu (ID %u: %s:%s:%s:%s): " "%s%s in %s%s", epid, errpd->id, errpd->prv, errpd->mod, errpd->fun, errpd->prb, dtrace_faultstr(dtp, err.dteda_fault), details,
@@ -256,7 +257,7 @@ dt_handle_liberr(dtrace_hdl_t *dtp, const dtrace_probedata_t *data, str =alloca (len);snprintf (str, len, -"error on enabled probe ID %u (ID %u: %s:%s:%s:%s): %s" , +"error on enabled probe ID %lu (ID %u: %s:%s:%s:%s): %s" , data->dtpda_epid, errpd->id, errpd->prv, errpd->mod, errpd->fun, errpd->prb, faultstr);
libdtrace/dt_map.c +3 -0
@@ -137,6 +137,9 @@ int dt_epid_lookup(dtrace_hdl_t *dtp, dtrace_epid_t epid, dtrace_datadesc_t **ddp, dtrace_probedesc_t **pdp) { +/* Remove the PRID portion of the EPID. */ + epid &=0xffffffff ; +if (epid >= dtp->dt_maxprobe || dtp->dt_ddesc[epid] ==NULL || dtp->dt_pdesc[epid] ==NULL )return -1 ;
libdtrace/dt_open.c +1 -1
@@ -169,7 +169,7 @@ static const dt_ident_t _dtrace_globals[] = { {"discard" ,DT_IDENT_ACTFUNC ,0 ,DT_ACT_DISCARD ,DT_ATTR_STABCMN ,DT_VERS_1_0 , &dt_idops_func, "void(int)" }, { "epid", DT_IDENT_SCALAR, 0, DIF_VAR_EPID, DT_ATTR_STABCMN, DT_VERS_1_0, - &dt_idops_type, "uint_t" }, + &dt_idops_type, "uint64_t" }, { "errno", DT_IDENT_SCALAR, 0, DIF_VAR_ERRNO, DT_ATTR_STABCMN, DT_VERS_1_0, &dt_idops_type, "int" }, { "execname", DT_IDENT_SCALAR, 0, DIF_VAR_EXECNAME,
test/demo/dtrace/error.r +1 -1
@@ -3,4 +3,4 @@ -- @@stderr -- dtrace: script 'test/demo/dtrace/error.d' matched 2 probes -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/stress/buffering/tst.resize3-manual.r +1 -1
@@ -1,5 +1,5 @@ FUNCTION:NAME - :BEGIN 3 + :BEGIN 4294967299 :BEGIN -- @@stderr --
test/stress/buffering/tst.resize3.r +1 -1
@@ -1,5 +1,5 @@ FUNCTION:NAME - :BEGIN 3 + :BEGIN 4294967299 :BEGIN -- @@stderr --
test/unittest/actions/setopt/tst.badopt.r +7 -7
@@ -1,16 +1,16 @@ -- @@stderr -- -dtrace: error on enabled probe ID 2 (ID 1: dtrace:::BEGIN): couldn't set option "Nixon" to "1": Invalid option name +dtrace: error on enabled probe ID 4294967298 (ID 1: dtrace:::BEGIN): couldn't set option "Nixon" to "1": Invalid option name -dtrace: error on enabled probe ID 2 (ID 1: dtrace:::BEGIN): couldn't set option "Harding" to "1": Invalid option name +dtrace: error on enabled probe ID 4294967298 (ID 1: dtrace:::BEGIN): couldn't set option "Harding" to "1": Invalid option name -dtrace: error on enabled probe ID 2 (ID 1: dtrace:::BEGIN): couldn't set option "Hoover" to "1": Invalid option name +dtrace: error on enabled probe ID 4294967298 (ID 1: dtrace:::BEGIN): couldn't set option "Hoover" to "1": Invalid option name -dtrace: error on enabled probe ID 2 (ID 1: dtrace:::BEGIN): couldn't set option "Bush" to "1": Invalid option name +dtrace: error on enabled probe ID 4294967298 (ID 1: dtrace:::BEGIN): couldn't set option "Bush" to "1": Invalid option name -dtrace: error on enabled probe ID 2 (ID 1: dtrace:::BEGIN): couldn't set option "quiet" to "um, no": Invalid value for specified option +dtrace: error on enabled probe ID 4294967298 (ID 1: dtrace:::BEGIN): couldn't set option "quiet" to "um, no": Invalid value for specified option -dtrace: error on enabled probe ID 2 (ID 1: dtrace:::BEGIN): couldn't set option "aggrate" to "0.5hz": Invalid value for specified option +dtrace: error on enabled probe ID 4294967298 (ID 1: dtrace:::BEGIN): couldn't set option "aggrate" to "0.5hz": Invalid value for specified option -dtrace: error on enabled probe ID 2 (ID 1: dtrace:::BEGIN): couldn't set option "bufsize" to "1m": Operation illegal when tracing is active +dtrace: error on enabled probe ID 4294967298 (ID 1: dtrace:::BEGIN): couldn't set option "bufsize" to "1m": Operation illegal when tracing is active
test/unittest/arrays/tst.declared-bounds.runtime_out.r +1 -1
@@ -1,3 +1,3 @@ expected run-time error -- @@stderr -- -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): index out of bounds (8) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): index out of bounds (8) in action #1 at BPF pc NNN
test/unittest/codegen/err.deref_0.r +1 -1
@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address (0) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid address (0) in action #1 at BPF pc NNN
test/unittest/codegen/err.deref_1.r +1 -1
@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address (1) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid address (1) in action #1 at BPF pc NNN
test/unittest/codegen/err.deref_i0.r +1 -1
@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address (0) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid address (0) in action #1 at BPF pc NNN
test/unittest/codegen/err.deref_i1.r +1 -1
@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address (1) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid address (1) in action #1 at BPF pc NNN
test/unittest/codegen/err.deref_string-assoc.r +1 -1
@@ -1,3 +1,3 @@ 66 -- @@stderr -- -dtrace: error on enabled probe ID 4 (ID 1: dtrace:::BEGIN): invalid address (1) in action #2 at BPF pc NNN +dtrace: error on enabled probe ID 4294967300 (ID 1: dtrace:::BEGIN): invalid address (1) in action #2 at BPF pc NNN
test/unittest/codegen/err.deref_string-gvar.r +1 -1
@@ -1,3 +1,3 @@ 66 -- @@stderr -- -dtrace: error on enabled probe ID 4 (ID 1: dtrace:::BEGIN): invalid address (1) in action #2 at BPF pc NNN +dtrace: error on enabled probe ID 4294967300 (ID 1: dtrace:::BEGIN): invalid address (1) in action #2 at BPF pc NNN
test/unittest/codegen/err.deref_string-lvar.r +1 -1
@@ -1,3 +1,3 @@ 66 -- @@stderr -- -dtrace: error on enabled probe ID 4 (ID 1: dtrace:::BEGIN): invalid address (1) in action #2 at BPF pc NNN +dtrace: error on enabled probe ID 4294967300 (ID 1: dtrace:::BEGIN): invalid address (1) in action #2 at BPF pc NNN
test/unittest/codegen/err.deref_string-tvar.r +1 -1
@@ -1,3 +1,3 @@ 66 -- @@stderr -- -dtrace: error on enabled probe ID 4 (ID 1: dtrace:::BEGIN): invalid address (1) in action #2 at BPF pc NNN +dtrace: error on enabled probe ID 4294967300 (ID 1: dtrace:::BEGIN): invalid address (1) in action #2 at BPF pc NNN
test/unittest/codegen/err.str_NULL_plus_offset-assoc.r +1 -1
@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/codegen/err.str_NULL_plus_offset-lvar.r +1 -1
@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/codegen/err.str_NULL_plus_offset-tvar.r +1 -1
@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/codegen/err.str_NULL_plus_offset.r +1 -1
@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/disasm/tst.vartab-bvar.r +1 -1
@@ -4,7 +4,7 @@ curthread scl glb r D type (pointer) (size 8) timestamp scl glb r D type (integer) (size 8) vtimestamp scl glb r D type (integer) (size 8) ipl scl glb r D type (integer) (size 4) -epid scl glb r D type (integer) (size 4) +epid scl glb r D type (integer) (size 8) id scl glb r D type (integer) (size 4) arg0 scl glb r D type (integer) (size 8) arg1 scl glb r D type (integer) (size 8)
test/unittest/error/tst.DTRACEFLT_BADADDR.null_ptr_field.r +1 -1
@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/error/tst.DTRACEFLT_BADADDR.r +2 -2
@@ -1,6 +1,6 @@ -The arguments are 3 1 1 0 +The arguments are 4294967299 1 1 0 The value of arg4 should be 1 The value of arg5 should be 0 -- @@stderr -- -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/error/tst.DTRACEFLT_DIVZERO.div.r +1 -1
@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): divide-by-zero in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): divide-by-zero in action #1 at BPF pc NNN
test/unittest/error/tst.DTRACEFLT_DIVZERO.mod.r +1 -1
@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): divide-by-zero in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): divide-by-zero in action #1 at BPF pc NNN
test/unittest/error/tst.DTRACEFLT_UNKNOWN.r +2 -2
@@ -1,5 +1,5 @@ -The arguments are 3 1 PC 1 64 +The arguments are 4294967299 1 PC 1 64 The value of arg4 = 0 -- @@stderr -- -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/error/tst.clause_scope-begin-ended.r +1 -1
@@ -2,4 +2,4 @@ Error fired Clause executed -- @@stderr -- -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/error/tst.clause_scope-begin.r +1 -1
@@ -2,4 +2,4 @@ Error fired Clause executed -- @@stderr -- -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/error/tst.clause_scope-regular.r.p +10 -2
@@ -1,3 +1,11 @@ -#!/bin/sed -f +#!/usr/bin/awk -f + # This report has a variable probe ID in it. -s/ID [0-9][0-9]*: profile/ID nnn: profile/ +/^dtrace: error on enabled probe ID / { + $7 = and($7, 0xffffffff); # mask out the high 32 bits (variable prid) +} + +{ + sub("ID [0-9][0-9]*: profile", "ID nnn: profile"); + print; +}
test/unittest/error/tst.error.r +1 -1
@@ -1,4 +1,4 @@ Error fired -- @@stderr -- -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/error/tst.errorend.r +1 -1
@@ -2,4 +2,4 @@ Error fired End fired after exit -- @@stderr -- -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/funcs/alloca/err.alloca-bcopy-before-beyond.r +1 -1
@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/funcs/alloca/err.alloca-bcopy-before-bottom.r +1 -1
@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/funcs/alloca/err.alloca-bcopy-beyond-top.r +1 -1
@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/funcs/alloca/err.alloca-bcopy-crossing-bottom.r +1 -1
@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/funcs/alloca/err.alloca-bcopy-crossing-top.r +1 -1
@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid size ({ptr}) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid size ({ptr}) in action #1 at BPF pc NNN
test/unittest/funcs/alloca/err.alloca-crossing-clauses.r +1 -1
@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 4 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #2 at BPF pc NNN +dtrace: error on enabled probe ID 4294967300 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #2 at BPF pc NNN
test/unittest/funcs/alloca/err.alloca-load-before-bottom.r +1 -1
@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/funcs/alloca/err.alloca-load-beyond-top.r +1 -1
@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/funcs/alloca/err.alloca-load-crossing-bottom.r +1 -1
@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/funcs/alloca/err.alloca-null-deref-lvalue.r +1 -1
@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/funcs/alloca/err.alloca-null-deref.r +1 -1
@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/funcs/alloca/err.alloca-scratch-exceeding-bcopy.r +1 -1
@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid size ({ptr}) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid size ({ptr}) in action #1 at BPF pc NNN
test/unittest/funcs/alloca/err.alloca-store-before-bottom.r +1 -1
@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/funcs/alloca/err.alloca-store-beyond-top.r +1 -1
@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/funcs/alloca/err.alloca-store-crossing-bottom.r +1 -1
@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/funcs/bcopy/err.badbcopy1.r +1 -1
@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/funcs/bcopy/err.badbcopy4.r +1 -1
@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/funcs/bcopy/err.badbcopy5.r +1 -1
@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/funcs/bcopy/err.badbcopy6.r +1 -1
@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid size ({ptr}) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid size ({ptr}) in action #1 at BPF pc NNN
test/unittest/funcs/bcopy/err.badbcopy7.r +1 -1
@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid size ({ptr}) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid size ({ptr}) in action #1 at BPF pc NNN
test/unittest/funcs/bcopy/err.badbcopy8.r +1 -1
@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid size ({ptr}) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid size ({ptr}) in action #1 at BPF pc NNN
test/unittest/funcs/copyin/err.badaddr.r +1 -1
@@ -3,4 +3,4 @@ -- @@stderr -- dtrace: script 'test/unittest/funcs/copyin/err.badaddr.d' matched 2 probes -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/funcs/copyin/err.null_arg1.r +1 -1
@@ -3,4 +3,4 @@ -- @@stderr -- dtrace: script 'test/unittest/funcs/copyin/err.null_arg1.d' matched 2 probes -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/funcs/copyinstr/err.badaddr.r +1 -1
@@ -3,4 +3,4 @@ -- @@stderr -- dtrace: script 'test/unittest/funcs/copyinstr/err.badaddr.d' matched 2 probes -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/funcs/copyinstr/err.null_arg1.r +1 -1
@@ -3,4 +3,4 @@ -- @@stderr -- dtrace: script 'test/unittest/funcs/copyinstr/err.null_arg1.d' matched 2 probes -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/funcs/copyinto/err.badaddr.r +1 -1
@@ -3,4 +3,4 @@ -- @@stderr -- dtrace: script 'test/unittest/funcs/copyinto/err.badaddr.d' matched 2 probes -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/funcs/copyinto/err.badsize.r +1 -1
@@ -3,4 +3,4 @@ -- @@stderr -- dtrace: script 'test/unittest/funcs/copyinto/err.badsize.d' matched 2 probes -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid size ({ptr}) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid size ({ptr}) in action #1 at BPF pc NNN
test/unittest/funcs/copyinto/err.null_arg1.r +1 -1
@@ -3,4 +3,4 @@ -- @@stderr -- dtrace: script 'test/unittest/funcs/copyinto/err.null_arg1.d' matched 2 probes -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/funcs/err.badalloca.r.p +10 -2
@@ -1,3 +1,11 @@ -#!/bin/sed -f +#!/usr/bin/awk -f -s/(ID [0-9]*/(ID NNN/g +# This report has a variable probe ID in it. +/^dtrace: error on enabled probe ID / { + $7 = and($7, 0xffffffff); # mask out the high 32 bits (variable prid) +} + +{ + sub("ID [0-9]*: profile", "ID NNN: profile"); + print; +}
test/unittest/funcs/err.link_ntopbadaddr.r +1 -1
@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/funcs/err.link_ntopbadarg.r +1 -1
@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): illegal operation in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): illegal operation in action #1 at BPF pc NNN
test/unittest/funcs/inet_ntoa6/err.inet_ntoa6.arg1_null.r +1 -1
@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/funcs/inet_ntoa6/err.inet_ntoa6.arg1_null_const.r +1 -1
@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/funcs/strlen/tst.null.r +1 -1
@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/funcs/strtok/tst.strtok_null.r +1 -1
@@ -3,4 +3,4 @@ -- @@stderr -- dtrace: script 'test/unittest/funcs/strtok/tst.strtok_null.d' matched 2 probes -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/funcs/strtok/tst.strtok_nulldel.r +1 -1
@@ -3,4 +3,4 @@ -- @@stderr -- dtrace: script 'test/unittest/funcs/strtok/tst.strtok_nulldel.d' matched 2 probes -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/funcs/strtok/tst.strtok_nullstr.r +1 -1
@@ -3,4 +3,4 @@ -- @@stderr -- dtrace: script 'test/unittest/funcs/strtok/tst.strtok_nullstr.d' matched 2 probes -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/funcs/strtok/tst.strtok_nullstr2.r +1 -1
@@ -4,4 +4,4 @@ -- @@stderr -- dtrace: script 'test/unittest/funcs/strtok/tst.strtok_nullstr2.d' matched 4 probes -dtrace: error on enabled probe ID 4 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #2 at BPF pc NNN +dtrace: error on enabled probe ID 4294967300 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #2 at BPF pc NNN
test/unittest/funcs/substr/err.substr_null_arg1.r +1 -1
@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/pointers/err.AllocaOverrun.r +1 -1
@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/pointers/err.BadAlign.r +1 -1
@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/pointers/err.InvalidAddress2.r +1 -1
@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/pointers/err.InvalidAddress4.r +1 -1
@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967299 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/speculation/err.CommitWithInvalid.r +1 -1
@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 4 (ID 1: dtrace:::BEGIN): illegal operation in action #2 at BPF pc NNN +dtrace: error on enabled probe ID 4294967300 (ID 1: dtrace:::BEGIN): illegal operation in action #2 at BPF pc NNN
test/unittest/speculation/err.DiscardWithInvalid.r +1 -1
@@ -1,3 +1,3 @@ -- @@stderr -- -dtrace: error on enabled probe ID 4 (ID 1: dtrace:::BEGIN): illegal operation in action #2 at BPF pc NNN +dtrace: error on enabled probe ID 4294967300 (ID 1: dtrace:::BEGIN): illegal operation in action #2 at BPF pc NNN
test/unittest/speculation/tst.SpecSizeVariations.r +0 -22
@@ -11,26 +11,6 @@ Speculative buffer ID: 1 123456706 counts: 1 1 -Speculative buffer ID: 1 -123456700 -123456701 -123456702 -123456703 -123456704 -123456705 -123456706 -counts: 1 1 - -Speculative buffer ID: 1 -123456700 -123456701 -123456702 -123456703 -123456704 -123456705 -123456706 -counts: 2 1 - Speculative buffer ID: 1 123456700 123456701
@@ -64,5 +44,3 @@ counts: 2 1 dtrace: 2 speculative drops dtrace: 1 speculative drop dtrace: 1 speculative drop -dtrace: 1 speculative drop -dtrace: 1 speculative drop
test/unittest/speculation/tst.SpecSizeVariations.sh +1 -1
@@ -9,7 +9,7 @@ dtrace=$1 -for x in 63 64 79 80 143 144; do +for x in 71 72 159 160; do $dtrace $dt_flags -xspecsize=$x -qn ' BEGIN {
test/unittest/speculation/tst.negcommit.r +1 -1
@@ -3,4 +3,4 @@ -- @@stderr -- dtrace: script 'test/unittest/speculation/tst.negcommit.d' matched 2 probes -dtrace: error on enabled probe ID 2 (ID 1: dtrace:::BEGIN): illegal operation in action #1 at BPF pc NNN +dtrace: error on enabled probe ID 4294967298 (ID 1: dtrace:::BEGIN): illegal operation in action #1 at BPF pc NNN
Signature · 1 line
2.18.4
PATCH 33/38 Eliminate dt_pdesc
In reply to [email protected]From: Eugene Loh <[email protected]>
--- libdtrace/dt_cc.c | 8 +------- libdtrace/dt_consume.c | 3 +-- libdtrace/dt_handle.c | 2 +- libdtrace/dt_impl.h | 7 ++----- libdtrace/dt_map.c | 36 +++++++----------------------------- 5 files changed, 12 insertions(+), 44 deletions(-)
libdtrace/dt_cc.c +1 -7
@@ -958,7 +958,6 @@ dt_link_construct(dtrace_hdl_t *dtp, const dt_probe_t *prp, dtrace_difo_t *dp,uint_t len = sdp->dtdo_brelen;const dof_relodesc_t *rp = sdp->dtdo_breltab;dof_relodesc_t *nrp = &dp->dtdo_breltab[rc]; -dtrace_id_t prid = prp->desc->id;int no_deps =0 ;if (idp !=NULL ) {
@@ -1199,11 +1198,6 @@ dt_link_construct(dtrace_hdl_t *dtp, const dt_probe_t *prp, dtrace_difo_t *dp,case DT_CONST_STACK_SKIP : nrp->dofr_data = prp->prov->impl->stack_skip;continue ; -default : -/* probe name -> value is probe id */ -if (strchr (idp->di_name,':' ) !=NULL ) - prid = rp->dofr_data; -continue ; }continue ;
@@ -1220,7 +1214,7 @@ dt_link_construct(dtrace_hdl_t *dtp, const dt_probe_t *prp, dtrace_difo_t *dp,if (rdp ==NULL )return -1 ;if (rdp->dtdo_ddesc !=NULL ) { - nepid =dt_epid_add (dtp, rdp->dtdo_ddesc, prid); + nepid =dt_epid_add (dtp, rdp->dtdo_ddesc); clid++; }else nepid =0 ;
libdtrace/dt_consume.c +1 -2
@@ -2229,8 +2229,7 @@ dt_consume_one_probe(dtrace_hdl_t *dtp, FILE *fp, char *data, uint32_t size, pdat->dtpda_epid = epid; pdat->dtpda_data = data; - rval =dt_epid_lookup (dtp, epid, &pdat->dtpda_ddesc, - &pdat->dtpda_pdesc); + rval =dt_epid_lookup (dtp, epid, &pdat->dtpda_ddesc);if (rval !=0 )return dt_set_errno (dtp,EDT_BADEPID ); pdat->dtpda_pdesc = (dtrace_probedesc_t *)dtp->dt_probes[prid]->desc;
libdtrace/dt_handle.c +1 -1
@@ -150,7 +150,7 @@ dt_handle_err(dtrace_hdl_t *dtp, dtrace_probedata_t *data)*/ epid =DT_REC (uint64_t,0 ); -if (dt_epid_lookup (dtp, epid, &errdd, &errpd) !=0 ) +if (dt_epid_lookup (dtp, epid, &errdd) !=0 )return dt_set_errno (dtp,EDT_BADERROR ); errpd = (dtrace_probedesc_t *)dtp->dt_probes[epid>>32 ]->desc; err.dteda_ddesc = errdd;
libdtrace/dt_impl.h +2 -5
@@ -371,7 +371,6 @@ struct dtrace_hdl {dtrace_epid_t dt_nextepid;/* next enabled probe ID to assign */ size_t dt_maxprobe;/* max enabled probe ID */ dtrace_datadesc_t **dt_ddesc;/* probe data descriptions */ -dtrace_probedesc_t **dt_pdesc;/* probe descriptions for enabled prbs */ size_t dt_maxagg;/* max aggregation ID */ dtrace_aggdesc_t **dt_adesc;/* aggregation descriptions */ dt_aggregate_t dt_aggregate;/* aggregate */
@@ -826,10 +825,8 @@ extern dtrace_datadesc_t *dt_datadesc_hold(dtrace_datadesc_t *ddp);extern void dt_datadesc_release (dtrace_hdl_t *,dtrace_datadesc_t *);extern dtrace_datadesc_t *dt_datadesc_create (dtrace_hdl_t *);extern int dt_datadesc_finalize (dtrace_hdl_t *,dtrace_datadesc_t *); -extern dtrace_epid_t dt_epid_add (dtrace_hdl_t *,dtrace_datadesc_t *, -dtrace_id_t ); -extern int dt_epid_lookup (dtrace_hdl_t *,dtrace_epid_t ,dtrace_datadesc_t **, -dtrace_probedesc_t **); +extern dtrace_epid_t dt_epid_add (dtrace_hdl_t *,dtrace_datadesc_t *); +extern int dt_epid_lookup (dtrace_hdl_t *,dtrace_epid_t ,dtrace_datadesc_t **);extern void dt_epid_destroy (dtrace_hdl_t *);typedef void (*dt_cg_gap_f )(dt_pcb_t *,int ); extern uint32_t dt_rec_add(dtrace_hdl_t *, dt_cg_gap_f, dtrace_actkind_t,
libdtrace/dt_map.c +7 -29
@@ -91,7 +91,7 @@ dt_datadesc_finalize(dtrace_hdl_t *dtp, dtrace_datadesc_t *ddp)* description. */ dtrace_epid_t -dt_epid_add (dtrace_hdl_t *dtp,dtrace_datadesc_t *ddp,dtrace_id_t prid) +dt_epid_add (dtrace_hdl_t *dtp,dtrace_datadesc_t *ddp) {dtrace_id_t max = dtp->dt_maxprobe;dtrace_epid_t epid;
@@ -100,27 +100,19 @@ dt_epid_add(dtrace_hdl_t *dtp, dtrace_datadesc_t *ddp, dtrace_id_t prid)if (epid >= max || dtp->dt_ddesc ==NULL ) {dtrace_id_t nmax = max ? (max <<1 ) :2 ;dtrace_datadesc_t **nddesc; -dtrace_probedesc_t **npdesc; nddesc =dt_calloc (dtp, nmax,sizeof (void *)); - npdesc =dt_calloc (dtp, nmax,sizeof (void *)); -if (nddesc ==NULL || npdesc ==NULL ) { -dt_free (dtp, nddesc); -dt_free (dtp, npdesc); +if (nddesc ==NULL )return dt_set_errno (dtp,EDT_NOMEM ); - }if (dtp->dt_ddesc !=NULL ) {size_t osize = max *sizeof (void *);memcpy (nddesc, dtp->dt_ddesc, osize);dt_free (dtp, dtp->dt_ddesc); -memcpy (npdesc, dtp->dt_pdesc, osize); -dt_free (dtp, dtp->dt_pdesc); } dtp->dt_ddesc = nddesc; - dtp->dt_pdesc = npdesc; dtp->dt_maxprobe = nmax; }
@@ -128,24 +120,20 @@ dt_epid_add(dtrace_hdl_t *dtp, dtrace_datadesc_t *ddp, dtrace_id_t prid)return epid; dtp->dt_ddesc[epid] =dt_datadesc_hold (ddp); - dtp->dt_pdesc[epid] = (dtrace_probedesc_t *)dtp->dt_probes[prid]->desc;return epid; }int -dt_epid_lookup (dtrace_hdl_t *dtp,dtrace_epid_t epid,dtrace_datadesc_t **ddp, -dtrace_probedesc_t **pdp) +dt_epid_lookup (dtrace_hdl_t *dtp,dtrace_epid_t epid,dtrace_datadesc_t **ddp) {/* Remove the PRID portion of the EPID. */ epid &=0xffffffff ; -if (epid >= dtp->dt_maxprobe || - dtp->dt_ddesc[epid] ==NULL || dtp->dt_pdesc[epid] ==NULL ) +if (epid >= dtp->dt_maxprobe || dtp->dt_ddesc[epid] ==NULL )return -1 ; *ddp = dtp->dt_ddesc[epid]; - *pdp = dtp->dt_pdesc[epid];return 0 ; }
@@ -155,26 +143,16 @@ dt_epid_destroy(dtrace_hdl_t *dtp) {size_t i; -assert ((dtp->dt_pdesc !=NULL && dtp->dt_ddesc !=NULL && - dtp->dt_maxprobe >0 ) || (dtp->dt_pdesc ==NULL && - dtp->dt_ddesc ==NULL && dtp->dt_maxprobe ==0 )); - -if (dtp->dt_pdesc ==NULL ) -return ; +assert ((dtp->dt_ddesc !=NULL && dtp->dt_maxprobe >0 ) || + (dtp->dt_ddesc ==NULL && dtp->dt_maxprobe ==0 ));for (i =0 ; i < dtp->dt_maxprobe; i++) { -if (dtp->dt_ddesc[i] ==NULL ) { -assert (dtp->dt_pdesc[i] ==NULL ); +if (dtp->dt_ddesc[i] ==NULL )continue ; - }dt_datadesc_release (dtp, dtp->dt_ddesc[i]); -assert (dtp->dt_pdesc[i] !=NULL ); } -free (dtp->dt_pdesc); - dtp->dt_pdesc =NULL ; -free (dtp->dt_ddesc); dtp->dt_ddesc =NULL ; dtp->dt_nextepid =0 ;
Signature · 1 line
2.18.4
PATCH 34/38 Create the BPF uprobes map
In reply to [email protected]From: Eugene Loh <[email protected]>
WIP, sizing is hardwired for now.
WIP, should add new pids and purge old ones (after the initial call).
--- libdtrace/dt_bpf.c | 44 +++++++++++++++++++++++++++ libdtrace/dt_dlibs.c | 1 + libdtrace/dt_impl.h | 3 ++ libdtrace/dt_prov_uprobe.c | 61 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 109 insertions(+)
libdtrace/dt_bpf.c +44 -0
@@ -944,6 +944,49 @@ gmap_create_probes(dtrace_hdl_t *dtp)return 0 ; } +/* +* Create the 'uprobes' BPF map. +* +* Uprobe information map. This is a global hash map for use +* with USDT and pid probes). It is indexed by (pid, probe ID), +* using the probe ID of the underlying probe. The value is a +* probe ID for the overlying probe and a bit mask indicating +* which clauses to execute for this pid. +* +* WIP. Just make up some sizes for now. +* +* How big is a probe ID? Sometimes, it's a dtrace_id_t. +* And uts/common/sys/dtrace_types.h gives us "typedef uint32_t dtrace_id_t". +* Meanwhile, libdtrace/dt_impl.h has "uint32_t dt_probe_id". +* So either uint32_t or dtrace_id_t is fine. +* +* How big should our bit mask be? Start with 8*sizeof(long long) bits. +* +* How many entries should we allow? Start with 1000. +* +* WIP. Note that two different overlying probes (differing by more +* than just pid) could map to the same underlying probe. E.g., a +* USDT probe would have an underlying probe and pid probe with the +* right offset could map to the same uprobe. This means that clauses +* called by the uprobe might have to be called more than once; one +* would need to go through the clauses once for one overlying probe +* and then again for the other. This scenario is not yet addressed. +* It is a problem even before this patch, but easier to fix. +*/ +static int +gmap_create_uprobes (dtrace_hdl_t *dtp) +{ + dtp->dt_uprobesmap_fd =create_gmap (dtp,"uprobes" ,BPF_MAP_TYPE_HASH , + dtp->dt_uprobesmap_ksz, dtp->dt_uprobesmap_vsz,1000 ); +if (dtp->dt_uprobesmap_fd ==-1 ) +return -1 ; + +/* Populate the newly created map. FIXME: this is probably not the right place for this. */ + dt_uprobe.update (dtp,NULL ); + +return 0 ; +} +/* * Create the 'gvars' BPF map. *
@@ -1049,6 +1092,7 @@ dt_bpf_gmap_create(dtrace_hdl_t *dtp) CREATE_MAP(scratchmem) CREATE_MAP(strtab) CREATE_MAP(probes) + CREATE_MAP(uprobes) CREATE_MAP(gvars) CREATE_MAP(lvars) CREATE_MAP(dvars)
libdtrace/dt_dlibs.c +1 -0
@@ -66,6 +66,7 @@ static const dt_ident_t dt_bpf_symbols[] = {DT_BPF_SYMBOL (lvars,DT_IDENT_PTR ),DT_BPF_SYMBOL (mem,DT_IDENT_PTR ),DT_BPF_SYMBOL (probes,DT_IDENT_PTR ), +DT_BPF_SYMBOL (uprobes,DT_IDENT_PTR ),DT_BPF_SYMBOL (scratchmem,DT_IDENT_PTR ),DT_BPF_SYMBOL (specs,DT_IDENT_PTR ), DT_BPF_SYMBOL(state, DT_IDENT_PTR),
libdtrace/dt_impl.h +3 -0
@@ -423,6 +423,9 @@ struct dtrace_hdl {int dt_aggmap_fd;/* file descriptor for the 'aggs' BPF map */ int dt_genmap_fd;/* file descriptor for the 'agggen' BPF map */ int dt_cpumap_fd;/* file descriptor for the 'cpuinfo' BPF map */ +int dt_uprobesmap_fd;/* file descriptor for the 'uprobes' BPF map */ +int dt_uprobesmap_ksz;/* 'uprobes' BPF map key size */ +int dt_uprobesmap_vsz;/* 'uprobes' BPF map value size */ dtrace_handle_err_f *dt_errhdlr;/* error handler, if any */ void *dt_errarg;/* error handler argument */ dtrace_handle_drop_f *dt_drophdlr;/* drop handler, if any */
libdtrace/dt_prov_uprobe.c +61 -0
91 lines not on this page · raw message
Signature · 1 line
2.18.4
PATCH 35/38 Use uprobes map to call clauses conditionally
In reply to [email protected]From: Eugene Loh <[email protected]>
Check that the is-enabled trampoline is sufficiently tested.
--- libdtrace/dt_prov_uprobe.c | 147 +++++++++++++++++-------------------- 1 file changed, 68 insertions(+), 79 deletions(-)
libdtrace/dt_prov_uprobe.c +68 -79
@@ -517,8 +517,11 @@ static int trampoline(dt_pcb_t *pcb, uint_t exitlbl)dt_irlist_t *dlp = &pcb->pcb_ir;const dt_probe_t *uprp = pcb->pcb_probe;const dt_uprobe_t *upp = uprp->prv_data; -const list_probe_t *pop;uint_t lbl_exit = pcb->pcb_exitlbl; +dt_ident_t *uprobes =dt_dlib_get_map (pcb->pcb_hdl,"uprobes" ); +dt_probe_clause_t *pcp; + +assert (uprobes !=NULL );dt_cg_tramp_prologue (pcb);
@@ -527,7 +530,6 @@ static int trampoline(dt_pcb_t *pcb, uint_t exitlbl)* // (%r7 = dctx->mst) * // (%r8 = dctx->ctx) */ -dt_cg_tramp_copy_regs (pcb);if (upp->flags &PP_IS_RETURN )dt_cg_tramp_copy_rval_from_regs (pcb);
@@ -542,47 +544,59 @@ static int trampoline(dt_pcb_t *pcb, uint_t exitlbl)emit (dlp,BPF_ALU64_IMM (BPF_RSH ,BPF_REG_0 ,32 ));/* -* Generate a composite conditional clause: -* -* if (pid == PID1) { -* dctx->mst->prid = PRID1; -* < any number of clause calls > -* goto exit; -* } else if (pid == PID2) { -* dctx->mst->prid = PRID2; -* < any number of clause calls > -* goto exit; -* } else if (pid == ...) { -* < ... > -* } -* -* It is valid and safe to use %r0 to hold the pid value because there -* are no assignments to %r0 possible in between the conditional -* statements. +* Look up in the BPF uprobes map. Space for the look-up key will be used +* on the BPF stack at %r9-sizeof(uprobe_map_key_t). The key comprises the +* pid (in %r0) and the underlying-probe prid. */ -for (pop =dt_list_next (&upp->probes); pop !=NULL ; - pop =dt_list_next (pop)) { -const dt_probe_t *prp = pop->probe; -uint_t lbl_next =dt_irlist_label (dlp); -pid_t pid; -dt_ident_t *idp; +emit (dlp,BPF_STORE (BPF_W ,BPF_REG_9 , (int )(-sizeof (uprobe_map_key_t)),BPF_REG_0 )); +emit (dlp,BPF_STORE_IMM (BPF_W ,BPF_REG_9 , (int )(-sizeof (dtrace_id_t))/* or -sizeof(uprobe_map_key_t) + sizeof(pid_t) */ , uprp->desc->id)); +dt_cg_xsetx (dlp, uprobes,DT_LBL_NONE ,BPF_REG_1 , uprobes->di_id); +emit (dlp,BPF_MOV_REG (BPF_REG_2 ,BPF_REG_9 )); +emit (dlp,BPF_ALU64_IMM (BPF_ADD ,BPF_REG_2 , (int )(-sizeof (uprobe_map_key_t)))); +emit (dlp,BPF_CALL_HELPER (BPF_FUNC_map_lookup_elem)); +emit (dlp,BPF_BRANCH_IMM (BPF_JEQ ,BPF_REG_0 ,0 , lbl_exit)); + +/* Read the PRID from the table lookup and store to mst->prid. */ +emit (dlp,BPF_LOAD (BPF_W ,BPF_REG_1 ,BPF_REG_0 ,0 )); +emit (dlp,BPF_STORE (BPF_W ,BPF_REG_7 ,DMST_PRID ,BPF_REG_1 )); - pid =dt_pid_get_pid (prp->desc, pcb->pcb_hdl, pcb,NULL ); -assert (pid !=-1 ); +/* Read the bit mask from the table lookup in %r6. */ // FIXME someday, extend this past 64 bits +emit (dlp,BPF_LOAD (BPF_DW ,BPF_REG_6 ,BPF_REG_0 , offsetof(uprobe_map_val_t , mask))); - idp =dt_dlib_add_probe_var (pcb->pcb_hdl, prp); -assert (idp !=NULL ); +/* +* Hold the bit mask in %r6 between clause calls. +*/ +for (pcp =dt_list_next (&uprp->clauses); pcp; pcp =dt_list_next (pcp)) { +dt_ident_t *idp = pcp->clause; +uint_t lbl_next =dt_irlist_label (dlp); + +/* If the lowest %r6 bit is 0, skip over this clause. */ +emit (dlp,BPF_MOV_REG (BPF_REG_1 ,BPF_REG_6 )); +emit (dlp,BPF_ALU64_IMM (BPF_AND ,BPF_REG_1 ,1 )); +emit (dlp,BPF_BRANCH_IMM (BPF_JEQ ,BPF_REG_1 ,0 , lbl_next));/* -* Check whether this pid-provider probe serves the current -* process, and emit a sequence of clauses for it when it does. +* if (*dctx.act != act) // ldw %r0, [%r9 + DCTX_ACT] +* goto exit; // ldw %r0, [%r0 + 0] +* // jne %r0, act, lbl_exit */ -emit (dlp,BPF_BRANCH_IMM (BPF_JNE ,BPF_REG_0 , pid, lbl_next)); -emite (dlp,BPF_STORE_IMM (BPF_W ,BPF_REG_7 ,DMST_PRID , prp->desc->id), idp); -dt_cg_tramp_call_clauses (pcb, prp,DT_ACTIVITY_ACTIVE ); -emit (dlp,BPF_JUMP (lbl_exit)); +emit (dlp,BPF_LOAD (BPF_DW ,BPF_REG_0 ,BPF_REG_9 ,DCTX_ACT )); +emit (dlp,BPF_LOAD (BPF_W ,BPF_REG_0 ,BPF_REG_0 ,0 )); +emit (dlp,BPF_BRANCH_IMM (BPF_JNE ,BPF_REG_0 ,DT_ACTIVITY_ACTIVE , lbl_exit)); + +/* dctx.mst->scratch_top = 8 */ +emit (dlp,BPF_STORE_IMM (BPF_W ,BPF_REG_7 ,DMST_SCRATCH_TOP ,8 )); + +/* Call clause. */ +emit (dlp,BPF_MOV_REG (BPF_REG_1 ,BPF_REG_9 )); +emite (dlp,BPF_CALL_FUNC (idp->di_id), idp); + +/* Finished this clause. */ emitl (dlp, lbl_next,BPF_NOP ()); + +/* Right-shift %r6. */ +emit (dlp,BPF_ALU64_IMM (BPF_RSH ,BPF_REG_6 ,1 )); }dt_cg_tramp_return (pcb);
@@ -630,10 +644,9 @@ static int trampoline_is_enabled(dt_pcb_t *pcb, uint_t exitlbl) {dt_irlist_t *dlp = &pcb->pcb_ir;const dt_probe_t *uprp = pcb->pcb_probe; -const dt_uprobe_t *upp = uprp->prv_data; -const list_probe_t *pop; -uint_t lbl_assign =dt_irlist_label (dlp); -uint_t lbl_exit = pcb->pcb_exitlbl; +dt_ident_t *uprobes =dt_dlib_get_map (pcb->pcb_hdl,"uprobes" ); + +assert (uprobes !=NULL );dt_cg_tramp_prologue (pcb);
@@ -642,8 +655,7 @@ static int trampoline_is_enabled(dt_pcb_t *pcb, uint_t exitlbl)* // (%r7 = dctx->mst) * // (%r8 = dctx->ctx) */ - -dt_cg_tramp_copy_regs (pcb); +dt_cg_tramp_copy_regs (pcb);// FIXME, wait, why are we doing this? /* * Copy in the first function argument, a pointer value to which
@@ -660,46 +672,23 @@ static int trampoline_is_enabled(dt_pcb_t *pcb, uint_t exitlbl)emit (dlp,BPF_ALU64_IMM (BPF_RSH ,BPF_REG_0 ,32 ));/* -* Generate a composite conditional clause, as above, except that rather -* than emitting call_clauses, we emit copyouts instead, using -* copyout_val() above: -* -* if (pid == PID1) { -* goto assign; -* } else if (pid == PID2) { -* goto assign; -* } else if (pid == ...) { -* goto assign; -* } -* goto exit; -* assign: -* *arg0 = 1; -* goto exit; -* -* It is valid and safe to use %r0 to hold the pid value because there -* are no assignments to %r0 possible in between the conditional -* statements. +* Look up in the BPF uprobes map. Space for the look-up key will be used +* on the BPF stack at %r9-sizeof(uprobe_map_key_t). The key comprises the +* pid (in %r0) and the underlying-probe prid. */ -for (pop =dt_list_next (&upp->probes); pop !=NULL ; - pop =dt_list_next (pop)) { -const dt_probe_t *prp = pop->probe; -pid_t pid; -dt_ident_t *idp; - - pid =dt_pid_get_pid (prp->desc, pcb->pcb_hdl, pcb,NULL ); -assert (pid !=-1 ); +emit (dlp,BPF_STORE (BPF_W ,BPF_REG_9 , (int )(-sizeof (uprobe_map_key_t)),BPF_REG_0 )); +emit (dlp,BPF_STORE_IMM (BPF_W ,BPF_REG_9 , (int )(-sizeof (dtrace_id_t))/* or -sizeof(uprobe_map_key_t) + sizeof(pid_t) */ , uprp->desc->id)); +dt_cg_xsetx (dlp, uprobes,DT_LBL_NONE ,BPF_REG_1 , uprobes->di_id); +emit (dlp,BPF_MOV_REG (BPF_REG_2 ,BPF_REG_9 )); +emit (dlp,BPF_ALU64_IMM (BPF_ADD ,BPF_REG_2 , (int )(-sizeof (uprobe_map_key_t)))); +emit (dlp,BPF_CALL_HELPER (BPF_FUNC_map_lookup_elem)); +emit (dlp,BPF_BRANCH_IMM (BPF_JEQ ,BPF_REG_0 ,0 , pcb->pcb_exitlbl)); - idp =dt_dlib_add_probe_var (pcb->pcb_hdl, prp); -assert (idp !=NULL ); - -/* -* Check whether this pid-provider probe serves the current -* process, and copy out a 1 into arg 0 if so. -*/ -emit (dlp,BPF_BRANCH_IMM (BPF_JEQ ,BPF_REG_0 , pid, lbl_assign)); - } -emit (dlp,BPF_JUMP (lbl_exit)); -copyout_val (pcb, lbl_assign,1 ,0 ); +/* +* If we succeeded, then we use copyout_val() above to assign: +* *arg0 = 1; +*/ +copyout_val (pcb,DT_LBL_NONE ,1 ,0 );// FIXME: This is the only copyout_val() call site... should we just inline it here? dt_cg_tramp_return (pcb);
Signature · 1 line
2.18.4
PATCH 36/38 Inline copyout_val()
In reply to [email protected]From: Eugene Loh <[email protected]>
Squash to "Use uprobes map to call clauses conditionally"?
Why do we call dt_cg_tramp_copy_regs()?
Why do we copy [%r8+PT_REGS_ARG0] to [%r7+DMST_ARG(0)]? Can we not use it in place?
--- libdtrace/dt_prov_uprobe.c | 38 ++++++++------------------------------ 1 file changed, 8 insertions(+), 30 deletions(-)
libdtrace/dt_prov_uprobe.c +8 -30
@@ -604,33 +604,6 @@ static int trampoline(dt_pcb_t *pcb, uint_t exitlbl)return 0 ; } -/* -* Copy the given immediate value into the address given by the specified probe -* argument. -*/ -static void -copyout_val (dt_pcb_t *pcb,uint_t lbl,uint32_t val,int arg) -{ -dt_regset_t *drp = pcb->pcb_regs; -dt_irlist_t *dlp = &pcb->pcb_ir; - -emitl (dlp, lbl,BPF_STORE_IMM (BPF_DW ,BPF_REG_FP ,DT_TRAMP_SP_SLOT (0 ), - val)); - -if (dt_regset_xalloc_args (drp) ==-1 ) -longjmp (yypcb->pcb_jmpbuf,EDT_NOREG ); -emit (dlp,BPF_LOAD (BPF_DW ,BPF_REG_1 ,BPF_REG_7 ,DMST_ARG (arg))); -emit (dlp,BPF_MOV_REG (BPF_REG_2 ,BPF_REG_FP )); -emit (dlp,BPF_ALU64_IMM (BPF_ADD ,BPF_REG_2 ,DT_TRAMP_SP_SLOT (0 ))); -emit (dlp,BPF_MOV_IMM (BPF_REG_3 ,sizeof (uint32_t ))); -dt_regset_xalloc (drp,BPF_REG_0 ); -emit (dlp,BPF_CALL_HELPER (BPF_FUNC_probe_write_user)); - -/* XXX any point error-checking here? What can we possibly do? */ -dt_regset_free (drp,BPF_REG_0 ); -dt_regset_free_args (drp); -} -/* * Generate a BPF trampoline for an is-enabled probe. The is-enabled probe * prototype looks like:
@@ -661,7 +634,7 @@ static int trampoline_is_enabled(dt_pcb_t *pcb, uint_t exitlbl)* Copy in the first function argument, a pointer value to which * the is-enabled state of the probe will be written (necessarily * 1 if this probe is running at all). -*/ +*/ // FIXME why are we doing this? can't we use it in-place? emit (dlp,BPF_LOAD (BPF_DW ,BPF_REG_0 ,BPF_REG_8 ,PT_REGS_ARG0 ));emit (dlp,BPF_STORE (BPF_DW ,BPF_REG_7 ,DMST_ARG (0 ),BPF_REG_0 ));
@@ -685,10 +658,15 @@ static int trampoline_is_enabled(dt_pcb_t *pcb, uint_t exitlbl)emit (dlp,BPF_BRANCH_IMM (BPF_JEQ ,BPF_REG_0 ,0 , pcb->pcb_exitlbl));/* -* If we succeeded, then we use copyout_val() above to assign: +* If we succeeded, then we assign: * *arg0 = 1; */ -copyout_val (pcb,DT_LBL_NONE ,1 ,0 );// FIXME: This is the only copyout_val() call site... should we just inline it here? +emit (dlp,BPF_STORE_IMM (BPF_DW ,BPF_REG_FP ,DT_TRAMP_SP_SLOT (0 ),1 )); +emit (dlp,BPF_LOAD (BPF_DW ,BPF_REG_1 ,BPF_REG_7 ,DMST_ARG (0 )));// FIXME: Why don't we just copy from %r8+? +emit (dlp,BPF_MOV_REG (BPF_REG_2 ,BPF_REG_FP )); +emit (dlp,BPF_ALU64_IMM (BPF_ADD ,BPF_REG_2 ,DT_TRAMP_SP_SLOT (0 ))); +emit (dlp,BPF_MOV_IMM (BPF_REG_3 ,sizeof (uint32_t ))); +emit (dlp,BPF_CALL_HELPER (BPF_FUNC_probe_write_user));dt_cg_tramp_return (pcb);
Signature · 1 line
2.18.4
PATCH 37/38 Fix some dctx->mst->specsize comments
In reply to [email protected]From: Eugene Loh <[email protected]>
--- libdtrace/dt_cg.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
libdtrace/dt_cg.c +3 -3
@@ -1739,7 +1739,7 @@ ok:/* * if (*((uint32_t *)&buf[DBUF_SPECID]) != 0) { -* if (dctx->dmst->specsize + off + size > +* if (dctx->mst->specsize + off + size > * dtp->dt_options[DTRACEOPT_SPECSIZE]) { * state[DT_STATE_SPEC_DROPS]++; *
@@ -2461,7 +2461,7 @@ dt_cg_act_setopt(dt_pcb_t *pcb, dt_node_t *dnp, dtrace_actkind_t kind)* back pending a commit() or discard() for the speculation with the given id. * * Updates the specid in the output buffer header, rather than emitting a new -* record into it. The dctx->dmst->specsize value is initialized with the size +* record into it. The dctx->mst->specsize value is initialized with the size * of the data thus far recorded for this speculation. */ static void
@@ -2491,7 +2491,7 @@ dt_cg_act_speculate(dt_pcb_t *pcb, dt_node_t *dnp, dtrace_actkind_t kind)* goto exit; * *((uint32_t *)&buf[DBUF_SPECID]) = specid; * // mov [%r9 + DBUF_SPECID], %dn_reg -* dctx->dmst->specsize = spec->size; +* dctx->mst->specsize = spec->size; * exit: // nop */
Signature · 1 line
2.18.4
Re: [PATCH 37/38] Fix some dctx->mst->specsize comments
Quoted 3 lines · On Thu, Jun 27, 2024 at 01:39:03AM -0400, [email protected] wrote:
From: Eugene Loh <[email protected]>
Signed-off-by Eugene Loh <[email protected]>
Quoted 38 lines
--- libdtrace/dt_cg.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)libdtrace/dt_cg.c +3
-3@@ -1739,7 +1739,7 @@ ok:/* * if (*((uint32_t *)&buf[DBUF_SPECID]) != 0) { -* if (dctx->dmst->specsize + off + size > +* if (dctx->mst->specsize + off + size > * dtp->dt_options[DTRACEOPT_SPECSIZE]) { * state[DT_STATE_SPEC_DROPS]++; * @@ -2461,7 +2461,7 @@ dt_cg_act_setopt(dt_pcb_t *pcb, dt_node_t *dnp, dtrace_actkind_t kind)* back pending a commit() or discard() for the speculation with the given id. * * Updates the specid in the output buffer header, rather than emitting a new -* record into it. The dctx->dmst->specsize value is initialized with the size +* record into it. The dctx->mst->specsize value is initialized with the size * of the data thus far recorded for this speculation. */ static void@@ -2491,7 +2491,7 @@ dt_cg_act_speculate(dt_pcb_t *pcb, dt_node_t *dnp, dtrace_actkind_t kind)* goto exit; * *((uint32_t *)&buf[DBUF_SPECID]) = specid; * // mov [%r9 + DBUF_SPECID], %dn_reg -* dctx->dmst->specsize = spec->size; +* dctx->mst->specsize = spec->size; * exit: // nop */ Signature · 1 line
2.18.4
PATCH 38/38 Systemwide USDT WIP
In reply to [email protected]From: Eugene Loh <[email protected]>
need to:
- review tests
- handle globs in dt_pid_create_probes_module()
- add process monitoring / inotify
- deal with FIXMEs
--- libdtrace/dt_cc.c | 3 +- libdtrace/dt_pid.c | 133 +++++++++++++++--- .../dtrace-util/tst.ListProbesNameUSDT.sh | 1 - .../dtrace-util/tst.ListProbesProviderUSDT.sh | 1 - test/unittest/usdt/tst.forker.sh | 1 - 5 files changed, 119 insertions(+), 20 deletions(-)
libdtrace/dt_cc.c +2 -1
@@ -278,7 +278,8 @@ dt_setcontext(dtrace_hdl_t *dtp, const dtrace_probedesc_t *pdp)* and tag -- we just have to longjmp() out of here. */ if (pdp->prv && pdp->prv[0 ] && -isdigit (pdp->prv[strlen (pdp->prv) -1 ]) && + (isdigit (pdp->prv[strlen (pdp->prv) -1 ]) || + pdp->prv[strlen (pdp->prv) -1 ] =='*' ) && ((pvp =dt_provider_lookup (dtp, pdp->prv)) ==NULL || pvp->pv_flags &DT_PROVIDER_PID ) &&dt_pid_create_probes ((dtrace_probedesc_t *)pdp, dtp, yypcb) !=0 ) {
libdtrace/dt_pid.c +117 -16
199 lines not on this page · raw message
test/unittest/dtrace-util/tst.ListProbesNameUSDT.sh +0 -1
@@ -5,7 +5,6 @@ # Licensed under the Universal Permissive License v 1.0 as shown at # http://oss.oracle.com/licenses/upl. # -# @@xfail: dtv2 ## #
test/unittest/dtrace-util/tst.ListProbesProviderUSDT.sh +0 -1
@@ -5,7 +5,6 @@ # Licensed under the Universal Permissive License v 1.0 as shown at # http://oss.oracle.com/licenses/upl. # -# @@xfail: dtv2 ## #
test/unittest/usdt/tst.forker.sh +0 -1
@@ -7,7 +7,6 @@ # # # @@timeout: 120 -# @@xfail: dtv2 USDT wildcard if [ $# != 1 ]; then echo expected one argument: '<'dtrace-path'>'
Signature · 1 line
2.18.4
This patch surely should be part of another one that actually provides some code to use the new callback. The implementation of the callback in any particular provider could remain in its own patch after that if you like, but adding this without the code that actually calls it seems less useful. If anything, the commit message itself makes it so generic sounding that one is likely to have no idea what this is meant to be used for, where it would be called from, why, and what the expected result ought to be.
So, combine with the code that uses it please. Which I will review next :)
Quoted 42 lines · On Thu, Jun 27, 2024 at 01:38:46AM -0400, [email protected] wrote:
From: Eugene Loh <[email protected]>
For up-coming USDT-probe support, we need to update a BPF map -- at least when the dtrace session starts but possibly also later to support systemwide USDT tracing for processes that may start up later.
One way to do this is with a USDT-specific update function.
For now, let's add a hook for providers to have provider-specific update functions. User space can either call
for (i = 0; i < ARRAY_SIZE(dt_providers); i++) { if (dt_providers[i]->update) dt_providers[i]->update(...); }any time it likes. Or it can call
dt_usdt.update(...).This is for WIP. A different approach can be adopted later instead.
Signed-off-by Eugene Loh <[email protected]>--- libdtrace/dt_provider.h | 2 ++ 1 file changed, 2 insertions(+)libdtrace/dt_provider.h +2
-0@@ -71,6 +71,8 @@ typedef struct dt_provimpl { void *datap);void (*destroy)(dtrace_hdl_t *dtp,/* free provider data */ void *datap); +void (*update)(dtrace_hdl_t *dtp,/* update provider-specific info */ +void *datap); } dt_provimpl_t;/* list dt_dtrace first */ Signature · 1 line
2.18.4
The plane has barely taken off the ground and already you expect me to have completed the aircraft design??? :^) (I was hoping the magic letters WIP in the commit message would have absolved me of responsibility here.)
Would you be willing to proceed with reviews of the other patches and then we get back to this patch? There is a clearly provider-specific motivation for this function, but the style is to make these functions as provider-agnostic as possible. Maybe we can defer some of the questions this patch raises. Like, how often will the function be called, what triggers that call, will the call be USDT-specific or will it check all providers, etc. For now, I only have USDT-specific answers, but we need to guess what other considerations we expect to have to accommodate.
Quoted 53 lines · Kris Van Hees
This patch surely should be part of another one that actually provides some code to use the new callback. The implementation of the callback in any particular provider could remain in its own patch after that if you like, but adding this without the code that actually calls it seems less useful. If anything, the commit message itself makes it so generic sounding that one is likely to have no idea what this is meant to be used for, where it would be called from, why, and what the expected result ought to be.
So, combine with the code that uses it please. Which I will review next :)
Quoted 42 lines · On Thu, Jun 27, 2024 at 01:38:46AM -0400, [email protected] wrote:
From: Eugene Loh <[email protected]>
For up-coming USDT-probe support, we need to update a BPF map -- at least when the dtrace session starts but possibly also later to support systemwide USDT tracing for processes that may start up later.
One way to do this is with a USDT-specific update function.
For now, let's add a hook for providers to have provider-specific update functions. User space can either call
for (i = 0; i < ARRAY_SIZE(dt_providers); i++) { if (dt_providers[i]->update) dt_providers[i]->update(...); }any time it likes. Or it can call
dt_usdt.update(...).This is for WIP. A different approach can be adopted later instead.
Signed-off-by Eugene Loh <[email protected]>--- libdtrace/dt_provider.h | 2 ++ 1 file changed, 2 insertions(+)libdtrace/dt_provider.h +2
-0@@ -71,6 +71,8 @@ typedef struct dt_provimpl { void *datap);void (*destroy)(dtrace_hdl_t *dtp,/* free provider data */ void *datap); +void (*update)(dtrace_hdl_t *dtp,/* update provider-specific info */ +void *datap); } dt_provimpl_t;/* list dt_dtrace first */ Signature · 1 line
2.18.4