On 09/07/20 13:13, pet...@infradead.org wrote: > On Mon, Sep 07, 2020 at 11:48:45AM +0100, Qais Yousef wrote: > > IMHO the above is a hack. Out-of-tree modules should rely on public headers > > and > > exported functions only. What you propose means that people who want to use > > these tracepoints in meaningful way must have a prebuilt kernel handy. > > Which is > > maybe true for us who work in the embedded world. But users who run normal > > distro kernels (desktop/servers) will fail to build against > > But this isn't really aimed at regular users. We're aiming this at > developers (IIUC) so I dont really see this as a problem. > > > FWIW, I did raise this concern with Peter in 2019 OSPM and he was okay with > > the > > exports as it's still not a contract and they can disappear anytime we want. > > Migrating to using BTF is the right way forward IMO. I don't think what we > > have > > here is out-of-control yet. Though I agree they're annoying. > > Right, we're hiding behind the explicit lack of ABI for modules. > > Anyway, CTF/BTF/random other crap that isn't DWARFs should work fine to > replace all this muck. Just no idea what the state of any of that is.
So I was thinking of having a function that allows a module to read member of struct rq (or any struct for that matters), but I think that's the harder (though neater) way around. Just compiled a kernel with CONFIG_DEBUG_INFO_BTF_INFO; and doing $ pahole rq struct rq { raw_spinlock_t lock; /* 0 4 */ unsigned int nr_running; /* 4 4 */ long unsigned int last_blocked_load_update_tick; /* 8 8 */ unsigned int has_blocked_load; /* 16 4 */ /* XXX 12 bytes hole, try to pack */ call_single_data_t nohz_csd; /* 32 32 */ /* --- cacheline 1 boundary (64 bytes) --- */ unsigned int nohz_tick_stopped; /* 64 4 */ atomic_t nohz_flags; /* 68 4 */ unsigned int ttwu_pending; /* 72 4 */ /* XXX 4 bytes hole, try to pack */ u64 nr_switches; /* 80 8 */ . . . } dumps the struct rq {...}; which means one can easily use that to autogenerate a header containing the structs they care about accessing for their running kernel. pahole automatically knows how to find /sys/kernel/btf/vmlinux to parse the debug info btw. The only caveat is that one has to recompile the module for each running kernel; but that's acceptable I think. Not sure how many allow loading a module that's not compiled for that particular kernel version anyway. Note to try this you'll need pahole v1.16 or newer. And compiling pahole on Ubuntu is a pain. I had to create a fedora docker image to compile it in. So I think we have this already solved. Though not sure how to document it.. Thanks -- Qais Yousef