[DTrace-devel] [PATCH 07/12] Fix drop counter handling for local-only updates
Kris Van Hees
kris.van.hees at oracle.com
Mon Jan 8 20:53:55 UTC 2024
On Mon, Jan 08, 2024 at 03:27:26PM -0500, Eugene Loh via DTrace-devel wrote:
> I'm not familiar with how drops are handled, but...
> Reviewed-by: Eugene Loh <eugene.loh at oracle.com>
>
> A 2006 copyright year on a "new" file looks weird. Maybe it's right. I'm
> no lawyer. Just weird.
Oops, will change. Copied an existing test and changed it but forgot to make
sure the copyright is correct.
> On 1/5/24 00:29, Kris Van Hees via DTrace-devel wrote:
> > When at the end of a work loop, the drop counters are updates for local
>
> "are updates"
> ->
> "are updated"
Thanks.
> > updates only (i.e. when tracing is not stopped yet), an invalid drop
> > count could be reported if a drop occured in the BEGIN probe. The cause
> > is that the code assumed that both copies of the status data contained
> > valid data. But when a drop occurs in the BEGIN probe, only the first
> > copy will have non-zero values. Since local-only updates assume that
> > the two copies are identical except for a possible change due to the
> > local update, and any earlier status update would already have reported
> > any differences, it is safe to just copy all data prior to performing
> > the local updates.
> >
> > Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
> > ---
> > libdtrace/dt_work.c | 4 ++-
> > .../drops/drp.DTRACEDROP_DYNAMIC.local_only.d | 30 +++++++++++++++++++
> > .../drops/drp.DTRACEDROP_DYNAMIC.local_only.r | 6 ++++
> > 3 files changed, 39 insertions(+), 1 deletion(-)
> > create mode 100644 test/unittest/drops/drp.DTRACEDROP_DYNAMIC.local_only.d
> > create mode 100644 test/unittest/drops/drp.DTRACEDROP_DYNAMIC.local_only.r
> >
> > diff --git a/libdtrace/dt_work.c b/libdtrace/dt_work.c
> > index fe88a48e..6cac93ea 100644
> > --- a/libdtrace/dt_work.c
> > +++ b/libdtrace/dt_work.c
> > @@ -1,6 +1,6 @@
> > /*
> > * Oracle Linux DTrace.
> > - * Copyright (c) 2006, 2023, 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.
> > */
> > @@ -271,6 +271,8 @@ dtrace_work(dtrace_hdl_t *dtp, FILE *fp, dtrace_consume_probe_f *pfunc,
> > * than once).
> > */
> > if (!dtp->dt_stopped) {
> > + gen = dtp->dt_statusgen;
> > + dtp->dt_status[gen] = dtp->dt_status[gen ^ 1];
> > dt_add_local_status(dtp);
> > gen = dtp->dt_statusgen ^ 1;
> > } else {
> > diff --git a/test/unittest/drops/drp.DTRACEDROP_DYNAMIC.local_only.d b/test/unittest/drops/drp.DTRACEDROP_DYNAMIC.local_only.d
> > new file mode 100644
> > index 00000000..2ebcf150
> > --- /dev/null
> > +++ b/test/unittest/drops/drp.DTRACEDROP_DYNAMIC.local_only.d
> > @@ -0,0 +1,30 @@
> > +/*
> > + * Oracle Linux DTrace.
> > + * 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.
> > + */
> > +
> > +/*
> > + * Ensure that when (at the end of a work loop) a local-only update is done, we
> > + * do not end up reporting (unsigned long long)-1.
> > + *
> > + * If this bug exists, output will look like:
> > + * dtrace: [DTRACEDROP_DYNAMIC] 1 dynamic variable drop
> > + * dtrace: [DTRACEDROP_DYNAMIC] 18446744073709551615 dynamic variable drops
> > + */
> > +
> > +#pragma D option dynvarsize=15
> > +
> > +BEGIN
> > +{
> > + self->a = 1;
> > + self->b = 2;
> > + self->c = 3;
> > + self->d = 4;
> > +}
> > +
> > +tick-1s
> > +{
> > + exit(0);
> > +}
> > diff --git a/test/unittest/drops/drp.DTRACEDROP_DYNAMIC.local_only.r b/test/unittest/drops/drp.DTRACEDROP_DYNAMIC.local_only.r
> > new file mode 100644
> > index 00000000..8af0a5f5
> > --- /dev/null
> > +++ b/test/unittest/drops/drp.DTRACEDROP_DYNAMIC.local_only.r
> > @@ -0,0 +1,6 @@
> > + FUNCTION:NAME
> > + :tick-1s
> > +
> > +-- @@stderr --
> > +dtrace: script 'test/unittest/drops/drp.DTRACEDROP_DYNAMIC.local_only.d' matched 2 probes
> > +dtrace: [DTRACEDROP_DYNAMIC] 1 dynamic variable drop
>
> _______________________________________________
> DTrace-devel mailing list
> DTrace-devel at oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/dtrace-devel
More information about the DTrace-devel
mailing list