Linux DTrace development list
 help / color / mirror / Atom feed
From: Kris Van Hees <kris.van.hees@oracle.com>
To: Alan Maguire <alan.maguire@oracle.com>
Cc: dtrace@lists.linux.dev, dtrace-devel@oss.oracle.com
Subject: Re: [PATCH dtrace 0/3] fprobe fallback kprobe support, sched fix
Date: Wed, 9 Oct 2024 13:34:19 -0400	[thread overview]
Message-ID: <Zwa+m69lJ00WQ7ju@oracle.com> (raw)
In-Reply-To: <20241009140236.883884-1-alan.maguire@oracle.com>

Hi Alan,

I see what you are doing here and I think that it certainly has merit, but I
would say that the implementation is breaking some assumptions that are part
of the provider design in the code base.  The way that a probe is related to
a provider implementation is rather fundamental and you end up breaking that
by having a fprobe-backed probe actually use the kprobe implementation.  I am
thinking how we can establish the same without breaking that association.

There is also the fact to consider that if we end up attaching a given probe
both as an fprobe-backed FBT probe and a kprobe-based FBT probe, things can
get really interesting because the defined order of execution of clauses will
no longer be satisfied.

Now, what perhaps could work is if we were to first try to determine whether
we can use a fprobe-backed for an FBT probe, and if that is not possible, do
a fall-back to a kprobe-backed probe by removing the probe and re-inserting it
as a kprobe-backed FBT probe.  Since a probe is associated with a provider by
a pointer to the provider implementation, that should work.

It should also still work for probe lookup (though that should no longer be
taking place at that point in processing) because the lookup code is based
on the provider name selecting the correct bucket, which can contain probes
that have that same provider name even if the implementation for them is
different.

This way we can never have a probe that is associated with the fprobe
implementation but really ends up using the kprobe implementation.  The
association between probe and provider implementation would still be kept
as-is.

Do you think that would work?

ONe complication I can think of is cases where both func and func.<suffix>
should be traced when you use an fbt::func:entry (or return) probe.  They
would both need to be done as kprobes, because (again) we cannot have a mix.

On Wed, Oct 09, 2024 at 03:02:33PM +0100, Alan Maguire wrote:
> This series is focused on solving a few issues with fprobe-based
> attachment which prevent us being able to attach to functions
> like finish_task_switch.isra.0.  Such functions are present in
> available_filter_functions, but because they either lack BTF
> representations or those representations are named without the
> .isra suffix, attachment via fentry/fexit is currently impossible.
> Falling back to kprobe attach is the best solution here.
> 
> However providers have been written with the implicit assumption
> that certain aspects of the probes are shared across the provider;
> program type, stack skips etc.  Patch 1 addresses this by providing
> optional provider implementation callbacks to return these values
> for a specific probe.  Patch 2 then updates the fbt provider to
> use these mechanisms to support fallback to kprobe and to support
> "."-suffixed functions.  Finally patch 3 can then specify
> fbt::finish_task_switch*:return as the underlying probe for
> sched:::on-cpu.
> 
> Tested on upstream, UEK7 (5.15-based kernel) and UEK6 (5.4-based).
> 
> Alan Maguire (3):
>   dtrace: add support for probe-specific prog types, stack skips
>   fbt: support ".isra.0" suffixed functions
>   sched: fix on-cpu firing for kernels < 5.16
> 
>  libdtrace/dt_bpf.c         |  4 +-
>  libdtrace/dt_cc.c          |  2 +-
>  libdtrace/dt_probe.c       | 16 ++++++++
>  libdtrace/dt_probe.h       |  2 +
>  libdtrace/dt_prov_fbt.c    | 84 +++++++++++++++++++++++++++++++-------
>  libdtrace/dt_prov_rawtp.c  |  2 +-
>  libdtrace/dt_prov_sched.c  | 23 +----------
>  libdtrace/dt_prov_sdt.c    |  2 +-
>  libdtrace/dt_provider.h    |  4 ++
>  libdtrace/dt_provider_tp.c | 12 +++++-
>  libdtrace/dt_provider_tp.h |  9 +++-
>  11 files changed, 117 insertions(+), 43 deletions(-)
> 
> -- 
> 2.43.5
> 

  parent reply	other threads:[~2024-10-09 17:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-09 14:02 [PATCH dtrace 0/3] fprobe fallback kprobe support, sched fix Alan Maguire
2024-10-09 14:02 ` [PATCH dtrace 1/3] dtrace: add support for probe-specific prog types, stack skips Alan Maguire
2024-10-09 14:02 ` [PATCH dtrace 2/3] fbt: support ".isra.0" suffixed functions Alan Maguire
2024-10-09 14:02 ` [PATCH dtrace 3/3] sched: fix on-cpu firing for kernels < 5.16 Alan Maguire
2024-10-09 17:34 ` Kris Van Hees [this message]
2024-10-10 21:03   ` [PATCH dtrace 0/3] fprobe fallback kprobe support, sched fix Alan Maguire
2024-10-11  2:47     ` Kris Van Hees

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Zwa+m69lJ00WQ7ju@oracle.com \
    --to=kris.van.hees@oracle.com \
    --cc=alan.maguire@oracle.com \
    --cc=dtrace-devel@oss.oracle.com \
    --cc=dtrace@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox