[DTrace-devel] [oracle/dtrace-utils] 2ac25e: cg: fix offset for > 8 bit bitfields in dt_cg_ctf_...

euloh noreply at github.com
Tue Sep 16 23:26:58 UTC 2025


  Branch: refs/heads/dev-queue
  Home:   https://github.com/oracle/dtrace-utils
  Commit: 2ac25e06153636fc07b156886ab79dc736012e55
      https://github.com/oracle/dtrace-utils/commit/2ac25e06153636fc07b156886ab79dc736012e55
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2025-09-16 (Tue, 16 Sep 2025)

  Changed paths:
    M libdtrace/dt_cg.c

  Log Message:
  -----------
  cg: fix offset for > 8 bit bitfields in dt_cg_ctf_offsetof()

The tcp provider uses dt_cg_tramp_get_member() to retrieve the
offset of the sk_protocol field in struct sock.  However it
returns the wrong value on UEK6 since it is an 8-bit bitfield.
>From pahole we see:

	unsigned int               __sk_flags_offset[0]; /*   560     0 */
	unsigned int               sk_padding:1;         /*   560: 0  4 */
	unsigned int               sk_kern_sock:1;       /*   560: 1  4 */
	unsigned int               sk_no_check_tx:1;     /*   560: 2  4 */
	unsigned int               sk_no_check_rx:1;     /*   560: 3  4 */
	unsigned int               sk_userlocks:4;       /*   560: 4  4 */
	unsigned int               sk_protocol:8;        /*   560: 8  4 */

In other words it is really at offset 561 but because we just
lookup the member offset and not the member type offset we get the
wrong value for the sk_protoocol.

This in turn causes tcp state-change probes (and in-progress UDP
probes) to not fire since we verify that sk_protocol == IPPROTO_TCP.

The fix is to look up the member _type_ offset and add it to the
bit offset we get for the member itself.  With this in place the
state-change probes fire, but the local tcp tests still fail due
to separate issues with the tcp:::accept-established probe.

This issue is not seen on more recent kernels because sk_protocol
becomes a __u16 as the number of protocols exceeds 256.

Signed-off-by: Alan Maguire <alan.maguire at oracle.com>
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>


  Commit: 8b21972fd58b26ee72a65b1eab258c7ce72b534d
      https://github.com/oracle/dtrace-utils/commit/8b21972fd58b26ee72a65b1eab258c7ce72b534d
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2025-09-16 (Tue, 16 Sep 2025)

  Changed paths:
    M libdtrace/dt_prov_tcp.c

  Log Message:
  -----------
  tcp provider: use __ip_queue_xmit() as it is non-static on 5.4

On older kernels - 5.4 to be precise - ip_queue_xmit() is a static
function, so it is better to instrument __ip_queue_xmit() as it
is extern so not prone to optimization on 5.4 and later kernels.
With this change, the following previously-failing-on-UEK6U3 tcp tests
pass (and continue to pass when tested on an upstream kernel):

tst.ipv4localtcp.sh
tst.ipv4remotetcp.sh
tst.ipv6localtcp.sh

More work is required to fix up the tcpstate tests for UEK6U3.

Reported-by: Eugene Loh <eugene.loh at oracle.com>
Signed-off-by: Alan Maguire <alan.maguire at oracle.com>
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>


  Commit: c08a5fcf23555c21af73e193b49e34dc5dfe1c5f
      https://github.com/oracle/dtrace-utils/commit/c08a5fcf23555c21af73e193b49e34dc5dfe1c5f
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2025-09-16 (Tue, 16 Sep 2025)

  Changed paths:
    M dlibs/aarch64/5.11/ip.d
    M dlibs/aarch64/5.11/tcp.d
    M dlibs/aarch64/5.12/ip.d
    M dlibs/aarch64/5.12/tcp.d
    M dlibs/aarch64/5.14/ip.d
    M dlibs/aarch64/5.14/tcp.d
    M dlibs/aarch64/5.16/ip.d
    M dlibs/aarch64/5.16/tcp.d
    M dlibs/aarch64/5.2/ip.d
    M dlibs/aarch64/5.2/tcp.d
    M dlibs/aarch64/5.6/ip.d
    M dlibs/aarch64/5.6/tcp.d
    M dlibs/aarch64/6.1/ip.d
    M dlibs/aarch64/6.1/tcp.d
    M dlibs/aarch64/6.10/ip.d
    M dlibs/aarch64/6.10/tcp.d
    M dlibs/x86_64/5.11/ip.d
    M dlibs/x86_64/5.11/tcp.d
    M dlibs/x86_64/5.12/ip.d
    M dlibs/x86_64/5.12/tcp.d
    M dlibs/x86_64/5.14/ip.d
    M dlibs/x86_64/5.14/tcp.d
    M dlibs/x86_64/5.16/ip.d
    M dlibs/x86_64/5.16/tcp.d
    M dlibs/x86_64/5.2/ip.d
    M dlibs/x86_64/5.2/tcp.d
    M dlibs/x86_64/5.6/ip.d
    M dlibs/x86_64/5.6/tcp.d
    M dlibs/x86_64/6.1/ip.d
    M dlibs/x86_64/6.1/tcp.d
    M dlibs/x86_64/6.10/ip.d
    M dlibs/x86_64/6.10/tcp.d
    M libdtrace/dt_prov_tcp.c
    M libdtrace/ip.d
    M libdtrace/tcp.d

  Log Message:
  -----------
  tcp provider: support tcp:::accept-established in absence of skb

On a 5.4 kernel, the function we instrument for tcp:::accept-established
(tcp_init_transfer()) does not have a struct sk_buff * as argument;
that does not appear until 5.10.  As a result we need to fake up
the IP and TCP headers from the TCP socket.  We can reuse existing
code (ensuring to mark accept-established correctly as an _INBOUND
probe) once we fix up references in ip.d to be arg6 and not arg7 (this
parameter is used to mark a probe point as inbound, outbound or as a
state change).  We need to ensure that args[2] is translated from
a __dtrace_tcp_void_ip_t * to get this to work for the IP header.

For the TCP header we need a similar solution; add a
__dtrace_tcp_void_tcp_t type and translate from either the tcp header
passed in (if non-null) or use arg3 (the socket) to fill out the TCP
header info.  We can get the ports, seq/ack and because we know that
only accept-established is used we know the flags will just be an
ACK.

With this in place (along with previous fixes for the TCP provider)
the TCP state-related tests finally pass on a 5.4 kernel.

Reported-by: Eugene Loh <eugene.loh at oracle.com>
Signed-off-by: Alan Maguire <alan.maguire at oracle.com>
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>


  Commit: 3f41d21e8f1e432dd21999d5f11c8b219d8ba8ff
      https://github.com/oracle/dtrace-utils/commit/3f41d21e8f1e432dd21999d5f11c8b219d8ba8ff
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2025-09-16 (Tue, 16 Sep 2025)

  Changed paths:
    M dlibs/aarch64/5.11/udp.d
    M dlibs/aarch64/5.12/udp.d
    M dlibs/aarch64/5.14/udp.d
    M dlibs/aarch64/5.16/udp.d
    M dlibs/aarch64/5.2/udp.d
    M dlibs/aarch64/5.6/udp.d
    M dlibs/aarch64/6.1/udp.d
    M dlibs/aarch64/6.10/udp.d
    M dlibs/x86_64/5.11/udp.d
    M dlibs/x86_64/5.12/udp.d
    M dlibs/x86_64/5.14/udp.d
    M dlibs/x86_64/5.16/udp.d
    M dlibs/x86_64/5.2/udp.d
    M dlibs/x86_64/5.6/udp.d
    M dlibs/x86_64/6.1/udp.d
    M dlibs/x86_64/6.10/udp.d
    M libdtrace/Build
    A libdtrace/dt_prov_udp.c
    M libdtrace/dt_provider.c
    M libdtrace/dt_provider.h
    M libdtrace/udp.d
    M test/unittest/dtrace-util/tst.ListProbes.r
    M test/unittest/dtrace-util/tst.ListProbes.sh
    M test/unittest/udp/test.x

  Log Message:
  -----------
  udp: new provider

Support UDP send and receive, using raw fbt probes; since
udp.d changes sync dlibs also.  Update test.x provider check
for udp, and add udp to expected providers.

Signed-off-by: Alan Maguire <alan.maguire at oracle.com>
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>


  Commit: 68467655069fa3782a19fd5f350b8c9fa38bf5c2
      https://github.com/oracle/dtrace-utils/commit/68467655069fa3782a19fd5f350b8c9fa38bf5c2
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2025-09-16 (Tue, 16 Sep 2025)

  Changed paths:
    M test/unittest/udp/tst.ipv4remoteudp.sh

  Log Message:
  -----------
  test/unittest/udp: enable IPv4 remote udp test

It just tests send so we can send to remote address
and verify probe firing.

Signed-off-by: Alan Maguire <alan.maguire at oracle.com>
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>


  Commit: 79a3a50b4db78d2a723fcd9dd95c3928a3cc0c48
      https://github.com/oracle/dtrace-utils/commit/79a3a50b4db78d2a723fcd9dd95c3928a3cc0c48
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2025-09-16 (Tue, 16 Sep 2025)

  Changed paths:
    M test/unittest/dtrace-util/tst.APIVersion.r

  Log Message:
  -----------
  test: Update DTrace version string

Commit a48a76472 ("version: fix DTrace version string") changed
the DTrace version string without addressing associated testing.

Update the test suite to match the version string change.

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: 4a6c00af779d7238e3746cbfcfcbbaa5783ae6a4
      https://github.com/oracle/dtrace-utils/commit/4a6c00af779d7238e3746cbfcfcbbaa5783ae6a4
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2025-09-16 (Tue, 16 Sep 2025)

  Changed paths:
    M libdtrace/dt_provider_tp.c

  Log Message:
  -----------
  Clean up unused argsz

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Nick Alcock <nick.alcock at oracle.com>


  Commit: 9da4c706160dead898ac0d0b93115269debb7baf
      https://github.com/oracle/dtrace-utils/commit/9da4c706160dead898ac0d0b93115269debb7baf
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2025-09-16 (Tue, 16 Sep 2025)

  Changed paths:
    M libdtrace/dt_provider_tp.c

  Log Message:
  -----------
  Defer stripping out "__data_loc" until we know that is useful

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Nick Alcock <nick.alcock at oracle.com>


  Commit: d39385d2ce42ab2ee118b682b0940c6a1f2baa61
      https://github.com/oracle/dtrace-utils/commit/d39385d2ce42ab2ee118b682b0940c6a1f2baa61
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2025-09-16 (Tue, 16 Sep 2025)

  Changed paths:
    M libdtrace/dt_provider_tp.c

  Log Message:
  -----------
  Add more robust mechanism to skip tracepoint common fields

In dt_tp_event_info(), we parse tracepoint format files -- e.g.,
/sys/kernel/debug/tracing/events/*/*/format.  Specifically, we
are interested in the argument descriptions found in the file,
but we are interested in skipping over "common fields."

The mechanism we used for this purpose was, in dt_provider_tp.c,
to hardwire the number of fields to skip to SKIP_FIELDS_COUNT=4,
assuming the common fields would always be type, flags, pid, and
preempt_count.

This is hardly a robust mechanism.  For example, consider
    https://kernel.googlesource.com/pub/scm/linux/kernel/git/rt/
        linux-rt-devel/+/refs/tags/v5.9.1-rt20-patches/patches/
        preempt-lazy-support.patch
which introduces a preempt_lazy_count common field (on top of
others).  Recent dtrace testing on RHCK 5.14 indicates widespread
test failures due to this problem.

Implement a more robust mechanism.

Specifically, instead of skipping a hardwired (SKIP_FIELDS_COUNT=4)
number of common fields, look for "common_" names.  E.g., in
kernel/trace/trace_events.c in trace_define_common_fields(), we
see the macro __common_field() is used to define common fields,
and the names are prepended with "common_".

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Nick Alcock <nick.alcock at oracle.com>


Compare: https://github.com/oracle/dtrace-utils/compare/589a81d416fb...d39385d2ce42

To unsubscribe from these emails, change your notification settings at https://github.com/oracle/dtrace-utils/settings/notifications



More information about the DTrace-devel mailing list