Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Want abstraction over USDT/SDT split in probes #389

Open
FelixMcFelix opened this issue Sep 6, 2023 · 0 comments
Open

Want abstraction over USDT/SDT split in probes #389

FelixMcFelix opened this issue Sep 6, 2023 · 0 comments
Labels
cleanup Code cleanliness

Comments

@FelixMcFelix
Copy link
Collaborator

Many of the DTrace probes we have in OPTE are structured such that they automatically switch between USDT and SDT probes depending on whether the crate is compiled for userland (cargo test) or as part of the kernel module (xde):

impl Port {
    fn xyz_probe(&self, dir: Direction, pkt: &Packet<Parsed>, msg: String) {
        cfg_if::cfg_if! {
            if #[cfg(all(not(feature = "std"), not(test)))] {
                /* SDT-specific arg conversion: String->CString, ... */
                unsafe {
                    __dtrace_probe_xyz(
                        /* ... pointers to args ... */
                    );
                }
            } else if #[cfg(feature = "usdt")] {
                /* USDT-specific arg conversion */
                crate::opte_provider::xyz!(
                    || (/* ... Rust-friendly args (references, owned types) ... */)
                );
            } else {
                /* feature-flag-driven no-op */
                let (..) = (dir, pkt, msg);
            }
        }
    }
}

Many of the Port::*_probe methods have a structure more or less in line with this, which leads to a lot of duplication and noise. We should define a macro or similar abstraction to simplify the implementation of {current, future} DTrace probes we choose to insert.

@FelixMcFelix FelixMcFelix added the cleanup Code cleanliness label Sep 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup Code cleanliness
Projects
None yet
Development

No branches or pull requests

1 participant